Changeset 195
- Timestamp:
- 05/01/2009 09:03:29 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
-
MainFrame.cpp (modified) (9 diffs)
-
MainFrame.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MainFrame.cpp
r194 r195 658 658 wxString out; 659 659 short int temp; 660 if (m_rolls < 3){661 YahtzeeBonus();662 switch(event.GetId()) { 663 case ID_ACES:664 temp = m_score_dice.Aces(); 665 break;666 case ID_TWOS:667 temp = m_score_dice.Twos();668 break;669 case ID_THREES:670 temp = m_score_dice.Threes();671 break;672 case ID_FOURS:673 temp = m_score_dice.Fours();674 break;675 case ID_FIVES:676 temp = m_score_dice.Fives();677 break;678 case ID_SIXES:679 temp = m_score_dice.Sixes();680 break;681 }682 683 out.Printf(wxT("%i"),temp);684 wxTextCtrl *text_ctrl = dynamic_cast<wxTextCtrl*>(FindWindow(event.GetId() - ID_ACES + ID_ACESTEXT));685 text_ctrl->SetValue(out);686 text_ctrl->SetBackgroundColour(*wxWHITE);687 text_ctrl->Refresh();688 689 PostScore(event.GetId());690 }691 else692 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this);660 if (!IsValidClick()) 661 return; 662 663 YahtzeeBonus(); 664 665 switch(event.GetId()) { 666 case ID_ACES: 667 temp = m_score_dice.Aces(); 668 break; 669 case ID_TWOS: 670 temp = m_score_dice.Twos(); 671 break; 672 case ID_THREES: 673 temp = m_score_dice.Threes(); 674 break; 675 case ID_FOURS: 676 temp = m_score_dice.Fours(); 677 break; 678 case ID_FIVES: 679 temp = m_score_dice.Fives(); 680 break; 681 case ID_SIXES: 682 temp = m_score_dice.Sixes(); 683 break; 684 } 685 686 out.Printf(wxT("%i"),temp); 687 wxTextCtrl *text_ctrl = dynamic_cast<wxTextCtrl*>(FindWindow(event.GetId() - ID_ACES + ID_ACESTEXT)); 688 text_ctrl->SetValue(out); 689 text_ctrl->SetBackgroundColour(*wxWHITE); 690 text_ctrl->Refresh(); 691 692 PostScore(event.GetId()); 693 693 } 694 694 … … 699 699 void MainFrame::On3ofakindButton(wxCommandEvent& event) 700 700 { 701 if(m_rolls>=3) { 702 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 703 return; 704 } 701 if (!IsValidClick()) 702 return; 703 705 704 YahtzeeBonus(); 706 705 wxString out; … … 721 720 void MainFrame::On4ofakindButton(wxCommandEvent& event) 722 721 { 723 if(m_rolls>=3) { 724 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 725 return; 726 } 722 if (!IsValidClick()) 723 return; 724 727 725 YahtzeeBonus(); 728 726 wxString out; … … 745 743 wxString out; 746 744 747 if(m_rolls>=3) { 748 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 749 return; 750 } 745 if (!IsValidClick()) 746 return; 747 751 748 YahtzeeBonus(); 752 749 … … 768 765 wxString out; 769 766 770 if(m_rolls>=3) { 771 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 772 return; 773 } 767 if (!IsValidClick()) 768 return; 774 769 775 770 YahtzeeBonus(); … … 792 787 wxString out; 793 788 794 if(m_rolls>=3) { 795 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 796 return; 797 } 789 if (!IsValidClick()) 790 return; 798 791 799 792 YahtzeeBonus(); … … 817 810 wxString out; 818 811 819 if(m_rolls>=3) { 820 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 821 return; 822 } 812 if (!IsValidClick()) 813 return; 823 814 824 815 if (m_score_dice.IsYahtzee()) m_yahtzee = true; … … 839 830 { 840 831 wxString out; 841 if(m_rolls < 3){ 842 YahtzeeBonus(); 843 844 out.Printf(wxT("%i"),m_score_dice.Chance()); 845 wxTextCtrl *text_ctrl = dynamic_cast<wxTextCtrl*>(FindWindow(ID_CHANCETEXT)); 846 text_ctrl->SetValue(out); 847 text_ctrl->SetBackgroundColour(*wxWHITE); 848 text_ctrl->Refresh(); 849 PostScore(event.GetId()); 850 } 851 else 852 wxMessageBox(wxT("First you need to roll, and after you roll you may score"), wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 853 832 if (!IsValidClick()) 833 return; 834 835 YahtzeeBonus(); 836 837 out.Printf(wxT("%i"),m_score_dice.Chance()); 838 wxTextCtrl *text_ctrl = dynamic_cast<wxTextCtrl*>(FindWindow(ID_CHANCETEXT)); 839 text_ctrl->SetValue(out); 840 text_ctrl->SetBackgroundColour(*wxWHITE); 841 text_ctrl->Refresh(); 842 PostScore(event.GetId()); 854 843 } 855 844 … … 1344 1333 } 1345 1334 1335 bool MainFrame::IsValidClick() 1336 { 1337 if (m_rolls >= 3) { 1338 wxMessageBox(wxT("First you need to roll, and after you roll you may score."), 1339 wxT("Open Yahtzee"), wxOK | wxICON_INFORMATION, this); 1340 return false; 1341 } 1342 return true; 1343 } 1344 1346 1345 MainFrame::~MainFrame() { 1347 1346 // free pointers -
trunk/src/MainFrame.h
r194 r195 98 98 void ConnectEventTable(); 99 99 void AddControlsAndLayout(); 100 /** 101 * Check if a click on a score button is valid or should 102 * be ignored. 103 * \returns true if the click is valid and should be scored. 104 */ 105 bool IsValidClick(); 100 106 101 107 void OnRollButton ();
Note: See TracChangeset
for help on using the changeset viewer.
