Subversion Repositories Games.Chess Giants

Rev

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

Rev 130 Rev 136
Line 42... Line 42...
42
   int index_column;
42
   int index_column;
43
   int part_index;
43
   int part_index;
44
   int part_color;
44
   int part_color;
45
   int viewer_index;
45
   int viewer_index;
46
   RECT rect;
46
   RECT rect;
-
 
47
   POINT point;
47
 
48
 
48
   // filter out the commonly used message values
49
   // filter out the commonly used message values
49
   wParam_hiword = HIWORD (wParam);
50
   wParam_hiword = HIWORD (wParam);
50
   wParam_loword = LOWORD (wParam);
51
   wParam_loword = LOWORD (wParam);
51
 
52
 
Line 110... Line 111...
110
 
111
 
111
      // game menu, new game
112
      // game menu, new game
112
      if (wParam_loword == MENUID_GAME_NEWGAME)
113
      if (wParam_loword == MENUID_GAME_NEWGAME)
113
      {
114
      {
114
         if ((the_board.game_state == STATE_PLAYING) && (the_board.move_count > 1))
115
         if ((the_board.game_state == STATE_PLAYING) && (the_board.move_count > 1))
115
            DialogBox_Resign (); // if a game is playing, ask to resign first
116
            DialogBox_Resign (RESIGNTYPE_NEWGAME); // if a game is playing, ask to resign first
116
         else
117
         else
117
            DialogBox_NewGame (); // game not started yet, show the new game dialog box
118
            DialogBox_NewGame (); // game not started yet, show the new game dialog box
118
      }
119
      }
119
 
120
 
120
      // game menu, setup start position
121
      // game menu, setup start position
121
      else if (wParam_loword == MENUID_GAME_SETUPPOSITION)
122
      else if (wParam_loword == MENUID_GAME_SETUPPOSITION)
-
 
123
         Board_EnterSetupPosition (&the_board); // enter setup position mode
-
 
124
 
-
 
125
      // game menu, load game
-
 
126
      else if (wParam_loword == MENUID_GAME_LOAD)
122
      {
127
      {
123
         if ((the_board.game_state == STATE_PLAYING) && (the_board.move_count > 1))
128
         if ((the_board.game_state == STATE_PLAYING) && (the_board.move_count > 1))
124
            DialogBox_Resign (); // if a game is playing, ask to resign first
129
            DialogBox_Resign (RESIGNTYPE_LOADGAME); // if a game is playing, ask to resign first
125
         else
130
         else
126
         {
-
 
127
            current_move = &the_board.moves[0]; // quick access to start move
-
 
128
            memset (&current_move->slots, 0, sizeof (current_move->slots)); // erase all slots
-
 
129
 
-
 
130
            the_board.game_state = STATE_SETUPPOSITION; // game not started yet, enter board setup mode
-
 
131
            the_board.reevaluate = true; // evaluate board again
131
            DialogBox_Load (); // fire up the load dialog box
132
 
-
 
133
            // display the "please choose start position" phrase in the middle of the screen
-
 
134
            Scene_SetText (&the_scene.gui.central_text, 50.0f, 50.0f, -1, ALIGN_CENTER, ALIGN_CENTER, ALIGN_CENTER, centermsg_fontindex, RGBA_TO_RGBACOLOR (255, 255, 255, 191),
-
 
135
                           999999.0f, true, LOCALIZE (L"SetupMode"));
-
 
136
            the_scene.gui.partspick_selectedpart = ' '; // no selected part yet
-
 
137
            the_scene.update = true; // and update the 3D scene
-
 
138
         }
-
 
139
      }
132
      }
140
 
-
 
141
      // game menu, load game
-
 
142
      else if (wParam_loword == MENUID_GAME_LOAD)
-
 
143
         DialogBox_Load (); // fire up the load dialog box
-
 
144
 
133
 
145
      // game menu, save game
134
      // game menu, save game
146
      else if (wParam_loword == MENUID_GAME_SAVE)
135
      else if (wParam_loword == MENUID_GAME_SAVE)
147
      {
136
      {
148
         if (save_pathname[0] != 0)
137
         if (save_pathname[0] != 0)
Line 167... Line 156...
167
         the_board.reevaluate = true; // evaluate board again
156
         the_board.reevaluate = true; // evaluate board again
168
      }
157
      }
169
 
158
 
170
      // game menu, resign
159
      // game menu, resign
171
      else if (wParam_loword == MENUID_GAME_RESIGN)
160
      else if (wParam_loword == MENUID_GAME_RESIGN)
172
         DialogBox_Resign (); // if a game has started, ask for confirmation
161
         DialogBox_Resign (RESIGNTYPE_UNDEFINED); // if a game has started, ask for confirmation
173
 
162
 
