Subversion Repositories Games.Chess Giants

Rev

Rev 140 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 140 Rev 193
Line 31... Line 31...
31
 
31
 
32
 
32
 
33
void DialogBox_SendSeek (void)
33
void DialogBox_SendSeek (void)
34
{
34
{
35
   // helper function to fire up the modeless dialog box
35
   // helper function to fire up the modeless dialog box
-
 
36
 
-
 
37
   if (IsWindow (hThisWnd))
-
 
38
      SendMessage (hThisWnd, WM_CLOSE, 0, 0); // if such a dialog already exists, close it
-
 
39
 
-
 
40
   // prepare the sendseek structure
-
 
41
   if ((sendseek.color == COLOR_UNSPECIFIED) && options.want_playblackside)
-
 
42
      sendseek.color = COLOR_BLACK; // if last seek color was unspecified AND user prefers to play black, save it
36
 
43
 
37
   is_dialogbox_displayed = true;
44
   is_dialogbox_displayed = true;
38
   _beginthread (StartThread_ThisDialog, 0, NULL); // fire up the thread
45
   _beginthread (StartThread_ThisDialog, 0, NULL); // fire up the thread
39
   return; // return as soon as the thread is fired up
46
   return; // return as soon as the thread is fired up
40
}
47
}
41
 
48
 
42
 
49
 
43
void DialogBox_SendSeek_Validated (void)
50
void DialogBox_SendSeek_Validated (void)
44
{
51
{
45
   // callback function called by the main game thread when the dialog box is validated
52
   // callback function called by the main game thread when the dialog box is validated
46
 
53
 
47
   player_t *network_player;
54
   player_t *network_player;
48
 
55
 
49
   // remember this callback is no longer to be called
56
   // remember this callback is no longer to be called
50
   is_dialogbox_sendseek_validated = false;
57
   is_dialogbox_sendseek_validated = false;
51
 
58
 
52
   network_player = Player_FindByType (PLAYER_INTERNET); // quick access to network player
59
   network_player = Player_FindByType (PLAYER_INTERNET); // quick access to network player
53
   if (network_player == NULL)
60
   if (network_player == NULL)
Line 67... Line 74...
67
   messagebox.hWndParent = hMainWnd;
74
   messagebox.hWndParent = hMainWnd;
68
   wcscpy_s (messagebox.title, WCHAR_SIZEOF (messagebox.title), LOCALIZE (L"SendSeek_Title"));
75
   wcscpy_s (messagebox.title, WCHAR_SIZEOF (messagebox.title), LOCALIZE (L"SendSeek_Title"));
69
   wcscpy_s (messagebox.text, WCHAR_SIZEOF (messagebox.text), LOCALIZE (L"SendSeek_SeekSent"));
76
   wcscpy_s (messagebox.text, WCHAR_SIZEOF (messagebox.text), LOCALIZE (L"SendSeek_SeekSent"));
70
   messagebox.flags = MB_ICONINFORMATION | MB_OK;
77
   messagebox.flags = MB_ICONINFORMATION | MB_OK;
71
   DialogBox_Message (&messagebox);
78
   DialogBox_Message (&messagebox);
72
 
79
 
73
   return; // finished, game request is sent
80
   return; // finished, game request is sent
74
}
81
}
75
 
82
 
76
 
83
 
77
static void StartThread_ThisDialog (void *thread_parms)
84
static void StartThread_ThisDialog (void *thread_parms)
78
{
85
{
79
   // this function runs in a separate thread, for that's the only way (seemingly)
86
   // this function runs in a separate thread, for that's the only way (seemingly)
80
   // to implement a non-modal message box using the Common Controls library.
87
   // to implement a non-modal message box using the Common Controls library.
81
 
-
 
82
   if (IsWindow (hThisWnd))
-
 
83
      SendMessage (hThisWnd, WM_CLOSE, 0, 0); // if such a dialog already exists, close it
-
 
84
 
88
 
85
   // display the dialog box
89
   // display the dialog box
86
   if (DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog) == 1)
90
   if (DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog) == 1)
87
      is_dialogbox_sendseek_validated = true; // notify main game thread to fire up our callback
91
      is_dialogbox_sendseek_validated = true; // notify main game thread to fire up our callback
88
   is_dialogbox_displayed = false;
92
   is_dialogbox_displayed = false;
Line 117... Line 121...
117
 
121
 
118
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_QUESTION, LOCALIZE (L"SendSeek_Question"));
122
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_QUESTION, LOCALIZE (L"SendSeek_Question"));
119
 
123
 
120
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_COLOR, LOCALIZE (L"SendSeek_ColorIWishToPlay"));
124
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_COLOR, LOCALIZE (L"SendSeek_ColorIWishToPlay"));
121
      ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), L"");
125
      ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), L"");
122
      ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), LOCALIZE (L"Games_White"));
126
      ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), LOCALIZE (L"Games_Black")); // because COLOR_BLACK is id #0
123
      ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), LOCALIZE (L"Games_Black"));
127
      ComboBox_AddString (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), LOCALIZE (L"Games_White")); // because COLOR_WHITE is id #1
124
      ComboBox_SetCurSel (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), 1 + sendseek.color);
128
      ComboBox_SetCurSel (GetDlgItem (hWnd, COMBOBOX_SENDSEEK_COLOR), 1 + sendseek.color);
125
 
129
 
126
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_INITIALTIME, LOCALIZE (L"SendSeek_InitialTime"));
130
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_INITIALTIME, LOCALIZE (L"SendSeek_InitialTime"));
127
      SetDlgItemInt (hWnd, EDITBOX_SENDSEEK_INITIALTIME, sendseek.initial_time, false);
131
      SetDlgItemInt (hWnd, EDITBOX_SENDSEEK_INITIALTIME, sendseek.initial_time, false);
128
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_INCREMENT, LOCALIZE (L"SendSeek_Increment"));
132
      SetDlgItemText (hWnd, STATICTEXT_SENDSEEK_INCREMENT, LOCALIZE (L"SendSeek_Increment"));