1 #pragma once
2 #include "Replay.h"
3 #include "../vdrift/cardefs.h"
4 #include "CarModel.h"
5 #include "CarReflection.h"
6 
7 #include "common/MessageBox/MessageBox.h"
8 #include "common/MessageBox/MessageBoxStyle.h"
9 #include "common/GraphView.h"
10 
11 #include "../network/networkcallbacks.hpp"
12 #include <boost/thread.hpp>
13 #include <MyGUI.h>
14 #include <OgreShadowCameraSetup.h>
15 //#include <OgreOverlayElement.h>
16 #include <OgreOverlay.h>
17 
18 #include "../shiny/Main/Factory.hpp"
19 
20 
21 namespace Ogre {  class SceneNode;  class SceneManager;  class Viewport;  class ManualObject;  }
22 namespace MyGUI  {  class MultiList2;  class Slider;  }
23 class GraphView;  class App;  class SETTINGS;  class CGui;
24 
25 
26 class CHud
27 {
28 public:
29 	App* app;
30 	SETTINGS* pSet;
31 	CGui* gui;
32 
33 	CHud(App* ap1);
34 
35 
36 	//  minimap pos triangle, all needed info
37 	struct SMiniPos
38 	{
39 		float x,y;  // pos
40 		float px[4],py[4];  // points, rotation
41 	};
42 
43 	///  HUD  ------------
44 	class Hud  // for 1 viewport/player
45 	{
46 	public:
47 		//  times bar
48 		MyGUI::TextBox *txTimTxt,*txTimes;  //MyGUI::ImageBox *bckTimes;
49 		Ogre::String sTimes,sLap;
50 		//  lap results
51 		MyGUI::TextBox *txLapTxt,*txLap;  MyGUI::ImageBox *bckLap;
52 		//  opponents list  columns: trk %, dist m, nick
53 		MyGUI::TextBox *txOpp[3];  MyGUI::ImageBox *bckOpp;
54 		int xOpp, yOpp, lastOppH;
55 
56 		//  wrong check warning, win place
57 		MyGUI::TextBox *txWarn,*txPlace;  MyGUI::ImageBox *bckWarn,*bckPlace;
58 		//  start countdown
59 		MyGUI::TextBox *txCountdown;
60 
61 		//  gauges
62 		Ogre::SceneNode    *ndNeedles, *ndGauges;
63 		Ogre::ManualObject *moNeedles, *moGauges;
64 		//  gear, vel
65 		MyGUI::TextBox *txGear,*txVel, *txAbs,*txTcs;
66 		MyGUI::ImageBox *bckVel;
67 
68 		//  boost fuel, damage %, rewind time
69 		MyGUI::TextBox  *txBFuel, *txDamage, *txRewind;
70 		MyGUI::ImageBox *icoBFuel,*icoBInf,*icoDamage,*icoRewind;
71 
72 		//  current camera name
73 		MyGUI::TextBox *txCam;
74 
75 		//  miniap
76 		Ogre::ManualObject *moMap;  Ogre::SceneNode *ndMap;
77 		//  all info for this car's minimap
78 		std::vector<SMiniPos> vMiniPos;  // const size: 6
79 
80 		//  center position .
81 		Ogre::Vector2 vcRpm, vcVel;  Ogre::Real fScale;
82 		bool updGauges;
83 
84 		MyGUI::Widget* parent;
85 		Hud();
86 	};
87 	std::vector<Hud> hud;  // const size: max viewports 4
88 
89 	///  global hud  ---------
90 
91 	//  car pos tris on minimap
92 	//  one for all cars on all viewports
93 	Ogre::SceneNode* ndPos;
94 	Ogre::ManualObject* moPos;
95 
96 	//  chat messages
97 	MyGUI::TextBox *txMsg;  MyGUI::ImageBox *bckMsg;
98 	//  camera move info
99 	MyGUI::TextBox *txCamInfo;
100 	//  car debug texts  todo...
101 	MyGUI::TextBox *txDbgCar,*txDbgTxt,*txDbgExt;
102 
103 	Ogre::SceneNode    *ndTireVis[4];
104 	Ogre::ManualObject *moTireVis[4];
105 
106 	struct OvrDbg
107 	{
108 		Ogre::OverlayElement* oL,*oR,*oS, *oU,*oX;
109 		OvrDbg();
110 	};
111 	std::vector<OvrDbg> ov;
112 	Ogre::Overlay *ovCarDbg,*ovCarDbgTxt,*ovCarDbgExt;
113 
114 
115 	///  checkpoint arrow
116 	struct Arrow
117 	{
118 		Ogre::Entity* ent;
119 		Ogre::SceneNode* node,*nodeRot;  // checkpoint arrow
120 		Ogre::Quaternion qStart, qEnd, qCur;  // smooth animation
121 		Arrow();
122 		void Create(Ogre::SceneManager* mSceneMgr, SETTINGS* pSet);
123 	} arrow;
124 
125 	float asp, scX,scY, minX,maxX, minY,maxY;  // minimap visible range
126 	Ogre::SceneNode *ndLine;
127 
128 	//------------------------------------------
129 
130 	//  init
131 	void Create(), Destroy();
132 	Ogre::ManualObject* CreateVdrMinimap();  //vdr only
133 
134 	//  show, size
135 	void Size(), Show(bool hideAll=false), ShowVp(bool vp);
136 
137 	///  update
138 	void Update(int carId, float time);
139 
140 	//  update internal
141 	void UpdRot(int baseCarId, int carId, float vel, float rpm);  // rpm < 0.f to hide
142 	void GetVals(int id, float* vel, float* rpm, float* clutch, int* gear);
143 	void UpdMiniTer(), UpdDbgTxtClr();
144 
145 	//  util create
146 	Ogre::ManualObject* Create2D(const Ogre::String& mat, Ogre::SceneManager* sceneMgr,
147 		Ogre::Real size, bool dyn /*= false*/, bool clr /*= false*/,
148 		Ogre::Real mul, Ogre::Vector2 ofs,
149 		Ogre::uint32 vis, Ogre::uint8 rndQue, int cnt = 1);
150 
151 	MyGUI::TextBox* CreateNickText(int carId, Ogre::String text);
152 	Ogre::Vector3 projectPoint(const Ogre::Camera* cam, const Ogre::Vector3& pos);  // 2d xy, z - out info
153 
154 	//  string utils
155 	Ogre::String StrClr(Ogre::ColourValue c);
156 
157 #ifndef BT_NO_PROFILE
158 	//  bullet debug text
159 	void bltDumpRecursive(class CProfileIterator* profileIterator, int spacing, std::stringstream& os);
160 	void bltDumpAll(std::stringstream& os);
161 #endif // BT_NO_PROFILE
162 };
163