1 #pragma once
2 #include "../ogre/common/Gui_Def.h"
3 #include <OgreVector3.h>
4 #include <OgreString.h>
5 #include <OgreFrameListener.h>
6 #include "../sdl4ogre/events.h"
7 namespace SFO  {  class InputWrapper;  class SDLCursorManager;  }
8 struct SDL_Window;
9 namespace MyGUI{  class OgreD3D11Platform;  class OgrePlatform;  }
10 namespace Ogre {  class SceneNode;  class Root;  class SceneManager;  class RenderWindow;
11 	class Viewport;  class Camera;  class Overlay;  class OverlayElement;  }
12 class SplineRoad;  class SETTINGS;
13 
14 
15 enum ED_MODE
16 {
17 	ED_Deform=0, ED_Smooth, ED_Height, ED_Filter, /*ED_Paint,*/
18 	ED_Road, ED_Start, ED_PrvCam, ED_Fluids, ED_Objects, ED_Rivers, ED_ALL
19 };
20 enum WND_Types
21 {	WND_Track=0, WND_Edit, WND_Help, WND_Options, WND_ALL  };  // pSet->inMenu
22 enum TABS_Edit
23 {	TAB_Back=0, TAB_Sun, TAB_Terrain, TAB_Layers, TAB_Grass, TAB_Veget, TAB_Surface, TAB_Road, TAB_Objects, TabsEdit_ALL  };
24 
25 
26 class BaseApp : public BGui,
27 		public Ogre::FrameListener,
28 		public SFO::KeyListener, public SFO::MouseListener, public SFO::WindowListener
29 {
30 public:
31 	BaseApp();	virtual ~BaseApp();
32 	virtual void Run( bool showDialog );
33 
34 	friend class CGui;
35 	friend class CGuiCom;
36 	friend class CScene;
37 
38 	SETTINGS* pSet;
39 
40 	bool bWindowResized;
41 	Ogre::SceneNode* ndSky;  //- out to CScene?
42 
43 	// stuff to be executed in App after BaseApp init
44 	virtual void postInit() = 0;
45 
46 	bool mShutDown;
47 protected:
48 	bool mShowDialog;//, mShutDown;
49 	bool setup(), configure();  void updateStats();
50 
51 	bool bFirstRenderFrame;
52 
53 	///  create
54 	virtual void createScene() = 0;
55 	virtual void destroyScene() = 0;
56 
57 	void createCamera(), createFrameListener();
58 	void setupResources(), loadResources();
59 
60 	///  frame events
61 	virtual bool frameStarted(const Ogre::FrameEvent& evt);
62 	virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
63 	virtual bool frameEnded(const Ogre::FrameEvent& evt);
64 
65 	///  input events
66 	/*virtual*/
67 	bool keyPressed( const SDL_KeyboardEvent &arg) = 0;
68 	bool keyReleased(const SDL_KeyboardEvent &arg);
69 	bool mouseMoved( const SFO::MouseMotionEvent &arg );
70 	bool mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id );
71 	bool mouseReleased(const SDL_MouseButtonEvent &arg, Uint8 id );
72 	void textInput(const SDL_TextInputEvent &arg);
73 
74 	void onCursorChange(const std::string& name);
75 
76 	virtual void windowResized(int x, int y);
77 	virtual void windowClosed();
78 
79 	///  Ogre
80 public:
81 	Ogre::Root *mRoot;
82 protected:
83 	Ogre::SceneManager* mSceneMgr;
84 	Ogre::Viewport* mViewport;
85 	Ogre::RenderWindow* mWindow;
86 	SDL_Window* mSDLWindow;
87 	Ogre::Camera* mCamera;
88 	Ogre::Vector3 mCamPosOld,mCamDirOld;
89 
90 	///  input
91 	SFO::InputWrapper* mInputWrapper;
92 	SFO::SDLCursorManager* mCursorManager;
93 
94 	///  ovelay
95 	Ogre::Overlay *ovBrushPrv, *ovTerPrv;
96 	Ogre::OverlayElement *ovBrushMtr, *ovTerMtr;
97 	float fStFade;
98 
99 	bool alt, ctrl, shift;  // key modifiers
100 	bool mbLeft, mbRight, mbMiddle;  // mouse buttons
101 
102 	Ogre::String  mDebugText;	// info texts
103 	bool mbWireFrame;  void UpdWireframe();
104 
105 	///  camera upd
106 	bool bMoveCam;
107 	int mx,my,mz;  double mDTime;
108 	Ogre::Real mRotX, mRotY,  mRotKX, mRotKY,  moveMul, rotMul;
109 	Ogre::Vector3 mTrans;
110 
111 	ED_MODE	edMode,edModeOld;
112 
113 	///  Gui  ..........................
114 	bool bGuiFocus;  // gui shown
115 	MyGUI::Gui* mGui;
116 	void baseInitGui();
117 
118 	#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
119 	MyGUI::OgreD3D11Platform* mPlatform;
120 	#else
121 	MyGUI::OgrePlatform* mPlatform;
122 	#endif
123 	Wnd mWndBrush, mWndCam, mWndStart,  // tool windows
124 		mWndRoadCur, mWndRoadStats,
125 		mWndFluids, mWndObjects, mWndRivers;
126 
127 	//MyGUI::VectorWidgetPtr
128 	std::vector<WP> vwGui;  // all widgets to destroy
129 	Img bckFps, imgCur, bckInput;
130 	Txt txFps, txCamPos, txInput;
131 
132 	Wnd mWndMain, mWndTrack,mWndEdit,mWndHelp,mWndOpts;  // menu, windows
133 	Wnd mWndTrkFilt, mWndPick;
134 	Tab mWndTabsTrack,mWndTabsEdit,mWndTabsHelp,mWndTabsOpts;  // main tabs on windows
135 
136 	///  main menu
137 	WP mWndMainPanels[WND_ALL];
138 	Btn mWndMainBtns[WND_ALL];
139 
140 
141 public:
bCam()142 	inline bool bCam()  {  return  bMoveCam && !bGuiFocus;  }
bEdit()143 	inline bool bEdit() {  return !bMoveCam && !bGuiFocus;  }
144 
145 };
146