- // dialog_playerinfoname.cpp 
-   
- #include "../common.h" 
-   
-   
- // dialog template 
- #define THIS_DIALOG DIALOG_PLAYERINFONAME 
-   
-   
- // global variables 
- static wchar_t player_name[64]; 
-   
-   
- // prototypes of local functions 
- static void StartThread_ThisDialog (void *thread_parms); 
- static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam); 
-   
-   
- void DialogBox_PlayerInfoName (void) 
- { 
-    // helper function to fire up the modeless dialog box 
-   
-    player_t *network_player; 
-   
-    network_player = Player_FindByType (PLAYER_INTERNET); // quick access to network player 
-    if (network_player == NULL) 
-       return; // consistency check 
-   
-    if (lastonlineplayers_time + 5.0f < current_time) 
-       Player_SendBuffer_Add (network_player, 1000, L"who\n"); // request a players list update 
-   
-    is_dialogbox_displayed = true; 
-    _beginthread (StartThread_ThisDialog, 0, NULL); // fire up a new message box thread 
-   
-    return; // return as soon as the thread is fired up 
- } 
-   
-   
- void DialogBox_PlayerInfoName_Validated (void) 
- { 
-    // callback function called by the main game thread when the dialog box is validated 
-   
-    // remember this callback is no longer to be called 
-    is_dialogbox_playerinfoname_validated = false; 
-   
-    return; // finished 
- } 
-   
-   
- static void StartThread_ThisDialog (void *thread_parms) 
- { 
-    // this function runs in a separate thread, for that's the only way (seemingly) 
-    // to implement a non-modal message box using the Common Controls library. 
-   
-    // display the dialog box 
-    if (DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog) == 1) 
-       is_dialogbox_playerinfoname_validated = true; 
-    is_dialogbox_displayed = false; 
-   
-    the_board.reevaluate = true; // refresh the GUI buttons if needed 
-    return; // _endthread() implied 
- } 
-   
-   
- static int CALLBACK DialogProc_ThisDialog (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam) 
- { 
-    unsigned short wParam_hiword; 
-    unsigned short wParam_loword; 
-   
-    // filter out the commonly used message values 
-    wParam_hiword = HIWORD (wParam); 
-    wParam_loword = LOWORD (wParam); 
-   
-    // have we just fired up this window ? 
-    if (message == WM_INITDIALOG) 
-    { 
-       // center the window 
-       CenterWindow (hWnd, hMainWnd); 
-   
-       // set dialog icons (small one for title bar & big one for task manager) 
-       SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN))); 
-       SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN))); 
-   
-       // set window title and control texts 
-       SetWindowText (hWnd, LOCALIZE (L"PlayerInfoName_Title")); 
-       SetDlgItemText (hWnd, STATICTEXT_PLAYERINFONAME_QUESTION, LOCALIZE (L"PlayerInfoName_Question")); 
-       SetDlgItemText (hWnd, BUTTON_DISPLAY, LOCALIZE (L"PlayerInfoName_Display")); 
-       SetDlgItemText (hWnd, STATICTEXT_PLAYERINFONAME_STATUSBAR, LOCALIZE (L"PlayerInfoName_StatusBar")); 
-   
-       // convert the status bar message to a hyperlink 
-       ConvertStaticToHyperlink (GetDlgItem (hWnd, STATICTEXT_PLAYERINFONAME_STATUSBAR)); 
-    } 
-   
-    // else did we take action on one of the controls ? 
-    else if (message == WM_COMMAND) 
-    { 
-       // was it the display button ? 
-       if (wParam_loword == BUTTON_DISPLAY) 
-       { 
-          GetDlgItemText (hWnd, EDITBOX_PLAYERINFONAME_NAME, player_name, WCHAR_SIZEOF (player_name)); // get player name 
-          PlayerCard_FindOrCreate (player_name); // and fire up the relevant player card 
-   
-          EndDialog (hWnd, 1); // close the dialog box and return OK 
-       } 
-   
-       // else did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key) 
-       else if (wParam_loword == IDCANCEL) 
-          EndDialog (hWnd, 0); // close the dialog box 
-   
-       // else was it the status bar hyperlink ? 
-       else if (wParam_loword == STATICTEXT_PLAYERINFONAME_STATUSBAR) 
-          ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the donation page in the default browser, maximized 
-    } 
-   
-    // call the default dialog message processing function to keep things going 
-    return (false); 
- } 
-