//==========================================================================//
// File:	BTMODE.CPP                                                         //
// Project: MUNGA           Brick: Controls Manager                         //
// Contents: Interface specification for BT LBE4 Controls                   //
//--------------------------------------------------------------------------//
//   Date    Who  Modification                                              //
// --------  ---  ----------------------------------------------------------//
// 02/13/96  CPB  Built from CONTROLS.CPP                                   //
//--------------------------------------------------------------------------//
// Copyright (C) 1994-1996, Virtual World Entertainment, Inc.               //
// All Rights reserved worldwide                                            //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL              //
//==========================================================================//

#include <btl4.hpp>
#pragma hdrstop

#if !defined(BTL4MODE_HPP)
#	include <btl4mode.hpp>
#endif

#if defined(DEBUG)
#	define Test_Tell(n) DEBUG_STREAM << n
#else
#	define Test_Tell(n)
#endif

struct ModeLookup
{
	const char *name;
	ModeMask modeMask;
};

static ModeLookup
	mode_lookup[] =
	{
		{"ModeMFD1Quad",     BTL4ModeManager::ModeMFD1Quad},
		{"ModeMFD1Eng1",     BTL4ModeManager::ModeMFD1Eng1},
		{"ModeMFD1Eng2",     BTL4ModeManager::ModeMFD1Eng2},
		{"ModeMFD1Eng3",     BTL4ModeManager::ModeMFD1Eng3},
		{"ModeMFD1Eng4",     BTL4ModeManager::ModeMFD1Eng4},
		{"ModeMFD2Quad",     BTL4ModeManager::ModeMFD2Quad},
		{"ModeMFD2Eng1",     BTL4ModeManager::ModeMFD2Eng1},
		{"ModeMFD2Eng2",     BTL4ModeManager::ModeMFD2Eng2},
		{"ModeMFD2Eng3",     BTL4ModeManager::ModeMFD2Eng3},
		{"ModeMFD2Eng4",     BTL4ModeManager::ModeMFD2Eng4},
		{"ModeMFD3Quad",     BTL4ModeManager::ModeMFD3Quad},
		{"ModeMFD3Eng1",     BTL4ModeManager::ModeMFD3Eng1},
		{"ModeMFD3Eng2",     BTL4ModeManager::ModeMFD3Eng2},
		{"ModeMFD3Eng3",     BTL4ModeManager::ModeMFD3Eng3},
		{"ModeMFD3Eng4",     BTL4ModeManager::ModeMFD3Eng4},
		{"ModeMapping",      BTL4ModeManager::ModeMapping},
		{"ModeNonMapping",   BTL4ModeManager::ModeNonMapping},
		{"ModeIntercom",     BTL4ModeManager::ModeIntercom},
		{"ModeSecondaryDamage",   BTL4ModeManager::ModeSecondaryDamage},
		{"ModeSecondaryCritical", BTL4ModeManager::ModeSecondaryCritical},
		{"ModeSecondaryHeat",     BTL4ModeManager::ModeSecondaryHeat},
		{"ModeEject",        BTL4ModeManager::ModeEject},
		{"ModePlasmaDisplay", BTL4ModeManager::ModePlasmaDisplay},

		{"ModeInitial",      BTL4ModeManager::ModeInitial},
		{"ModeNonConfig",    BTL4ModeManager::ModeNonConfig},
		{"ModeMFD1NonQuad",  BTL4ModeManager::ModeMFD1NonQuad},
		{"ModeMFD1All",      BTL4ModeManager::ModeMFD1All},
		{"ModeMFD2NonQuad",  BTL4ModeManager::ModeMFD2NonQuad},
		{"ModeMFD2All",      BTL4ModeManager::ModeMFD2All},
		{"ModeMFD3NonQuad",  BTL4ModeManager::ModeMFD3NonQuad},
		{"ModeMFD3All",      BTL4ModeManager::ModeMFD3All},
		{"ModeSecondaryAll", BTL4ModeManager::ModeSecondaryAll},
		{ NULL, (ModeMask)0}
	};

Logical
	BTL4ModeManager::ModeStringLookup(
		const char *name,
		ModeMask *returned_value
	)
{
	Check(this);
	Check_Pointer(name); 
	Check_Pointer(returned_value); 
	//----------------------------------------
	// Search table for match
	//----------------------------------------
	ModeLookup
		*lookup;

	for(lookup=mode_lookup; lookup->name!=NULL; ++lookup)
	{
		if (stricmp(name, lookup->name) == 0)
		{
			*returned_value = lookup->modeMask;
			Check_Fpu();
			return True;
		}
	}
	//----------------------------------------
	// Not found here, check next level down.
	//----------------------------------------
	Check_Fpu();
	return ModeManager::ModeStringLookup(name, returned_value);
}


