本文整理汇总了C++中CLTGUITextCtrl类的典型用法代码示例。如果您正苦于以下问题:C++ CLTGUITextCtrl类的具体用法?C++ CLTGUITextCtrl怎么用?C++ CLTGUITextCtrl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLTGUITextCtrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove
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: LTVector2n
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: FillAvailList
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: CreateTextItem
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: CreateTitle
// 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: BuildChapterList
// 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: AddMissionToList
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: SaveMissionList
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: assert
// 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: CreateTitle
// 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: GetCampaignDir
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: CreateTitle
// 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: debug_newa
// 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: switch
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: LTSNPrintF
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);
}
}