Rev 3 | Rev 24 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3 | Rev 21 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | #include "../common.h" |
3 | #include "../common.h" |
- | 4 | ||
- | 5 | ||
- | 6 | // global variables used in this module only |
|
- | 7 | static wchar_t folder_path[MAX_PATH]; |
|
4 | 8 | ||
5 | 9 | ||
6 | // prototypes of local functions |
10 | // prototypes of local functions |
7 | static bool Button_IsHovered (guibutton_t *button, int gui_x, int gui_y); |
11 | static bool Button_IsHovered (guibutton_t *button, int gui_x, int gui_y); |
8 | static bool Button_UpdateHoverState (guibutton_t *button, int gui_x, int gui_y); |
12 | static bool Button_UpdateHoverState (guibutton_t *button, int gui_x, int gui_y); |
Line 68... | Line 72... | ||
68 | //////////////////////////////////////////////////////////////////////////////////////////////// |
72 | //////////////////////////////////////////////////////////////////////////////////////////////// |
69 | // else is the user closing its session OR the window is being destroyed ? |
73 | // else is the user closing its session OR the window is being destroyed ? |
70 | else if ((message == WM_QUERYENDSESSION) || (message == WM_ENDSESSION) || (message == WM_DESTROY)) |
74 | else if ((message == WM_QUERYENDSESSION) || (message == WM_ENDSESSION) || (message == WM_DESTROY)) |
71 | terminate_everything = true; // suicide (for some reason, PostQuitMessage() is unreliable !?) |
75 | terminate_everything = true; // suicide (for some reason, PostQuitMessage() is unreliable !?) |
72 | 76 | ||
- | 77 | ///////////////// |
|
- | 78 | // MENU EVENTS // |
|
73 | |
79 | ///////////////// |
- | 80 | ||
- | 81 | /////////////// |
|
74 | // menu |
82 | // menu command |
75 | else if (message == WM_COMMAND) |
83 | else if (message == WM_COMMAND) |
76 | { |
84 | { |
77 | // game menu, new game |
85 | // game menu, new game |
78 | if (wParam_loword == MENUID_GAME_NEWGAME) |
86 | if (wParam_loword == MENUID_GAME_NEWGAME) |
79 | { |
87 | { |
Line 293... | Line 301... | ||
293 | ShellExecute (NULL, L"open", L"Chess Giants.html", NULL, NULL, SW_MAXIMIZE); // fire up the help file |
301 | ShellExecute (NULL, L"open", L"Chess Giants.html", NULL, NULL, SW_MAXIMIZE); // fire up the help file |
294 | 302 | ||
295 | // help menu, get chess games |
303 | // help menu, get chess games |
296 | else if (wParam_loword == MENUID_HELP_GETCHESSGAMES) |
304 | else if (wParam_loword == MENUID_HELP_GETCHESSGAMES) |
297 | ShellExecute (NULL, L"open", L"http://www.chessgames.com", NULL, NULL, SW_MAXIMIZE); // fire up the browser |
305 | ShellExecute (NULL, L"open", L"http://www.chessgames.com", NULL, NULL, SW_MAXIMIZE); // fire up the browser |
- | 306 | ||
- | 307 | // help menu, add/modify visual themes |
|
- | 308 | else if (wParam_loword == MENUID_HELP_ADDMODIFYVISUALTHEMES) |
|
- | 309 | { |
|
- | 310 | swprintf_s (folder_path, WCHAR_SIZEOF (folder_path), L"%s\\themes", app_path); |
|
- | 311 | ShellExecute (NULL, L"open", folder_path, NULL, NULL, SW_SHOWNORMAL); // fire up Windows Explorer |
|
- | 312 | } |
|
- | 313 | ||
- | 314 | // help menu, add/modify translations |
|
- | 315 | else if (wParam_loword == MENUID_HELP_ADDMODIFYTRANSLATIONS) |
|
- | 316 | { |
|
- | 317 | swprintf_s (folder_path, WCHAR_SIZEOF (folder_path), L"%s\\data\\languages", app_path); |
|
- | 318 | ShellExecute (NULL, L"open", folder_path, NULL, NULL, SW_SHOWNORMAL); // fire up Windows Explorer |
|
- | 319 | } |
|
298 | 320 | ||
299 | // help menu, about |
321 | // help menu, about |
300 | else if (wParam_loword == MENUID_HELP_ABOUT) |
322 | else if (wParam_loword == MENUID_HELP_ABOUT) |
301 | DialogBox_About (); // show the About dialog box |
323 | DialogBox_About (); // show the About dialog box |
302 | 324 | ||
Line 320... | Line 342... | ||
320 | the_scene.update = true; // update the 3D scene |
342 | the_scene.update = true; // update the 3D scene |
321 | 343 | ||
322 | // call the default window message processing function to keep things going |
344 | // call the default window message processing function to keep things going |
323 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
345 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
324 | } |
346 | } |
- | 347 | ||
- | 348 | ////////////////// |
|
- | 349 | // MOUSE EVENTS // |
|
- | 350 | ////////////////// |
|
325 | 351 | ||
326 | //////////////////////////////////////////////////////////////////////////////////////////////// |
352 | //////////////////////////////////////////////////////////////////////////////////////////////// |
327 | // left mouse button push |
353 | // left mouse button push |
328 | else if |
354 | else if (message == WM_LBUTTONDOWN) |
329 | { |
355 | { |
- | 356 | // are we in animation OR are mouse commands NOT allowed ? |
|
- | 357 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
|
- | 358 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
|
- | 359 | ||
330 | // is the ctrl key pressed (emulates a right click) ? |
360 | // is the ctrl key pressed (emulates a right click) ? |
331 | if (ctrl_pressed) |
361 | if (ctrl_pressed) |
332 | { |
362 | { |
333 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
363 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
334 | prevgui_y = GET_Y_LPARAM (lParam); |
364 | prevgui_y = GET_Y_LPARAM (lParam); |
Line 343... | Line 373... | ||
343 | // call the default window message processing function to keep things going |
373 | // call the default window message processing function to keep things going |
344 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
374 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
345 | } |
375 | } |
346 | 376 | ||
347 | //////////////////////////////////////////////////////////////////////////////////////////////// |
377 | //////////////////////////////////////////////////////////////////////////////////////////////// |
348 | // left mouse button release |
378 | // left mouse button release |
349 | else if |
379 | else if (message == WM_LBUTTONUP) |
350 | { |
380 | { |
- | 381 | // are we in animation OR are mouse commands NOT allowed ? |
|
- | 382 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
|
- | 383 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
|
- | 384 | ||
351 | // is the ctrl key pressed (emulates a right click) ? |
385 | // is the ctrl key pressed (emulates a right click) ? |
352 | if (ctrl_pressed) |
386 | if (ctrl_pressed) |
353 | { |
387 | { |
354 | rbutton_pushed = false; // remember button is released |
388 | rbutton_pushed = false; // remember button is released |
355 | the_scene.update = true; // update the 3D scene |
389 | the_scene.update = true; // update the 3D scene |
Line 620... | Line 654... | ||
620 | // call the default window message processing function to keep things going |
654 | // call the default window message processing function to keep things going |
621 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
655 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
622 | } |
656 | } |
623 | 657 | ||
624 | //////////////////////////////////////////////////////////////////////////////////////////////// |
658 | //////////////////////////////////////////////////////////////////////////////////////////////// |
625 | // right mouse button push |
659 | // right mouse button push |
626 | else if |
660 | else if (message == WM_RBUTTONDOWN) |
627 | { |
661 | { |
- | 662 | // are we in animation OR are mouse commands NOT allowed ? |
|
- | 663 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
|
- | 664 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
|
- | 665 | ||
628 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
666 | prevgui_x = GET_X_LPARAM (lParam); // remember mouse coordinates |
629 | prevgui_y = GET_Y_LPARAM (lParam); |
667 | prevgui_y = GET_Y_LPARAM (lParam); |
630 | 668 | ||
631 | // if we click something, stop moving the table immediately |
669 | // if we click something, stop moving the table immediately |
632 | the_board.players[current_viewer].view_pitch = current_pitch; |
670 | the_board.players[current_viewer].view_pitch = current_pitch; |
Line 637... | Line 675... | ||
637 | // call the default window message processing function to keep things going |
675 | // call the default window message processing function to keep things going |
638 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
676 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
639 | } |
677 | } |
640 | 678 | ||
641 | //////////////////////////////////////////////////////////////////////////////////////////////// |
679 | //////////////////////////////////////////////////////////////////////////////////////////////// |
642 | // right mouse button release |
680 | // right mouse button release |
643 | else if |
681 | else if (message == WM_RBUTTONUP) |
644 | { |
682 | { |
- | 683 | // are we in animation OR are mouse commands NOT allowed ? |
|
- | 684 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
|
- | 685 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
|
- | 686 | ||
645 | rbutton_pushed = false; // remember button is released |
687 | rbutton_pushed = false; // remember button is released |
646 | the_scene.update = true; // update the 3D scene |
688 | the_scene.update = true; // update the 3D scene |
647 | 689 | ||
648 | // call the default window message processing function to keep things going |
690 | // call the default window message processing function to keep things going |
649 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
691 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
650 | } |
692 | } |
651 | 693 | ||
652 | ///////////////////////////////// |
694 | //////////////////////////////////////////////////////////////////////////////////////////////// |
653 | // left mouse button DOUBLE-click |
695 | // left mouse button DOUBLE-click |
654 | else if |
696 | else if (message == WM_LBUTTONDBLCLK) |
655 | { |
697 | { |
- | 698 | // are we in animation OR are mouse commands NOT allowed ? |
|
- | 699 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
|
- | 700 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
|
- | 701 | ||
656 | // get mouse coordinates |
702 | // get mouse coordinates |
657 | gui_x = GET_X_LPARAM (lParam); |
703 | gui_x = GET_X_LPARAM (lParam); |
658 | gui_y = GET_Y_LPARAM (lParam); |
704 | gui_y = GET_Y_LPARAM (lParam); |
659 | 705 | ||
660 | // are we in game and did we click the move comments area ? |
706 | // are we in game and did we click the move comments area ? |
661 | if ((the_board.game_state >= STATE_PLAYING) && (the_board.viewed_move > 0) && Render_IsMouseInBox (gui_x, gui_y, 10.0f, 0.0f, 80.0f, 10.0f)) |
707 | if ((the_board.game_state >= STATE_PLAYING) && (the_board.viewed_move > 0) && Render_IsMouseInBox (gui_x, gui_y, 10.0f, 0.0f, 80.0f, 10.0f)) |
662 | { |
708 | { |
663 | DialogBox_Comment (); // fire up the comment dialog box |
709 | DialogBox_Comment (); // fire up the comment dialog box |
664 | return (DefWindowProc (hWnd, message, wParam, lParam)); // call the default window message processing function to keep things going |
710 | return (DefWindowProc (hWnd, message, wParam, lParam)); // call the default window message processing function to keep things going |
665 | } |
711 | } |
- | 712 | ||
- | 713 | // call the default window message processing function to keep things going |
|
- | 714 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
|
666 | } |
715 | } |
667 | 716 | ||
668 | //////////////////////////////////////////////////////////////////////////////////////////////// |
717 | //////////////////////////////////////////////////////////////////////////////////////////////// |
669 | // mouse move (while not in animation) |
718 | // mouse move (while not in animation) |
670 | else if |
719 | else if (message == WM_MOUSEMOVE) |
671 | { |
720 | { |
- | 721 | // are we in animation OR are mouse commands NOT allowed ? |
|
- | 722 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
|
- | 723 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
|
- | 724 | ||
672 | // get mouse coordinates |
725 | // get mouse coordinates |
673 | gui_x = GET_X_LPARAM (lParam); |
726 | gui_x = GET_X_LPARAM (lParam); |
674 | gui_y = GET_Y_LPARAM (lParam); |
727 | gui_y = GET_Y_LPARAM (lParam); |
675 | 728 | ||
676 | // handle button update status |
729 | // handle button update status |
Line 791... | Line 844... | ||
791 | // call the default window message processing function to keep things going |
844 | // call the default window message processing function to keep things going |
792 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
845 | return (DefWindowProc (hWnd, message, wParam, lParam)); |
793 | } |
846 | } |
794 | 847 | ||
795 | //////////////////////////////////////////////////////////////////////////////////////////////// |
848 | //////////////////////////////////////////////////////////////////////////////////////////////// |
796 | // mouse scroll |
849 | // mouse scroll |
797 | else if |
850 | else if (message == WM_MOUSEWHEEL) |
798 | { |
851 | { |
- | 852 | // are we in animation OR are mouse commands NOT allowed ? |
|
- | 853 | if ((animation_endtime + 1.0f >= current_time) || (command_ignoretime >= current_time)) |
|
- | 854 | return (DefWindowProc (hWnd, message, wParam, lParam)); // if so, call the default message proc to keep things going |
|
- | 855 | ||
799 | // see if we're online |
856 | // see if we're online |
800 | remote_player = Player_FindByType (PLAYER_INTERNET); |
857 | remote_player = Player_FindByType (PLAYER_INTERNET); |
801 | 858 | ||
802 | // are we online AND do we NOT have the right to select anything ? |
859 | // are we online AND do we NOT have the right to select anything ? |
803 | if ((remote_player != NULL) && !remote_player->is_in_game) |
860 | if ((remote_player != NULL) && !remote_player->is_in_game) |