Пример #1
0
void CScreenHostLevels::SaveMissionList()
{
	// Sanity checks...

	if (!m_pSelMissions) return;

	remove(m_sCampaignFile.c_str());

	char szString[256];
	char szNum[4];

	sprintf(szNum, "%d", (m_bLoopMissions ? 1 : 0) );
	CWinUtil::WinWritePrivateProfileString( "MissionList", "LoopMissions", szNum, m_sCampaignFile.c_str());

	CWinUtil::WinWritePrivateProfileString( "MissionList", "MissionSourceFile", g_pMissionButeMgr->GetAttributeFile(), m_sCampaignFile.c_str());

	for (int n = 0; n < m_pSelMissions->GetNumControls(); n++)
	{
		CLTGUITextCtrl *pCtrl = (CLTGUITextCtrl *)m_pSelMissions->GetControl(n);
		if (pCtrl)
		{
			sprintf(szString,"Mission%d",n);
			sprintf(szNum,"%d",pCtrl->GetParam1());
			CWinUtil::WinWritePrivateProfileString( "MissionList", szString, szNum, m_sCampaignFile.c_str());
		}
	}

	// Flush the file.
	CWinUtil::WinWritePrivateProfileString( NULL, NULL, NULL, m_sCampaignFile.c_str());
}			
Пример #2
0
void CScreenProfile::CreateProfileList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();

	// Get new stuff
	m_ProfileList.clear();
	g_pProfileMgr->GetProfileList(m_ProfileList);

	CLTGUICtrl_create cs;
	cs.rnBaseRect.m_vMin.Init();
	cs.rnBaseRect.m_vMax = LTVector2n(kDlgWd - 48,nListFontSz);
	cs.nCommandID = CMD_OK;

	// Profiles to the list
	for (ProfileArray::iterator iter = m_ProfileList.begin(); iter != m_ProfileList.end(); ++iter)
	{
		CLTGUITextCtrl* pTextCtrl = CreateTextItem( iter->m_sFriendlyName.c_str(), cs, false, sListFont.c_str(), nListFontSz);
		if (pTextCtrl)
		{
			uint32 ndx = m_pListCtrl->AddControl(pTextCtrl);
			pTextCtrl->SetParam1(ndx);

			if (LTStrIEquals(iter->m_sFriendlyName.c_str(),m_pProfile->m_sFriendlyName.c_str()))
				m_pListCtrl->SetSelection(ndx);

		}
	}

}
Пример #3
0
LTBOOL CScreenHostLevels::FillAvailList()
{
	// Sanity checks...

    if (!m_pAvailMissions) return(LTFALSE);


	for (int nMission = 0; nMission < g_pMissionButeMgr->GetNumMissions(); nMission++)
	{
		MISSION* pMission = g_pMissionButeMgr->GetMission(nMission);
		if (pMission)
		{
			CLTGUITextCtrl *pCtrl = NULL;
			if (pMission->nNameId > 0)
				pCtrl = CreateTextItem(LoadTempString(pMission->nNameId),CMD_ADD_LEVEL,pMission->nDescId);
			else if (!pMission->sName.empty())
				pCtrl = CreateTextItem((char *)pMission->sName.c_str(),CMD_ADD_LEVEL,pMission->nDescId);
			else
			{
				char szWorldTitle[MAX_PATH] = "";
				_splitpath( pMission->aLevels[0].szLevel, NULL, NULL, szWorldTitle, NULL );
				pCtrl = CreateTextItem(szWorldTitle,CMD_ADD_LEVEL,0);
			}
			pCtrl->SetFont(LTNULL,nListFontSize);
			pCtrl->SetParam1(nMission);
			pCtrl->SetFixedWidth(nAvailWidth,LTTRUE);
			m_pAvailMissions->AddControl(pCtrl);
		}
	}


    return (LTTRUE);
}
Пример #4
0
void CScreenProfile::CreateProfileList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();

	// Get new stuff
	m_ProfileList.clear();
	g_pProfileMgr->GetProfileList(m_ProfileList);

	CUIFont *pFont = g_pInterfaceResMgr->GetFont(nListFont);

	// Profiles to the list
	for (StringSet::iterator iter = m_ProfileList.begin(); iter != m_ProfileList.end(); ++iter)
	{
		char *pStr = (char *)iter->c_str();
		CLTGUITextCtrl* pTextCtrl = CreateTextItem(pStr, CMD_OK, LTNULL);
		pTextCtrl->SetFont(pFont,nListFontSz);
		uint16 ndx = m_pListCtrl->AddControl(pTextCtrl);
		pTextCtrl->SetParam1(ndx);

		if (stricmp(iter->c_str(),m_pProfile->m_sName.c_str()) == 0)
			m_pListCtrl->SetSelection(ndx);
	}

}
Пример #5
0
// Build the screen
LTBOOL CScreenFailure::Build()
{
	CreateTitle(NULL);

	if (g_pLayoutMgr->HasCustomValue(SCREEN_ID_FAILURE,"FailStringRect"))
	{
		stringRect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_FAILURE,"FailStringRect");
	}
	if (g_pLayoutMgr->HasCustomValue(SCREEN_ID_FAILURE,"FailStringSize"))
	{
		stringSize = (uint8)g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_FAILURE,"FailStringSize");
	}

	if (g_pLayoutMgr->HasCustomValue(SCREEN_ID_FAILURE,"HelpStringPos"))
	{
		helpPos = g_pLayoutMgr->GetScreenCustomPoint(SCREEN_ID_FAILURE,"HelpStringPos");
	}
	if (g_pLayoutMgr->HasCustomValue(SCREEN_ID_FAILURE,"HelpStringSize"))
	{
		helpSize = (uint8)g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_FAILURE,"HelpStringSize");
	}

	LTIntPt stringPos;
	stringPos.x = (stringRect.left + stringRect.right) / 2;
	stringPos.y = stringRect.top;
	m_pString = AddTextItem("failed",NULL,NULL,stringPos,LTTRUE);
	if (m_pString)
	{
		m_pString->SetFont(NULL,stringSize);
		m_pString->SetFixedWidth(stringRect.right - stringRect.left);
		CUIFormattedPolyString *pStr = m_pString->GetString();
		if (pStr)
		{
			pStr->SetAlignmentH(CUI_HALIGN_CENTER);
		}
	}

	if (g_pLayoutMgr->HasCustomValue(SCREEN_ID_FAILURE,"Delay"))
	{
		g_fDelay = g_pLayoutMgr->GetScreenCustomFloat(SCREEN_ID_FAILURE,"Delay");
	}

	CLTGUITextCtrl *pString = AddTextItem(IDS_HELP_FAILURE,NULL,NULL,helpPos,LTTRUE);
	if (pString)
	{
		pString->SetFont(NULL,helpSize);
	}


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

	UseBack(LTFALSE);
	return LTTRUE;
}
Пример #6
0
// Build the list of Chapters
void CScreenSingle::BuildChapterList()
{
	LTRect rect = g_pLayoutMgr->GetScreenCustomRect((eScreenID)m_nScreenID,"ChapterRect");
	int nWidth = (rect.right - rect.left) - 16;


	CLTGUITextCtrl* pItem;

	uint8 nListFontSize = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontSize");
	for (int i = 0; i < g_pMissionButeMgr->GetNumMissions(); i++)
	{
		const MISSION* pMission = g_pMissionButeMgr->GetMission(i);

		pItem = CreateTextItem(pMission->nNameId, CMD_CUSTOM+1000+i, pMission->nDescId);
		pItem->SetFont(LTNULL, nListFontSize);
		pItem->SetFixedWidth(nWidth,LTTRUE);

		m_pChapter->AddControl(pItem);
		
	}
}
Пример #7
0
void CScreenHostLevels::AddMissionToList(int nMissionId)
{
	// Sanity checks...

	if (!m_pSelMissions) return;
	if (m_pSelMissions->GetNumControls() == MAX_GAME_LEVELS) return;


	// Add the level to the list...

	MISSION *pMission = g_pMissionButeMgr->GetMission(nMissionId);

	if (pMission)
	{
		
		CLTGUITextCtrl *pCtrl = NULL;
		if (pMission->nNameId > 0)
			pCtrl = CreateTextItem(LoadTempString(pMission->nNameId),CMD_REMOVE_LEVEL,pMission->nDescId);
		else if (!pMission->sName.empty())
			pCtrl = CreateTextItem((char *)pMission->sName.c_str(),CMD_REMOVE_LEVEL,pMission->nDescId);
		else
		{
			char szWorldTitle[MAX_PATH] = "";
			_splitpath( pMission->aLevels[0].szLevel, NULL, NULL, szWorldTitle, NULL );
			pCtrl = CreateTextItem(szWorldTitle,CMD_REMOVE_LEVEL,0);
		}
		pCtrl->SetFont(LTNULL,nListFontSize);
		pCtrl->SetParam1(nMissionId);
		pCtrl->SetFixedWidth(nSelWidth,LTTRUE);
		m_pSelMissions->AddControl(pCtrl);
		
	}
	else
	{
		ASSERT(!"Invalid mission id");
	}

}
Пример #8
0
void CScreenHostLevels::SaveMissionList()
{
	// Sanity checks...

	if (!m_pSelMissions) return;

	char szMission[MAX_PATH*2];
	for (uint32 n = 0; n < m_pSelMissions->GetNumControls(); n++)
	{
		CLTGUITextCtrl *pCtrl = (CLTGUITextCtrl *)m_pSelMissions->GetControl(n);
		if( !pCtrl )
			continue;

		LTStrCpy( szMission, g_pLTDatabase->GetRecordName( g_pMissionDB->GetMission( pCtrl->GetParam1( ))), 
			LTARRAYSIZE( szMission ));
		GameModeMgr::Instance( ).SetMissionByIndex( g_pProfileMgr->GetCurrentProfile( )->m_sServerOptionsFile.c_str( ),
			n, szMission );
	}

	// Write out an empty entry to indicate the end of the list.
	GameModeMgr::Instance( ).SetNumMissions( g_pProfileMgr->GetCurrentProfile( )->m_sServerOptionsFile.c_str( ), 
		m_pSelMissions->GetNumControls( ));
}			
Пример #9
0
// Adds a column to the control
// nWidth	  - Width of the column
// hString	  - The initial text for the column
uint8 CLTGUIColumnCtrl::AddColumn(const char *pString, uint16 nWidth, LTBOOL bClip)
{
    if ( !pString )
    {
        assert(LTFALSE);
        return -1;
    }

    CLTGUITextCtrl *pCtrl = debug_new(CLTGUITextCtrl);
    if (!pCtrl->Create(pString,LTNULL,LTNULL,m_pFont,m_nBaseFontSize,LTNULL))
    {
        debug_delete(pCtrl);
        return -1;
    }
    m_columnArray.push_back(pCtrl);

    //force a little extra space between columns, if we can
    nWidth -= (m_nBaseFontSize/2);
    if (nWidth < m_nBaseFontSize + 1)
        nWidth = m_nBaseFontSize + 1 ;

    pCtrl->SetFixedWidth(nWidth,bClip);



    LTIntPt pos = m_basePos;
    pos.x += m_nBaseWidth;
    pCtrl->SetColors(m_argbSelected, m_argbNormal, m_argbDisabled);
    pCtrl->SetBasePos(pos);
    pCtrl->SetScale(m_fScale);


    CalculateSize();


    return m_columnArray.size() - 1;
}
Пример #10
0
// Build the screen
LTBOOL CScreenConfigure::Build()
{

	CreateTitle(IDS_TITLE_CONFIGURE);

	m_nActionWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"ActionWidth");
	m_nEqualsWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"EqualsWidth");
	m_nCommandWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"CommandWidth");
	m_ListRect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_CONFIGURE,"ListRect");
	m_nListFontSize = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"ListFontSize");


	int nWidth = GetPageRight() - GetPageLeft();
	LTIntPt topPos = g_pLayoutMgr->GetScreenCustomPoint(SCREEN_ID_CONFIGURE,"MoveControlPos");

	CLTGUITextCtrl *pCtrl = AddTextItem(IDS_MOVE_CONTROLS,CMD_MOVE_COM,LTNULL,topPos);
	pCtrl->SetFixedWidth(nWidth);

	pCtrl = AddTextItem(IDS_INV_CONTROLS,CMD_INV_COM,LTNULL);
	pCtrl->SetFixedWidth(nWidth);

	pCtrl = AddTextItem(IDS_VIEW_CONTROLS,CMD_VIEW_COM,LTNULL);
	pCtrl->SetFixedWidth(nWidth);

	pCtrl = AddTextItem(IDS_MISC_CONTROLS,CMD_MISC_COM,LTNULL);
	pCtrl->SetFixedWidth(nWidth);

	
	LTIntPt pos(m_ListRect.left,m_ListRect.top);
	int nHt = m_ListRect.bottom - m_ListRect.top;
	int nWd = m_nActionWidth + m_nEqualsWidth + m_nCommandWidth;

	char szFrame[128];
	g_pLayoutMgr->GetScreenCustomString(SCREEN_ID_CONFIGURE,"FrameTexture",szFrame,sizeof(szFrame));
	HTEXTURE hFrame = g_pInterfaceResMgr->GetTexture(szFrame);
	m_pFrame = debug_new(CLTGUIFrame);
	m_pFrame->Create(hFrame,nWd,nHt+8,LTTRUE);
	m_pFrame->SetBasePos(pos);
	AddControl(m_pFrame);


	for (int nType = 0; nType < kNumCommandTypes; nType++)
	{
		m_pList[nType] = AddList(pos,nHt);
		m_pList[nType]->SetFrameWidth(2);
		m_pList[nType]->SetIndent(LTIntPt(4,4));
		m_pList[nType]->Show(LTFALSE);

		pCtrl = LTNULL;
		switch (nType)
		{
		case COM_MOVE:
			pCtrl = CreateTextItem(IDS_MOVE_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE);
			break;
		case COM_INV:
			pCtrl = CreateTextItem(IDS_INV_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE);
			break;
		case COM_VIEW:
			pCtrl = CreateTextItem(IDS_VIEW_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE);
			break;
		case COM_MISC:
			pCtrl = CreateTextItem(IDS_MISC_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE);
			break;
		}

		if (pCtrl)
			m_pList[nType]->AddControl(pCtrl);

	}

	InitControlList();

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

	UseBack(LTTRUE,LTTRUE);
	return LTTRUE;
}
Пример #11
0
void CScreenHostMission::CreateCampaignList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();
	m_CampaignList.clear();

	CUIFont *pFont = g_pInterfaceResMgr->GetFont(nListFont);

	m_CampaignList.insert(DEFAULT_CAMPAIGN);

	// Get new stuff
	struct _finddata_t file;
	intptr_t hFile;

	CUserProfile* pUserProfile = g_pProfileMgr->GetCurrentProfile( );
	std::string directory = GetCampaignDir( g_pProfileMgr->GetCurrentProfileName( ), 
		pUserProfile->m_ServerGameOptions.m_eGameType );
	directory += "*.txt"; 

	// find first file
	if((hFile = _findfirst(directory.c_str(), &file)) != -1L)
	{
		do
		{
			if (_stricmp(file.name,DEFAULT_CAMPAIGN_FILE) != 0)
			{
				char *pName = strtok(file.name,".");
				m_CampaignList.insert(pName);
			}

		}
		while(_findnext(hFile, &file) == 0);
	}
	_findclose(hFile);

	// add campaigns to the list control
	for (StringSet::iterator iter = m_CampaignList.begin(); iter != m_CampaignList.end(); ++iter)
	{
		CLTGUITextCtrl* pTextCtrl = NULL;
		uint16 ndx = 0;
		if (iter->compare(DEFAULT_CAMPAIGN) == 0)
		{
			m_pDefaultTextCtrl = CreateTextItem(IDS_HOST_CAMPAIGN_DEFAULT, CMD_OK, LTNULL);
			ndx = m_pListCtrl->AddControl(m_pDefaultTextCtrl);
			m_nDefaultCampaign = ndx;
			m_pDefaultTextCtrl->Show(LTFALSE);
			m_pDefaultTextCtrl->SetParam1(ndx);
			m_pDefaultTextCtrl->SetFont(pFont,nListFontSz);
		}
		else
		{
			pTextCtrl = CreateTextItem((char *)iter->c_str(), CMD_OK, LTNULL);
			pTextCtrl->SetFont(pFont,nListFontSz);
			ndx = m_pListCtrl->AddControl(pTextCtrl);
			pTextCtrl->SetParam1(ndx);
		}

		
		

		if (iter->compare(m_pProfile->m_ServerGameOptions.GetCampaignName()) == 0)
			m_pListCtrl->SetSelection(ndx);
	}

}
Пример #12
0
// Build the screen
bool CScreenProfile::Build()
{
	// Set the title's text
	CreateTitle("IDS_TITLE_PROFILE");


	CLTGUICtrl_create cs;
	cs.rnBaseRect.m_vMin.Init();
	cs.rnBaseRect.m_vMax = LTVector2n(m_ScreenRect.GetWidth(),g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenFontSize));

	m_pCurrent = AddTextItem(L" ", cs, true);

	cs.nCommandID = CMD_CREATE;
	cs.szHelpID = "IDS_HELP_PROFILE_CREATE";
	AddTextItem("IDS_CREATE", cs );

	cs.nCommandID = CMD_LOAD;
	cs.szHelpID = "IDS_HELP_PROFILE_LOAD";
	AddTextItem("IDS_LOAD", cs);

	cs.nCommandID = CMD_DELETE;
	cs.szHelpID = "IDS_HELP_PROFILE_DELETE";
	m_pDelete = AddTextItem("IDS_DELETE", cs);


	LTRect2n dlgRect = g_pLayoutDB->GetRect(m_hLayout,LDB_ScreenDialogRect);
	std::string sDlgFont = g_pLayoutDB->GetFont(m_hLayout,LDB_ScreenDialogFont);
	uint8 nDlgFontSz = ( uint8 )g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenDialogSize);

	sListFont = g_pLayoutDB->GetListFont(m_hLayout,0);
	nListFontSz = g_pLayoutDB->GetListSize(m_hLayout,0);

	CLTGUICtrl_create dcs;
	dcs.rnBaseRect = dlgRect;
	m_pDlg = debug_new(CLTGUIWindow);
	m_pDlg->Create(TextureReference(g_pLayoutDB->GetString(m_hLayout,LDB_ScreenDialogFrame)),dcs);

	LTVector2n tmp(8,8);
	cs.nCommandID = NULL;
	cs.szHelpID = "";
	CLTGUITextCtrl *pCtrl = CreateTextItem("IDS_PROFILE_LIST", cs, true, sDlgFont.c_str(), nDlgFontSz);
	m_pDlg->AddControl(pCtrl, tmp);

	tmp.y += 24;

	CLTGUIListCtrl_create listCs;
	listCs.rnBaseRect.m_vMin.Init();
	listCs.rnBaseRect.Right() = kDlgWd - 48;
	listCs.rnBaseRect.Bottom() = kDlgWd - 64;
	listCs.bArrows = true;
	listCs.vnArrowSz = g_pLayoutDB->GetListArrowSize(m_hLayout,0); 
	m_pListCtrl = CreateList(listCs);
	if (m_pListCtrl)
	{
		m_pListCtrl->SetIndent(g_pLayoutDB->GetListIndent(m_hLayout,0));
		TextureReference hFrame(g_pLayoutDB->GetListFrameTexture(m_hLayout,0,0));
		TextureReference hSelFrame(g_pLayoutDB->GetListFrameTexture(m_hLayout,0,1));
		m_pListCtrl->SetFrame(hFrame,hSelFrame,g_pLayoutDB->GetListFrameExpand(m_hLayout,0));
		m_pListCtrl->Show(true);

		m_pDlg->AddControl(m_pListCtrl, tmp);
	}


	cs.nCommandID = CMD_CANCEL;
	cs.szHelpID = "";
	cs.rnBaseRect.Bottom() = nDlgFontSz;
	cs.rnBaseRect.Right() = kDlgWd / 2;

	pCtrl = CreateTextItem("IDS_CANCEL", cs, false, sDlgFont.c_str(), nDlgFontSz);
	pCtrl->SetAlignment(kCenter);
	tmp.x = kDlgWd / 2;
	tmp.y = (kDlgHt - nDlgFontSz) - 8;
	m_pDlg->AddControl(pCtrl, tmp);

	AddControl(m_pDlg);

	m_pDlg->Show(false);

	m_pDlg->SetSelection(1);

	UseBack(true);


	// Make sure to call the base class
	return CBaseScreen::Build();
}
Пример #13
0
// Build the list of Custom Levels
void CScreenSingle::BuildCustomLevelsList(int nWidth)
{
	m_Filenames.clear();
	m_pCustom->RemoveAll();

	// Get a list of world names and sort them alphabetically

    uint8 nNumPaths = g_pClientButeMgr->GetNumSingleWorldPaths();

    char pathBuf[128];
	FileEntry** pFilesArray = debug_newa(FileEntry*, nNumPaths);

	if (pFilesArray)
	{
		for (int i=0; i < nNumPaths; ++i)
		{
			pathBuf[0] = '\0';
			g_pClientButeMgr->GetWorldPath(i, pathBuf, ARRAY_LEN(pathBuf));

			if (pathBuf[0])
			{
                pFilesArray[i] = g_pLTClient->GetFileList(pathBuf);
			}
			else
			{
                pFilesArray[i] = LTNULL;
			}
		}
	}



	char Buf[255];

	for (int i=0; i < nNumPaths; ++i)
	{
		pathBuf[0] = '\0';
		g_pClientButeMgr->GetWorldPath(i, pathBuf, ARRAY_LEN(pathBuf));

		if (pathBuf[0] && pFilesArray[i])
		{
			sprintf(Buf, "%s\\", pathBuf);
			AddFilesToFilenames(pFilesArray[i], Buf);
            g_pLTClient->FreeFileList(pFilesArray[i]);
		}
	}

	debug_deletea(pFilesArray);

	CLTGUITextCtrl* pItem;

	uint8 nListFontSize = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontSize");
	int index = 0;
	StringSet::iterator iter = m_Filenames.begin();
	while (iter != m_Filenames.end())
	{
		pItem = CreateTextItem((char *)iter->c_str(), CMD_CUSTOM+index, IDS_HELP_CUSTOMLEVEL);
		pItem->SetFont(LTNULL, nListFontSize);
		pItem->SetFixedWidth(nWidth,LTTRUE);

		m_pCustom->AddControl(pItem);
		++index;
		iter++;
	}

}
Пример #14
0
uint32 CScreenHostLevels::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	switch(dwCommand)
	{
	case CMD_ADD_LEVEL:
		{
			if (m_pAvailMissions->GetSelectedIndex() >= 0 && (m_pSelMissions->GetNumControls() < MAX_GAME_LEVELS))
			{
				CLTGUITextCtrl *pCtrl = (CLTGUITextCtrl *)m_pAvailMissions->GetSelectedControl();
				if (pCtrl)
				{
					AddMissionToList(pCtrl->GetParam1(),true,false);
					m_pSelMissions->ClearSelection();
				}
			}
			UpdateButtons();
		} break;
	case CMD_ADD_ALL:
		{
			if (m_pAvailMissions->GetNumControls())
			{
				for (uint32 i = 0; i < m_pAvailMissions->GetNumControls() && (m_pSelMissions->GetNumControls() < MAX_GAME_LEVELS); i++)
				{
					CLTGUITextCtrl *pCtrl = (CLTGUITextCtrl *)m_pAvailMissions->GetControl(i);
					if (pCtrl)
					{
						AddMissionToList(pCtrl->GetParam1(),false,false);
					}
				}
			}
			m_pSelMissions->ClearSelection();
			UpdateButtons();
		} break;
	case CMD_REMOVE_LEVEL:
		{
			int nIndex = m_pSelMissions->GetSelectedIndex();
			if (nIndex >= 0)
			{
				m_pSelMissions->ClearSelection();
				m_pSelMissions->RemoveControl(nIndex);
				int numLeft = m_pSelMissions->GetNumControls();
				if (numLeft > 0)
				{
					if (nIndex >= numLeft)
						nIndex = numLeft-1;
					m_pSelMissions->SetSelection(nIndex);
				}
			}
			UpdateButtons();

		} break;
	case CMD_REMOVE_ALL:
		{
			if (m_pSelMissions->GetNumControls() > 0)
			{
				m_pSelMissions->ClearSelection();
				m_pSelMissions->RemoveAll();
			}
			UpdateButtons();
		} break;
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}
	return 1;
};
Пример #15
0
void CScreenHostOptionFile::CreateFileList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();
	m_List.clear();

	// Get new stuff
	LTFINDFILEINFO file;
	LTFINDFILEHANDLE hFile;

	// Create directory search string.
	char szDirectory[MAX_PATH*2];
	LTSNPrintF( szDirectory, LTARRAYSIZE( szDirectory ), "%s*.txt", GameModeMgr::Instance( ).GetOptionsFolder( ));

	// Create the title of the default option file, which we won't show in the list.
	char szExample[MAX_PATH*2];
	LTFileOperations::SplitPath( SERVEROPTIONS_EXAMPLE, NULL, szExample, NULL );
	CResExtUtil::StripFileExtension( szExample, LTARRAYSIZE( szExample ));

	// find first file
	if( LTFileOperations::FindFirst( szDirectory, hFile, &file ))
	{
		do
		{
			CResExtUtil::StripFileExtension( file.name, LTARRAYSIZE( file.name ));

			if( !LTStrIEquals( szExample, file.name ))
			{
				const wchar_t* wszFriendlyName = CHostOptionsMapMgr::Instance().GetFriendlyNameFromFileName( file.name );
				if( wszFriendlyName )
					m_List.insert( wszFriendlyName );
				else
					m_List.insert( MPA2W(file.name).c_str() );
			}
		}
		while( LTFileOperations::FindNext( hFile, &file ));
	}
	LTFileOperations::FindClose( hFile );

	CLTGUICtrl_create cs;
	cs.rnBaseRect.m_vMin.Init();
	cs.rnBaseRect.m_vMax = LTVector2n(kDlgWd - 48,nListFontSz);
	cs.nCommandID = CMD_OK;

	// Get the current file title.
	wchar_t wszCurrentName[MAX_PATH*2];
	CUserProfile* pProfile = g_pProfileMgr->GetCurrentProfile();
	const wchar_t* wszFriendlyName = CHostOptionsMapMgr::Instance().GetFriendlyNameFromFileName( pProfile->m_sServerOptionsFile.c_str() );
	if( wszFriendlyName )
		LTStrCpy( wszCurrentName, wszFriendlyName, LTARRAYSIZE( wszCurrentName ));
	else
		LTStrCpy( wszCurrentName, MPA2W( pProfile->m_sServerOptionsFile.c_str( )).c_str( ), LTARRAYSIZE( wszCurrentName ));

	// add files to the list control
	for (WStringSet::iterator iter = m_List.begin(); iter != m_List.end(); ++iter)
	{
		CLTGUITextCtrl* pTextCtrl = NULL;
		uint16 ndx = 0;
		pTextCtrl = CreateTextItem(iter->c_str(), cs, false, sListFont.c_str(), nListFontSz);
		ndx = m_pListCtrl->AddControl(pTextCtrl);
		pTextCtrl->SetParam1(ndx);

		if( LTStrEquals( iter->c_str( ), wszCurrentName ))
			m_pListCtrl->SetSelection(ndx);
	}
}
Пример #16
0
// Build the screen
LTBOOL CScreenProfile::Build()
{
	// Set the title's text
	CreateTitle(IDS_TITLE_PROFILE);

	// Get edit controls position and create it.
	LTIntPt pos = g_pLayoutMgr->GetScreenCustomPoint((eScreenID)m_nScreenID,"ProfileNamePos");
	m_pCurrent = AddTextItem(" ", LTNULL, LTNULL, pos, LTTRUE);

	AddTextItem(IDS_CREATE, CMD_CREATE, IDS_HELP_PROFILE_CREATE);

	AddTextItem(IDS_LOAD, CMD_LOAD, IDS_HELP_PROFILE_LOAD);

//jrg - 8/18/02 removed as a quick and dirty to multiple issues caused by renaming profiles.
//	m_pRename = AddTextItem(IDS_RENAME, CMD_RENAME, IDS_HELP_PROFILE_RENAME);

	m_pDelete = AddTextItem(IDS_DELETE, CMD_DELETE, IDS_HELP_PROFILE_DELETE);


	LTIntPt dlgPos = g_pLayoutMgr->GetScreenCustomPoint((eScreenID)m_nScreenID,"DialogPos");
	LTIntPt dlgSz = g_pLayoutMgr->GetScreenCustomPoint((eScreenID)m_nScreenID,"DialogSize");
	kDlgHt = dlgSz.y;
	kDlgWd = dlgSz.x;
	uint8 nDlgFont = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"DialogFontFace");
	uint8 nDlgFontSz = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"DialogFontSize");

	nListFont = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontFace");
	nListFontSz = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontSize");

	char szBack[128] = "";
	g_pLayoutMgr->GetScreenCustomString((eScreenID)m_nScreenID,"DialogFrame",szBack,sizeof(szBack));

	m_pDlg = debug_new(CLTGUIWindow);
	m_pDlg->Create(g_pInterfaceResMgr->GetTexture(szBack),kDlgHt,kDlgWd);

	LTIntPt tmp(8,8);
	CUIFont *pFont = g_pInterfaceResMgr->GetFont(nDlgFont);

	CLTGUITextCtrl *pCtrl = CreateTextItem(IDS_PROFILE_LIST, LTNULL, LTNULL, kDefaultPos, LTTRUE);
	pCtrl->SetFont(pFont,nDlgFontSz);
	m_pDlg->AddControl(pCtrl, tmp);

	tmp.y += 24;

	
	// Make a list controller
	m_pListCtrl = debug_new(CLTGUIListCtrl);
    if (m_pListCtrl->Create(kDlgHt-64))
	{
		HTEXTURE hUp = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowup.dtx");
		HTEXTURE hUpH = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowup_h.dtx");
		HTEXTURE hDown = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowdn.dtx");
		HTEXTURE hDownH = g_pInterfaceResMgr->GetTexture("interface\\menu\\sprtex\\arrowdn_h.dtx");
		m_pListCtrl->UseArrows(kDlgWd-48,1.0f,hUp,hUpH,hDown,hDownH);
		m_pListCtrl->SetIndent(LTIntPt(4,4));
		m_pListCtrl->SetFrameWidth(2);
		m_pListCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor);

		m_pDlg->AddControl(m_pListCtrl, tmp);

	}

	pCtrl = CreateTextItem(IDS_CANCEL, CMD_CANCEL, LTNULL);
	pCtrl->SetFont(pFont,nDlgFontSz);
	tmp.x = (kDlgWd - pCtrl->GetBaseWidth()) / 2;
	tmp.y = (kDlgHt - pCtrl->GetBaseHeight()) - 8;
	m_pDlg->AddControl(pCtrl, tmp);

	AddControl(m_pDlg);

	m_pDlg->SetBasePos(dlgPos);
	m_pDlg->SetScale(g_pInterfaceResMgr->GetXRatio());
	m_pDlg->Show(LTFALSE);

	m_pDlg->SetSelection(1);

	UseBack(LTTRUE);


	// Make sure to call the base class
	return CBaseScreen::Build();
}
Пример #17
0
uint32 CScreenHostLevels::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	switch(dwCommand)
	{
	case CMD_BACK:
		{
			m_pAvailMissions->Enable(LTFALSE);
			m_pSelMissions->Enable(LTFALSE);
			m_pScreenMgr->EscapeCurrentScreen();
			break;
		}

	case CMD_ADD_LEVEL:
		{
			if (!m_pAvailMissions->IsEnabled() && m_pAvailMissions->GetNumControls())
			{
				m_pSelMissions->Enable(LTFALSE);
				m_pRemove->Enable(LTTRUE);
				m_pAvailMissions->Enable(LTTRUE);
				m_pAdd->Enable(LTFALSE);
				SetSelection(GetIndex(m_pAvailMissions));
				m_pAvailMissions->SetSelection(0);
			}
			else
			{
				char sMission[256] = "";

				if (m_pAvailMissions->GetSelectedIndex() >= 0 && (m_pSelMissions->GetNumControls() < MAX_GAME_LEVELS))
				{
					CLTGUITextCtrl *pCtrl = (CLTGUITextCtrl *)m_pAvailMissions->GetSelectedControl();
					if (pCtrl)
					{
						AddMissionToList(pCtrl->GetParam1());
						m_pSelMissions->ClearSelection();
					}
				}

				UpdateButtons();
			}
		} break;
	case CMD_ADD_ALL:
		{
			if (m_pAvailMissions->GetNumControls())
			{
				for (int i = 0; i < m_pAvailMissions->GetNumControls() && (m_pSelMissions->GetNumControls() < MAX_GAME_LEVELS); i++)
				{
					char sMission[256] = "";
					CLTGUITextCtrl *pCtrl = (CLTGUITextCtrl *)m_pAvailMissions->GetControl(i);
					if (pCtrl)
					{
						AddMissionToList(pCtrl->GetParam1());
					}
				}
			}
			m_pSelMissions->ClearSelection();
			UpdateButtons();
		} break;
	case CMD_REMOVE_LEVEL:
		{
			if (!m_pSelMissions->IsEnabled() && m_pSelMissions->GetNumControls())
			{
				m_pAvailMissions->Enable(LTFALSE);
				m_pAdd->Enable(LTTRUE);
				m_pSelMissions->Enable(LTTRUE);
				m_pRemove->Enable(LTFALSE);
				SetSelection(GetIndex(m_pSelMissions));
				m_pSelMissions->SetSelection(0);
			}
			else
			{
				int nIndex = m_pSelMissions->GetSelectedIndex();
				if (nIndex >= 0)
				{
					m_pSelMissions->RemoveControl(nIndex);
				}
				UpdateButtons();
			}

		} break;
	case CMD_REMOVE_ALL:
		{
			if (m_pSelMissions->GetNumControls() > 0)
			{
				m_pSelMissions->ClearSelection();
				m_pSelMissions->RemoveAll();
			}
			UpdateButtons();
		} break;
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}
	return 1;
};
Пример #18
0
LTBOOL CMenuMgr::Init()
{
	//build menu array
	m_MenuArray.reserve(MENU_ID_UNASSIGNED);

	//add menus here
	m_MenuArray.push_back(&m_MenuSystem);
	m_MenuArray.push_back(&m_MenuMission);
	m_MenuArray.push_back(&m_MenuInventory);
	m_MenuArray.push_back(&m_MenuKeys);
	m_MenuArray.push_back(&m_MenuIntel);
	m_MenuArray.push_back(&m_MenuPlayer);

	//init menus
	MenuArray::iterator iter = m_MenuArray.begin();
	while (iter != m_MenuArray.end())
	{
		if (!(*iter)->Init())
			return LTFALSE;
		iter++;
	}

	m_fSlideInTime	= g_pLayoutMgr->GetMenuSlideInTime();
	m_fSlideOutTime = g_pLayoutMgr->GetMenuSlideOutTime();
	m_nMenuPos		= g_pLayoutMgr->GetMenuPosition();

	char szTemp[128];
	char *pTag = "Menu";

	g_pLayoutMgr->GetString(pTag,"SlideInSound",szTemp,sizeof(szTemp));
	m_sSlideInSound = szTemp;

	g_pLayoutMgr->GetString(pTag,"SlideOutSound",szTemp,sizeof(szTemp));
	m_sSlideOutSound = szTemp;

	g_pLayoutMgr->GetString(pTag,"Bar",szTemp,sizeof(szTemp));
	HTEXTURE hBar = g_pInterfaceResMgr->GetTexture(szTemp);

	g_pLayoutMgr->GetString(pTag,"BarTip",szTemp,sizeof(szTemp));
	HTEXTURE hBarTip = g_pInterfaceResMgr->GetTexture(szTemp);



	LTIntPt size = g_pLayoutMgr->GetPoint(pTag,"BarSize");
	uint8 fontFace = (uint8)g_pLayoutMgr->GetInt(pTag,"BarFont");
	uint8 fontSize = (uint8)g_pLayoutMgr->GetInt(pTag,"BarFontSize");
	m_nBarPos = g_pLayoutMgr->GetInt(pTag,"BarPosition");
	int nBarSpacing = g_pLayoutMgr->GetInt(pTag,"BarSpacing");
	LTVector vCol = g_pLayoutMgr->GetVector(pTag,"BarSelectColor");
	uint8 nR = (uint8)vCol.x;
	uint8 nG = (uint8)vCol.y;
	uint8 nB = (uint8)vCol.z;
	g_nSelectColor = SET_ARGB(0xFF,nR,nG,nB);


	m_MenuBar.Init(hBar,hBarTip,size);
	m_MenuBar.SetBasePos(LTIntPt(0,m_nBarPos));
	
	CUIFont* pFont = g_pInterfaceResMgr->GetFont(fontFace);
	
	LTIntPt offset(nBarSpacing,(size.y-fontSize)/2);
	for (uint8 i =0; i < m_MenuArray.size(); i++)
	{
		CLTGUITextCtrl *pCtrl = debug_new(CLTGUITextCtrl);
		CBaseMenu *pMenu = m_MenuArray[i];
		pCtrl->Create(pMenu->GetTitle(),i,NULL,pFont,fontSize,&m_MenuBar);
		pCtrl->SetColors(g_nSelectColor,argbBlack,argbWhite);
		pCtrl->SetParam1(pMenu->GetMenuID());
		m_MenuBar.AddControl(pCtrl,offset);
		offset.x += nBarSpacing + pCtrl->GetWidth();
	}

    return LTTRUE;
}
Пример #19
0
// This is called when the screen gets or loses focus
void CMenuIntel::OnFocus(LTBOOL bFocus)
{
	if (!m_PopupText.IsVisible())
	{
		ClearSelection();
	}

	if (bFocus)
	{
		uint16 nextItem = 0;
		CIntelItemList *pList = g_pPlayerStats->GetIntelList();
		char szTemp[512] = "";
		for (uint16 i = 0; i < pList->GetCount(); i++)
		{
			uint16 nIndex = (pList->GetCount() - i) - 1;
			INTEL_ITEM* pItem = pList->Get(nIndex);
			if (!pItem)
			{
				continue;
			}

			GetIntelName(pItem->nTextId,szTemp,sizeof(szTemp));

			CLTGUITextCtrl* pCtrl = LTNULL;
			if (nextItem < m_List.GetNumControls())
			{
				pCtrl = (CLTGUITextCtrl*)m_List.GetControl(nextItem);
				if (pCtrl)
				{
					pCtrl->SetString(szTemp);
					pCtrl->Show(LTTRUE);
					nextItem++;
				}
			}
			else
			{
				uint16 ndx = AddControl(szTemp,MC_INTEL);
				pCtrl = (CLTGUITextCtrl*)m_List.GetControl(ndx);
				nextItem++;
			}

			if (pCtrl)
			{
				pCtrl->SetParam1(nIndex);
				if (pItem->bIsIntel)
				{
					pCtrl->SetColors(0xFFFF0000,0xFFA00000,m_DisabledColor);
				}
				else
				{
					pCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor);
				}
			}
		}

		for (uint16 nIndex = nextItem; nIndex < m_List.GetNumControls(); nIndex++)
		{
					 
			CLTGUITextCtrl* pCtrl = (CLTGUITextCtrl*)m_List.GetControl(nIndex);
			if (pCtrl)
			{
				pCtrl->Show(LTFALSE);
			}
		}

		if (m_fScale != g_pInterfaceResMgr->GetXRatio())
		{
			SetScale(g_pInterfaceResMgr->GetXRatio());
		}

		SetSelection(GetIndex(&m_List));
	}
}