Changeset 194 for trunk/src/MainFrame.cpp
- Timestamp:
- 05/01/2009 08:05:17 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/MainFrame.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MainFrame.cpp
r193 r194 70 70 71 71 using namespace main_frame; 72 const wxEventType wxEVT_ENABLE_ROLL = wxNewEventType();73 72 74 73 MainFrame::MainFrame(const wxString& title, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE) … … 129 128 m_yahtzeebonus = false; 130 129 m_numofplaysleft = 13; 131 m_skiproll = false; // the roll button hasn't been pressed yet, no need for skipping132 130 } 133 131 … … 352 350 //END connecting the menu items' events 353 351 354 Connect(ID_ROLL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (MainFrame::OnRollButton)); 355 Connect(ID_ROLL, wxEVT_ENABLE_ROLL, wxCommandEventHandler (MainFrame::OnRollButton)); 352 Connect(ID_ROLL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (MainFrame::DoubleRollLock)); 356 353 357 354 //BEGIN connecting the scoreboard buttons to the events … … 557 554 * \param event 558 555 */ 559 void MainFrame::OnRollButton ( wxCommandEvent& event)556 void MainFrame::OnRollButton () 560 557 { 561 558 short int dice[5]; //holds the dices score 562 559 563 if (event.GetEventType() == wxEVT_IDLE) {564 m_skiproll = false;565 Disconnect(wxEVT_IDLE, wxCommandEventHandler(MainFrame::OnRollButton));566 return;567 }568 569 //skip rolling the dice if the user accidently rolled the dice before they finished spinning.570 if (m_skiproll) return;571 m_skiproll = true;572 573 560 if (m_numofplaysleft == 13) 574 561 m_stats->game_started(); … … 633 620 (GetMenuBar()->FindItem(wxID_UNDO))->Enable(false); 634 621 m_yahtzeebonus = false; //if we scored yahtzee bonus before we don't care anymore. 635 636 Connect(wxEVT_IDLE, wxCommandEventHandler(MainFrame::OnRollButton)); 622 } 623 624 void MainFrame::DoubleRollLock(wxCommandEvent& event) 625 { 626 /* The function works by connecting to idle event, and raising a 627 * flag when it process a valid click on the Roll button. When the 628 * another click happens and the flag is up, it means it is 629 * accidental. When the idle events is triggered it means that we 630 * no longer roll the dice, so we lower the flag. 631 */ 632 static bool skip_roll = false; 633 if (event.GetEventType() == wxEVT_IDLE) { 634 skip_roll = false; 635 Disconnect(wxEVT_IDLE, wxCommandEventHandler(MainFrame::DoubleRollLock)); 636 return; 637 } 638 639 if (skip_roll) 640 return; 641 skip_roll = true; 642 643 Connect(wxEVT_IDLE, wxCommandEventHandler(MainFrame::DoubleRollLock)); 644 OnRollButton(); 637 645 } 638 646
Note: See TracChangeset
for help on using the changeset viewer.
