Debian Codegraph @

src/MainFrame.h

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2006-2016 by Guy Rutenberg *
3 * [email protected] *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 /**\file MainFrame.h
21 *\brief Header file for MainFrame class.
22 *
23 * This File contains the declaration of the class MainFrame
24 */
25
26
27 #ifndef OPENYAHTZEE_MAIN_FRAME_INC
28 #define OPENYAHTZEE_MAIN_FRAME_INC
29 #include "ScoreDice.h"
30 #include "configuration.h"
31 #include <memory>
32 #include <boost/scoped_ptr.hpp>
33 #include <wx/wx.h>
34
35 namespace main_frame {
36
37 /// MainFrame class - the main window
38 /**
39 The Main Frame class is a derieved class from wxFrame which is responsible to
40 the main window of the application. This class also hold all the functions
41 that process the dice and handles the gameplay. This function are called as
42 event handlers.
43 */
44 class MainFrame : public wxFrame
45 {
46 public:
47 // Constructor
48 MainFrame(const wxString& title, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE ^ wxRESIZE_BORDER );
49 ~MainFrame();
50
51 // Event handlers
52 void OnQuit(wxCommandEvent& event);
53 void OnAbout(wxCommandEvent& event);
54 void OnNewGame (wxCommandEvent& event);
55 void OnUndo (wxCommandEvent& event);
56 void OnShowHighscore (wxCommandEvent& event);
57 void OnSettings (wxCommandEvent& event);
58 void OnSendComment (wxCommandEvent& event);
59 void OnHelpMenuLink (wxCommandEvent& event);
60
61 /**
62 * Prevent accidental roll of the dice by double clicking the button.
63 * \param event The event that was send to the ::OnRollButton()
64 */
65 void DoubleRollLock(wxCommandEvent& event);
66
67 void OnUpperButtons (wxCommandEvent& event);
68 void On3ofakindButton (wxCommandEvent& event);
69 void On4ofakindButton (wxCommandEvent& event);
70 void OnFullHouseButton (wxCommandEvent& event);
71 void OnSmallSequenceButton (wxCommandEvent& event);
72 void OnLargeSequenceButton (wxCommandEvent& event);
73 void OnYahtzeeButton (wxCommandEvent& event);
74 void OnChanceButton (wxCommandEvent& event);
75 void OnDiceClick (wxCommandEvent& event);
76 void OnKeepClick (wxCommandEvent& event);
77
78 void OnScoreMouseEnter (wxMouseEvent& event);
79 void OnScoreMouseLeave (wxMouseEvent& event);
80
81 bool IsValidDice();
82
83 ScoreDice m_score_dice;
84
85 boost::scoped_ptr<configuration::Configuration> m_config;
86
87 private:
88 void ClearDiceHash();
89 void ResetRolls();
90 void YahtzeeBonus();
91 bool YahtzeeJoker();
92 void EndofGame();
93 void HighScoreHandler(int score);
94 inline void EnableUndo(int id);
95 void PostScore(int id);
96 void CalculateSubTotal();
97 void Relayout();
98 void AddMenus();
99 void ConnectEventTable();
100 void AddControlsAndLayout();
101
102 /**
103 * Adjust the frame size to the specified sizer and set proper
104 * size hints to avoid resizing.
105 */
106 void AdjustFrameSize(wxSizer* sizer);
107
108 /**
109 * Check if a click on a score button is valid or should
110 * be ignored.
111 * \returns true if the click is valid and should be scored.
112 */
113 bool IsValidClick();
114
115 void OnRollButton ();
116
117 wxStaticBoxSizer *uppersection, *lowersection;
118 wxBoxSizer *sectionsSizer;
119 wxBoxSizer *diceSizer;
120
121 //pointers to hold bitmap data for the dices
122 wxBitmap *bitmap_dice[6];
123
124 short int m_rolls; //holds how many rolls left
125 short int m_numofplaysleft; //holds how many times the user got to score untill the end of the game
126 bool m_yahtzee;
127 bool m_yahtzeebonus; //tells the undo if there is also an yahtzee bonus to undo
128
129 short int m_lastmove; //stores the ID of the last button pressed.
130 short int m_rollsundo; //holds the number of remaining rolls for use with the undo option
131
132 class MainFrameEvtHandler *m_evt_handler;
133 };
134
135 /**
136 * This class handles events for windows in MainFrame where it hasn't been
137 * possible to use the regular event handler.
138 */
139 class MainFrameEvtHandler : public wxEvtHandler
140 {
141 public:
142 MainFrameEvtHandler(MainFrame *main_frame) { m_main_frame = main_frame;}
143 void OnScoreMouseEnter (wxMouseEvent& event);
144 void OnScoreMouseLeave (wxMouseEvent& event);
145 private:
146 MainFrame *m_main_frame;
147
148 };
149
150 enum {
151 ID_PANEL,
152 ID_SHOWHIGHSCORE,
153 ID_SETTINGS,
154 ID_THEMES,
155 ID_HOWTOPLAY,
156 ID_FAQ,
157 ID_SENDCOMMENT,
158
159 ID_ACES,
160 ID_TWOS,
161 ID_THREES,
162 ID_FOURS,
163 ID_FIVES,
164 ID_SIXES,
165 ID_THREEOFAKIND,
166 ID_FOUROFAKIND,
167 ID_FULLHOUSE,
168 ID_SMALLSEQUENCE,
169 ID_LARGESEQUENCE,
170 ID_YAHTZEE,
171 ID_CHANCE,
172
173 ID_ACESTEXT,
174 ID_TWOSTEXT,
175 ID_THREESTEXT,
176 ID_FOURSTEXT,
177 ID_FIVESTEXT,
178 ID_SIXESTEXT,
179 ID_THREEOFAKINDTEXT,
180 ID_FOUROFAKINDTEXT,
181 ID_FULLHOUSETEXT,
182 ID_SMALLSEQUENCETEXT,
183 ID_LARGESEQUENCETEXT,
184 ID_YAHTZEETEXT,
185 ID_CHANCETEXT,
186 ID_YAHTZEEBONUSTEXT,
187
188 ID_UPPERSECTIONTOTAL,
189 ID_BONUS,
190 ID_UPPERTOTAL,
191 ID_LOWERTOTAL,
192 ID_GRANDTOTAL,
193
194 ID_ROLL,
195 ID_DICE1,
196 ID_DICE2,
197 ID_DICE3,
198 ID_DICE4,
199 ID_DICE5,
200
201 ID_DICE1KEEP,
202 ID_DICE2KEEP,
203 ID_DICE3KEEP,
204 ID_DICE4KEEP,
205 ID_DICE5KEEP,
206 };
207
208 }
209 #endif