ControlGui.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. #ifndef CONTROLGUI_H
  2. #define CONTROLGUI_H
  3. /*************************************************************************************************\
  4. ControlGui.h : Interface for the ControlGui component. This thing holds the tac map
  5. and everything else on the left hand side of the screen.
  6. //---------------------------------------------------------------------------//
  7. // Copyright (C) Microsoft Corporation. All rights reserved. //
  8. //===========================================================================//
  9. \*************************************************************************************************/
  10. #ifndef GAMETACMAP_H
  11. #include "GameTacMap.h"
  12. #endif
  13. #ifndef FORCEGROUPBAR_H
  14. #include "ForceGroupBar.h"
  15. #endif
  16. #ifndef MOVER_H
  17. #include "mover.h"
  18. #endif
  19. #ifndef UTILITIES_H
  20. #include "Utilities.h"
  21. #endif
  22. #ifndef PAUSEWINDOW_H
  23. #include "PauseWindow.h"
  24. #endif
  25. #ifndef AFONT_H
  26. #include "aFont.h"
  27. #endif
  28. #ifndef AEDIT_H
  29. #include "aEdit.h"
  30. #endif
  31. #ifndef MC2movie_H
  32. #include "mc2movie.h"
  33. #endif
  34. #ifndef MPSTATS_H
  35. #include "MPStats.h"
  36. #endif
  37. class CObjective;
  38. class InfoWindow;
  39. class PauseWindow;
  40. //*************************************************************************************************
  41. #define LAST_VEHICLE MAX_VEHICLE - LARGE_AIRSTRIKE
  42. #define OBJECTVE_MOVE_COUNT 2
  43. #define RESULTS_MOVE_COUNT 3
  44. #define MAX_CHAT_COUNT 5
  45. #define RPTOTAL_CALLOUT 21185
  46. /**************************************************************************************************
  47. CLASS DESCRIPTION
  48. ControlGui:
  49. **************************************************************************************************/
  50. struct ButtonData
  51. {
  52. long ID;
  53. long helpTextHeader;
  54. long helpTextID;
  55. long textID;
  56. long textColors[4];
  57. aFont textFont;
  58. char fileName[32];
  59. long stateCoords[4][2];
  60. long textureWidth;
  61. long textureHeight;
  62. int fileWidth;
  63. int fileHeight;
  64. unsigned long textureHandle;
  65. bool textureRotated;
  66. };
  67. class ControlButton
  68. {
  69. public:
  70. gos_VERTEX location[4];
  71. long ID;
  72. ButtonData* data;
  73. int state;
  74. void render();
  75. void press( bool );
  76. void toggle();
  77. void disable( bool );
  78. bool isEnabled();
  79. void makeAmbiguous( bool bAmbiguous );
  80. void hide( bool );
  81. void move( float deltaX, float deltaY );
  82. void setColor( unsigned long newColor );
  83. static void makeUVs( gos_VERTEX* vertices, int State, ButtonData& data );
  84. static void initButtons( FitIniFile& file, long buttonCount,
  85. ControlButton* buttons, ButtonData* buttonData, const char* str, aFont* font = 0 );
  86. enum States
  87. {
  88. ENABLED = 0,
  89. PRESSED,
  90. DISABLED,
  91. AMBIGUOUS,
  92. HIDDEN
  93. };
  94. };
  95. class ControlGui
  96. {
  97. public:
  98. static ControlGui* instance;
  99. static long hiResOffsetX;
  100. static long hiResOffsetY;
  101. ControlGui();
  102. ~ControlGui();
  103. bool inRegion( int mouseX, int mouseY, bool bPaused );
  104. void render( bool bPaused );
  105. void update( bool bPaused, bool bLOS );
  106. void initTacMapBuildings( unsigned char* data, int size ){ tacMap.initBuildings( data, size ); }
  107. void initTacMap( unsigned char* data, int size ){ tacMap.init( data, size ); }
  108. void initMechs();
  109. void unPressAllVehicleButtons();
  110. void disableAllVehicleButtons();
  111. void addMover (MoverPtr mover);
  112. void removeMover (MoverPtr mover);
  113. int updateChat();
  114. void beginPause();
  115. void endPause();
  116. bool resultsDone();
  117. void startObjectives( bool bStart );
  118. bool objectivesStarted() { return renderObjectives; }
  119. void setInfoWndMover( Mover* pMover );
  120. void setVehicleCommand( bool );
  121. bool getVehicleCommand( );
  122. void playMovie( const char* fileName );
  123. bool isMoviePlaying();
  124. bool playPilotVideo( MechWarrior* pPilot, char movieCode );
  125. void endPilotVideo();
  126. bool isSelectingInfoObject();
  127. bool isOverTacMap();
  128. bool isChatting() { return bChatting; }
  129. //TUTORIAL
  130. bool animateTacMap (long buttonId,float timeToScroll,long numFlashes);
  131. bool pushButton (long buttonId);
  132. bool flashRPTotal (long numFlashes);
  133. const char* getVehicleName( long& ID );
  134. const char* getVehicleNameFromID (long ID);
  135. void swapResolutions( int newResolution );
  136. GameTacMap tacMap;
  137. ForceGroupBar forceGroupBar;
  138. bool mouseInVehicleStopButton;
  139. enum Commands
  140. {
  141. DEFAULT_RANGE = 0,
  142. SHORT_RANGE ,
  143. MED_RANGE,
  144. LONG_RANGE,
  145. JUMP_COMMAND,
  146. RUN_COMMAND,
  147. GUARD_COMMAND,
  148. FIRE_FROM_CURRENT_POS,
  149. STOP_COMMAND,
  150. INFO_COMMAND,
  151. OBJECTIVES_COMMAND,
  152. SAVE_COMMAND,
  153. TACMAP_TAB,
  154. INFO_TAB,
  155. VEHICLE_TAB,
  156. LAYMINES,
  157. REPAIR,
  158. SALVAGE,
  159. GUARDTOWER,
  160. CUR_RANGE, // fire from right where I AM
  161. LAST_COMMAND
  162. };
  163. enum VehicleCommands
  164. {
  165. LARGE_AIRSTRIKE = 100,
  166. GUARD_TOWER,
  167. SENSOR_PROBE,
  168. REPAIR_VEHICLE,
  169. PEGASUS_SCOUT,
  170. MINELAYER,
  171. RECOVERY_TEAM,
  172. STOP_VEHICLE,
  173. MAX_VEHICLE
  174. };
  175. bool isDefaultSpeed();
  176. void toggleDefaultSpeed( );
  177. void toggleJump( );
  178. bool getJump( );
  179. bool getWalk( );
  180. bool getRun( );
  181. void toggleGuard( );
  182. bool getGuard( );
  183. void setDefaultSpeed();
  184. void toggleHoldPosition();
  185. void setRange( int Range );
  186. void doStop();
  187. void toggleFireFromCurrentPos();
  188. bool getFireFromCurrentPos(){ return fireFromCurrentPos; }
  189. void setFireFromCurrentPos( bool bset ) { fireFromCurrentPos = bset; }
  190. bool isAddingVehicle(){ return addingVehicle; }
  191. bool isAddingAirstrike() { return addingArtillery; }
  192. bool isAddingSalvage() { return addingSalvage; }
  193. bool isButtonPressed( int ID ) { return getButton( ID )->state & ControlButton::PRESSED; }
  194. bool getMines();
  195. bool getSalvage();
  196. bool getRepair();
  197. bool getGuardTower();
  198. void switchTabs( int direction );
  199. void renderObjective( CObjective* pObjective, long xPos, long yPos, bool bDrawTotal );
  200. void renderMissionStatus( bool bRender){ renderStatusInfo = bRender; }
  201. int getCurrentRange();
  202. void pressInfoButton( ){ handleClick( INFO_COMMAND ); }
  203. bool infoButtonPressed() { return getButton( INFO_COMMAND )->state & ControlButton::PRESSED; }
  204. void showServerMissing();
  205. void pressAirstrikeButton()
  206. {
  207. for ( int i = 0; i < LAST_VEHICLE; i++ )
  208. {
  209. if (( vehicleButtons[i].ID == LARGE_AIRSTRIKE) &&
  210. !( vehicleButtons[i].state & ControlButton::PRESSED ))
  211. {
  212. handleVehicleClick( LARGE_AIRSTRIKE );
  213. }
  214. }
  215. }
  216. void pressLargeAirstrikeButton() { handleVehicleClick( LARGE_AIRSTRIKE ); }
  217. void pressSensorStrikeButton()
  218. {
  219. for ( int i = 0; i < LAST_VEHICLE; i++ )
  220. {
  221. if (( vehicleButtons[i].ID == SENSOR_PROBE) &&
  222. !( vehicleButtons[i].state & ControlButton::PRESSED ))
  223. {
  224. handleVehicleClick( SENSOR_PROBE );
  225. }
  226. }
  227. }
  228. void setRolloverHelpText( unsigned long textID );
  229. void setChatText( const char* playerName, const char* message, unsigned long backgroundColor,
  230. unsigned long textColor );
  231. void toggleChat( bool setTeamOnly );
  232. void eatChatKey();
  233. void cancelInfo();
  234. ControlButton* getButton( int ID );
  235. struct RectInfo
  236. {
  237. GUI_RECT rect;
  238. long color;
  239. };
  240. private:
  241. struct ChatInfo
  242. {
  243. char playerName[32];
  244. char message[128];
  245. unsigned long backgroundColor;
  246. unsigned long time;
  247. unsigned long messageLength; // number of lines
  248. unsigned long chatTextColor;
  249. };
  250. ChatInfo chatInfos[MAX_CHAT_COUNT]; // max five lines -- could change
  251. RectInfo* rectInfos;
  252. long rectCount;
  253. //static ButtonFile vehicleFileData[LAST_VEHICLE];
  254. static unsigned long RUN;
  255. static unsigned long WALK;
  256. static unsigned long GUARD;
  257. static unsigned long JUMP;
  258. ControlButton* buttons;
  259. ControlButton* vehicleButtons;
  260. static ButtonData* buttonData;
  261. static ButtonData* vehicleData;
  262. static const char* vehicleNames[5];
  263. static long vehicleIDs[5];
  264. static const char* vehiclePilots[5];
  265. static long vehicleCosts[LAST_VEHICLE];
  266. InfoWindow* infoWnd;
  267. PauseWindow* pauseWnd;
  268. StaticInfo* staticInfos;
  269. long staticCount;
  270. StaticInfo* objectiveInfos; //2nd to last one is check, last is x
  271. long objectiveInfoCount;
  272. StaticInfo* missionStatusInfos;
  273. long missionStatusInfoCount;
  274. RectInfo missionStatusRect;
  275. bool renderStatusInfo;
  276. float resultsTime;
  277. bool renderObjectives;
  278. float objectiveTime;
  279. float tabFlashTime;
  280. static long OBJECTIVESTOP;
  281. static long OBJECTIVESLEFT;
  282. static long OBJECTIVESSKIP;
  283. static long OBJECTIVESTOTALRIGHT;
  284. static long OBJEECTIVESHEADERSKIP;
  285. static long OBJECTIVESHEADERTOP;
  286. static long OBJECTIVEBOXX;
  287. static long OBJECTIVEBOXSKIP;
  288. static long OBJECTIVECHECKSKIP;
  289. static long OBJECTIVEHEADERLEFT;
  290. static long HELPAREA_LEFT;
  291. static long HELPAREA_BOTTOM;
  292. static long RPLEFT;
  293. static long RPTOP;
  294. static MoveInfo objectiveMoveInfo[OBJECTVE_MOVE_COUNT];
  295. static MoveInfo missionResultsMoveInfo[RESULTS_MOVE_COUNT];
  296. StaticInfo* videoInfos;
  297. long videoInfoCount;
  298. GUI_RECT videoRect;
  299. GUI_RECT videoTextRect;
  300. MC2MoviePtr bMovie;
  301. StaticInfo* timerInfos;
  302. long timerInfoCount;
  303. RectInfo timerRect;
  304. //TUTORIAL!!
  305. RectInfo rpCallout;
  306. long rpNumFlashes;
  307. float rpFlashTime;
  308. long buttonToPress;
  309. unsigned long curOrder;
  310. bool fireFromCurrentPos;
  311. bool addingVehicle;
  312. bool addingArtillery;
  313. bool addingSalvage;
  314. bool wasLayingMines;
  315. bool moviePlaying;
  316. bool twoMinWarningPlayed;
  317. bool thirtySecondWarningPlayed;
  318. bool bChatting;
  319. long idToUnPress;
  320. aFont guiFont;
  321. aFont helpFont;
  322. aFont vehicleFont;
  323. aFont timerFont;
  324. aFont missionResultsFont;
  325. aText chatEdit;
  326. aEdit playerNameEdit;
  327. aEdit personalEdit;
  328. void handleClick( int ID );
  329. void updateVehicleTab( int mouseX, int mouseY, bool bLOS );
  330. void renderVehicleTab();
  331. void RenderObjectives();
  332. void renderResults();
  333. void handleVehicleClick( int ID );
  334. void renderHelpText();
  335. void renderInfoTab();
  336. void renderChatText();
  337. void initStatics( FitIniFile& file );
  338. void initRects( FitIniFile& file );
  339. void renderPlayerStatus( float delta);
  340. MPStatsEntry mpStats[9];
  341. bool chatIsTeamOnly;
  342. bool bServerWarningShown;
  343. public:
  344. RectInfo *getRect (long id)
  345. {
  346. if ((id >= 0) && (id < rectCount))
  347. {
  348. return &(rectInfos[id]);
  349. }
  350. if (id == RPTOTAL_CALLOUT)
  351. {
  352. return &rpCallout;
  353. }
  354. return NULL;
  355. }
  356. };
  357. //*************************************************************************************************
  358. #endif // end of file ( ControlGui.h )