174
      // game menu, statistics (stats are only available in online mode)
163
      // game menu, statistics (stats are only available in online mode)
175
      else if (wParam_loword == MENUID_GAME_STATISTICS)
164
      else if (wParam_loword == MENUID_GAME_STATISTICS)
176
      {
165
      {
177
         local_player = Player_FindByType (PLAYER_HUMAN);
166
         local_player = Player_FindByType (PLAYER_HUMAN);
Line 189... Line 178...
189
         if ((the_board.game_state == STATE_PLAYING) && ((the_board.move_count > 1) || (remote_player != NULL)))
178
         if ((the_board.game_state == STATE_PLAYING) && ((the_board.move_count > 1) || (remote_player != NULL)))
190
            DialogBox_Quit (); // if a game has started OR if we are online against somebody, ask for confirmation
179
            DialogBox_Quit (); // if a game has started OR if we are online against somebody, ask for confirmation
191
         else
180
         else
192
            is_dialogbox_quit_validated = true; // if game hasn't started yet, quit without question
181
            is_dialogbox_quit_validated = true; // if game hasn't started yet, quit without question
193
      }
182
      }
194
 
-
 
195
      // chessboard menu, suggest move
-
 
196
      else if (wParam_loword == MENUID_CHESSBOARD_SUGGESTMOVE)
-
 
197
         the_board.players[current_viewer].wants_hint = true; // remember this player wants a hint
-
 
198
 
183
 
199
      // chessboard menu, cancel last move
184
      // chessboard menu, cancel last move
200
      else if (wParam_loword == MENUID_CHESSBOARD_CANCELLASTMOVE)
185
      else if (wParam_loword == MENUID_MOVE_CANCELLASTMOVE)
201
         the_board.players[current_viewer].wants_cancel = true; // remember this player wants to cancel his last move
186
         the_board.players[current_viewer].wants_cancel = true; // remember this player wants to cancel his last move
-
 
187
 
-
 
188
      // chessboard menu, suggest move
-
 
189
      else if (wParam_loword == MENUID_MOVE_SUGGESTMOVE)
-
 
190
         the_board.players[current_viewer].wants_hint = true; // remember this player wants a hint
202
 
191
 
203
      // chessboard menu, comment move
192
      // chessboard menu, comment move
204
      else if (wParam_loword == MENUID_CHESSBOARD_COMMENTMOVE)
193
      else if (wParam_loword == MENUID_MOVE_COMMENTMOVE)
205
         DialogBox_Comment (); // fire up the comment dialog box
194
         DialogBox_Comment (); // fire up the comment dialog box
206
 
195
 
207
      // chessboard menu, go to move
196
      // chessboard menu, go to move
208
      else if (wParam_loword == MENUID_CHESSBOARD_GOTOMOVE)
197
      else if (wParam_loword == MENUID_MOVE_GOTOMOVE)
209
         DialogBox_GoToMove (); // fire up the go to move dialog box
198
         DialogBox_GoToMove (); // fire up the go to move dialog box
210
 
199
 
211
      // chessboard menu, swap sides
200
      // chessboard menu, swap sides
212
      else if (wParam_loword == MENUID_CHESSBOARD_SWAPSIDES)
201
      else if (wParam_loword == MENUID_CHESSBOARD_SWAPSIDES)
213
         the_board.want_playerswap = true; // remember board sides are to be swapped
202
         the_board.want_playerswap = true; // remember board sides are to be swapped
Line 541... Line 530...
541
            }
530
            }
542
      }
531
      }
543
 
532
 
544
      // if we are not allowed to select anything, don't even try
533
      // if we are not allowed to select anything, don't even try
545
      if (is_paused || (current_player->type != PLAYER_HUMAN) || (the_board.viewed_move != the_board.move_count - 1)
534
      if (is_paused || (current_player->type != PLAYER_HUMAN) || (the_board.viewed_move != the_board.move_count - 1)
-
 
535
          || ((the_board.game_state != STATE_SETUPPOSITION) && (the_board.game_state != STATE_PLAYING))
546
          || ((remote_player != NULL) && !remote_player->is_in_game))
536
          || ((remote_player != NULL) && !remote_player->is_in_game))
547
      {
537
      {
548
         the_scene.update = true; // update the 3D scene
538
         the_scene.update = true; // update the 3D scene
549
 
539
 
550
         // call the default window message processing function to keep things going
540
         // call the default window message processing function to keep things going
Line 921... Line 911...
921
         // do they differ from last time ?
911
         // do they differ from last time ?
922
         if ((the_board.hovered_position[0] != prev_hovered_position[0]) || (the_board.hovered_position[1] != prev_hovered_position[1]))
912
         if ((the_board.hovered_position[0] != prev_hovered_position[0]) || (the_board.hovered_position[1] != prev_hovered_position[1]))
923
            the_scene.update = true; // if so, update scene
913
            the_scene.update = true; // if so, update scene
924
      }
914
      }
