📄 netstart.cpp
字号:
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_Sessions
//
// PURPOSE: Does the SESSIONS dialog
//
// ----------------------------------------------------------------------- //
BOOL CALLBACK NetDlg_Sessions(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HCURSOR hCurCursor;
static BOOL bFirstFill = TRUE;
switch (uMsg)
{
case WM_INITDIALOG:
{
bFirstFill = TRUE;
hCurCursor = (HCURSOR)GetClassLong(hDlg, GCL_HCURSOR);
ForceActiveFocus(hDlg);
NetStart_ClearSelectedSessionInfo(hDlg);
EnableWindow(GetDlgItem(hDlg, IDC_NEXT), FALSE);
int nTabs[10] = {80, 82, 84, 86, 88, 90, 92, 94, 96, 98 };
SendMessage(GetDlgItem(hDlg, IDC_PLAYERLIST), LB_SETTABSTOPS, 10, (LPARAM)&nTabs);
SetTimer(hDlg, 1, 500, NULL);
return(TRUE);
}
case WM_TIMER:
{
KillTimer(hDlg, 1);
hCurCursor = LoadCursor(NULL, IDC_WAIT);
HCURSOR hOldCursor = SetCursor(hCurCursor);
int c = NetStart_FillSessionList(hDlg);
if (c == 0) NetStart_ClearSelectedSessionInfo(hDlg);
EnableWindow(GetDlgItem(hDlg, IDC_NEXT), c > 0);
hCurCursor = hOldCursor;
SetCursor(hCurCursor);
if (c == 0 && bFirstFill && !s_bDontDisplayNoSessions)
{
bFirstFill = FALSE;
int nRet = DoNoSessionsMessage(hDlg);
if (nRet == ID_NO) PostMessage(hDlg, WM_COMMAND, IDCANCEL, 0);
SetTimer(hDlg, 1, 3000, NULL);
}
else
{
SetTimer(hDlg, 1, 10000, NULL);
}
return(TRUE);
}
case WM_ACTIVATE:
case WM_ACTIVATEAPP:
{
SetCursor(hCurCursor);
return(FALSE);
}
case WM_SETCURSOR:
{
SetCursor(hCurCursor);
return(TRUE);
}
case WM_COMMAND:
{
if (NetStart_HandleDefaultDialogCommands(hDlg, wParam))
{
KillTimer(hDlg, 1);
return(TRUE);
}
else if (wParam == IDC_NEXT)
{
if (!NetStart_JoinCurrentSession(GetDlgItem(hDlg, IDC_SESSIONLIST)))
{
s_nErrorString = IDS_NETERR_JOINSESSION;
EndDialog(hDlg, DLG_ERROR);
}
else
{
EndDialog(hDlg, DLG_NEXT);
}
KillTimer(hDlg, 1);
return(TRUE);
}
else if (HIWORD(wParam) == LBN_SELCHANGE)
{
if (!NetStart_DisplaySelectedSessionInfo(hDlg))
{
NetStart_ClearSelectedSessionInfo(hDlg);
}
return(TRUE);
}
}
}
return(FALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_Game
//
// PURPOSE: Does the GAME dialog
//
// ----------------------------------------------------------------------- //
BOOL CALLBACK NetDlg_Game(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
ClientDE *pClientDE = s_pClient;
switch (uMsg)
{
case WM_INITDIALOG:
{
ForceActiveFocus(hDlg);
SetDlgItemText(hDlg, IDC_NAME, s_sSessionName);
NetStart_SetEndGameInfo(hDlg);
NetStart_InitGameType(hDlg);
return(TRUE);
}
case WM_COMMAND:
{
if (NetStart_HandleDefaultDialogCommands(hDlg, wParam))
{
return(TRUE);
}
else if (wParam == IDC_NEXT)
{
if (!NetStart_HostSession1(hDlg))
{
s_nErrorString = IDS_NETERR_HOSTSESSION;
EndDialog(hDlg, DLG_ERROR);
}
else
{
NetStart_FillGameStruct(hDlg);
NetStart_FillGameEnd(hDlg);
NetStart_FillGameType(hDlg);
EndDialog(hDlg, DLG_NEXT);
}
return(TRUE);
}
}
}
return(FALSE);
}
void ForceActiveFocus(HWND hWnd)
{
#ifdef _DEMO
SetWindowText(hWnd, "Blood2 Demo Multiplayer Wizard");
#endif
SetActiveWindow(hWnd);
BringWindowToTop(hWnd);
SetForegroundWindow(hWnd);
SetFocus(hWnd);
}
BOOL NetStart_InitGameType(HWND hDlg)
{
if (!hDlg) return(FALSE);
CheckDlgButton(hDlg, IDC_BB, s_nGameType == NGT_DEATHMATCH ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_CTF, s_nGameType == NGT_CAPTUREFLAG ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_TEAMS, s_nGameType == NGT_TEAMS ? BST_CHECKED : BST_UNCHECKED);
#ifdef _ADDON
CheckDlgButton(hDlg, IDC_SOCCER, s_nGameType == NGT_SOCCER ? BST_CHECKED : BST_UNCHECKED);
#endif
return(TRUE);
}
BOOL NetStart_FillGameType(HWND hDlg)
{
if (!hDlg) return(FALSE);
if (IsDlgButtonChecked(hDlg, IDC_BB) == BST_CHECKED) s_nGameType = NGT_DEATHMATCH;
if (IsDlgButtonChecked(hDlg, IDC_CTF) == BST_CHECKED) s_nGameType = NGT_CAPTUREFLAG;
if (IsDlgButtonChecked(hDlg, IDC_TEAMS) == BST_CHECKED) s_nGameType = NGT_TEAMS;
#ifdef _ADDON
if (IsDlgButtonChecked(hDlg, IDC_SOCCER) == BST_CHECKED) s_nGameType = NGT_SOCCER;
#endif
s_NetGame.m_byType = s_nGameType;
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_FillGameStruct
//
// PURPOSE: Fills the NetGame structure with the main game info
//
// ----------------------------------------------------------------------- //
BOOL NetStart_FillGameStruct(HWND hDlg)
{
// Sanity checks...
if (!hDlg) return(FALSE);
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_Player
//
// PURPOSE: Does the PLAYER dialog
//
// ----------------------------------------------------------------------- //
BOOL CALLBACK NetDlg_Player(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
ForceActiveFocus(hDlg);
if (s_bLobbyLaunch && !s_pNetStart->m_bHost) SetDlgItemText(hDlg, IDC_NEXT, "&Finished");
if (s_pNetStart->m_bHaveTcpIp) SetDlgItemText(hDlg, IDC_NEXT, "&Finished");
NetStart_InitPlayer(hDlg);
NetStart_FillNetSpeed(hDlg);
NetStart_InitFpsLimit(hDlg);
return(TRUE);
}
case WM_COMMAND:
{
if (NetStart_HandleDefaultDialogCommands(hDlg, wParam))
{
return(TRUE);
}
else if (wParam == IDC_NEXT)
{
GetDlgItemText(hDlg, IDC_NAME, s_pNetStart->m_sPlayer, 60);
if (strlen(s_pNetStart->m_sPlayer) <= 0) strcpy(s_pNetStart->m_sPlayer, "Caleb");
PostProcessName(s_pNetStart->m_sPlayer);
NetStart_FillPlayerStruct(hDlg);
NetStart_FillFpsLimit(hDlg);
NetStart_SelectNetSpeed(GetDlgItem(hDlg, IDC_NETCONNECTION));
EndDialog(hDlg, DLG_NEXT);
return(TRUE);
}
else if (HIWORD(wParam) == LBN_SELCHANGE)
{
CConfig* pConfig = s_ConfigMgr.GetListBoxSelection(GetDlgItem(hDlg, IDC_CONFIGS));
if (pConfig) pConfig->FillDialog(hDlg);
return(TRUE);
}
}
}
return(FALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_InitPlayer
//
// PURPOSE: Inits the player dialog
//
// ----------------------------------------------------------------------- //
BOOL NetStart_InitPlayer(HWND hDlg)
{
// Sanity checks...
if (!hDlg) return(FALSE);
// Init the config manager...
if (!s_ConfigMgr.Init("Players"))
{
return(FALSE);
}
// Set the player name...
PostProcessName(s_sPlayerName);
SetDlgItemText(hDlg, IDC_NAME, s_sPlayerName);
// Fill the list of .b2c files...
HWND hList = GetDlgItem(hDlg, IDC_CONFIGS);
if (!hList) return(FALSE);
s_ConfigMgr.FillListBox(hList, s_sNetConfigFile, "Caleb.b2c");
CConfig* pConfig = s_ConfigMgr.GetListBoxSelection(GetDlgItem(hDlg, IDC_CONFIGS));
if (pConfig) pConfig->FillDialog(hDlg);
// Set the team...
CheckDlgButton(hDlg, IDC_TEAM1, s_nNetTeam == TEAM_1 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_TEAM2, s_nNetTeam == TEAM_2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, IDC_AUTOTEAM, s_nNetTeam == TEAM_AUTO ? BST_CHECKED : BST_UNCHECKED);
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_FillPlayerStruct
//
// PURPOSE: Fills the player struct with the player info from the dlg
//
// ----------------------------------------------------------------------- //
BOOL NetStart_FillPlayerStruct(HWND hDlg, BOOL bUseComboConfig)
{
// Sanity checks...
if (!hDlg) return(FALSE);
// Get the player name...
GetDlgItemText(hDlg, IDC_NAME, s_pNetStart->m_sPlayer, 60);
if (_mbstrlen(s_pNetStart->m_sPlayer) <= 0) _mbscpy((unsigned char*)s_pNetStart->m_sPlayer, (const unsigned char*)"Caleb");
GetDlgItemText(hDlg, IDC_NAME, s_NetPlayer.m_sName, MAX_PLAYER_NAME-1);
if (_mbstrlen(s_NetPlayer.m_sName) <= 0) _mbscpy((unsigned char*)s_NetPlayer.m_sName, (const unsigned char*)"Caleb");
_mbscpy((unsigned char*)s_sPlayerName, (const unsigned char*)s_NetPlayer.m_sName);
PostProcessName(s_NetPlayer.m_sName);
PostProcessName(s_pNetStart->m_sPlayer);
PostProcessName(s_sPlayerName);
// Get the config file...
_mbscpy((unsigned char*)s_NetPlayer.m_sConfig, (const unsigned char*)"Caleb.b2c");
_mbscpy((unsigned char*)s_sNetConfigFile, (const unsigned char*)"Caleb.b2c");
CConfig* pConfig = NULL;
if (bUseComboConfig)
{
pConfig = s_ConfigMgr.GetComboBoxSelection(GetDlgItem(hDlg, IDC_CONFIGS));
}
else
{
pConfig = s_ConfigMgr.GetListBoxSelection(GetDlgItem(hDlg, IDC_CONFIGS));
}
if (pConfig)
{
_mbscpy((unsigned char*)s_NetPlayer.m_sConfig, (const unsigned char*)pConfig->GetFileName());
_mbscpy((unsigned char*)s_sNetConfigFile, (const unsigned char*)pConfig->GetFileName());
}
// Get the player team...
int nTeam = TEAM_AUTO;
if (IsDlgButtonChecked(hDlg, IDC_TEAM1) == BST_CHECKED) nTeam = TEAM_1;
if (IsDlgButtonChecked(hDlg, IDC_TEAM2) == BST_CHECKED) nTeam = TEAM_2;
s_NetPlayer.m_dwTeam = nTeam;
s_NetClientData.m_dwTeam = nTeam;
s_nNetTeam = nTeam;
// All done...
return(TRUE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_Welcome
//
// PURPOSE: Does the WELCOME dialog
//
// ----------------------------------------------------------------------- //
BOOL CALLBACK NetDlg_Welcome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
ForceActiveFocus(hDlg);
SetTimer(hDlg, 1, 500, NULL);
return(TRUE);
}
case WM_TIMER:
{
KillTimer(hDlg, 1);
ForceActiveFocus(hDlg);
return(TRUE);
}
case WM_COMMAND:
{
if (NetStart_HandleDefaultDialogCommands(hDlg, wParam))
{
return(TRUE);
}
else if (wParam == IDC_NEXT)
{
EndDialog(hDlg, DLG_NEXT);
return(TRUE);
}
}
}
return(FALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_Finished
//
// PURPOSE: Does the FINISHED dialog
//
// ----------------------------------------------------------------------- //
BOOL CALLBACK NetDlg_Finished(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
ForceActiveFocus(hDlg);
return(TRUE);
}
case WM_COMMAND:
{
if (NetStart_HandleDefaultDialogCommands(hDlg, wParam))
{
KillTimer(hDlg, 1);
return(TRUE);
}
else if (wParam == IDC_NEXT)
{
EndDialog(hDlg, DLG_NEXT);
return(TRUE);
}
}
}
return(FALSE);
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: NetStart_FillLevelList
//
// PURPOSE: Fills a list box with the list of levels
//
// ----------------------------------------------------------------------- //
BOOL NetStart_FillLevelList(HWND hList, char* sDir, int nData, BOOL bClearList)
{
// Sanity checks...
if (!hList) return(FALSE);
if (!sDir) return(FALSE);
// Get a list of world names and put them in the list box...
if (bClearList)
{
SendMessage(hList, LB_RESETCONTENT, 0, 0);
}
FileEntry* pFiles = s_pClient->GetFileList(sDir);
if (!pFiles) return(FALSE);
FileEntry* ptr = pFiles;
while (ptr)
{
if (ptr->m_Type == TYPE_FILE)
{
if (strnicmp(&ptr->m_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -