示例#1
0
uint32 CScreenProfile::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	switch (dwCommand)
	{
	case CMD_OK:
		{
			m_pDlg->Show(LTFALSE);
			SetCapture(LTNULL);
			HandleDlgCommand(nCommand,(uint16)dwParam1);
			SetSelection(1);
		}
		break;
	case CMD_CANCEL:
		{
			m_pDlg->Show(LTFALSE);
			SetCapture(LTNULL);
			SetSelection(1);
		}
		break;

	case CMD_LOAD:
		{
			m_pDlg->Show(LTTRUE);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CONFIRM:
		{
			uint16 nIndex = (uint16)dwParam1;
			if (dwParam2 == CMD_DELETE)
			{
				if (nIndex < m_pListCtrl->GetNumControls()) 
				{
					StringSet::iterator iter = m_ProfileList.begin();
					for (int i = 0; i < nIndex && iter != m_ProfileList.end(); ++i, ++iter);

					if (iter != m_ProfileList.end())
					{
						std::string profile = *iter;
						g_pProfileMgr->DeleteProfile(profile);

					}
					m_pProfile = g_pProfileMgr->GetCurrentProfile();
					SAFE_STRCPY(m_szProfile, m_pProfile->m_sName.c_str());
					UpdateProfileName();

				}
			}
			else if (dwParam2 == CMD_LOAD)
			{
				if (nIndex < m_pListCtrl->GetNumControls()) 
				{
					StringSet::iterator iter = m_ProfileList.begin();
					for (int i = 0; i < nIndex && iter != m_ProfileList.end(); ++i, ++iter);

					if (iter != m_ProfileList.end())
					{
						std::string profile = *iter;
						g_pProfileMgr->NewProfile(profile);
						m_pProfile = g_pProfileMgr->GetCurrentProfile();

						SAFE_STRCPY(m_szProfile, profile.c_str());
						UpdateProfileName();
					}
				}
			}
			else if (dwParam2 == CMD_CREATE)
			{
				SAFE_STRCPY(m_szOldProfile,m_szProfile);
				bCreate = LTTRUE;

				//show edit box here	
				MBCreate mb;
				mb.eType = LTMB_EDIT;
				mb.pFn = EditCallBack;
				mb.pString = m_szProfile;
				mb.nMaxChars = MAX_PROFILE_NAME;
				mb.eInput = CLTGUIEditCtrl::kInputFileFriendly;
				g_pInterfaceMgr->ShowMessageBox(IDS_ENTER_PROFILE_NAME,&mb);
			}
		}
		break;
	case CMD_DELETE:
		{
			m_pDlg->Show(LTTRUE);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CREATE:
		{
			if (g_pLTClient->IsConnected())
			{
				MBCreate mb;
				mb.eType = LTMB_YESNO;
				mb.pFn = CreateCallBack,
				g_pInterfaceMgr->ShowMessageBox(IDS_CONFIRM_NEWPROFILE,&mb);
			}
			else
				SendCommand(CMD_CONFIRM,0,CMD_CREATE);
		}
		break;
	case CMD_RENAME:
		{
			m_pDlg->Show(LTTRUE);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_EDIT:
		{
			SAFE_STRCPY(m_szProfile,(char *)dwParam1);
			std::string profileName = m_szProfile;
			StringSet::iterator iter = m_ProfileList.find(profileName);

			if (iter != m_ProfileList.end())
			{
				//don't proceed renaming or creating a new one if we already have a profile of that
				//name
				MBCreate mb;
				mb.eType = LTMB_OK;
				mb.pFn = NULL,
				g_pInterfaceMgr->ShowMessageBox(IDS_PROFILE_ALREADY_EXISTS,&mb);
			}
			else
			{
				if (bCreate)
				{
					g_pProfileMgr->NewProfile(profileName);
				}
				else
				{
					g_pProfileMgr->RenameProfile(szOldFN,profileName);
				}
				m_pProfile = g_pProfileMgr->GetCurrentProfile();
				SAFE_STRCPY(m_szProfile,m_pProfile->m_sName.c_str());
				UpdateProfileName();
			}
		}
		break;
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}

	return 1;
};
示例#2
0
uint32 CScreenHostMission::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	switch (dwCommand)
	{
	case CMD_OK:
		{
			m_pDlg->Show(LTFALSE);
			SetCapture(LTNULL);
			HandleDlgCommand(nCommand,(uint16)dwParam1);
			SetSelection(1);
		}
		break;
	case CMD_CANCEL:
		{
			m_pDlg->Show(LTFALSE);
			SetCapture(LTNULL);
			SetSelection(1);
		}
		break;

	case CMD_SET_LEVELS:
		{

			if (m_pProfile->m_ServerGameOptions.IsDefaultCampaign() )
				return 0;
			else
			{
				g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_HOST_LEVELS);
			}
		}
		break;


	case CMD_LOAD:
		{
			m_pDefaultTextCtrl->Show(LTTRUE);
			m_pListCtrl->SetStartIndex(0);
			m_pDlg->Show(LTTRUE);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CONFIRM:
		{
			uint16 nIndex = (uint16)dwParam1;
			if (dwParam2 == CMD_DELETE)
			{
				if (nIndex != m_nDefaultCampaign && nIndex < m_pListCtrl->GetNumControls()) 
				{
					StringSet::iterator iter = m_CampaignList.begin();
					for (int i = 0; i < nIndex && iter != m_CampaignList.end(); ++i, ++iter);

					if (iter != m_CampaignList.end())
					{
						DeleteCampaign(*iter);

					}
				}
			}
			else if (dwParam2 == CMD_LOAD)
			{
				if (nIndex < m_pListCtrl->GetNumControls()) 
				{
					StringSet::iterator iter = m_CampaignList.begin();
					for (int i = 0; i < nIndex && iter != m_CampaignList.end(); ++i, ++iter);

					if (iter != m_CampaignList.end())
					{
						SetCampaignName( (*iter).c_str());
					}

				}
			}
			else if (dwParam2 == CMD_CREATE)
			{
				m_sOldCampaign = m_pProfile->m_ServerGameOptions.GetCampaignName();
				std::string sNew = m_sOldCampaign;
				if (sNew.compare(DEFAULT_CAMPAIGN) == 0)
					sNew = m_pProfile->m_sName;
				bCreate = LTTRUE;

				//show edit box here	
				MBCreate mb;
				mb.eType = LTMB_EDIT;
				mb.pFn = EditCallBack;
				mb.pString = sNew.c_str();
				mb.nMaxChars = MAX_PROFILE_NAME;
				mb.eInput = CLTGUIEditCtrl::kInputFileFriendly;
				g_pInterfaceMgr->ShowMessageBox(IDS_ENTER_CAMPAIGN_NAME,&mb);
			}
		}
		break;
	case CMD_DELETE:
		{
			m_pDefaultTextCtrl->Show(LTFALSE);
			m_pListCtrl->SetStartIndex(0);
			m_pDlg->Show(LTTRUE);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CREATE:
		{
			if (g_pLTClient->IsConnected())
			{
				MBCreate mb;
				mb.eType = LTMB_YESNO;
				mb.pFn = CreateCallBack,
				g_pInterfaceMgr->ShowMessageBox(IDS_CONFIRM_NEWPROFILE,&mb);
			}
			else
				SendCommand(CMD_CONFIRM,0,CMD_CREATE);
		}
		break;
	case CMD_RENAME:
		{
			m_pDefaultTextCtrl->Show(LTFALSE);
			m_pListCtrl->SetStartIndex(0);
			m_pDlg->Show(LTTRUE);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_EDIT:
		{
			std::string campaignName = (char *)dwParam1;

			StringSet::iterator iter = m_CampaignList.find(campaignName);
			if (iter != m_CampaignList.end())
				campaignName = (*iter);

			if (bCreate)
			{
				NewCampaign(campaignName);
			}
			else
			{
				RenameCampaign(sOldFN,campaignName);
			}
			
		}
		break;
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}

	return 1;
};
示例#3
0
uint32 CScreenProfile::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	switch (dwCommand)
	{
	case CMD_OK:
		{
			m_pDlg->Show(false);
			SetCapture(NULL);
			HandleDlgCommand(nCommand,(uint16)dwParam1);
			SetSelection(1);
		}
		break;
	case CMD_CANCEL:
		{
			m_pDlg->Show(false);
			SetCapture(NULL);
			SetSelection(1);
		}
		break;

	case CMD_LOAD:
		{
			m_pDlg->Show(true);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CONFIRM:
		{
			uint16 nIndex = (uint16)dwParam1;
			if (dwParam2 == CMD_DELETE)
			{
				if (nIndex < m_pListCtrl->GetNumControls()) 
				{
					ProfileArray::iterator iter = m_ProfileList.begin();
					for (int i = 0; i < nIndex && iter != m_ProfileList.end(); ++i, ++iter);

					if (iter != m_ProfileList.end())
					{
						g_pProfileMgr->DeleteProfile(iter->m_sFileName.c_str());

					}
					m_pProfile = g_pProfileMgr->GetCurrentProfile();
					LTStrCpy(m_szProfile, m_pProfile->m_sFriendlyName.c_str(), LTARRAYSIZE(m_szProfile));
					UpdateProfileName();

				}
			}
			else if (dwParam2 == CMD_LOAD)
			{
				if (nIndex < m_pListCtrl->GetNumControls()) 
				{
					ProfileArray::iterator iter = m_ProfileList.begin();
					for (int i = 0; i < nIndex && iter != m_ProfileList.end(); ++i, ++iter);

					if (iter != m_ProfileList.end())
					{
						g_pProfileMgr->NewProfile((*iter).m_sFileName.c_str(),L"",true);
						m_pProfile = g_pProfileMgr->GetCurrentProfile();

						LTStrCpy(m_szProfile, (*iter).m_sFriendlyName.c_str(), LTARRAYSIZE(m_szProfile));
						UpdateProfileName();
					}
				}
			}
			else if (dwParam2 == CMD_CREATE)
			{
				LTStrCpy(m_szOldProfile,m_szProfile, LTARRAYSIZE(m_szOldProfile));
				bCreate = true;

				//show edit box here	
				MBCreate mb;
				mb.eType = LTMB_EDIT;
				mb.pFn = EditCallBack;
				mb.pUserData = this;
				mb.pString = g_pProfileMgr->GetCurrentProfile()->m_sFriendlyName.c_str();
				mb.nMaxChars = MAX_PROFILE_NAME;
//				mb.eInput = kInputFileFriendly;
				g_pInterfaceMgr->ShowMessageBox("IDS_ENTER_PROFILE_NAME",&mb);
			}
		}
		break;
	case CMD_DELETE:
		{
			m_pDlg->Show(true);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CREATE:
		{
			if (g_pLTClient->IsConnected())
			{
				MBCreate mb;
				mb.eType = LTMB_YESNO;
				mb.pFn = CreateCallBack;
				mb.pUserData = this;
				g_pInterfaceMgr->ShowMessageBox("IDS_CONFIRM_NEWPROFILE",&mb);
			}
			else
				SendCommand(CMD_CONFIRM,0,CMD_CREATE);
		}
		break;
	case CMD_RENAME:
		{
			m_pDlg->Show(true);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_EDIT:
		{
			std::wstring profileName = (wchar_t *)dwParam1;
			
			ProfileArray::iterator iter = m_ProfileList.begin();
			while (iter != m_ProfileList.end() && !LTStrIEquals( (*iter).m_sFriendlyName.c_str(), profileName.c_str() ) )
			{
				iter++;
			}

			if (iter != m_ProfileList.end())
			{
				//don't proceed renaming or creating a new one if we already have a profile of that
				//name
				MBCreate mb;
				mb.eType = LTMB_OK;
				mb.pFn = NULL,
				g_pInterfaceMgr->ShowMessageBox("IDS_PROFILE_ALREADY_EXISTS",&mb);
			}
			else
			{
				if (bCreate)
				{
					char szName[32] = "";
					uint32 n = 0;
					do 
					{
						LTSNPrintF(szName,LTARRAYSIZE(szName),"Profile%03d",n);
						n++;
					} while (CWinUtil::FileExist(GetAbsoluteProfileFile( g_pLTClient, szName)));
					g_pProfileMgr->NewProfile(szName, profileName.c_str(), false);
				}
				else
				{
					g_pProfileMgr->RenameProfile(szOldFN,profileName.c_str());
				}
				m_pProfile = g_pProfileMgr->GetCurrentProfile();
				LTStrCpy(m_szProfile,m_pProfile->m_sFriendlyName.c_str(), LTARRAYSIZE(m_szProfile));
				UpdateProfileName();
			}
		}
		break;
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}

	return 1;
};
示例#4
0
uint32 CScreenHostOptionFile::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	switch (dwCommand)
	{
	case CMD_OK:
		{
			m_pDlg->Show(false);
			SetCapture(NULL);
			HandleDlgCommand(nCommand,(uint16)dwParam1);
			SetSelection(1);
		}
		break;
	case CMD_CANCEL:
		{
			m_pDlg->Show(false);
			SetCapture(NULL);
			SetSelection(1);
		}
		break;

	case CMD_LOAD:
		{
			m_pListCtrl->SetStartIndex(0);
			m_pDlg->Show(true);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CONFIRM:
		{
			uint16 nIndex = (uint16)dwParam1;
			if (dwParam2 == CMD_DELETE)
			{
				if (nIndex < m_pListCtrl->GetNumControls()) 
				{
					WStringSet::iterator iter = m_List.begin();
					for (int i = 0; i < nIndex && iter != m_List.end(); ++i, ++iter);

					if (iter != m_List.end())
					{
						Delete(iter->c_str());
					}
				}
			}
			else if (dwParam2 == CMD_LOAD)
			{
				if (nIndex < m_pListCtrl->GetNumControls()) 
				{
					WStringSet::iterator iter = m_List.begin();
					for (int i = 0; i < nIndex && iter != m_List.end(); ++i, ++iter);

					if (iter != m_List.end())
					{
						SetName( (*iter).c_str());
					}

				}
			}
			else if (dwParam2 == CMD_CREATE)
			{
				std::wstring sNew = g_pProfileMgr->GetCurrentProfile()->m_sFriendlyName.c_str( );
				bCreate = true;

				//show edit box here	
				MBCreate mb;
				mb.eType = LTMB_EDIT;
				mb.pFn = EditCallBack;
				mb.pUserData = this;
				mb.pString = sNew.c_str();
				mb.nMaxChars = MAX_PROFILE_NAME;
//				mb.eInput = kInputFileFriendly;
				g_pInterfaceMgr->ShowMessageBox("IDS_ENTER_OPTIONFILE_NAME",&mb);
			}
		}
		break;
	case CMD_DELETE:
		{
			m_pListCtrl->SetStartIndex(0);
			m_pDlg->Show(true);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_CREATE:
		{
			SendCommand(CMD_CONFIRM,0,CMD_CREATE);
		}
		break;
	case CMD_RENAME:
		{
			m_pListCtrl->SetStartIndex(0);
			m_pDlg->Show(true);
			SetCapture(m_pDlg);
			nCommand = dwCommand;
		}
		break;
	case CMD_EDIT:
		{
			std::wstring name = (wchar_t *)dwParam1;

			WStringSet::iterator iter = m_List.find(name);
			if (iter != m_List.end())
				name = (*iter);

			if (bCreate)
			{
				New( name.c_str() );
			}
			else
			{
				Rename( sOldFN.c_str(), name.c_str() );
			}
			
		}
		break;
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}

	return 1;
};