Changeset 21


Ignore:
Timestamp:
17/12/06 17:09:23 (8 years ago)
Author:
guyru
Message:

added functionality to undo button

Location:
trunk/OpenYahtzee
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/OpenYahtzee/openyahtzee.kdevelop

    r20 r21  
    1414    <projectdirectory>.</projectdirectory> 
    1515    <absoluteprojectpath>false</absoluteprojectpath> 
    16     <description></description> 
     16    <description/> 
    1717  </general> 
    1818  <kdevautoproject> 
     
    186186    </codecompletion> 
    187187    <creategettersetter> 
    188       <prefixGet></prefixGet> 
     188      <prefixGet/> 
    189189      <prefixSet>set</prefixSet> 
    190190      <prefixVariable>m_,_</prefixVariable> 
     
    202202  <kdevdebugger> 
    203203    <general> 
    204       <programargs></programargs> 
    205       <gdbpath></gdbpath> 
    206       <dbgshell></dbgshell> 
    207       <configGdbScript></configGdbScript> 
    208       <runShellScript></runShellScript> 
    209       <runGdbScript></runGdbScript> 
     204      <programargs/> 
     205      <gdbpath/> 
     206      <dbgshell/> 
     207      <configGdbScript/> 
     208      <runShellScript/> 
     209      <runGdbScript/> 
    210210      <breakonloadinglibs>true</breakonloadinglibs> 
    211211      <separatetty>false</separatetty> 
  • trunk/OpenYahtzee/openyahtzee.kdevses

    r20 r21  
    22<!DOCTYPE KDevPrjSession> 
    33<KDevPrjSession> 
    4  <DocsAndViews NumberOfDocuments="7" > 
     4 <DocsAndViews NumberOfDocuments="6" > 
    55  <Doc0 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/SettingsDB.h" > 
    6    <View0 line="23" Type="Source" /> 
     6   <View0 Type="Source" /> 
    77  </Doc0> 
    88  <Doc1 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/openyahtzee.cpp" > 
    9    <View0 line="0" Type="Source" /> 
     9   <View0 Type="Source" /> 
    1010  </Doc1> 
    1111  <Doc2 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/MainFrame.cpp" > 
    12    <View0 line="86" Type="Source" /> 
     12   <View0 line="186" Type="Source" /> 
    1313  </Doc2> 
    1414  <Doc3 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/ObjectsID.h" > 
    15    <View0 line="44" Type="Source" /> 
     15   <View0 Type="Source" /> 
    1616  </Doc3> 
    1717  <Doc4 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/MainFrame.h" > 
    18    <View0 line="80" Type="Source" /> 
     18   <View0 Type="Source" /> 
    1919  </Doc4> 
    2020  <Doc5 NumberOfViews="1" URL="file:///home/guy/workspace/OpenYahtzee/src/DBwrapper.h" > 
    2121   <View0 line="26" Type="Source" /> 
    2222  </Doc5> 
    23   <Doc6 NumberOfViews="1" URL="file:///usr/include/wx-2.6/wx/gtk/bitmap.h" > 
    24    <View0 line="74" Type="Source" /> 
    25   </Doc6> 
    2623 </DocsAndViews> 
    2724 <pluginList> 
    2825  <kdevdebugger> 
    29    <breakpointList> 
    30     <breakpoint0 location="/home/guy/workspace/OpenYahtzee/src/MainFrame.cpp:228" type="1" tracingFormatString="" traceFormatStringEnabled="0" condition="" tracingEnabled="0" enabled="1" > 
    31      <tracedExpressions/> 
    32     </breakpoint0> 
    33     <breakpoint1 location="/home/guy/workspace/OpenYahtzee/src/MainFrame.cpp:215" type="1" tracingFormatString="" traceFormatStringEnabled="0" condition="" tracingEnabled="0" enabled="1" > 
    34      <tracedExpressions/> 
    35     </breakpoint1> 
    36    </breakpointList> 
     26   <breakpointList/> 
    3727  </kdevdebugger> 
    3828  <kdevbookmarks> 
  • trunk/OpenYahtzee/src/MainFrame.cpp

    r20 r21  
    8181        gameMenu->Append(ID_NEWGAME,wxT("&New Game\tF2"),wxT("Start a new game")); 
    8282        //create the undo button and make it disabled 
    83         (gameMenu->Append(ID_UNDO,wxT("&Undo"),wxT("Undo the last move")))->Enable(false); 
     83        gameMenu->Append(ID_UNDO,wxT("&Undo"),wxT("Undo the last move")); 
    8484        gameMenu->Append(ID_SHOWHIGHSCORE,wxT("High &Scores"),wxT("Show high-scores table")); 
    8585        gameMenu->Append(ID_SETTINGS,wxT("Settings"),wxT("Show settings dialog")); 
     
    183183                textctrl->SetEditable(false); 
    184184        } 
     185         
     186        //disable the undo button 
     187        (GetMenuBar()->FindItem(ID_UNDO))->Enable(false); 
     188 
    185189 
    186190         
     
    254258void MainFrame::OnUndo(wxCommandEvent& event) 
    255259{ 
    256         std::cout<<"in undo"<<std::endl; 
    257260        m_rolls = m_rollsundo; 
    258261 
    259         //enable the roll button if neccessary 
    260         if (m_rolls > 0) //we still have remaining rolls  
    261                 ((wxButton*) FindWindow(ID_ROLL)) -> Enable(true); 
    262  
     262        //after the user scored the button was enabled, check if it should be disabled 
     263        if (m_rolls <= 0) //we don't have remaining rolls  
     264                ((wxButton*) FindWindow(ID_ROLL)) -> Enable(false); 
     265 
     266        //restore the 'keep' checkboxes 
     267        for (int i=0; i<5; i++) 
     268                ((wxCheckBox*) FindWindow(i + ID_DICE1KEEP)) -> Enable(true); 
     269         
    263270        //reset the users last choice 
    264271        FindWindow(m_lastmove)->Enable(true); 
     272 
    265273        //clear the score; 
    266274        ((wxTextCtrl*)FindWindow(ID_ACESTEXT + (m_lastmove - ID_ACES)))->SetValue(wxT("")); 
    267         FindWindow(ID_UNDO)->Enable(false); 
    268         m_numofplaysleft--; 
     275 
     276        (GetMenuBar()->FindItem(ID_UNDO))->Enable(false); 
     277        //cancel the counting for the choice that was canceled 
     278        m_numofplaysleft++; 
    269279} 
    270280///This function enables the undo button and stores the last move 
    271281inline void MainFrame::EnableUndo(int id) 
    272282{ 
    273                 FindWindow(ID_UNDO)->Enable(true); 
     283                (GetMenuBar()->FindItem(ID_UNDO))->Enable(true); 
    274284                m_lastmove = id; 
    275285} 
     
    328338        for (int i=0; i<5; i++) 
    329339                ((wxCheckBox*) FindWindow(i + ID_DICE1KEEP)) -> Enable(true); 
     340         
     341        //we rolled the dices so undoing isn't allowed 
     342        (GetMenuBar()->FindItem(ID_UNDO))->Enable(false); 
    330343 
    331344} 
     
    347360                FindWindow(event.GetId())->Enable(false); 
    348361                m_numofplaysleft--; 
     362                EnableUndo(event.GetId()); 
    349363                EndofGame(); 
    350364        } 
     
    382396        FindWindow(event.GetId())->Enable(false); 
    383397        m_numofplaysleft--; 
     398        EnableUndo(event.GetId()); 
    384399        EndofGame(); 
    385400} 
     
    414429        FindWindow(event.GetId())->Enable(false); 
    415430        m_numofplaysleft--; 
     431        EnableUndo(event.GetId()); 
    416432        EndofGame(); 
    417433} 
     
    444460        FindWindow(event.GetId())->Enable(false); 
    445461        m_numofplaysleft--; 
     462        EnableUndo(event.GetId()); 
    446463        EndofGame(); 
    447464} 
     
    471488        FindWindow(event.GetId())->Enable(false); 
    472489        m_numofplaysleft--; 
     490        EnableUndo(event.GetId()); 
    473491        EndofGame(); 
    474492} 
     
    497515        FindWindow(event.GetId())->Enable(false); 
    498516        m_numofplaysleft--; 
     517        EnableUndo(event.GetId()); 
    499518        EndofGame(); 
    500519} 
     
    516535        m_numofplaysleft--; 
    517536        ResetRolls(); 
     537        EnableUndo(event.GetId()); 
    518538        EndofGame(); 
    519539} 
     
    536556                FindWindow(event.GetId())->Enable(false); 
    537557                m_numofplaysleft--; 
     558                EnableUndo(event.GetId()); 
    538559                EndofGame(); 
    539560        } 
Note: See TracChangeset for help on using the changeset viewer.