source: trunk/OpenYahtzee/src/MainFrame.h @ 123

Last change on this file since 123 was 123, checked in by guyru, 7 years ago

more work on scoring hints

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1// $Header$
2/***************************************************************************
3 *   Copyright (C) 2006 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#include "SettingsDB.h"
28#include "HighScoreTableDB.h"
29#include "ScoreDice.h"
30#ifndef MAINFRAME_INC
31#define MAINFRAME_INC
32
33DECLARE_EVENT_TYPE(wxEVT_ENABLE_ROLL, -1) /*just to satisfy kdevelop*/;
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
48        // Event handlers
49        void OnQuit(wxCommandEvent& event);
50        void OnAbout(wxCommandEvent& event);
51        void OnNewGame (wxCommandEvent& event);
52        void OnUndo (wxCommandEvent& event);
53        void OnShowHighscore (wxCommandEvent& event);
54        void OnSettings (wxCommandEvent& event);
55        void OnCheckForUpdates (wxCommandEvent& event);
56        void OnSendComment (wxCommandEvent& event);
57
58        void OnRollButton (wxCommandEvent& event);
59        void OnUpperButtons (wxCommandEvent& event);
60        void On3ofakindButton (wxCommandEvent& event);
61        void On4ofakindButton (wxCommandEvent& event); 
62        void OnFullHouseButton (wxCommandEvent& event);
63        void OnSmallSequenceButton (wxCommandEvent& event);
64        void OnLargeSequenceButton (wxCommandEvent& event);
65        void OnYahtzeeButton (wxCommandEvent& event);
66        void OnChanceButton (wxCommandEvent& event);
67        void OnDiceClick (wxCommandEvent& event);
68        void OnKeepClick (wxCommandEvent& event);       
69
70        void OnScoreMouseEnter (wxMouseEvent& event);
71        void OnScoreMouseLeave (wxMouseEvent& event);
72       
73
74        ScoreDice m_score_dice;
75
76private:
77        void ClearDiceHash();
78        void ResetRolls();
79        void YahtzeeBonus();
80        bool YahtzeeJoker();
81        void EndofGame();
82        void HighScoreHandler(int score);
83        inline void EnableUndo(int id);
84        void PostScore(int id);
85        void CalculateSubTotal();
86        int InitializeDatabase();
87        void Relayout();
88
89        wxStaticBoxSizer *uppersection, *lowersection;
90        wxBoxSizer *sectionsSizer;
91
92        //pointers to hold bitmap data for the dices
93        wxBitmap *bitmap_dices[6];
94
95        short int m_rolls;      //holds how many rolls left
96        short int m_numofplaysleft; //holds how many times the user got to score untill the end of the game
97        bool m_yahtzee;
98        bool m_yahtzeebonus; //tells the undo if there is also an yahtzee bonus to undo
99
100        short int m_lastmove; //stores the ID of the last button pressed.
101        short int m_rollsundo; //holds the number of remaining rolls for use with the undo option
102
103        SettingsDB *m_settingsdb; //handles the settings database
104        HighScoreTableDB *m_highscoredb; //handles the highscore database managment
105
106        bool m_animate; //sets whether to animate the dice.
107        bool m_calculatesubtotal; //sets whether to calculate the subtotal after every score or not
108
109        bool m_horizontallayout;
110       
111        bool m_skiproll; ///used to prevent the user from accidently rolling the dice twice
112
113        class MainFrameEvtHandler *m_evt_handler;
114};
115
116/**
117 * This class handles events for windows in MainFrame where it hasn't been
118 * possible to use the regular event handler.
119 */
120class MainFrameEvtHandler : public wxEvtHandler
121{
122public:
123        MainFrameEvtHandler(MainFrame *main_frame) { m_main_frame = main_frame;}
124        void OnScoreMouseEnter (wxMouseEvent& event);
125        void OnScoreMouseLeave (wxMouseEvent& event);
126private:
127        MainFrame *m_main_frame;
128
129};
130#endif
Note: See TracBrowser for help on using the repository browser.