source: trunk/src/MainFrame.h @ 182

Last change on this file since 182 was 180, checked in by guyru, 5 years ago

code cleanup: removed ObjectsID.h

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