1 #pragma once 2 #include "common/Gui_Def.h" 3 #include <OgreFrameListener.h> 4 #include <OgreWindowEventUtilities.h> 5 #include <OgreMaterialManager.h> 6 #include <boost/scoped_ptr.hpp> 7 #include "../sdl4ogre/events.h" 8 namespace SFO { class InputWrapper; class SDLCursorManager; } 9 namespace ICS { class InputControlSystem; class DetectingBindingListener; } 10 11 namespace MyGUI{ class OgreD3D11Platform; class OgrePlatform; } 12 namespace Ogre { class SceneNode; class Root; class SceneManager; class RenderWindow; } 13 namespace sh { class Factory; } 14 15 class MasterClient; class P2PGameClient; 16 17 18 // gui 19 enum MNU_Btns { MNU_Single=0, MNU_Tutorial, MNU_Champ, MNU_Challenge, MNU_Replays, MNU_Help, MNU_Options, ciMainBtns }; 20 enum TAB_Game { TAB_Back=0, TAB_Track,TAB_Car, TAB_Setup,TAB_Game, TAB_Multi, TAB_Champs,TAB_Stages,TAB_Stage }; 21 enum TAB_Options { TABo_Back=0, TABo_Screen, TABo_Input, TABo_View, TABo_Graphics, TABo_Settings, TABo_Sound, TABo_Tweak }; 22 enum LobbyState { DISCONNECTED, HOSTING, JOINED }; 23 24 25 26 class BaseApp : public BGui, 27 public Ogre::FrameListener, 28 public SFO::KeyListener, public SFO::MouseListener, 29 public SFO::JoyListener, public SFO::WindowListener 30 { 31 friend class CarModel; 32 friend class CGame; 33 friend class CHud; 34 friend class CGui; 35 public: 36 BaseApp(); 37 virtual ~BaseApp(); 38 virtual void Run(bool showDialog); 39 40 bool bLoading,bLoadingEnd,bSimulating; int iLoad1stFrames; 41 42 // has to be in baseApp for camera mouse move 43 typedef std::vector<class CarModel*> CarModels; 44 CarModels carModels; 45 46 void showMouse(), hideMouse(), updMouse(); 47 48 // stuff to be executed in App after BaseApp init 49 virtual void postInit() = 0; 50 51 /// effects 52 class SplitScr* mSplitMgr; 53 class HDRLogic* mHDRLogic; class MotionBlurLogic* mMotionBlurLogic; 54 class CameraBlurLogic* mCameraBlurLogic; 55 class SSAOLogic* mSSAOLogic; 56 class GodRaysLogic* mGodRaysLogic; 57 class SoftParticlesLogic* mSoftParticlesLogic; 58 class DepthOfFieldLogic* mDepthOfFieldLogic; 59 class GBufferLogic* mGBufferLogic; 60 class FilmGrainLogic* mFilmGrainLogic; 61 void recreateCompositor(); 62 bool AnyEffectEnabled(); 63 bool NeedMRTBuffer(); 64 float motionBlurIntensity; 65 66 class SETTINGS* pSet; 67 68 sh::Factory* mFactory; 69 70 // wnd, hud, upl 71 bool bWindowResized, bSizeHUD, bRecreateHUD; 72 float roadUpdTm; 73 class LoadingBar* mLoadingBar; 74 Ogre::SceneNode* ndSky; //- 75 76 77 bool mShowDialog, mShutDown; 78 bool setup(), configure(); void updateStats(); 79 80 int mMouseX,mMouseY; 81 82 /// create 83 virtual void createScene() = 0; 84 virtual void destroyScene() = 0; 85 86 void createFrameListener(), createViewports(), refreshCompositor(bool disableAll=false); 87 void setupResources(), createResourceListener(), loadResources(); 88 void LoadingOn(), LoadingOff(); 89 90 /// frame events 91 bool frameRenderingQueued(const Ogre::FrameEvent& evt); 92 bool frameEnded(const Ogre::FrameEvent& evt); 93 virtual bool frameStart(Ogre::Real time) = 0; 94 virtual bool frameEnd(Ogre::Real time) = 0; 95 96 /// input events 97 virtual bool mouseMoved(const SFO::MouseMotionEvent &arg ); 98 virtual bool mousePressed(const SDL_MouseButtonEvent &arg, Uint8 id ); 99 virtual bool mouseReleased(const SDL_MouseButtonEvent &arg, Uint8 id ); 100 virtual void textInput(const SDL_TextInputEvent& arg); 101 virtual bool keyPressed(const SDL_KeyboardEvent &arg) = 0; 102 virtual bool keyReleased(const SDL_KeyboardEvent &arg); 103 virtual bool buttonPressed(const SDL_JoyButtonEvent &evt, int button ); 104 virtual bool buttonReleased(const SDL_JoyButtonEvent &evt, int button ); 105 virtual bool axisMoved(const SDL_JoyAxisEvent &arg, int axis ); 106 107 void onCursorChange(const std::string& name); 108 109 /// Ogre 110 Ogre::Root* mRoot; Ogre::SceneManager* mSceneMgr; 111 Ogre::RenderWindow* mWindow; 112 SDL_Window* mSDLWindow; 113 114 virtual void windowResized (int x, int y); 115 virtual void windowClosed(); 116 117 /// input 118 SFO::InputWrapper* mInputWrapper; 119 SFO::SDLCursorManager* mCursorManager; 120 ICS::InputControlSystem* mInputCtrl; 121 ICS::InputControlSystem* mInputCtrlPlayer[4]; 122 std::vector<SDL_Joystick*> mJoysticks; 123 124 // this is set to true when the user is asked to assign a new key 125 bool bAssignKey; 126 ICS::DetectingBindingListener* mBindListner; 127 IsFocGuiInput()128 bool IsFocGuiInput() { return isFocGui || isFocRpl; } 129 bool IsFocGui(); getWindow()130 Ogre::RenderWindow* getWindow() { return mWindow; } 131 132 /// input 133 bool alt, ctrl, shift; // key modifiers 134 bool mbLeft, mbRight, mbMiddle; // mouse buttons 135 bool mbWireFrame; 136 int iCurCam; 137 138 /// Gui .......................... 139 bool isFocGui,isFocRpl; // gui shown 140 bool isTweak(); 141 142 MyGUI::Gui* mGui; 143 void baseInitGui(), baseSizeGui(); 144 145 Img bckFps, imgBack; 146 Txt txFps; 147 148 // loading 149 Img bckLoad, bckLoadBar, barLoad, imgLoad; 150 Txt txLoadBig, txLoad; 151 int barSizeX, barSizeY; 152 153 154 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 155 MyGUI::OgreD3D11Platform* mPlatform; 156 #else 157 MyGUI::OgrePlatform* mPlatform; 158 #endif 159 160 /// main menu // pSet->inMenu 161 WP mWndMainPanels[ciMainBtns]; 162 Btn mWndMainBtns[ciMainBtns]; 163 164 Wnd mWndMain, mWndGame,mWndReplays,mWndHelp,mWndOpts, // menu, windows 165 mWndWelcome, mWndRpl, mWndNetEnd, mWndTweak, mWndTrkFilt, // rpl controls, netw, tools 166 mWndChampStage,mWndChampEnd, mWndChallStage,mWndChallEnd; 167 Tab mWndTabsGame,mWndTabsOpts,mWndTabsHelp,mWndTabsRpl; // main tabs on windows 168 169 //MyGUI::VectorWidgetPtr 170 std::vector<WP> vwGui; // all widgets to destroy 171 172 /// networking 173 boost::scoped_ptr<MasterClient> mMasterClient; 174 boost::scoped_ptr<P2PGameClient> mClient; 175 LobbyState mLobbyState; 176 }; 177