Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 244 | chris | 1 | #ifndef __GAMEAPP_H__ |
| 2 | #define __GAMEAPP_H__ |
||
| 3 | |||
| 4 | ////////////////////////////////////////////////////////////////////////// |
||
| 5 | // GameApp.h |
||
| 6 | // |
||
| 7 | // This is what drives the whole game. In here, you derive your class |
||
| 8 | // from SexyAppBase and implement common game tasks, such as |
||
| 9 | // responding to widgets (covered later), initializing and loading |
||
| 10 | // resources, setting up the various game screens, etc. |
||
| 11 | // All applications at minimum must have a class that derives from |
||
| 12 | // SexyAppBase. |
||
| 13 | // |
||
| 14 | // The GameApp class is used to do such things as create the main |
||
| 15 | // menu screen, create the main game class (where all drawing/updating/ |
||
| 16 | // interaction takes place), etc. |
||
| 17 | // |
||
| 18 | // IMPORTANT: Comments for topics covered in the previous demos will |
||
| 19 | // be kept to a minimum and removed in most cases. You should read through |
||
| 20 | // the previous demos to familiarize yourself with anything you don't |
||
| 21 | // understand. All functions, variables, and concepts are explained |
||
| 22 | // either in this demo, or in previous ones if they've already been covered. |
||
| 23 | ////////////////////////////////////////////////////////////////////////// |
||
| 24 | |||
| 25 | #include "SexyAppFramework/SexyAppBase.h" |
||
| 26 | |||
| 27 | |||
| 28 | namespace Sexy |
||
| 29 | { |
||
| 30 | |||
| 31 | class Board; |
||
| 32 | class TitleScreen; |
||
| 33 | |||
| 34 | class GameApp : public SexyAppBase |
||
| 35 | { |
||
| 36 | |||
| 37 | private: |
||
| 38 | |||
| 39 | Board* mBoard; |
||
| 40 | TitleScreen* mTitleScreen; |
||
| 41 | |||
| 42 | // Because it's annoying to hear the sound of the planets hitting a wall too many |
||
| 43 | // times in a second, we'll limit how many can occur. |
||
| 44 | int mLastPlanetHitSoundTime; |
||
| 45 | |||
| 46 | public: |
||
| 47 | |||
| 48 | GameApp(); |
||
| 49 | virtual ~GameApp(); |
||
| 50 | |||
| 51 | ////////////////////////////////////////////////////////////////////////// |
||
| 52 | // Function: Init |
||
| 53 | // Parameters: none |
||
| 54 | // Returns: none |
||
| 55 | // |
||
| 56 | // Purpose: Initializes the application. Sets the resolution, overrides |
||
| 57 | // any default settings, and if there is a loader/intro screen (not in this demo) |
||
| 58 | // creates it and displays it. The framework will then automatically |
||
| 59 | // call the LoadingThreadProc() method after this method returns. |
||
| 60 | ////////////////////////////////////////////////////////////////////////// |
||
| 61 | virtual void Init(); |
||
| 62 | |||
| 63 | ////////////////////////////////////////////////////////////////////////// |
||
| 64 | // Function: LoadingThreadProc |
||
| 65 | // Parameters: none |
||
| 66 | // Returns: none |
||
| 67 | // |
||
| 68 | // Purpose: Loads all resources in a separate thread. If there is a |
||
| 69 | // loader/intro screen (not in this demo), would also update the |
||
| 70 | // loader progress indicator. When the function returns, the |
||
| 71 | // LoadingThreadCompleted() method is automatically called. |
||
| 72 | ////////////////////////////////////////////////////////////////////////// |
||
| 73 | virtual void LoadingThreadProc(); |
||
| 74 | |||
| 75 | ////////////////////////////////////////////////////////////////////////// |
||
| 76 | // Function: LoadingThreadCompleted |
||
| 77 | // Parameters: none |
||
| 78 | // Returns: none |
||
| 79 | // |
||
| 80 | // Purpose: Called when LoadingThreadProc is complete and all resources |
||
| 81 | // have been loaded. It is in this function that you would then set up |
||
| 82 | // your main menu or similar screen. For this particular demo however, |
||
| 83 | // we will go straight to the main game class, "Board". |
||
| 84 | ////////////////////////////////////////////////////////////////////////// |
||
| 85 | virtual void LoadingThreadCompleted(); |
||
| 86 | |||
| 87 | ////////////////////////////////////////////////////////////////////////// |
||
| 88 | // Function: TitleScreenIsFinished |
||
| 89 | // Parameters: none |
||
| 90 | // Returns: none |
||
| 91 | // |
||
| 92 | // Purpose: Called by the TitleScreen widget when it is about to close |
||
| 93 | // down, this indicates that we should now add the board widget and |
||
| 94 | // start the game. |
||
| 95 | ////////////////////////////////////////////////////////////////////////// |
||
| 96 | void TitleScreenIsFinished(); |
||
| 97 | |||
| 98 | ////////////////////////////////////////////////////////////////////////// |
||
| 99 | // Function: NewDialog |
||
| 100 | // Parameters: |
||
| 101 | // theDialogId - Unique ID to give this dialog box |
||
| 102 | // isModal - If true, only itself and widgets above it receive |
||
| 103 | // input events. |
||
| 104 | // theDialogHeader - String to display in the header part of the dialog box |
||
| 105 | // theDialogLines - String to use for the body of the dialog. May use |
||
| 106 | // \n characters to indicate new lines. |
||
| 107 | // theDialogFooter - If the button mode is BUTTONS_FOOTER, this is the text |
||
| 108 | // to use for the button, otherwise ignored. |
||
| 109 | // theButtonMode - One of 3 settings: Dialog::BUTTONS_YES_NO creates two |
||
| 110 | // "Yes" "No" buttons, Dialog::BUTTONS_OK_CANCEL creates two |
||
| 111 | // "OK" "Cancel" buttons, Dialog::BUTTONS_FOOTER creates one |
||
| 112 | // button with the text from theDialogFooter. |
||
| 113 | // |
||
| 114 | // Returns: A new dialog pointer for use by SexyAppBase's DoDialog method. |
||
| 115 | // |
||
| 116 | // Purpose: SexyAppBase contains a convenience function, DoDialog, that relies on |
||
| 117 | // this overriden function. DoDialog calls NewDialog which instructs it how to make |
||
| 118 | // a dialog box. You should use DoDialog to create and add your dialog boxes. |
||
| 119 | // The reason for this function is to allow for customized dialog boxes and to avoid |
||
| 120 | // having to have a gigantic function with every possible parameter to pass to the Dialog's |
||
| 121 | // constructor. |
||
| 122 | ////////////////////////////////////////////////////////////////////////// |
||
| 123 | virtual Dialog* NewDialog(int theDialogId, bool isModal, const std::string& theDialogHeader, |
||
| 124 | const std::string& theDialogLines, const std::string& theDialogFooter, int theButtonMode); |
||
| 125 | |||
| 126 | ////////////////////////////////////////////////////////////////////////// |
||
| 127 | // Function: LostFocus |
||
| 128 | // Parameters: none |
||
| 129 | // Returns: none |
||
| 130 | // |
||
| 131 | // Purpose: Called when the game itself loses focus, such as the user switch |
||
| 132 | // to another application. |
||
| 133 | ////////////////////////////////////////////////////////////////////////// |
||
| 134 | virtual void LostFocus(void); |
||
| 135 | |||
| 136 | ////////////////////////////////////////////////////////////////////////// |
||
| 137 | // Function: GotFocus |
||
| 138 | // Parameters: none |
||
| 139 | // Returns: none |
||
| 140 | // |
||
| 141 | // Purpose: Called when the app regains focus after losing it. |
||
| 142 | ////////////////////////////////////////////////////////////////////////// |
||
| 143 | virtual void GotFocus(void); |
||
| 144 | |||
| 145 | ////////////////////////////////////////////////////////////////////////// |
||
| 146 | // Function: ButtonPress: |
||
| 147 | // Parameters: |
||
| 148 | // theId - ID of the button pressed |
||
| 149 | // |
||
| 150 | // Returns: none |
||
| 151 | // |
||
| 152 | // Purpose: Called when the button is pressed, but before the mouse is |
||
| 153 | // released (which would instead generate a ButtonDepress event). |
||
| 154 | ////////////////////////////////////////////////////////////////////////// |
||
| 155 | virtual void ButtonPress(int theId); |
||
| 156 | |||
| 157 | ////////////////////////////////////////////////////////////////////////// |
||
| 158 | // Function: PlaySample |
||
| 159 | // Parameters: |
||
| 160 | // theSoundNum - The sound ID to play |
||
| 161 | // Returns: none |
||
| 162 | // |
||
| 163 | // Purpose: Plays the sample at normal pitch with no panning. |
||
| 164 | ////////////////////////////////////////////////////////////////////////// |
||
| 165 | virtual void PlaySample(int theSoundNum); |
||
| 166 | }; |
||
| 167 | |||
| 168 | } |
||
| 169 | |||
| 170 | |||
| 171 | #endif // __GAMEAPP_H__ |