925
 
915
 
926
      // has the user the right to leave a command AND is there no comment yet ?
916
      // has the user the right to leave a comment AND is there no comment yet ?
927
      if ((the_board.game_state >= STATE_PLAYING) && (the_board.viewed_move > 0)
917
      if ((the_board.game_state >= STATE_PLAYING) && (the_board.viewed_move > 0)
928
          && ((the_board.moves[the_board.viewed_move].comment == NULL) || (the_board.moves[the_board.viewed_move].comment[0] == 0)))
918
          && ((the_board.moves[the_board.viewed_move].comment == NULL) || (the_board.moves[the_board.viewed_move].comment[0] == 0)))
929
      {
919
      {
930
         // is the mouse above the comments zone ? if so, display a dimmed hint text
920
         // is the mouse above the comments zone ? if so, display a dimmed hint text
931
         if (Render_IsMouseInBox (gui_x, gui_y, 30.0f, 0.0f, 40.0f, 10.0f))
921
         if (Render_IsMouseInBox (gui_x, gui_y, 30.0f, 0.0f, 40.0f, 10.0f))
Line 965... Line 955...
965
      // are we in board closeup mode OR are we online AND do we NOT have the right to select anything ?
955
      // are we in board closeup mode OR are we online AND do we NOT have the right to select anything ?
966
      if (((current_distance == CLOSEUP_VIEW_DISTANCE) && (current_pitch == CLOSEUP_VIEW_PITCH))
956
      if (((current_distance == CLOSEUP_VIEW_DISTANCE) && (current_pitch == CLOSEUP_VIEW_PITCH))
967
          || ((remote_player != NULL) && !remote_player->is_in_game))
957
          || ((remote_player != NULL) && !remote_player->is_in_game))
968
         return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going
958
         return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default window message processing function to keep things going
969
 
959
 
-
 
960
      // get mouse coordinates (strangely enough, the WM_MOUSEWHEEL message outputs ABSOLUTE coordinates, and we need to convert them...)
-
 
961
      point.x = GET_X_LPARAM (lParam);
-
 
962
      point.y = GET_Y_LPARAM (lParam);
970
      // scroll up / scroll down ?
963
      ScreenToClient (hWnd, &point);
-
 
964
      gui_x = point.x;
-
 
965
      gui_y = point.y;
-
 
966
 
-
 
967
      // is a game history displayed and are we (roughly) hovering this area ?
-
 
968
      if (the_scene.gui.history_text.is_displayed && Render_IsMouseInBox (gui_x, gui_y, 90.0f, 10.0f, 10.0f, 40.0f))
-
 
969
      {
-
 
970
         // we want to scroll through the game history rather than zooming in/out. Scroll up or scroll down ?
-
 
971
         if ((GET_WHEEL_DELTA_WPARAM (wParam) > 0) && (the_scene.gui.larrow.state != 0))
-
 
972
            SendMessage (hWnd, WM_COMMAND, MENUID_CHESSBOARD_PREVIOUSMOVE, NULL); // send a "previous move" event
-
 
973
         else if ((GET_WHEEL_DELTA_WPARAM (wParam) < 0) && (the_scene.gui.rarrow.state != 0))
-
 
974
            SendMessage (hWnd, WM_COMMAND, MENUID_CHESSBOARD_NEXTMOVE, NULL); // send a "next move" event
-
 
975
 
-
 
976
         return (DefWindowProc (hWnd, message, wParam, lParam)); // and call the default window message processing function to keep things going
-
 
977
      }
-
 
978
 
-
 
979
      // we want to zoom in/out of the scene. Scroll up or scroll down ?
971
      if (GET_WHEEL_DELTA_WPARAM (wParam) > 0)
980
      if (GET_WHEEL_DELTA_WPARAM (wParam) > 0)
972
         the_board.players[current_viewer].view_distance = max (MIN_VIEW_DISTANCE, the_board.players[current_viewer].view_distance - 2.0f);
981
         the_board.players[current_viewer].view_distance = max (MIN_VIEW_DISTANCE, the_board.players[current_viewer].view_distance - 2.0f);
973
      else if (GET_WHEEL_DELTA_WPARAM (wParam) < 0)
982
      else if (GET_WHEEL_DELTA_WPARAM (wParam) < 0)
974
         the_board.players[current_viewer].view_distance = min (MAX_VIEW_DISTANCE, the_board.players[current_viewer].view_distance + 2.0f);
983
         the_board.players[current_viewer].view_distance = min (MAX_VIEW_DISTANCE, the_board.players[current_viewer].view_distance + 2.0f);
975
 
984