| 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 | #include "SettingsDB.h" |
|---|
| 28 | #include "HighScoreTableDB.h" |
|---|
| 29 | #include "ScoreDice.h" |
|---|
| 30 | #include "dice_graphics.h" |
|---|
| 31 | #include "configuration.h" |
|---|
| 32 | #ifndef MAINFRAME_INC |
|---|
| 33 | #define MAINFRAME_INC |
|---|
| 34 | |
|---|
| 35 | /// MainFrame class - the main window |
|---|
| 36 | /** |
|---|
| 37 | The Main Frame class is a derieved class from wxFrame which is responsible to |
|---|
| 38 | the main window of the application. This class also hold all the functions |
|---|
| 39 | that process the dice and handles the gameplay. This function are called as |
|---|
| 40 | event handlers. |
|---|
| 41 | */ |
|---|
| 42 | class MainFrame : public wxFrame |
|---|
| 43 | { |
|---|
| 44 | public: |
|---|
| 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 OnDiceTheme( wxCommandEvent& event); |
|---|
| 57 | void OnCheckForUpdates (wxCommandEvent& event); |
|---|
| 58 | void OnSendComment (wxCommandEvent& event); |
|---|
| 59 | |
|---|
| 60 | void OnRollButton (wxCommandEvent& event); |
|---|
| 61 | void OnUpperButtons (wxCommandEvent& event); |
|---|
| 62 | void On3ofakindButton (wxCommandEvent& event); |
|---|
| 63 | void On4ofakindButton (wxCommandEvent& event); |
|---|
| 64 | void OnFullHouseButton (wxCommandEvent& event); |
|---|
| 65 | void OnSmallSequenceButton (wxCommandEvent& event); |
|---|
| 66 | void OnLargeSequenceButton (wxCommandEvent& event); |
|---|
| 67 | void OnYahtzeeButton (wxCommandEvent& event); |
|---|
| 68 | void OnChanceButton (wxCommandEvent& event); |
|---|
| 69 | void OnDiceClick (wxCommandEvent& event); |
|---|
| 70 | void OnKeepClick (wxCommandEvent& event); |
|---|
| 71 | |
|---|
| 72 | void OnScoreMouseEnter (wxMouseEvent& event); |
|---|
| 73 | void OnScoreMouseLeave (wxMouseEvent& event); |
|---|
| 74 | |
|---|
| 75 | bool IsValidDice(); |
|---|
| 76 | |
|---|
| 77 | ScoreDice m_score_dice; |
|---|
| 78 | |
|---|
| 79 | configuration::Configuration *m_config; |
|---|
| 80 | |
|---|
| 81 | private: |
|---|
| 82 | void ClearDiceHash(); |
|---|
| 83 | void ResetRolls(); |
|---|
| 84 | void YahtzeeBonus(); |
|---|
| 85 | bool YahtzeeJoker(); |
|---|
| 86 | void EndofGame(); |
|---|
| 87 | void HighScoreHandler(int score); |
|---|
| 88 | inline void EnableUndo(int id); |
|---|
| 89 | void PostScore(int id); |
|---|
| 90 | void CalculateSubTotal(); |
|---|
| 91 | int InitializeDatabase(); |
|---|
| 92 | void Relayout(); |
|---|
| 93 | void AddMenus(); |
|---|
| 94 | void ConnectEventTable(); |
|---|
| 95 | void AddControlsAndLayout(); |
|---|
| 96 | |
|---|
| 97 | wxStaticBoxSizer *uppersection, *lowersection; |
|---|
| 98 | wxBoxSizer *sectionsSizer; |
|---|
| 99 | |
|---|
| 100 | //pointers to hold bitmap data for the dices |
|---|
| 101 | wxBitmap *bitmap_dices[6]; |
|---|
| 102 | DiceGraphics m_dice_graphics; |
|---|
| 103 | |
|---|
| 104 | short int m_rolls; //holds how many rolls left |
|---|
| 105 | short int m_numofplaysleft; //holds how many times the user got to score untill the end of the game |
|---|
| 106 | bool m_yahtzee; |
|---|
| 107 | bool m_yahtzeebonus; //tells the undo if there is also an yahtzee bonus to undo |
|---|
| 108 | |
|---|
| 109 | short int m_lastmove; //stores the ID of the last button pressed. |
|---|
| 110 | short int m_rollsundo; //holds the number of remaining rolls for use with the undo option |
|---|
| 111 | |
|---|
| 112 | SettingsDB *m_settingsdb; //handles the settings database |
|---|
| 113 | HighScoreTableDB *m_highscoredb; //handles the highscore database managment |
|---|
| 114 | |
|---|
| 115 | bool m_skiproll; ///used to prevent the user from accidently rolling the dice twice |
|---|
| 116 | |
|---|
| 117 | class MainFrameEvtHandler *m_evt_handler; |
|---|
| 118 | }; |
|---|
| 119 | |
|---|
| 120 | /** |
|---|
| 121 | * This class handles events for windows in MainFrame where it hasn't been |
|---|
| 122 | * possible to use the regular event handler. |
|---|
| 123 | */ |
|---|
| 124 | class MainFrameEvtHandler : public wxEvtHandler |
|---|
| 125 | { |
|---|
| 126 | public: |
|---|
| 127 | MainFrameEvtHandler(MainFrame *main_frame) { m_main_frame = main_frame;} |
|---|
| 128 | void OnScoreMouseEnter (wxMouseEvent& event); |
|---|
| 129 | void OnScoreMouseLeave (wxMouseEvent& event); |
|---|
| 130 | private: |
|---|
| 131 | MainFrame *m_main_frame; |
|---|
| 132 | |
|---|
| 133 | }; |
|---|
| 134 | #endif |
|---|