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 | } |
44 | 49 | ||
45 | 50 | ||
46 | void DialogBox_SendChallenge_Validated (void) |
51 | void DialogBox_SendChallenge_Validated (void) |
47 | { |
52 | { |
48 | // callback function called by the main game thread when the dialog box is validated |
53 | // callback function called by the main game thread when the dialog box is validated |
49 | 54 | ||
50 | player_t *network_player; |
55 | player_t *network_player; |
51 | 56 | ||
52 | // remember this callback is no longer to be called |
57 | // remember this callback is no longer to be called |
53 | is_dialogbox_sendchallenge_validated = false; |
58 | is_dialogbox_sendchallenge_validated = false; |
54 | 59 | ||
55 | network_player = Player_FindByType (PLAYER_INTERNET); // quick access to network player |
60 | network_player = Player_FindByType (PLAYER_INTERNET); // quick access to network player |
56 | if (network_player == NULL) |
61 | if (network_player == NULL) |
57 | return; // consistency check |
62 | return; // consistency check |
58 | 63 | ||
59 | // send the challenge |
64 | // send the challenge |
60 | Player_SendBuffer_Add (network_player, 1000, L"match %s %s %d %d %s %s\n", |
65 | Player_SendBuffer_Add (network_player, 1000, L"match %s %s %d %d %s %s\n", |
61 | sendchallenge.challengee, |
66 | sendchallenge.challengee, |
62 | (sendchallenge.is_rated ? L"rated" : L"unrated"), |
67 | (sendchallenge.is_rated ? L"rated" : L"unrated"), |
63 | sendchallenge.initial_time, |
68 | sendchallenge.initial_time, |
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")); |