Subversion Repositories Games.Chess Giants

Rev

Rev 19 | Rev 124 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19 Rev 119
Line 39... Line 39...
39
static void StartThread_ThisDialog (void *thread_parms)
39
static void StartThread_ThisDialog (void *thread_parms)
40
{
40
{
41
   // this function runs in a separate thread, for that's the only way (seemingly)
41
   // this function runs in a separate thread, for that's the only way (seemingly)
42
   // to implement a non-modal message box using the Common Controls library.
42
   // to implement a non-modal message box using the Common Controls library.
43
 
43
 
-
 
44
   int retval;
-
 
45
 
44
   // display the dialog box
46
   // display the dialog box and grab its return value
45
   if (DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog) == 1)
47
   retval = DialogBox (hAppInstance, MAKEINTRESOURCE (THIS_DIALOG), hMainWnd, DialogProc_ThisDialog);
-
 
48
   if (retval == 1)
-
 
49
      is_dialogbox_quit_validated = true; // if we simply want to quit, flag the quit dialog box as confirmed
46
      is_dialogbox_quit_validated = true;
50
   else if (retval == 2)
-
 
51
      DialogBox_Save (true); // else if we want to save THEN quit, fire up the save dialog box first (and tell it to raise the quit confirmation flag after it returns)
47
 
52
 
48
   return; // _endthread() implied
53
   return; // _endthread() implied
49
}
54
}
50
 
55
 
51
 
56
 
Line 70... Line 75...
70
      SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
75
      SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
71
      SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
76
      SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIcon (hAppInstance, MAKEINTRESOURCE (ICON_MAIN)));
72
 
77
 
73
      // set window title and control texts
78
      // set window title and control texts
74
      SetWindowText (hWnd, LOCALIZE (L"Quit_Title"));
79
      SetWindowText (hWnd, LOCALIZE (L"Quit_Title"));
-
 
80
 
-
 
81
      // are we online AND has a game started, or are we playing locally in which case it is acceptable to simply quit now ?
-
 
82
      if ((Player_FindByType (PLAYER_INTERNET) != NULL) && (the_board.move_count > 1))
-
 
83
      {
75
      Static_SetText (GetDlgItem (hWnd, STATICTEXT_QUIT_QUESTION), LOCALIZE (L"Quit_Question"));
84
         Static_SetText (GetDlgItem (hWnd, STATICTEXT_QUIT_QUESTION), LOCALIZE (L"Quit_OnlineQuestion"));
76
      SetWindowText (GetDlgItem (hWnd, BUTTON_GIVEUPANDQUIT), LOCALIZE (L"Quit_GiveUpAndQuit"));
85
         SetWindowText (GetDlgItem (hWnd, BUTTON_GIVEUPANDQUIT), LOCALIZE (L"Quit_GiveUpAndQuit"));
77
      SetWindowText (GetDlgItem (hWnd, BUTTON_BACKTOGAME), LOCALIZE (L"Quit_BackToGame"));
86
         SetWindowText (GetDlgItem (hWnd, BUTTON_BACKTOGAME), LOCALIZE (L"Quit_BackToGame"));
-
 
87
      }
-
 
88
      else
-
 
89
      {
-
 
90
         Static_SetText (GetDlgItem (hWnd, STATICTEXT_QUIT_QUESTION), LOCALIZE (L"Quit_OfflineQuestion"));
-
 
91
         SetWindowText (GetDlgItem (hWnd, BUTTON_GIVEUPANDQUIT), LOCALIZE (L"Quit_SaveAndQuit"));
-
 
92
         SetWindowText (GetDlgItem (hWnd, BUTTON_BACKTOGAME), LOCALIZE (L"Quit_SimplyQuit"));
-
 
93
      }
78
      Static_SetText (GetDlgItem (hWnd, STATICTEXT_QUIT_STATUSBAR), LOCALIZE (L"Quit_StatusBar"));
94
      Static_SetText (GetDlgItem (hWnd, STATICTEXT_QUIT_STATUSBAR), LOCALIZE (L"Quit_StatusBar"));
79
 
95
 
80
      // play the "question" system sound
96
      // play the "question" system sound
81
      PlaySound ((LPCWSTR) SND_ALIAS_SYSTEMASTERISK, NULL, SND_ALIAS_ID | SND_ASYNC);
97
      PlaySound ((LPCWSTR) SND_ALIAS_SYSTEMASTERISK, NULL, SND_ALIAS_ID | SND_ASYNC);
82
 
98
 
Line 93... Line 109...
93
   {
109
   {
94
      // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key)
110
      // did we cancel the dialog box ? (IDCANCEL is a system-wide dialog box handler value, that catches the ESC key)
95
      if (wParam_loword == IDCANCEL)
111
      if (wParam_loword == IDCANCEL)
96
         EndDialog (hWnd, 0); // close the dialog box
112
         EndDialog (hWnd, 0); // close the dialog box
97
 
113
 
98
      // else was it the quit button ?
114
      // else was it the "give up and quit" or "save and quit" button ?
99
      else if (wParam_loword == BUTTON_GIVEUPANDQUIT)
115
      else if (wParam_loword == BUTTON_GIVEUPANDQUIT)
-
 
116
      {
-
 
117
         // are we online AND has a game started, or are we playing locally ?
-
 
118
         if ((Player_FindByType (PLAYER_INTERNET) != NULL) && (the_board.move_count > 1))
100
         EndDialog (hWnd, 1); // close the dialog box and return a success value
119
            EndDialog (hWnd, 1); // when playing remotely, button is labeled "give up and quit" --> close the dialog box and return a value that tells to quit
-
 
120
         else
-
 
121
            EndDialog (hWnd, 2); // when playing locally, button is labeled "save and quit" --> close the dialog box and return a value that tells to display a "save" dialog box
-
 
122
      }
101
 
123
 
102
      // else was it the back to game button ?
124
      // else was it the "back to game" or "simply quit" button ?
103
      else if (wParam_loword == BUTTON_BACKTOGAME)
125
      else if (wParam_loword == BUTTON_BACKTOGAME)
-
 
126
      {
104
         EndDialog (hWnd, 0); // close the dialog box
127
         // are we online AND has a game started, or are we playing locally ?
-
 
128
         if ((Player_FindByType (PLAYER_INTERNET) != NULL) && (the_board.move_count > 1))
-
 
129
            EndDialog (hWnd, 0); // when playing remotely, button is labeled "back to game" --> close the dialog box and return a value that tells to do nothing
-
 
130
         else
-
 
131
            EndDialog (hWnd, 1); // when playing locally, button is labeled "just quit" --> close the dialog box and return a value that tells to quit
-
 
132
      }
105
 
133
 
106
      // else was it the status bar hyperlink ?
134
      // else was it the status bar hyperlink ?
107
      else if (wParam_loword == STATICTEXT_QUIT_STATUSBAR)
135
      else if (wParam_loword == STATICTEXT_QUIT_STATUSBAR)
108
         ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the donation page in the default browser, maximized
136
         ShellExecute (NULL, L"open", PROGRAM_URL, NULL, NULL, SW_MAXIMIZE); // open the donation page in the default browser, maximized
109
   }
137
   }