Rev 172 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 172 | Rev 193 | ||
|---|---|---|---|
| Line 30... | Line 30... | ||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | void DialogBox_SendChallenge (wchar_t *challengee_name) |
32 | void DialogBox_SendChallenge (wchar_t *challengee_name) |
| 33 | { |
33 | { |
| 34 | // helper function to fire up the modeless dialog box |
34 | // helper function to fire up the modeless dialog box |
| - | 35 | ||
| - | 36 | if (IsWindow (hThisWnd)) |
|
| - | 37 | SendMessage (hThisWnd, WM_CLOSE, 0, 0); // if such a dialog already exists, close it |
|
| 35 | 38 | ||
| 36 | // prepare the sendchallenge structure |
39 | // prepare the sendchallenge structure |
| 37 | wcscpy_s (sendchallenge.challengee, WCHAR_SIZEOF (sendchallenge.challengee), challengee_name); |
40 | wcscpy_s (sendchallenge.challengee, WCHAR_SIZEOF (sendchallenge.challengee), challengee_name); |
| 38 | sendchallenge.game_rules[0] = 0; // no special rules until told otherwise |
41 | sendchallenge.game_rules[0] = 0; // no special rules until told otherwise |
| - | 42 | if ((sendchallenge.color == COLOR_UNSPECIFIED) && options.want_playblackside) |
|
| - | 43 | sendchallenge.color = COLOR_BLACK; // if last challenge color was unspecified AND user prefers to play black, save it |
|
| 39 | 44 | ||
| 40 | is_dialogbox_displayed = true; |
45 | is_dialogbox_displayed = true; |
| 41 | _beginthread (StartThread_ThisDialog, 0, NULL); // fire up the thread |
46 | _beginthread (StartThread_ThisDialog, 0, NULL); // fire up the thread |
| 42 | return; // return as soon as the thread is fired up |
47 | return; // return as soon as the thread is fired up |
| 43 | } |
48 | } |
| Line 73... | Line 78... | ||
| 73 | 78 | ||
| 74 | static void StartThread_ThisDialog (void *thread_parms) |
79 | static void StartThread_ThisDialog (void *thread_parms) |
| 75 | { |
80 | { |
| 76 | // this function runs in a separate thread, for that's the only way (seemingly) |
81 | // this function runs in a separate thread, for that's the only way (seemingly) |
| 77 | // to implement a non-modal message box using the Common Controls library. |
82 | // to implement a non-modal message box using the Common Controls library. |
| 78 | - | ||
| 79 | if (IsWindow (hThisWnd)) |
- | |
| 80 | SendMessage (hThisWnd, WM_CLOSE, 0, 0); // if such a dialog already exists, close it |
- | |
| 81 | 83 | ||
| 82 | // display the dialog box |
84 | // display the dialog box |
| 83 | if (DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog) == 1) |
85 | if (DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog) == 1) |
| 84 | is_dialogbox_sendchallenge_validated = true; // notify main game thread to fire up our callback |
86 | is_dialogbox_sendchallenge_validated = true; // notify main game thread to fire up our callback |
| 85 | is_dialogbox_displayed = false; |
87 | is_dialogbox_displayed = false; |
| Line 116... | Line 118... | ||
| 116 | swprintf_s (temp_string, WCHAR_SIZEOF (temp_string), LOCALIZE (L"SendChallenge_Question"), sendchallenge.challengee); |
118 | swprintf_s (temp_string, WCHAR_SIZEOF (temp_string), LOCALIZE (L"SendChallenge_Question"), sendchallenge.challengee); |
| 117 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_QUESTION, temp_string); |
119 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_QUESTION, temp_string); |
| 118 | 120 | ||
| 119 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_COLOR, LOCALIZE (L"SendChallenge_ColorIWishToPlay")); |
121 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_COLOR, LOCALIZE (L"SendChallenge_ColorIWishToPlay")); |
| 120 | ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), L""); |
122 | ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), L""); |
| 121 | ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), LOCALIZE (L"Games_Black")); |
123 | ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), LOCALIZE (L"Games_Black")); // because COLOR_BLACK is id #0 |
| 122 | ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), LOCALIZE (L"Games_White")); |
124 | ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), LOCALIZE (L"Games_White")); // because COLOR_WHITE is id #1 |
| 123 | ComboBox_SetCurSel (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), 1 + sendchallenge.color); |
125 | ComboBox_SetCurSel (GetDlgItem (hWnd, COMBOBOX_SENDCHALLENGE_COLOR), 1 + sendchallenge.color); |
| 124 | 126 | ||
| 125 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_INITIALTIME, LOCALIZE (L"SendChallenge_InitialTime")); |
127 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_INITIALTIME, LOCALIZE (L"SendChallenge_InitialTime")); |
| 126 | SetDlgItemInt (hWnd, EDITBOX_SENDCHALLENGE_INITIALTIME, sendchallenge.initial_time, false); |
128 | SetDlgItemInt (hWnd, EDITBOX_SENDCHALLENGE_INITIALTIME, sendchallenge.initial_time, false); |
| 127 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_INCREMENT, LOCALIZE (L"SendChallenge_Increment")); |
129 | SetDlgItemText (hWnd, STATICTEXT_SENDCHALLENGE_INCREMENT, LOCALIZE (L"SendChallenge_Increment")); |