示例#1
0
/**
**  Draw the player resource in top line.
**
**  @todo FIXME : make DrawResources more configurable (format, font).
*/
void DrawResources()
{
	CLabel label(GetGameFont());

	// Draw all icons of resource.
	for (int i = 0; i <= FreeWorkersCount; ++i) {
		if (UI.Resources[i].G) {
			UI.Resources[i].G->DrawFrameClip(UI.Resources[i].IconFrame,
											 UI.Resources[i].IconX, UI.Resources[i].IconY);
		}
	}
	for (int i = 0; i < MaxCosts; ++i) {
		if (UI.Resources[i].TextX != -1) {
			const int resourceAmount = ThisPlayer->Resources[i];

			if (ThisPlayer->MaxResources[i] != -1) {
				const int resAmount = ThisPlayer->StoredResources[i] + ThisPlayer->Resources[i];
				char tmp[256];
				snprintf(tmp, sizeof(tmp), "%d (%d)", resAmount, ThisPlayer->MaxResources[i] - ThisPlayer->StoredResources[i]);
				label.SetFont(GetSmallFont());

				label.Draw(UI.Resources[i].TextX, UI.Resources[i].TextY + 3, tmp);
			} else {
				label.SetFont(resourceAmount > 99999 ? GetSmallFont() : GetGameFont());

				label.Draw(UI.Resources[i].TextX, UI.Resources[i].TextY + (resourceAmount > 99999) * 3, resourceAmount);
			}
		}
	}
	if (UI.Resources[FoodCost].TextX != -1) {
		char tmp[256];
		snprintf(tmp, sizeof(tmp), "%d/%d", ThisPlayer->Demand, ThisPlayer->Supply);
		label.SetFont(GetGameFont());
		if (ThisPlayer->Supply < ThisPlayer->Demand) {
			label.DrawReverse(UI.Resources[FoodCost].TextX, UI.Resources[FoodCost].TextY, tmp);
		} else {
			label.Draw(UI.Resources[FoodCost].TextX, UI.Resources[FoodCost].TextY, tmp);
		}
	}
	if (UI.Resources[ScoreCost].TextX != -1) {
		const int score = ThisPlayer->Score;

		label.SetFont(score > 99999 ? GetSmallFont() : GetGameFont());
		label.Draw(UI.Resources[ScoreCost].TextX, UI.Resources[ScoreCost].TextY + (score > 99999) * 3, score);
	}
	if (UI.Resources[FreeWorkersCount].TextX != -1) {
		const int workers = ThisPlayer->FreeWorkers.size();

		label.SetFont(GetGameFont());
		label.Draw(UI.Resources[FreeWorkersCount].TextX, UI.Resources[FreeWorkersCount].TextY, workers);
	}
}
示例#2
0
/**
**  Show unit's name under cursor or print the message if territory is invisible.
**
**  @param pos  Mouse position.
**  @param unit  Unit to show name.
**  @param hidden  If true, write "Unrevealed terrain"
**
*/
static void ShowUnitName(const CViewport &vp, PixelPos pos, CUnit *unit, bool hidden = false)
{
	CFont &font = GetSmallFont();
	int width;
	int height = font.Height() + 6;
	CLabel label(font, "white", "red");
	int x;
	int y = std::min<int>(GameCursor->G->Height + pos.y + 10, vp.BottomRightPos.y - 1 - height);
	const CPlayer *tplayer = ThisPlayer;

	if (unit && unit->IsAliveOnMap()) {
		int backgroundColor;
		if (unit->Player->Index == (*tplayer).Index) {
			backgroundColor = Video.MapRGB(TheScreen->format, 0, 0, 252);
		} else if (unit->Player->IsAllied(*tplayer)) {
			backgroundColor = Video.MapRGB(TheScreen->format, 0, 176, 0);
		} else if (unit->Player->IsEnemy(*tplayer)) {
			backgroundColor = Video.MapRGB(TheScreen->format, 252, 0, 0);
		} else {
			backgroundColor = Video.MapRGB(TheScreen->format, 176, 176, 176);
		}
		width = font.getWidth(unit->Type->Name) + 10;
		x = std::min<int>(GameCursor->G->Width + pos.x, vp.BottomRightPos.x - 1 - width);
		Video.FillTransRectangle(backgroundColor, x, y, width, height, 128);
		Video.DrawRectangle(ColorWhite, x, y, width, height);
		label.DrawCentered(x + width / 2, y + 3, unit->Type->Name);
	} else if (hidden) {
		const std::string str("Unrevealed terrain");
		width = font.getWidth(str) + 10;
		x = std::min<int>(GameCursor->G->Width + pos.x, vp.BottomRightPos.x - 1 - width);
		Video.FillTransRectangle(ColorBlue, x, y, width, height, 128);
		Video.DrawRectangle(ColorWhite, x, y, width, height);
		label.DrawCentered(x + width / 2, y + 3, str);
	}
}
int CFolderJoin::AddServerCtrl(CGameSpyServer* pGame)
{
	CLTGUIFont *pFont = GetSmallFont();
    CGroupCtrl *pGroup = CreateGroup(nServerGroupWidth,pFont->GetHeight(),LTNULL);
    LTIntPt pos(0,0);
    pGroup->SetParam1((uint32)pGame->GetHandle());

	char sTemp[128] = "";
	sprintf(sTemp,"%s",pGame->GetName());
    CStaticTextCtrl *pCtrl = CreateStaticTextItem(sTemp,CMD_SELECT_SERVER,LTNULL,nGameWidth,pFont->GetHeight(),LTFALSE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);
	pos.x += nGameWidth+nGap;

	sprintf(sTemp,"%d/%d",pGame->GetNumPlayers(), pGame->GetMaxPlayers());
    pCtrl = CreateStaticTextItem(sTemp,LTNULL,LTNULL,nPlayerWidth,pFont->GetHeight(),LTFALSE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);
	pos.x += nPlayerWidth+nGap;

	if (pGame->GetPing() >= 9999) strcpy(sTemp, "???");
	else sprintf(sTemp,"%d",pGame->GetPing());
    pCtrl = CreateStaticTextItem(sTemp,LTNULL,LTNULL,nPingWidth,pFont->GetHeight(),LTFALSE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);
	pos.x += nPingWidth+nGap;

	sprintf(sTemp,"%s",pGame->GetGameType());
    pCtrl = CreateStaticTextItem(sTemp,LTNULL,LTNULL,nTypeWidth,pFont->GetHeight(),LTFALSE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);
	pos.x += nTypeWidth+nGap;

	sprintf(sTemp,"%s",pGame->GetMap());
    pCtrl = CreateStaticTextItem(sTemp,LTNULL,LTNULL,nMapWidth,pFont->GetHeight(),LTFALSE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);

	return m_pServerList->AddControl(pGroup);
}
int CFolderJoin::AddPlayerCtrl(CGameSpyPlayer* pPlr)
{
	CLTGUIFont *pFont = GetSmallFont();
    CGroupCtrl *pGroup = CreateGroup(nPlayerGroupWidth,pFont->GetHeight(),LTNULL);
    LTIntPt pos(0,0);
    pGroup->SetParam1((uint32)pPlr);

	char sTemp[128] = "";
	strcpy(sTemp, pPlr->GetName());
    CStaticTextCtrl *pCtrl = CreateStaticTextItem(sTemp,LTNULL,LTNULL,nNameWidth,pFont->GetHeight(),LTTRUE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);
	pos.x += nNameWidth+nGap;

	sprintf(sTemp, "%i", pPlr->GetFrags());
    pCtrl = CreateStaticTextItem(sTemp,LTNULL,LTNULL,nScoreWidth,pFont->GetHeight(),LTTRUE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);
	pos.x += nScoreWidth+nGap;

	if (pPlr->GetPing() >= 9999) strcpy(sTemp, "???");
	else sprintf(sTemp,"%d",pPlr->GetPing());
    pCtrl = CreateStaticTextItem(sTemp,LTNULL,LTNULL,nPingWidth,pFont->GetHeight(),LTTRUE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);

	pGroup->Enable(LTFALSE);
	return m_pPlayerList->AddControl(pGroup);

}
示例#5
0
// Draws the version string to the lower left hand corner of the surface
void CMainMenus::DrawVersionString(HSURFACE hSurf)
{
	// The small font
	CLTGUIFont *pFont=GetSmallFont();

	if ( !pFont || !m_hstrVersion )
	{		
		return;
	}

	DWORD dwScreenWidth=0;
	DWORD dwScreenHeight=0;
	m_pClientDE->GetSurfaceDims (hSurf, &dwScreenWidth, &dwScreenHeight);
		
	int y=dwScreenHeight-pFont->GetHeight();

	HSTRING hString=m_pClientDE->CreateString(version_string);
	pFont->DrawSolid(hString, hSurf, 0, y, CF_JUSTIFY_LEFT, SETRGB(100,0,0));	

	if (hString)
	{
		m_pClientDE->FreeString(hString);
	}

}
示例#6
0
void CFolderIntel::BuildIntelList()
{
	if (m_nMissionNum < 0) return;
	MISSION* pMission = g_pMissionMgr->GetMission(m_nMissionNum);
	if (!pMission) return;

	CreateTitle(pMission->nNameId);


	for (int n =0;n < kNumSFXTypes;n++)
	{
		nSFXCounts[n] = 0;
	}
	CLTGUIFont *pFont;
	if (g_pLayoutMgr->GetListFontSize((eFolderID)m_nFolderID) == 0)
		pFont = GetSmallFont();
	else if (g_pLayoutMgr->GetListFontSize((eFolderID)m_nFolderID) == 1)
		pFont = GetMediumFont();
	else
		pFont = GetLargeFont();

	int numItems = g_pGameClientShell->GetIntelItemMgr()->GetNumItems(m_nMissionNum);
	for (int i = 0; i < numItems; i++)
	{
		IntelItem *pItem = debug_new(IntelItem);
		g_pGameClientShell->GetIntelItemMgr()->GetItem(m_nMissionNum,i,pItem);
		int nNameID = 0;
		int nCount = 0;
		if (pItem->nID)
		{
			for (int n =0;!nNameID && n < kNumSFXTypes;n++)
			{
				if (pItem->nType == nSFXIDs[n])
				{
					nSFXCounts[n]++;
					nNameID = nSFXNameIDs[n];
					nCount = nSFXCounts[n];
					
				}
			}
		}
		if (nNameID)
		{
			m_intelArray.Add(pItem);
			HSTRING hStr = g_pLTClient->FormatString(nNameID,nCount);
			CLTGUITextItemCtrl *pCtrl = AddTextItem(hStr,0,0,LTFALSE,pFont);
			g_pLTClient->FreeString(hStr);
			pCtrl->SetParam1(m_intelArray.GetSize());
		}
		else
		{
			debug_delete(pItem);
		}

	}
}
示例#7
0
/**
**  Draw additional informations of a unit.
**
**  @param unit  Unit pointer of drawn unit.
**  @param type  Unit-type pointer.
**  @param screenPos  screen pixel (top left) position of unit.
**
**  @todo FIXME: The different styles should become a function call.
*/
static void DrawInformations(const CUnit &unit, const CUnitType &type, const PixelPos &screenPos)
{
#if 0 && DEBUG // This is for showing vis counts and refs.
	char buf[10];
	sprintf(buf, "%d%c%c%d", unit.VisCount[ThisPlayer->Index],
			unit.Seen.ByPlayer & (1 << ThisPlayer->Index) ? 'Y' : 'N',
			unit.Seen.Destroyed & (1 << ThisPlayer->Index) ? 'Y' : 'N',
			unit.Refs);
	CLabel(GetSmallFont()).Draw(screenPos.x + 10, screenPos.y + 10, buf);
#endif

	const CUnitStats &stats = *unit.Stats;

	// For debug draw sight, react and attack range!
	if (IsOnlySelected(unit)) {
		const PixelPos center(screenPos + type.GetPixelSize() / 2);

		if (Preference.ShowSightRange) {
			const int value = stats.Variables[SIGHTRANGE_INDEX].Max;
			const int radius = value * PixelTileSize.x + (type.TileWidth - 1) * PixelTileSize.x / 2;

			if (value) {
				// Radius -1 so you can see all ranges
				Video.DrawCircleClip(ColorGreen, center.x, center.y, radius - 1);
			}
		}
		if (type.CanAttack) {
			if (Preference.ShowReactionRange) {
				const int value = (unit.Player->Type == PlayerPerson) ? type.ReactRangePerson : type.ReactRangeComputer;
				const int radius = value * PixelTileSize.x + (type.TileWidth - 1) * PixelTileSize.x / 2;

				if (value) {
					Video.DrawCircleClip(ColorBlue, center.x, center.y, radius);
				}
			}
			if (Preference.ShowAttackRange) {
				const int value = stats.Variables[ATTACKRANGE_INDEX].Max;
				const int radius = value * PixelTileSize.x + (type.TileWidth - 1) * PixelTileSize.x / 2;

				if (value) {
					// Radius +1 so you can see all ranges
					Video.DrawCircleClip(ColorGreen, center.x, center.y, radius - 1);
				}
			}
		}
	}

	// FIXME: johns: ugly check here, should be removed!
	if (unit.CurrentAction() != UnitActionDie && (unit.IsVisible(*ThisPlayer) || ReplayRevealMap)) {
		DrawDecoration(unit, type, screenPos);
	}
}
示例#8
0
void CFolderNew::BuildMissionList()
{
	int nextMission = g_pGameClientShell->GetPlayerSummary()->GetNextMission();
	int nCurrentMission = -1;
	for (int mis = 0; mis <= nextMission; ++mis)
	{
		MISSION* pMission = g_pMissionMgr->GetMission(mis);
        uint32 cmd = (uint32)mis + FOLDER_CMD_CUSTOM;
		if (!pMission) break;

		int nameId = pMission->nNameId;
		int nListWidth = m_ListRect.right - m_ListRect.left;
        HSTRING hStr = g_pLTClient->FormatString(nameId);

		CLTGUIFont *pFont;
		if (g_pLayoutMgr->GetListFontSize((eFolderID)m_nFolderID) == 0)
			pFont = GetSmallFont();
		else if (g_pLayoutMgr->GetListFontSize((eFolderID)m_nFolderID) == 1)
			pFont = GetMediumFont();
		else
			pFont = GetLargeFont();

		CBitmapCtrl *pCheck = debug_new(CBitmapCtrl);
		if (g_pLayoutMgr->GetListFontSize((eFolderID)m_nFolderID))
            pCheck->Create(g_pLTClient,"interface\\check-off.pcx","interface\\check-on.pcx");
		else
            pCheck->Create(g_pLTClient,"interface\\small_check-off.pcx","interface\\small_check-on.pcx");
		pCheck->Select((mis < nextMission));

		int nWidth = pCheck->GetWidth();
        CStaticTextCtrl *pCtrl = CreateStaticTextItem(hStr,cmd,LTNULL,(nListWidth - nWidth),0,LTFALSE,pFont);
        pCtrl->Enable(LTTRUE);


		int nHeight = Max(pCtrl->GetHeight(),pCheck->GetHeight());

		CGroupCtrl *pGroup = AddGroup(nListWidth,nHeight,cmd);
        g_pLTClient->FreeString(hStr);

        LTIntPt offset;

        pGroup->AddControl(pCheck,offset,LTFALSE);
		offset.x = nWidth;
        pGroup->AddControl(pCtrl,offset,LTTRUE);

//		AddPhotoBitmap(g_pInterfaceResMgr->GetSharedSurface(pMission->szPhoto));


	}
}
int CFolderJoin::AddOptionCtrl(int nID, char *pszValue)
{
	CLTGUIFont *pFont = GetSmallFont();
    CGroupCtrl *pGroup = CreateGroup(nOptionGroupWidth,pFont->GetHeight(),LTNULL);
    LTIntPt pos(0,0);

    CStaticTextCtrl *pCtrl = CreateStaticTextItem(nID,LTNULL,LTNULL,nOptionWidth,pFont->GetHeight(),LTTRUE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);
	pos.x += nOptionWidth+nGap;

    pCtrl = CreateStaticTextItem(pszValue,LTNULL,LTNULL,(nOptionGroupWidth-pos.x),pFont->GetHeight(),LTTRUE,pFont);
    pGroup->AddControl(pCtrl,pos,LTTRUE);

	return m_pOptionList->AddControl(pGroup);
}
示例#10
0
LTBOOL CFolderViewInventory::Build()
{
	CreateTitle(IDS_TITLE_INVENTORY);
	m_pFont = GetLargeFont();
	if (g_pLayoutMgr->GetListFontSize((eFolderID)m_nFolderID) == 0)
		m_pFont = GetSmallFont();
	else if (g_pLayoutMgr->GetListFontSize((eFolderID)m_nFolderID) == 1)
		m_pFont = GetMediumFont();

    UseArrows(LTTRUE);
	UseBack(LTTRUE,LTFALSE,LTTRUE);

    LTBOOL success = CBaseSelectionFolder::Build();


	return success;

}
// build a list of objectives for a new mission
void CFolderObjectives::BuildObjectivesList()
{
	int missionNum = g_pInterfaceMgr->GetMissionData()->GetMissionNum();
	MISSION* pMission = g_pMissionMgr->GetMission(missionNum);
	if (!pMission) return;

	CLTGUIFont *pFont = GetSmallFont();

	for (int i = 0; i < pMission->nNumObjectives ; i++)
	{
        uint32 objID = pMission->aObjectiveIds[i];

		CGroupCtrl *pGroup = debug_new(CGroupCtrl);
        CLTGUITextItemCtrl *pCtrl = CreateTextItem((int)objID,LTNULL,LTNULL,LTTRUE,pFont);
		if (pCtrl)
		{
            pCtrl->Enable(LTFALSE);
			pCtrl->SetFixedWidth(440);
			int nIndex= 0;
			CBitmapCtrl *pCheck = debug_new(CBitmapCtrl);
            pCheck->Create(g_pLTClient,"interface\\check-off.pcx");

			int strHeight = pCtrl->GetHeight();
			int bmpHeight = pCheck->GetHeight();
			int height = Max(strHeight,bmpHeight) + 4;


			pGroup->Create(480,height);

            LTIntPt offset(40, (height - strHeight) / 2 );
			pGroup->AddControl(pCtrl,offset);

			offset.x = 0;
			offset.y = (height - bmpHeight) / 2;
			pGroup->AddControl(pCheck,offset);
            pGroup->Enable(LTFALSE);

			AddFreeControl(pGroup);
		}


	}
}
void CFolderMultiBriefing::OnFocus(LTBOOL bFocus)
{
	if (bFocus)
	{
		int missionId = g_pGameClientShell->GetMPMissionName();
		int briefId = g_pGameClientShell->GetMPMissionBriefing();

		if (missionId)
		{
			CLTGUIFont *pFont = (briefId ? GetMediumFont() : GetLargeFont());
			CLTGUITextItemCtrl* pCtrl =AddTextItem(missionId,LTNULL,0,LTTRUE,pFont);
			pCtrl->SetFixedWidth(480);
			pCtrl->Enable(LTFALSE);
		}
		if (briefId)
		{
			if (missionId) AddBlankLine();

			CLTGUITextItemCtrl* pCtrl=AddTextItem(IDS_BRIEFING,LTNULL,0,LTTRUE,GetMediumFont());
			pCtrl->Enable(LTFALSE);

			CStaticTextCtrl *pBrief = AddStaticTextItem(briefId,LTNULL,LTNULL,480,0,LTTRUE,GetSmallFont());
			if (pBrief)
			{
				pBrief->Enable(LTFALSE);
			}

		}

		UseBack(LTFALSE);
	}
	else
	{
		RemoveFree();
	}
	CBaseFolder::OnFocus(bFocus);

}
示例#13
0
/**
**  Draw the map backgrounds.
**
** StephanR: variables explained below for screen:<PRE>
** *---------------------------------------*
** |                                       |
** |        *-----------------------*      |<-TheUi.MapY,dy (in pixels)
** |        |   |   |   |   |   |   |      |        |
** |        |   |   |   |   |   |   |      |        |
** |        |---+---+---+---+---+---|      |        |
** |        |   |   |   |   |   |   |      |        |MapHeight (in tiles)
** |        |   |   |   |   |   |   |      |        |
** |        |---+---+---+---+---+---|      |        |
** |        |   |   |   |   |   |   |      |        |
** |        |   |   |   |   |   |   |      |        |
** |        *-----------------------*      |<-ey,UI.MapEndY (in pixels)
** |                                       |
** |                                       |
** *---------------------------------------*
**          ^                       ^
**        dx|-----------------------|ex,UI.MapEndX (in pixels)
**            UI.MapX MapWidth (in tiles)
** (in pixels)
** </PRE>
*/
void CViewport::DrawMapBackgroundInViewport() const
{
    int ex = this->BottomRightPos.x;
    int ey = this->BottomRightPos.y;
    int sy = this->MapPos.y;
    int dy = this->TopLeftPos.y - this->Offset.y;
    const int map_max = Map.Info.MapWidth * Map.Info.MapHeight;
    unsigned short int tile;

    while (sy  < 0) {
        sy++;
        dy += PixelTileSize.y;
    }
    sy *=  Map.Info.MapWidth;

    while (dy <= ey && sy  < map_max) {

        /*
        	if (sy / Map.Info.MapWidth < 0) {
        		sy += Map.Info.MapWidth;
        		dy += PixelTileSize.y;
        		continue;
        	}
        */
        int sx = this->MapPos.x + sy;
        int dx = this->TopLeftPos.x - this->Offset.x;
        while (dx <= ex && (sx - sy < Map.Info.MapWidth)) {
            if (sx - sy < 0) {
                ++sx;
                dx += PixelTileSize.x;
                continue;
            }

            if (ReplayRevealMap) {
                tile = Map.Fields[sx].Tile;
            } else {
                tile = Map.Fields[sx].playerInfo.SeenTile;
            }
            Map.TileGraphic->DrawFrameClip(tile, dx, dy);

#ifdef DEBUG
#ifdef DEBUGMAPDRAW
            int my_mask = 0;
            unsigned int color = 0;
            if (Map.CheckMask(sx, MapFieldUnpassable)) {
                my_mask = 1;
            }
            if (Map.CheckMask(sx, MapFieldNoBuilding)) {
                my_mask |= 2;
            }
            switch (my_mask) {
            case 1://tile only Unpassable
                color = 0xFF0000;
                break;
            case 2://tile only NoBuilding
                color = 0x00FF00;
                break;
            case 3://tile Unpassable and NoBuilding
                color = 0xFF;
                break;
            default:
                break;
            }

            Video.DrawHLineClip(color, dx, dy, PixelTileSize.x);
            Video.DrawVLineClip(color, dx, dy, PixelTileSize.y);
            if (0 && my_mask) {
                CLabel label(GetSmallFont());
                label.Draw(dx + 2, dy + 2, tile);
                label.Draw(dx + 2, dy + GetSmallFont()->Height() + 4,
                           Map.Fields[sx].TilesetTile);

            }
#endif
#endif
            ++sx;
            dx += PixelTileSize.x;
        }
        sy += Map.Info.MapWidth;
        dy += PixelTileSize.y;
    }
}
示例#14
0
LTBOOL CFolderSave::Build()
{
	CreateTitle(IDS_TITLE_SAVEGAME);

    m_pEdit = CreateEditCtrl("", CMD_EDIT_NAME, LTNULL, m_szSaveName, sizeof(m_szSaveName), 0, LTTRUE, GetSmallFont());
	m_pEdit->EnableCursor();
    m_pEdit->Enable(LTFALSE);
	m_pEdit->SetAlignment(LTF_JUSTIFY_LEFT);

	return CBaseFolder::Build();
}
示例#15
0
void CFolderSave::BuildSavedLevelList()
{
	AddTextItem(IDS_QUICKSAVE,FOLDER_CMD_CUSTOM,IDS_HELP_QUICKSAVE,LTFALSE,GetMediumFont());

	// Create an empty string
    HSTRING hEmpty=g_pLTClient->CreateString(" ");


	int nFirstEmpty = -1;
	
	CLTGUITextItemCtrl *pCtrl = AddTextItem(IDS_LOAD_USERGAME,LTNULL,LTNULL,LTTRUE,GetMediumFont());
	pCtrl->Enable(LTFALSE);

 	for (int i = 0; i < kMaxSave; i++)
	{
		LTBOOL bEmpty = LTTRUE;

		char strFilename[128];
		sprintf (strFilename, "Save\\Slot%02d.sav", i+1);
		if (CWinUtil::FileExist(strFilename))
		{

			char strSaveGameSetting[256];
			memset (strSaveGameSetting, 0, 256);
			char strKey[32];
			sprintf (strKey, "SaveGame%02d", i+1);
			CWinUtil::WinGetPrivateProfileString (GAME_NAME, strKey, "", strSaveGameSetting, 256, SAVEGAMEINI_FILENAME);

			int mission = -1;
			int level = -1;
			struct tm* pTimeDate = LTNULL;
			char strWorldName[128] = "";
			char strUserName[128] = "";
			char strTime[128] = "";

			if (strlen (strSaveGameSetting) > 0)
			{
				char* pWorldName = strtok(strSaveGameSetting,"|");
				char* pNameStr = strtok(NULL,"|");
				char* pTimeStr = strtok(NULL,"|");

				time_t nSeconds = (time_t) atol (pTimeStr);
				pTimeDate = localtime (&nSeconds);
				if (pTimeDate)
				{
					if (g_pInterfaceResMgr->IsEnglish())
					{
						sprintf (strTime, "%02d/%02d/%02d %02d:%02d:%02d", pTimeDate->tm_mon + 1, pTimeDate->tm_mday, (pTimeDate->tm_year + 1900) % 100, pTimeDate->tm_hour, pTimeDate->tm_min, pTimeDate->tm_sec);
					}
					else
					{
						sprintf (strTime, "%02d/%02d/%02d %02d:%02d:%02d", pTimeDate->tm_mday, pTimeDate->tm_mon + 1, (pTimeDate->tm_year + 1900) % 100, pTimeDate->tm_hour, pTimeDate->tm_min, pTimeDate->tm_sec);
					}

				}
				sprintf(strWorldName,"    %s",pWorldName);
				sprintf(strUserName,"    %s",pNameStr);

			}


			HSTRING hWorld = LTNULL;
			HSTRING hTime = LTNULL;
			if (strlen(strUserName) > 0)
			{
				hWorld = g_pLTClient->CreateString(strUserName);
				bEmpty = LTFALSE;
			}
			else if (strlen(strWorldName) > 0)
			{
				hWorld=g_pLTClient->CreateString(strWorldName);
				bEmpty = LTFALSE;
			}


			if (!bEmpty && strlen(strTime) > 0)
			{
				// Set the text in the control
				hTime=g_pLTClient->CreateString(strTime);
			}


			if (hWorld)
			{
				CLTGUIColumnTextCtrl* pCtrl = AddColumnText(FOLDER_CMD_CUSTOM+1+i, IDS_HELP_SAVEGAME, LTFALSE, GetSmallFont());
				pCtrl->SetParam1( m_controlArray.GetSize() - 1);
				// The world name column

				pCtrl->AddColumn(hWorld, kColumnWidth, LTF_JUSTIFY_LEFT);

				// This is a spacer
				pCtrl->AddColumn(hEmpty, kGap, LTF_JUSTIFY_LEFT);

				if (hTime)
				{
					// The column that contains the date/time
					pCtrl->AddColumn(hTime, 230, LTF_JUSTIFY_LEFT);
					g_pLTClient->FreeString(hTime);
				}
				g_pLTClient->FreeString(hWorld);
			}


		}


		if (bEmpty && nFirstEmpty < 0) 
			nFirstEmpty = i;

	}

	if (nFirstEmpty >= 0)
	{
		CLTGUIColumnTextCtrl* pCtrl = AddColumnText(FOLDER_CMD_CUSTOM+1+nFirstEmpty, IDS_HELP_SAVEGAME, LTFALSE, GetSmallFont());
		pCtrl->SetParam1( m_controlArray.GetSize() - 1);
		// The world name column

		pCtrl->AddColumn(IDS_EMPTY, kColumnWidth, LTF_JUSTIFY_LEFT);

		// This is a spacer
		pCtrl->AddColumn(hEmpty, kGap, LTF_JUSTIFY_LEFT);

		// The column that contains the date/time
		pCtrl->AddColumn(hEmpty, 230, LTF_JUSTIFY_LEFT);
	}

    g_pLTClient->FreeString(hEmpty);


}
void CFolderSummary::UpdateData()
{
	CPlayerSummaryMgr *pPSummary = g_pGameClientShell->GetPlayerSummary();
	if (!pPSummary) return;

	CMissionData* pMissionData = g_pInterfaceMgr->GetMissionData();
	if (!pMissionData) return;

	int nMissionNum = pMissionData->GetMissionNum();
	MISSION* pMission = g_pMissionMgr->GetMission(nMissionNum);
	if (!pMission) return;

	MISSIONSUMMARY* pMSummary = pPSummary->GetMissionSummary(nMissionNum);
	if (!pMSummary) return;

	pPSummary->ReadRankData();

	RemoveFree();

    CLTGUITextItemCtrl* pCtrl = LTNULL;

	CLTGUIColumnTextCtrl *pRanks=AddColumnText(LTNULL, LTNULL, LTTRUE, GetLargeFont());

	// The rank header
	pRanks->AddColumn(IDS_STAT_RANK, 200, LTF_JUSTIFY_LEFT);
	if (m_nFolderID != FOLDER_ID_FAILURE)
	{
		pRanks->AddColumn(IDS_SUMMARY_BEST, 200, LTF_JUSTIFY_LEFT);
	}
    pRanks->Enable(LTFALSE);

	pRanks=AddColumnText(LTNULL, LTNULL, LTTRUE, GetSmallFont());

	//rank
    LTFLOAT fRank = 0.0f;
	int nRankId = 0;
	if (m_nFolderID == FOLDER_ID_FAILURE)
	{
		pRanks->AddColumn(IDS_STAT_FAILED, 200, LTF_JUSTIFY_LEFT);
	}
	else
	{
		fRank = pMSummary->fCurRank;
		nRankId = g_pMissionMgr->GetMissionRating()->GetRankId(fRank);
		pRanks->AddColumn(nRankId, 200, LTF_JUSTIFY_LEFT);
	}


	if (m_nFolderID != FOLDER_ID_FAILURE)
	{
		//best rank
		fRank = pMSummary->fBestRank;
		nRankId = g_pMissionMgr->GetMissionRating()->GetRankId(fRank);
		pRanks->AddColumn(nRankId, 200, LTF_JUSTIFY_LEFT);
	}
    pRanks->Enable(LTFALSE);


	//time in mission
	char str[128];
    LTFLOAT fSec = pMSummary->fTotalMissionTime;
    uint32 nMin = (uint32)fSec / 60;
    fSec -= (60.0f * (LTFLOAT)nMin);
    uint32 nHour = nMin / 60;
	nMin -= 60 * nHour;
	sprintf(str,"%02d:%02d:%.1f",nHour,nMin,fSec);

    HSTRING hTxt=g_pLTClient->FormatString(IDS_STAT_TIME,str);
    pCtrl= AddTextItem(hTxt,LTNULL,0,LTTRUE, GetLargeFont());
    pCtrl->Enable(LTFALSE);
    g_pLTClient->FreeString(hTxt);


	//accuracy
	if (pMission->bAllowAwards)
	{
		pCtrl = AddTextItem(IDS_STAT_ACCURACY,LTNULL,0, LTTRUE, GetLargeFont());
		pCtrl->Enable(LTFALSE);
		LTFLOAT fAccuracy = 0.0f;
		if (pMSummary->dwNumShotsFired)
		{
			fAccuracy = (LTFLOAT) pMSummary->dwNumHits / (LTFLOAT) pMSummary->dwNumShotsFired;
			int nAccuracy =(int)( 100.0f * fAccuracy);

			//shots fired
			hTxt=g_pLTClient->FormatString(IDS_STAT_SHOTS,
					pMSummary->dwNumShotsFired,pMSummary->dwNumHits, nAccuracy);
			pCtrl= AddTextItem(hTxt,LTNULL,0,LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);

			//hit locations
			uint32 h = pMSummary->dwHitLocations[HL_HEAD];
			uint32 t = pMSummary->dwHitLocations[HL_TORSO];
			uint32 a = pMSummary->dwHitLocations[HL_ARM];
			uint32 l = pMSummary->dwHitLocations[HL_LEG];
			hTxt=g_pLTClient->FormatString(IDS_STAT_HITS,h,t,(a+l));
			pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);

			// casualties
			pCtrl = AddTextItem(IDS_STAT_CASUALTIES,LTNULL,0, LTTRUE, GetLargeFont());
			pCtrl->Enable(LTFALSE);
			hTxt=g_pLTClient->FormatString(IDS_STAT_KILLS, pMSummary->dwNumEnemyKills,
											pMSummary->dwNumFriendKills, pMSummary->dwNumNeutralKills);
			pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);


		}
		else
		{
			hTxt=g_pLTClient->FormatString(IDS_STAT_NOSHOTS);
			pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);
		}
	

		//stealth
		pCtrl = AddTextItem(IDS_STAT_STEALTH,LTNULL,0, LTTRUE, GetLargeFont());
		pCtrl->Enable(LTFALSE);

		hTxt=g_pLTClient->FormatString(IDS_STAT_DETECTED,pMSummary->dwNumTimesDetected,pMSummary->dwNumDisturbances);
		pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
		pCtrl->Enable(LTFALSE);
		g_pLTClient->FreeString(hTxt);
		hTxt=g_pLTClient->FormatString(IDS_STAT_DETECTED2,pMSummary->dwNumBodies,pMSummary->dwNumTimesHit);
		pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
		pCtrl->Enable(LTFALSE);
		g_pLTClient->FreeString(hTxt);
	}


	//inteligence
    pCtrl = AddTextItem(IDS_STAT_INTEL,LTNULL,0, LTTRUE, GetLargeFont());
    pCtrl->Enable(LTFALSE);

	int cur = pMSummary->m_nMissionCurNumIntel;
	int total = pMSummary->m_nMissionTotalIntel;
    hTxt=g_pLTClient->FormatString(IDS_SUMMARY_FOUND,cur,total);
    pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
    pCtrl->Enable(LTFALSE);



	if (m_nFolderID == FOLDER_ID_FAILURE)
	{
		nContinueId = FOLDER_ID_LOAD;
		nContinueHelpId = IDS_HELP_LOAD;
	}
	else
	{
		//	Generate Awards
		CFolderAwards* pAwards = (CFolderAwards*)m_pFolderMgr->GetFolderFromID(FOLDER_ID_AWARDS);
		pAwards->UpdateData();
		if (pAwards->HasAwards())
		{
			nContinueId = FOLDER_ID_AWARDS;
			nContinueHelpId = IDS_HELP_AWARDS;
		}
		else
		{
			nContinueId = FOLDER_ID_BRIEFING;
			nContinueHelpId = IDS_HELP_NEXTMISSION;
		}
	}

	UseContinue(nContinueId,nContinueHelpId);
	CalculateLastDrawn();
	CheckArrows();
	SetSelection(GetIndex(m_pContinue));

}
// Build the folder
LTBOOL CFolderHostLevels::Build()
{
	if (!g_vtNetGameType.IsInitted())
	{
        g_vtNetGameType.Init(g_pLTClient,"NetGameType",LTNULL,(float)m_nGameType);
	}

	rcAvailRect = g_pLayoutMgr->GetFolderCustomRect((eFolderID)m_nFolderID,"AvailLevelsRect");
	rcSelRect = g_pLayoutMgr->GetFolderCustomRect((eFolderID)m_nFolderID,"SelLevelsRect");
	rcCommandRect = g_pLayoutMgr->GetFolderCustomRect((eFolderID)m_nFolderID,"CommandRect");
	nIndent = g_pLayoutMgr->GetFolderCustomInt((eFolderID)m_nFolderID,"TextIndent");
	nArrowWidth = g_pLayoutMgr->GetFolderCustomInt((eFolderID)m_nFolderID,"ArrowWidth");

	CreateTitle(IDS_TITLE_HOST_LEVELS);

	//Add Avail Levels List
    LTIntPt pos(rcAvailRect.left + nIndent,rcAvailRect.top);
	CLTGUIFont *pFont = GetLargeFont();
	nBarHeight = pFont->GetHeight();

    CStaticTextCtrl *pCtrl = CreateStaticTextItem(IDS_HOST_AVAIL_LEVELS, LTNULL, LTNULL,0,0, LTTRUE, pFont);
    AddFixedControl(pCtrl,pos,LTFALSE);
    pCtrl->Enable(LTFALSE);

	pFont = GetSmallFont();
	pos.x = rcAvailRect.left + nIndent;
	pos.y = rcAvailRect.top + nBarHeight;
	int nListHeight = (rcAvailRect.bottom - rcAvailRect.top) - nBarHeight;
	int nListWidth = (rcAvailRect.right - rcAvailRect.left) - nArrowWidth;

	m_pAvailLevels = debug_new(CListCtrl);
    m_pAvailLevels->Create(nListHeight, LTTRUE, nListWidth);
	m_pAvailLevels->SetParam1(nListWidth);
	m_pAvailLevels->SetItemSpacing(0);
    m_pAvailLevels->EnableMouseMoveSelect(LTTRUE);
	m_pAvailLevels->SetHelpID(IDS_HELP_AVAIL_LEVELS);
    AddFixedControl(m_pAvailLevels,pos,LTTRUE);

	//Add Selected Levels List
    pos = LTIntPt(rcSelRect.left + nIndent,rcSelRect.top);
	pFont = GetLargeFont();

    pCtrl = CreateStaticTextItem(IDS_HOST_SELECTED_LEVELS, LTNULL, LTNULL,0,0,LTTRUE, pFont);
    AddFixedControl(pCtrl,pos,LTFALSE);
    pCtrl->Enable(LTFALSE);

	pFont = GetSmallFont();
	pos.x = rcSelRect.left + nIndent;
	pos.y = rcSelRect.top + nBarHeight;
	nListHeight = (rcSelRect.bottom - rcSelRect.top) - nBarHeight;
	nListWidth = (rcSelRect.right - rcSelRect.left) - nArrowWidth;

	m_pSelLevels = debug_new(CListCtrl);
    m_pSelLevels->Create(nListHeight, LTTRUE, nListWidth);
	m_pSelLevels->SetParam1(nListWidth);
	m_pSelLevels->SetItemSpacing(0);
    m_pSelLevels->EnableMouseMoveSelect(LTTRUE);
	m_pSelLevels->SetHelpID(IDS_HELP_SEL_LEVELS);
    AddFixedControl(m_pSelLevels,pos,LTTRUE);

	//Add Commands
    pos = LTIntPt(rcCommandRect.left + nIndent,rcCommandRect.top);
	nListWidth = rcCommandRect.right - rcCommandRect.left;
	pFont = GetLargeFont();


	m_pAddAll = CreateStaticTextItem(IDS_HOST_ADD_ALL, CMD_ADD_ALL, IDS_HELP_ADD_ALL, nListWidth);
    AddFixedControl(m_pAddAll,pos,LTTRUE);
	pos.y += (m_nItemSpacing + pFont->GetHeight());

	m_pAddLevel = CreateStaticTextItem(IDS_HOST_ADD_LEVEL, CMD_ADD_LEVEL, IDS_HELP_ADD_LEVEL, nListWidth);
    AddFixedControl(m_pAddLevel,pos,LTTRUE);
	pos.y += (m_nItemSpacing + pFont->GetHeight());

	m_pRemoveLevel = CreateStaticTextItem(IDS_HOST_REMOVE_LEVEL, CMD_REMOVE_LEVEL, IDS_HELP_REM_LEVEL, nListWidth);
    AddFixedControl(m_pRemoveLevel,pos,LTTRUE);
	pos.y += (m_nItemSpacing + pFont->GetHeight());

	m_pRemoveAll = CreateStaticTextItem(IDS_HOST_REMOVE_ALL, CMD_REMOVE_ALL, IDS_HELP_REM_ALL, nListWidth);
    AddFixedControl(m_pRemoveAll,pos,LTTRUE);
	pos.y += (m_nItemSpacing + pFont->GetHeight());



 	// Make sure to call the base class
	if (!CBaseFolder::Build()) return LTFALSE;

	UseBack(LTTRUE,LTTRUE);

	return LTTRUE;

}
void CFolderHostLevels::AddLevelToList(CListCtrl *pList, char* sGameLevel)
{
	// Sanity checks...

	if (!pList) return;
	if (!sGameLevel) return;
	if (sGameLevel[0] == '\0') return;
	if (pList->GetNum() == MAX_GAME_LEVELS) return;

	char sLevel[128];
	char sTemp[128];
	strcpy(sLevel, sGameLevel);
	strcpy(sTemp, sGameLevel);

	// Prepare the level name by stripping out the prefixes...
	int nLen = strlen(sTemp);
	if (nLen > 2)
	{
		int i = nLen - 1;

		while (i > 0 && sTemp[i] != '\\')
		{
			i--;
		}

		if (i < nLen - 1)
		{
			if (sTemp[i] == '\\') i++;
			strcpy(sLevel, &sTemp[i]);
		}
	}


	// Add the level to the list...

    CStaticTextCtrl *pCtrl = CreateStaticTextItem(sLevel,LTNULL,LTNULL,(int)pList->GetParam1(),GetSmallFont()->GetHeight(),LTFALSE,GetSmallFont());
	pList->AddControl(pCtrl);

}
LTBOOL CFolderHostLevels::FillLevelList(CListCtrl *pList, char* sDir)
{
	// Sanity checks...

    if (!pList) return(LTFALSE);
    if (!sDir) return(LTFALSE);

    FileEntry* pFiles = g_pLTClient->GetFileList(sDir);
	if (!pFiles) return(FALSE);

	FileEntry* ptr = pFiles;

	// Array of controls to add to the list
	CMoArray<CString *>	m_levels;
	m_levels.SetSize(0);



	while (ptr)
	{
		if (ptr->m_Type == TYPE_FILE)
		{
			if (strnicmp(&ptr->m_pBaseFilename[strlen(ptr->m_pBaseFilename) - 4], ".dat", 4) == 0)
			{
				char sLevel[128];
				strcpy(sLevel, ptr->m_pBaseFilename);
				int len = strlen(sLevel);
				if (len > 4) sLevel[len - 4] = '\0';

				CString *pStr = debug_new1(CString, sLevel);


				m_levels.Add(pStr);

			}
		}

		ptr = ptr->m_pNext;
	}

    g_pLTClient->FreeFileList(pFiles);

	while (m_levels.GetSize())
	{
		uint32 nCur = 0;
		uint32 nTest = 1;
		while (nTest < m_levels.GetSize())
		{
		
			if (m_levels[nTest]->CompareNoCase((char *)(LPCTSTR)(*m_levels[nCur])) < 0)
			{
				nCur = nTest;
			}
			nTest++;
		}

		
		CStaticTextCtrl *pCtrl = CreateStaticTextItem((char *)(LPCTSTR)(*m_levels[nCur]),LTNULL,LTNULL,(int)pList->GetParam1(),GetSmallFont()->GetHeight(),LTFALSE,GetSmallFont());
		pList->AddControl(pCtrl);
		debug_delete(m_levels[nCur]);
		m_levels.Remove(nCur);

	}


    return (LTTRUE);
}
示例#20
0
void CFolderAwards::UpdateData()
{
	CPlayerSummaryMgr *pPSummary = g_pGameClientShell->GetPlayerSummary();
	if (!pPSummary) return;

	CMissionData* pMissionData = g_pInterfaceMgr->GetMissionData();
	if (!pMissionData) return;

	int nMissionNum = pMissionData->GetMissionNum();
	MISSION* pMission = g_pMissionMgr->GetMission(nMissionNum);
	if (!pMission) return;

	MISSIONSUMMARY* pMSummary = pPSummary->GetMissionSummary(nMissionNum);
	if (!pMSummary) return;

	pPSummary->ReadRankData();

	RemoveFree();

    CLTGUITextItemCtrl* pCtrl = LTNULL;


	g_pLTClient->CPrint("best:%0.2f,old best:%0.2f",pMSummary->fBestRank, pMSummary->fOldBestRank);
	if (pMSummary->fBestRank > pMSummary->fOldBestRank)
	{
		RANKBONUS oldBonus;
		RANKBONUS newBonus;
		pMission->GetRankBonus(pMSummary->fBestRank,&newBonus);
		pMission->GetRankBonus(pMSummary->fOldBestRank,&oldBonus);
		if (newBonus.nPerturbPoints > oldBonus.nPerturbPoints)
		{
			pCtrl = AddTextItem(IDS_BONUS_PERTURB,LTNULL,0, LTTRUE, GetMediumFont());
			pCtrl->Enable(LTFALSE);
		}

		if (newBonus.nAmmoPoints > oldBonus.nAmmoPoints)
		{
			pCtrl = AddTextItem(IDS_BONUS_AMMO,LTNULL,0, LTTRUE, GetMediumFont());
			pCtrl->Enable(LTFALSE);
		}

		if (newBonus.nArmorPoints > oldBonus.nArmorPoints)
		{
			pCtrl = AddTextItem(IDS_BONUS_ARMOR,LTNULL,0, LTTRUE, GetMediumFont());
			pCtrl->Enable(LTFALSE);
		}

		if (newBonus.nDamagePoints > oldBonus.nDamagePoints)
		{
			pCtrl = AddTextItem(IDS_BONUS_DAMAGE,LTNULL,0, LTTRUE, GetMediumFont());
			pCtrl->Enable(LTFALSE);
		}

		if (newBonus.nHealthPoints > oldBonus.nHealthPoints)
		{
			pCtrl = AddTextItem(IDS_BONUS_HEALTH,LTNULL,0, LTTRUE, GetMediumFont());
			pCtrl->Enable(LTFALSE);
		}

		if (newBonus.nReputationPoints > oldBonus.nReputationPoints)
		{
			pCtrl = AddTextItem(IDS_BONUS_REPUTATION,LTNULL,0, LTTRUE, GetMediumFont());
			pCtrl->Enable(LTFALSE);
		}

		if (newBonus.nStealthPoints > oldBonus.nStealthPoints)
		{
			pCtrl = AddTextItem(IDS_BONUS_STEALTH,LTNULL,0, LTTRUE, GetMediumFont());
			pCtrl->Enable(LTFALSE);
		}

	}

	if (pCtrl)
		AddBlankLine();


//	Generate Awards
	if (pMission->bAllowAwards)
	{
		MISSIONAWARDS *pAwards = g_pMissionMgr->GetMissionAwards();

		int awardNum = 0;
        pCtrl = AddTextItem(IDS_AWARDS,LTNULL,0, LTTRUE, GetLargeFont());
        pCtrl->Enable(LTFALSE);

        if (pAwards->nNumHighAmmoAwards && pMission->nHighAmmo > -1 && pMSummary->dwNumShotsFired >= (uint32)pMission->nHighAmmo)
		{
			awardNum = GetRandom(0,pAwards->nNumHighAmmoAwards-1);
            pCtrl = AddTextItem(pAwards->aHighAmmoAwards[awardNum],LTNULL,0, LTTRUE, GetSmallFont());
            pCtrl->Enable(LTFALSE);
		}
        if (pAwards->nNumLowAmmoAwards && pMission->nLowAmmo > -1 && pMSummary->dwNumShotsFired <= (uint32)pMission->nLowAmmo)
		{
			awardNum = GetRandom(0,pAwards->nNumLowAmmoAwards-1);
            pCtrl = AddTextItem(pAwards->aLowAmmoAwards[awardNum],LTNULL,0, LTTRUE, GetSmallFont());
            pCtrl->Enable(LTFALSE);
		}
	    LTFLOAT fAccuracy = 0.0f;
		if (pMSummary->dwNumShotsFired)
		{
			fAccuracy = (LTFLOAT) pMSummary->dwNumHits / (LTFLOAT) pMSummary->dwNumShotsFired;
		}

		if (pAwards->nNumAccuracyAwards && fAccuracy > pAwards->fAccuracyPct)
		{
			awardNum = GetRandom(0,pAwards->nNumAccuracyAwards-1);
            pCtrl = AddTextItem(pAwards->aAccuracyAwards[awardNum],LTNULL,0, LTTRUE, GetSmallFont());
            pCtrl->Enable(LTFALSE);
		}
		if (pAwards->nNumMarksmanAwards && pMSummary->dwNumShotsFired)
		{

            LTFLOAT fMarksman = (LTFLOAT) pMSummary->dwHitLocations[HL_HEAD] / (LTFLOAT) pMSummary->dwNumShotsFired;
			if (fMarksman > pAwards->fMarksmanPct)
			{
				awardNum = GetRandom(0,pAwards->nNumMarksmanAwards-1);
                pCtrl = AddTextItem(pAwards->aMarksmanAwards[awardNum],LTNULL,0, LTTRUE, GetSmallFont());
                pCtrl->Enable(LTFALSE);
			}
		}
		if (pAwards->nNumNonInjuryAwards && g_pInterfaceMgr->GetPlayerStats()->GetMissionDamage() == 0)
		{

			awardNum = GetRandom(0,pAwards->nNumNonInjuryAwards-1);
            pCtrl = AddTextItem(pAwards->aNonInjuryAwards[awardNum],LTNULL,0, LTTRUE, GetSmallFont());

            pCtrl->Enable(LTFALSE);
		}
		if (pAwards->nNumNotShotAwards && pMSummary->dwNumTimesHit == 0)
		{

			awardNum = GetRandom(0,pAwards->nNumNotShotAwards-1);
            pCtrl = AddTextItem(pAwards->aNotShotAwards[awardNum],LTNULL,0, LTTRUE, GetSmallFont());

            pCtrl->Enable(LTFALSE);
		}
        if (pAwards->nNumStealthAwards && pMission->nMaxDetect > -1 && (pMSummary->dwNumTimesDetected + pMSummary->dwNumBodies) <= (uint32)pMission->nMaxDetect)
		{
			awardNum = GetRandom(0,pAwards->nNumStealthAwards-1);
            pCtrl = AddTextItem(pAwards->aStealthAwards[awardNum],LTNULL,0, LTTRUE, GetSmallFont());
            pCtrl->Enable(LTFALSE);
		}

	}
}
LTBOOL CFolderJoin::Render(HSURFACE hDestSurf)
{
	// There's no update pump, so we'll have to do it here...

	if (GetGameSpyClientMgr()->IsInitialized())
	{
		Update(hDestSurf);
	}
	else
	{
		UpdateDummyStatus(hDestSurf);
	}

	int xo = g_pInterfaceResMgr->GetXOffset();
	int yo = g_pInterfaceResMgr->GetYOffset();

	//Draw server bar
	DrawBar(hDestSurf,&rcServerRect);

	if (m_pServerList->GetLastDisplayedIndex() >= 0)
	{
		if (m_pServerList->GetLastDisplayedIndex() != nOldIndex)
		{
			if (m_hServersShown)
			{
				g_pLTClient->FreeString(m_hServersShown);
			}
	//(servers %d-%d)
			m_hServersShown = g_pLTClient->FormatString(IDS_SERVERS_SHOWN,m_pServerList->GetStartIndex()+1,m_pServerList->GetLastDisplayedIndex()+1);
			nOldIndex = m_pServerList->GetLastDisplayedIndex();
		}
		
		GetSmallFont()->Draw(m_hServersShown, hDestSurf, xo+rcServerRect.right-nIndent, yo+rcServerRect.top+nIndent, LTF_JUSTIFY_RIGHT, m_hNonSelectedColor);
	}

    CLTGUICtrl *pSortCtrl = LTNULL;
	switch (m_nServerSort)
	{
	case FSS_SORT_NAME:
		pSortCtrl = pServerNameCtrl;
		break;
	case FSS_SORT_PLAYERS:
		pSortCtrl = pServerPlayersCtrl;
		break;
	case FSS_SORT_PING:
		pSortCtrl = pServerPingCtrl;
		break;
	case FSS_SORT_GAME:
		pSortCtrl = pServerGameCtrl;
		break;
	case FSS_SORT_MAP:
		pSortCtrl = pServerMapCtrl;
		break;
	}
	if (pSortCtrl)
	{
        LTIntPt pos = pSortCtrl->GetPos();
		pos.x += xo;
		pos.y += yo;
        LTRect rect(pos.x, (pos.y + pSortCtrl->GetHeight()) - 5, pos.x + pSortCtrl->GetWidth(), (pos.y + pSortCtrl->GetHeight()) - 3);
        g_pLTClient->FillRect(hDestSurf,&rect,m_hSelectedColor);

	}

	//Draw player bar
	DrawBar(hDestSurf,&rcPlayerRect);

    pSortCtrl = LTNULL;
	switch (m_nPlayerSort)
	{
	case FSS_SORT_NAME:
		pSortCtrl = pPlayerNameCtrl;
		break;
	case FSS_SORT_FRAGS:
		pSortCtrl = pPlayerFragCtrl;
		break;
	case FSS_SORT_PING:
		pSortCtrl = pPlayerPingCtrl;
		break;
	}
	if (pSortCtrl)
	{
        LTIntPt pos = pSortCtrl->GetPos();
		pos.x += xo;
		pos.y += yo;
        LTRect rect(pos.x, (pos.y + pSortCtrl->GetHeight()) - 5, pos.x + pSortCtrl->GetWidth(), (pos.y + pSortCtrl->GetHeight()) - 3);
        g_pLTClient->FillRect(hDestSurf,&rect,m_hSelectedColor);

	}

	//Draw option bar
	DrawBar(hDestSurf,&rcOptionRect);

	//Draw option bar
	DrawBar(hDestSurf,&rcStatusRect);

	if (m_hStatus)
	{

		if (m_nState == FSS_IDLE)
			GetSmallFont()->Draw(m_hStatus, hDestSurf, xo+nIndent, yo+rcStatusRect.top+nIndent, LTF_JUSTIFY_LEFT, m_hNonSelectedColor);
		else
			GetSmallFont()->Draw(m_hStatus, hDestSurf, xo+nIndent, yo+rcStatusRect.top+nIndent, LTF_JUSTIFY_LEFT, m_hSelectedColor);
	}

    LTBOOL bOK = CBaseFolder::Render(hDestSurf);

	if (GetGameSpyClientMgr()->IsInitialized())
	{
		// Let the GameSpy client manager do another update...
//		GetGameSpyClientMgr()->Update();
	}
	else
	{
		if (bFrameDelay)
		{
            bFrameDelay = LTFALSE;
		}
		else
		{
			// Init the GameSpy client manager...
			BOOL bRet = GetGameSpyClientMgr()->Init(GAMESPY_GAME_NAME, GAMESPY_SECRET_KEY);
			if (!bRet)
			{
                return LTFALSE;
			}
		}
	}

	return bOK;
}
void CFolderStats::UpdateData()
{
	CPlayerSummaryMgr *pPSummary = g_pGameClientShell->GetPlayerSummary();
	if (!pPSummary) return;
	CMissionData* pMissionData = g_pInterfaceMgr->GetMissionData();
	if (!pMissionData) return;
	int nMissionNum = pMissionData->GetMissionNum();
	MISSION* pMission = g_pMissionMgr->GetMission(nMissionNum);
	MISSIONSUMMARY* pMSummary = pPSummary->GetMissionSummary(nMissionNum);

	pPSummary->ReadRankData();

	RemoveFree();

    CLTGUITextItemCtrl* pCtrl = LTNULL;
    HSTRING hTxt = LTNULL;

	//time in mission
	char str[128];
    LTFLOAT fSec = pMSummary->fTotalMissionTime;
    uint32 nMin = (uint32)fSec / 60;
    fSec -= (60.0f * (LTFLOAT)nMin);
    uint32 nHour = nMin / 60;
	nMin -= 60 * nHour;
	sprintf(str,"%02d:%02d:%.1f",nHour,nMin,fSec);

    hTxt=g_pLTClient->FormatString(IDS_STAT_TIME,str);
    pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetLargeFont());
    pCtrl->Enable(LTFALSE);
    g_pLTClient->FreeString(hTxt);

	AddBlankLine();

	//accuracy
    pCtrl = AddTextItem(IDS_STAT_ACCURACY,LTNULL,0,LTTRUE, GetLargeFont());
    pCtrl->Enable(LTFALSE);
    LTFLOAT fAccuracy = 0.0f;
	if (pMSummary->dwNumShotsFired)
	{
        fAccuracy = (LTFLOAT) pMSummary->dwNumHits / (LTFLOAT) pMSummary->dwNumShotsFired;
		int nAccuracy =(int)( 100.0f * fAccuracy);

		//shots fired
        hTxt=g_pLTClient->FormatString(IDS_STAT_SHOTS,
				pMSummary->dwNumShotsFired,pMSummary->dwNumHits, nAccuracy);
        pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
        pCtrl->Enable(LTFALSE);
        g_pLTClient->FreeString(hTxt);

		//hit locations
        uint32 h = pMSummary->dwHitLocations[HL_HEAD];
        uint32 t = pMSummary->dwHitLocations[HL_TORSO];
        uint32 a = pMSummary->dwHitLocations[HL_ARM];
        uint32 l = pMSummary->dwHitLocations[HL_LEG];
        hTxt=g_pLTClient->FormatString(IDS_STAT_HITS,h,t,(a+l));
        pCtrl= AddTextItem(hTxt,LTNULL,0,LTTRUE, GetSmallFont());
        pCtrl->Enable(LTFALSE);
        g_pLTClient->FreeString(hTxt);

		AddBlankLine();

		// casualties
        pCtrl = AddTextItem(IDS_STAT_CASUALTIES,LTNULL,0, LTTRUE, GetLargeFont());
        pCtrl->Enable(LTFALSE);
        hTxt=g_pLTClient->FormatString(IDS_STAT_KILLS, pMSummary->dwNumEnemyKills,
										pMSummary->dwNumFriendKills, pMSummary->dwNumNeutralKills);
        pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
        pCtrl->Enable(LTFALSE);
        g_pLTClient->FreeString(hTxt);


	}
	else
	{
        hTxt=g_pLTClient->FormatString(IDS_STAT_NOSHOTS);
        pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
        pCtrl->Enable(LTFALSE);
        g_pLTClient->FreeString(hTxt);
	}

	AddBlankLine();

	//stealth
    pCtrl = AddTextItem(IDS_STAT_STEALTH,LTNULL,0, LTTRUE, GetLargeFont());
    pCtrl->Enable(LTFALSE);

    hTxt=g_pLTClient->FormatString(IDS_STAT_DETECTED,pMSummary->dwNumTimesDetected,pMSummary->dwNumDisturbances);
    pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
    pCtrl->Enable(LTFALSE);
    g_pLTClient->FreeString(hTxt);
    hTxt=g_pLTClient->FormatString(IDS_STAT_DETECTED2,pMSummary->dwNumBodies,pMSummary->dwNumTimesHit);
    pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
    pCtrl->Enable(LTFALSE);
    g_pLTClient->FreeString(hTxt);


	AddBlankLine();

	//inteligence
	int cur = pMSummary->m_nMissionCurNumIntel;
	if (cur)
	{
        pCtrl = AddTextItem(IDS_STAT_INTEL,LTNULL,0, LTTRUE, GetLargeFont());
        pCtrl->Enable(LTFALSE);
		
        hTxt=g_pLTClient->FormatString(IDS_STAT_FOUND,cur);
        pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
        pCtrl->Enable(LTFALSE);
	}
	if (cur || pMSummary->m_nMissionMaxIntel)
		AddTextItem(IDS_VIEW_GALLERY,CMD_INTEL,IDS_HELP_VIEW_GALLERY, LTFALSE, GetSmallFont());

	CalculateLastDrawn();
	CheckArrows();
}
void CFolderLoad::BuildSavedLevelList()
{
	char strSaveGameSetting[256];
	memset (strSaveGameSetting, 0, 256);

	if (CWinUtil::FileExist(QUICKSAVE_FILENAME))
	{
		SaveGameData sQuickSave;
		CWinUtil::WinGetPrivateProfileString (GAME_NAME, "SaveGame00", "", strSaveGameSetting, 256, SAVEGAMEINI_FILENAME);
		ParseSaveString(strSaveGameSetting,&sQuickSave,LTFALSE);
		if (strlen(sQuickSave.szUserName) > 0)
		{
			CLTGUITextItemCtrl *pCtrl = AddTextItem(IDS_QUICKLOAD,LTNULL,LTNULL,LTTRUE,GetMediumFont());
			pCtrl->Enable(LTFALSE);

			char szStr[256];
			sprintf(szStr,"    %s",sQuickSave.szUserName);
			HSTRING hLoad=g_pLTClient->CreateString(szStr);
			CLTGUIColumnTextCtrl* pColCtrl = AddColumnText(FOLDER_CMD_CUSTOM, IDS_HELP_QUICKLOAD, LTFALSE, GetSmallFont());

			// The world name column
			pColCtrl->AddColumn(hLoad, kColumnWidth, LTF_JUSTIFY_LEFT);

			if (strlen(sQuickSave.szTime) > 0)
			{
				// The column that contains the date/time
				HSTRING hTime=g_pLTClient->CreateString(sQuickSave.szTime);
				pColCtrl->AddColumn(hTime, 230, LTF_JUSTIFY_LEFT);
				g_pLTClient->FreeString(hTime);
			}
			g_pLTClient->FreeString(hLoad);
			
		}
	}

	if (CWinUtil::FileExist(RELOADLEVEL_FILENAME))
	{
		CWinUtil::WinGetPrivateProfileString (GAME_NAME, "Reload", "", strSaveGameSetting, 256, SAVEGAMEINI_FILENAME);
		SaveGameData sAutoSave;
		ParseSaveString(strSaveGameSetting,&sAutoSave,LTFALSE);
		if (strlen(sAutoSave.szUserName) > 0)
		{
			CLTGUITextItemCtrl *pCtrl = AddTextItem(IDS_LOADCURRENT,LTNULL,LTNULL,LTTRUE,GetMediumFont());
			pCtrl->Enable(LTFALSE);

			char szStr[256];
			sprintf(szStr,"    %s",sAutoSave.szUserName);
			HSTRING hLoad=g_pLTClient->CreateString(szStr);
			CLTGUIColumnTextCtrl* pColCtrl = AddColumnText(FOLDER_CMD_CUSTOM+1, IDS_HELP_RELOAD, LTFALSE, GetSmallFont());

			// The world name column
			pColCtrl->AddColumn(hLoad, kColumnWidth, LTF_JUSTIFY_LEFT);

			if (strlen(sAutoSave.szTime) > 0)
			{
				// The column that contains the date/time
				HSTRING hTime=g_pLTClient->CreateString(sAutoSave.szTime);
				pColCtrl->AddColumn(hTime, 230, LTF_JUSTIFY_LEFT);
				g_pLTClient->FreeString(hTime);
			}
			g_pLTClient->FreeString(hLoad);
		}
	}
	
	CLTGUITextItemCtrl *pCtrl = AddTextItem(IDS_LOAD_USERGAME,LTNULL,LTNULL,LTTRUE,GetMediumFont());
	pCtrl->Enable(LTFALSE);
	for (int i = 0; i < kMaxSave; i++)
	{

		char strFilename[128];
		sprintf (strFilename, "Save\\Slot%02d.sav", i+1);
		if (CWinUtil::FileExist(strFilename))
		{

			SaveGameData sSave;
			char szKey[32] = "";
			sprintf (szKey, "SaveGame%02d", i+1);
			CWinUtil::WinGetPrivateProfileString (GAME_NAME, szKey, "", strSaveGameSetting, 256, SAVEGAMEINI_FILENAME);
			ParseSaveString(strSaveGameSetting,&sSave);
			if (strlen(sSave.szUserName) > 0)
			{
				char szStr[256];
				sprintf(szStr,"    %s",sSave.szUserName);
				HSTRING hLoad=g_pLTClient->CreateString(szStr);

				CLTGUIColumnTextCtrl* pCtrl = AddColumnText(FOLDER_CMD_CUSTOM+2+i, IDS_HELP_LOADGAME, LTFALSE, GetSmallFont());

				// The world name column
				pCtrl->AddColumn(hLoad, kColumnWidth, LTF_JUSTIFY_LEFT);

				if (strlen(sSave.szTime) > 0)
				{
					// The column that contains the date/time
					HSTRING hTime=g_pLTClient->CreateString(sSave.szTime);
					pCtrl->AddColumn(hTime, 230, LTF_JUSTIFY_LEFT);
					g_pLTClient->FreeString(hTime);
				}
				g_pLTClient->FreeString(hLoad);
			}
		}

	}


}
// Change in focus
void CFolderWeaponControls::OnFocus(LTBOOL bFocus)
{
	if (bFocus)
	{
		nLastId = WMGR_INVALID_ID;
		ReadBindings();		
		CLTGUIColumnTextCtrl *pCtrl=AddColumnText(LTNULL, LTNULL, LTTRUE, GetMediumFont());

		HSTRING hText = g_pLTClient->FormatString(IDS_KEY);
		pCtrl->AddColumn(hText, 50, LTF_JUSTIFY_LEFT);
		g_pLTClient->FreeString(hText);

		hText = g_pLTClient->FormatString(IDS_WEAPON);
		pCtrl->AddColumn(hText, kWidth, LTF_JUSTIFY_LEFT);
		pCtrl->Enable(LTFALSE);
		g_pLTClient->FreeString(hText);

//		AddBlankLine();


		for (int i = 0; i < 10; i++)
		{
			pCtrl=AddColumnText(LTNULL, IDS_HELP_SETWEAPON, LTFALSE, GetSmallFont());
			pCtrl->SetParam1(i+1);

			char str[16];
			sprintf(str,"  %s",szTriggers[i]);
			hText = g_pLTClient->CreateString(str);
			pCtrl->AddColumn(hText, 50, LTF_JUSTIFY_LEFT);
			g_pLTClient->FreeString(hText);

			int nWeaponId = g_pWeaponMgr->GetWeaponId(m_nActions[i]);
			WEAPON *pWeapon = g_pWeaponMgr->GetWeapon(nWeaponId);
			if (pWeapon)
				pCtrl->AddColumn(pWeapon->nNameId, kWidth, LTF_JUSTIFY_LEFT);
			else
				pCtrl->AddColumn(IDS_CONTROL_UNASSIGNED, kWidth, LTF_JUSTIFY_LEFT);


		}

		AddBlankLine();

		m_bLargeIcon = (GetConsoleInt("BindingIconSize",0) > 0);
		CToggleCtrl *pToggle = AddToggle(IDS_WPN_ICON_SZ,IDS_HELP_WPN_ICON_SZ, kWidth, &m_bLargeIcon,LTFALSE,GetSmallFont());
		pToggle->SetOnString(IDS_LARGE);
		pToggle->SetOffString(IDS_SMALL);

		m_nIconAlpha = (int)(GetConsoleFloat("BindingIconAlpha",0.7f) * 10.0f);
		CSliderCtrl *pSlider = AddSlider(IDS_WPN_ICON_A,IDS_HELP_WPN_ICON_A,kWidth,kSlider,&m_nIconAlpha,LTFALSE,GetSmallFont());
		pSlider->SetSliderIncrement(1);
		pSlider->SetSliderRange(0,10);

		m_bUseNumbers = (GetConsoleInt("BindingNumbers",1) > 0);
		pToggle = AddToggle(IDS_WPN_USE_NUMS,IDS_HELP_WPN_USE_NUMS, kWidth, &m_bUseNumbers,LTFALSE,GetSmallFont());
		pToggle->SetOnString(IDS_YES);
		pToggle->SetOffString(IDS_NO);


        UpdateData(LTFALSE);

	}
	else
	{
		UpdateData();

		WriteConsoleInt("BindingIconSize",m_bLargeIcon);
		WriteConsoleInt("BindingNumbers",m_bUseNumbers);
		WriteConsoleFloat("BindingIconAlpha",((LTFLOAT)m_nIconAlpha) / 10.0f);
		WriteBindings();

		g_pInterfaceMgr->GetPlayerStats()->UpdateWeaponBindings();

		// Just to be safe save the config incase anything changed...
        g_pLTClient->WriteConfigFile("autoexec.cfg");
		RemoveFree();

	}
	CBaseFolder::OnFocus(bFocus);
	if (bFocus) UpdateSelection();

}
示例#25
0
// Initialization
DBOOL CMainMenus::Init(CClientDE* pClientDE)
{
	if (!pClientDE)
	{
		return DFALSE;
	}
	
	m_pClientDE = pClientDE;

	// Set the English flag
	HSTRING hString=m_pClientDE->FormatString(IDS_BLOOD2_LANGUAGE);
	if (hString && _mbsicmp((const unsigned char*)"english", (const unsigned char*)m_pClientDE->GetStringData(hString)) != 0)
	{
		m_bEnglish=DFALSE;
	}
	else
	{
		m_bEnglish=DTRUE;
	}
	m_pClientDE->FreeString(hString);
	hString=DNULL;

	// Load the virtual key codes for yes responses
	hString=m_pClientDE->FormatString(IDS_MENU_VKEY_YES);
	if (hString)
	{
		m_nYesVKeyCode=atoi(m_pClientDE->GetStringData(hString));
		m_pClientDE->FreeString(hString);
		hString=DNULL;
	}

	// Load the virtual key codes for no responses
	hString=m_pClientDE->FormatString(IDS_MENU_VKEY_NO);
	if (hString)
	{
		m_nNoVKeyCode=atoi(m_pClientDE->GetStringData(hString));
		m_pClientDE->FreeString(hString);
		hString=DNULL;
	}

	// Init the SharedResourceMgr class
	m_sharedResourceMgr.Init(m_pClientDE);

	// Determine if we need to set the low resolution flag
	RMode currentMode;
	if (m_pClientDE->GetRenderMode(&currentMode) == LT_OK)
	{
		if (currentMode.m_Width < 512 || currentMode.m_Height < 384)
		{
			m_bLowResolution=DTRUE;
			m_nMenuHeight=180;
		}
	}

	// Initialize the surfaces
	if ( !InitSurfaces() )
	{
		return DFALSE;
	}

	// Initialize the fonts
	InitFonts();

	// Initialize the message box
	m_messageBox.Create(m_pClientDE, "interface/mainmenus/dialog.pcx", GetSmallFont(), DNULL, DNULL);
	m_messageBox.SetTextColor(SETRGB(220,190,170));

	// Initialize the individual menus
	m_mainMenu.Init				(m_pClientDE, this, DNULL,				MENU_ID_MAINMENU,		m_nMenuHeight);
	m_singlePlayerMenu.Init		(m_pClientDE, this, &m_mainMenu,		MENU_ID_SINGLEPLAYER,	m_nMenuHeight);	
	m_bloodBathMenu.Init		(m_pClientDE, this, &m_mainMenu,		MENU_ID_BLOODBATH,		m_nMenuHeight);
	m_optionsMenu.Init			(m_pClientDE, this, &m_mainMenu,		MENU_ID_OPTIONS,		m_nMenuHeight);
	m_difficultyMenu.Init		(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_DIFFICULTY,		m_nMenuHeight);	
	m_customLevelMenu.Init		(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CUSTOM_LEVEL,	m_nMenuHeight);
	m_loadGameMenu.Init			(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_LOAD_GAME,		m_nMenuHeight);	
	m_saveGameMenu.Init			(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_SAVE_GAME,		m_nMenuHeight);
	m_controlsMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_CONTROLS,		m_nMenuHeight);
	m_soundMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_SOUND,			m_nMenuHeight);
	m_displayMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_DISPLAY,		m_nMenuHeight);
	m_characterMenu.Init		(m_pClientDE, this, &m_bloodBathMenu,	MENU_ID_CHARACTER,		m_nMenuHeight);	
	m_characterFilesMenu.Init	(m_pClientDE, this, &m_characterMenu,	MENU_ID_CHARACTERFILES,	100);
	m_characterSelectMenu.Init	(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CHARACTERSELECT,m_nMenuHeight);
	m_mouseMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_MOUSE		   ,m_nMenuHeight);
	m_keyboardMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_KEYBOARD	   ,m_nMenuHeight);
	m_joystickMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_JOYSTICK	   ,m_nMenuHeight);

	// Add each menu to the array
	m_menuArray.SetSize(0);
	m_menuArray.Add(&m_mainMenu);
	m_menuArray.Add(&m_singlePlayerMenu);
	m_menuArray.Add(&m_bloodBathMenu);
	m_menuArray.Add(&m_optionsMenu);
	m_menuArray.Add(&m_difficultyMenu);
	m_menuArray.Add(&m_customLevelMenu);
	m_menuArray.Add(&m_loadGameMenu);
	m_menuArray.Add(&m_saveGameMenu);
	m_menuArray.Add(&m_controlsMenu);
	m_menuArray.Add(&m_soundMenu);	
	m_menuArray.Add(&m_characterMenu);
	m_menuArray.Add(&m_characterFilesMenu);
	m_menuArray.Add(&m_characterSelectMenu);	
	m_menuArray.Add(&m_mouseMenu);
	m_menuArray.Add(&m_keyboardMenu);
	m_menuArray.Add(&m_joystickMenu);

	// Build each menu
	unsigned int i;
	for (i=0; i < m_menuArray.GetSize(); i++)
	{
		m_menuArray[i]->Build();
	}	

	// This is done after the build above because it shouldn't be built until the user
	// actually wants to go into the menu.	
	m_menuArray.Add(&m_displayMenu);

	SetCurrentMenu(MENU_ID_MAINMENU, MENU_ID_MAINMENU);	
	
	// Load the version string
	m_hstrVersion = m_pClientDE->FormatString(IDS_VERSION);

	return DTRUE;
}
// Called when the folder gains or focus
void CFolderDisplay::OnFocus(LTBOOL bFocus)
{
	CGameSettings *pSettings = g_pInterfaceMgr->GetSettings();

	if (bFocus)
	{
		m_bEscape = LTFALSE;

		m_bHardwareCursor = (GetConsoleInt("HardwareCursor",0) > 0 && GetConsoleInt("DisableHardwareCursor",0) == 0);
		m_pHardwareCursor->Enable(GetConsoleInt("DisableHardwareCursor",0) == 0);

		// The current render mode
		RMode currentMode;
		g_pLTClient->GetRenderMode(&currentMode);

		// Set the renderer controls so that they match the currently selected renderer
		unsigned int n;
		for (n=0; n < m_rendererArray.GetSize(); n++)
		{
			unsigned int i;
			for (i=0; i < m_rendererArray[n].m_resolutionArray.GetSize(); i++)
			{
				RMode mode=GetRendererModeStruct(n, i);

				if (IsRendererEqual(&currentMode, &mode))
				{
					// Set the renderer index
					m_pRendererCtrl->SetSelIndex(n);

					// Setup the resolution control
					SetupResolutionCtrl();

					// Set the resolution index
					m_pResolutionCtrl->SetSelIndex(i);
				}
			}
		}
		m_bTexture32 = pSettings->GetBoolVar("32BitTextures");
	

        UpdateData(LTFALSE);
		SetSelection(1);

	}
	else
	{
		UpdateData();


		if (m_bEscape)
		{
			LTBOOL bTexture32 = pSettings->GetBoolVar("32BitTextures");

			WriteConsoleInt("HardwareCursor",(int)m_bHardwareCursor);

			pSettings->SetBoolVar("32BitTextures",m_bTexture32);


			LTBOOL bRebind = (bTexture32 != m_bTexture32);

			// Set the render mode if we are losing focus
			if (m_pRendererCtrl && m_pResolutionCtrl)
			{

				int oldMO = (int)pSettings->GetFloatVar("MipmapOffset");

				LTBOOL bSet = SetRenderer(m_pRendererCtrl->GetSelIndex(), m_pResolutionCtrl->GetSelIndex());

				// If we didn't switch resolutions and the mipmap offset changed, rebind textures.
				if(!bSet)
				{
					int curMO = (int)pSettings->GetFloatVar("MipmapOffset");
					if(curMO != oldMO)
					{
						bRebind = LTTRUE;
					}
				}
			}
			if (bRebind)
			{

                g_pLTClient->Start3D();
                g_pLTClient->StartOptimized2D();

				g_pInterfaceResMgr->DrawMessage(GetSmallFont(),IDS_REBINDING_TEXTURES);

                g_pLTClient->EndOptimized2D();
                g_pLTClient->End3D();
                g_pLTClient->FlipScreen(0);
				g_pLTClient->RunConsoleString("RebindTextures");

			}
				
		}

		if (GetConsoleInt("BitDepth",16) == 16)
			WriteConsoleInt("DrawPortals",0);
		else if ((GetConsoleInt("BitDepth",16) == 32) && (GetConsoleInt("PerformanceLevel",1) == 2))
			WriteConsoleInt("DrawPortals",1);

        g_pLTClient->WriteConfigFile("autoexec.cfg");


	}
	CBaseFolder::OnFocus(bFocus);
}