Mercurial > mm7
comparison IO/Mouse.cpp @ 2544:c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
author | a.parshin |
---|---|
date | Mon, 11 May 2015 09:51:04 +0200 |
parents | a902abdfc7f2 |
children | 87e5590d034b |
comparison
equal
deleted
inserted
replaced
2543:b6140dfeac27 | 2544:c674d547cc7c |
---|---|
471 || (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y) | 471 || (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y) |
472 { | 472 { |
473 y = pY; | 473 y = pY; |
474 for ( int i = uNumVisibleWindows; i >= 0; --i ) | 474 for ( int i = uNumVisibleWindows; i >= 0; --i ) |
475 { | 475 { |
476 if ( x >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameX && x <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameZ | 476 if ( x >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameX && x <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameZ |
477 && y >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameY && y <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameW ) | 477 && y >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameY && y <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1]->uFrameW ) |
478 { | 478 { |
479 for ( control = pWindowList[pVisibleWindowsIdxs[i] - 1].pControlsHead; control; control = control->pNext ) | 479 for ( control = pWindowList[pVisibleWindowsIdxs[i] - 1]->pControlsHead; control; control = control->pNext ) |
480 { | 480 { |
481 if ( control->uButtonType == 1 ) | 481 if ( control->uButtonType == 1 ) |
482 { | 482 { |
483 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) | 483 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) |
484 { | 484 { |
602 //v2 = pMessageQueue_50CBD0->uNumMessages; | 602 //v2 = pMessageQueue_50CBD0->uNumMessages; |
603 for (int i = uNumVisibleWindows; i >= 0; --i) | 603 for (int i = uNumVisibleWindows; i >= 0; --i) |
604 //while ( 1 ) | 604 //while ( 1 ) |
605 { | 605 { |
606 v3 = pVisibleWindowsIdxs[i] - 1; | 606 v3 = pVisibleWindowsIdxs[i] - 1; |
607 if (!pWindowList[v3].receives_keyboard_input) | 607 if (!pWindowList[v3]->receives_keyboard_input) |
608 continue; | 608 continue; |
609 | 609 |
610 switch (vkKey) | 610 switch (vkKey) |
611 { | 611 { |
612 case VK_LEFT: | 612 case VK_LEFT: |
613 { | 613 { |
614 v12 = pWindowList[v3].field_34; | 614 v12 = pWindowList[v3]->field_34; |
615 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) | 615 if ( pWindowList[v3]->pCurrentPosActiveItem - pWindowList[v3]->pStartingPosActiveItem - v12 >= 0 ) |
616 { | 616 { |
617 v8 = current_screen_type == SCREEN_PARTY_CREATION; | 617 v8 = current_screen_type == SCREEN_PARTY_CREATION; |
618 pWindowList[v3].pCurrentPosActiveItem -= v12; | 618 pWindowList[v3]->pCurrentPosActiveItem -= v12; |
619 if ( v8 ) | 619 if ( v8 ) |
620 { | 620 { |
621 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); | 621 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); |
622 //v2 = pMessageQueue_50CBD0->uNumMessages; | 622 //v2 = pMessageQueue_50CBD0->uNumMessages; |
623 } | 623 } |
624 } | 624 } |
625 if ( pWindowList[v3].field_30 != 0 ) | 625 if ( pWindowList[v3]->field_30 != 0 ) |
626 { | 626 { |
627 break; | 627 break; |
628 } | 628 } |
629 pButton = pWindowList[v3].pControlsHead; | 629 pButton = pWindowList[v3]->pControlsHead; |
630 v13 = pWindowList[v3].pCurrentPosActiveItem; | 630 v13 = pWindowList[v3]->pCurrentPosActiveItem; |
631 if ( v13 > 0) | 631 if ( v13 > 0) |
632 { | 632 { |
633 do | 633 do |
634 { | 634 { |
635 pButton = pButton->pNext; | 635 pButton = pButton->pNext; |
640 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); | 640 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); |
641 break; | 641 break; |
642 } | 642 } |
643 case VK_RIGHT: | 643 case VK_RIGHT: |
644 { | 644 { |
645 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; | 645 v7 = pWindowList[v3]->pCurrentPosActiveItem + pWindowList[v3]->field_34; |
646 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) | 646 if ( v7 < pWindowList[v3]->pNumPresenceButton + pWindowList[v3]->pStartingPosActiveItem ) |
647 { | 647 { |
648 v8 = current_screen_type == SCREEN_PARTY_CREATION; | 648 v8 = current_screen_type == SCREEN_PARTY_CREATION; |
649 pWindowList[v3].pCurrentPosActiveItem = v7; | 649 pWindowList[v3]->pCurrentPosActiveItem = v7; |
650 if ( v8 ) | 650 if ( v8 ) |
651 { | 651 { |
652 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); | 652 pAudioPlayer->PlaySound(SOUND_SelectingANewCharacter, 0, 0, -1, 0, 0, 0, 0); |
653 //v2 = pMessageQueue_50CBD0->uNumMessages; | 653 //v2 = pMessageQueue_50CBD0->uNumMessages; |
654 } | 654 } |
655 } | 655 } |
656 if ( pWindowList[v3].field_30 != 0 ) | 656 if ( pWindowList[v3]->field_30 != 0 ) |
657 { | 657 { |
658 break; | 658 break; |
659 } | 659 } |
660 pButton = pWindowList[v3].pControlsHead; | 660 pButton = pWindowList[v3]->pControlsHead; |
661 v10 = pWindowList[v3].pCurrentPosActiveItem; | 661 v10 = pWindowList[v3]->pCurrentPosActiveItem; |
662 if ( v10 > 0) | 662 if ( v10 > 0) |
663 { | 663 { |
664 do | 664 do |
665 { | 665 { |
666 pButton = pButton->pNext; | 666 pButton = pButton->pNext; |
671 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); | 671 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); |
672 break; | 672 break; |
673 } | 673 } |
674 case VK_DOWN: | 674 case VK_DOWN: |
675 { | 675 { |
676 v17 = pWindowList[v3].pStartingPosActiveItem; | 676 v17 = pWindowList[v3]->pStartingPosActiveItem; |
677 v18 = pWindowList[v3].pCurrentPosActiveItem; | 677 v18 = pWindowList[v3]->pCurrentPosActiveItem; |
678 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) | 678 if ( v18 >= pWindowList[v3]->pNumPresenceButton + v17 - 1 ) |
679 pWindowList[v3].pCurrentPosActiveItem = v17; | 679 pWindowList[v3]->pCurrentPosActiveItem = v17; |
680 else | 680 else |
681 pWindowList[v3].pCurrentPosActiveItem = v18 + 1; | 681 pWindowList[v3]->pCurrentPosActiveItem = v18 + 1; |
682 if ( pWindowList[v3].field_30 != 0 ) | 682 if ( pWindowList[v3]->field_30 != 0 ) |
683 return true; | 683 return true; |
684 pButton = pWindowList[v3].pControlsHead; | 684 pButton = pWindowList[v3]->pControlsHead; |
685 v20 = pWindowList[v3].pCurrentPosActiveItem; | 685 v20 = pWindowList[v3]->pCurrentPosActiveItem; |
686 if ( v20 > 0) | 686 if ( v20 > 0) |
687 { | 687 { |
688 do | 688 do |
689 { | 689 { |
690 pButton = pButton->pNext; | 690 pButton = pButton->pNext; |
696 return true; | 696 return true; |
697 } | 697 } |
698 case VK_SELECT: | 698 case VK_SELECT: |
699 { | 699 { |
700 pMouse->GetClickPos(&uClickX, &uClickY); | 700 pMouse->GetClickPos(&uClickX, &uClickY); |
701 v4 = pWindowList[v3].pStartingPosActiveItem; | 701 v4 = pWindowList[v3]->pStartingPosActiveItem; |
702 v28 = v4 + pWindowList[v3].pNumPresenceButton; | 702 v28 = v4 + pWindowList[v3]->pNumPresenceButton; |
703 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) | 703 if ( v4 < v4 + pWindowList[v3]->pNumPresenceButton ) |
704 { | 704 { |
705 while ( 1 ) | 705 while ( 1 ) |
706 { | 706 { |
707 pButton = pWindowList[v3].pControlsHead; | 707 pButton = pWindowList[v3]->pControlsHead; |
708 if ( v4 > 0 ) | 708 if ( v4 > 0 ) |
709 { | 709 { |
710 v6 = v4; | 710 v6 = v4; |
711 do | 711 do |
712 { | 712 { |
729 //if ( i < 0 ) | 729 //if ( i < 0 ) |
730 return false; | 730 return false; |
731 //continue; | 731 //continue; |
732 } | 732 } |
733 } | 733 } |
734 pWindowList[v3].pCurrentPosActiveItem = v4; | 734 pWindowList[v3]->pCurrentPosActiveItem = v4; |
735 return true; | 735 return true; |
736 } | 736 } |
737 //v2 = pMessageQueue_50CBD0->uNumMessages; | 737 //v2 = pMessageQueue_50CBD0->uNumMessages; |
738 break; | 738 break; |
739 } | 739 } |
740 case VK_UP: | 740 case VK_UP: |
741 { | 741 { |
742 v22 = pWindowList[v3].pCurrentPosActiveItem; | 742 v22 = pWindowList[v3]->pCurrentPosActiveItem; |
743 v23 = pWindowList[v3].pStartingPosActiveItem; | 743 v23 = pWindowList[v3]->pStartingPosActiveItem; |
744 if ( v22 <= v23 ) | 744 if ( v22 <= v23 ) |
745 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; | 745 v24 = pWindowList[v3]->pNumPresenceButton + v23 - 1; |
746 else | 746 else |
747 v24 = v22 - 1; | 747 v24 = v22 - 1; |
748 v8 = pWindowList[v3].field_30 == 0; | 748 v8 = pWindowList[v3]->field_30 == 0; |
749 pWindowList[v3].pCurrentPosActiveItem = v24; | 749 pWindowList[v3]->pCurrentPosActiveItem = v24; |
750 if ( !v8 ) | 750 if ( !v8 ) |
751 return true; | 751 return true; |
752 pButton = pWindowList[v3].pControlsHead; | 752 pButton = pWindowList[v3]->pControlsHead; |
753 v25 = pWindowList[v3].pCurrentPosActiveItem; | 753 v25 = pWindowList[v3]->pCurrentPosActiveItem; |
754 if ( v25 > 0) | 754 if ( v25 > 0) |
755 { | 755 { |
756 do | 756 do |
757 { | 757 { |
758 pButton = pButton->pNext; | 758 pButton = pButton->pNext; |
763 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); | 763 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); |
764 return true; | 764 return true; |
765 } | 765 } |
766 case VK_NEXT: | 766 case VK_NEXT: |
767 { | 767 { |
768 if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw | 768 if ( pWindowList[v3]->field_30 != 0 ) //crashed at skill draw |
769 { | 769 { |
770 pMouse->GetClickPos(&uClickX, &uClickY); | 770 pMouse->GetClickPos(&uClickX, &uClickY); |
771 v29 = pWindowList[v3].pStartingPosActiveItem + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons | 771 v29 = pWindowList[v3]->pStartingPosActiveItem + pWindowList[v3]->pNumPresenceButton; //num buttons more than buttons |
772 for ( v4 = pWindowList[v3].pStartingPosActiveItem; v4 < v29; ++v4 ) | 772 for ( v4 = pWindowList[v3]->pStartingPosActiveItem; v4 < v29; ++v4 ) |
773 { | 773 { |
774 pButton = pWindowList[v3].pControlsHead; | 774 pButton = pWindowList[v3]->pControlsHead; |
775 if ( v4 > 0 ) | 775 if ( v4 > 0 ) |
776 { | 776 { |
777 for ( v15 = v4; v15; --v15 ) | 777 for ( v15 = v4; v15; --v15 ) |
778 pButton = pButton->pNext; | 778 pButton = pButton->pNext; |
779 } | 779 } |
780 if ( (signed int)uClickX >= (signed int)pButton->uX && (signed int)uClickX <= (signed int)pButton->uZ | 780 if ( (signed int)uClickX >= (signed int)pButton->uX && (signed int)uClickX <= (signed int)pButton->uZ |
781 && (signed int)uClickY >= (signed int)pButton->uY && (signed int)uClickY <= (signed int)pButton->uW ) | 781 && (signed int)uClickY >= (signed int)pButton->uY && (signed int)uClickY <= (signed int)pButton->uW ) |
782 { | 782 { |
783 pWindowList[v3].pCurrentPosActiveItem = v4; | 783 pWindowList[v3]->pCurrentPosActiveItem = v4; |
784 return true; | 784 return true; |
785 } | 785 } |
786 } | 786 } |
787 } | 787 } |
788 break; | 788 break; |