MAPEDIT.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/MAPEDIT.H 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : MAPEDIT.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : May 14, 1994 *
  26. * *
  27. * Last Update : May 14, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * This class is derived from the normal display map class. It exists *
  31. * only to allow editing and adding items to the map. *
  32. *---------------------------------------------------------------------------------------------*
  33. * House-setting functions: The editor contains several house maintenance routines: *
  34. * Verify_House: tells if the given ObjectType can be owned by the given HousesType *
  35. * Cycle_House: Finds the next valid house for the given ObjectType; used when a new object *
  36. * can't be owned by the current editor HousesType. *
  37. * Change_House: attempts to change the owner of the currently-selected object *
  38. * Toggle_House: cycles the HousesType of a pending placement object *
  39. * Set_House_Buttons: sets house buttons in accordance with the given HousesType *
  40. *---------------------------------------------------------------------------------------------*
  41. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  42. #ifndef MAPEDIT_H
  43. #define MAPEDIT_H
  44. #include "function.h"
  45. /*
  46. ** This is the maximum # of ObjectTypeClasses the editor has to deal with.
  47. */
  48. enum MapEdit1Enum {
  49. MAX_EDIT_OBJECTS = // max # of ObjectTypeClasses allowed
  50. (int)TEMPLATE_COUNT +
  51. (int)OVERLAY_COUNT +
  52. (int)SMUDGE_COUNT +
  53. (int)TERRAIN_COUNT +
  54. (int)UNIT_COUNT +
  55. (int)INFANTRY_COUNT +
  56. (int)VESSEL_COUNT +
  57. (int)STRUCT_COUNT,
  58. MAX_TEAM_CLASSES = // max # ObjectTypeClasses for a team
  59. (int)UNIT_COUNT +
  60. (int)INFANTRY_COUNT +
  61. (int)AIRCRAFT_COUNT,
  62. // NUM_EDIT_MISSIONS = 6, // # missions that can be assigned an object
  63. NUM_EDIT_CLASSES = 9, // # different classes (templates, terrain, etc)
  64. MAX_MAIN_MENU_NUM = 8,
  65. MAX_MAIN_MENU_LEN = 20,
  66. MAX_AI_MENU_NUM = 6,
  67. MAX_AI_MENU_LEN = 20,
  68. POPUP_HOUSE_X=10,
  69. POPUP_HOUSE_Y=100,
  70. POPUP_HOUSE_W=60,
  71. POPUP_HOUSE_H=(190-100),
  72. // POPUP_GDI_W = 50,
  73. // POPUP_GDI_H = 9,
  74. // POPUP_GDI_X = 10,
  75. // POPUP_GDI_Y = 160,
  76. // POPUP_NOD_W = 50,
  77. // POPUP_NOD_H = 9,
  78. // POPUP_NOD_X = 10,
  79. // POPUP_NOD_Y = 169,
  80. // POPUP_NEUTRAL_W = 50,
  81. // POPUP_NEUTRAL_H = 9,
  82. // POPUP_NEUTRAL_X = 10,
  83. // POPUP_NEUTRAL_Y = 178,
  84. // POPUP_MULTI1_W = 25,
  85. // POPUP_MULTI1_H = 9,
  86. // POPUP_MULTI1_X = 10,
  87. // POPUP_MULTI1_Y = 160,
  88. // POPUP_MULTI2_W = 25,
  89. // POPUP_MULTI2_H = 9,
  90. // POPUP_MULTI2_X = 35,
  91. // POPUP_MULTI2_Y = 160,
  92. // POPUP_MULTI3_W = 25,
  93. // POPUP_MULTI3_H = 9,
  94. // POPUP_MULTI3_X = 10,
  95. // POPUP_MULTI3_Y = 169,
  96. // POPUP_MULTI4_W = 25,
  97. // POPUP_MULTI4_H = 9,
  98. // POPUP_MULTI4_X = 35,
  99. // POPUP_MULTI4_Y = 169,
  100. POPUP_MISSION_W = 80,
  101. POPUP_MISSION_H = 40,
  102. POPUP_MISSION_X = 70,
  103. POPUP_MISSION_Y = 150,
  104. POPUP_FACEBOX_W = 30,
  105. POPUP_FACEBOX_H = 30,
  106. POPUP_FACEBOX_X = 160,
  107. POPUP_FACEBOX_Y = 160,
  108. POPUP_HEALTH_W = 50,
  109. POPUP_HEALTH_H = 10,
  110. POPUP_HEALTH_X = 200,
  111. POPUP_HEALTH_Y = 170,
  112. POPUP_BASE_W = 50,
  113. POPUP_BASE_H = 8,
  114. POPUP_BASE_X = 300 - 50,
  115. POPUP_BASE_Y = 0
  116. };
  117. /*
  118. ** These are the button ID's for the pop-up object-editing gizmos.
  119. ** The house button ID's must be sequential, with a 1-to-1 correspondence to
  120. ** the HousesType values.
  121. */
  122. enum MapEditButtonIDEnum{
  123. POPUP_SPAIN=500,
  124. POPUP_FIRST=POPUP_SPAIN,
  125. POPUP_GREECE,
  126. POPUP_USSR,
  127. POPUP_ENGLAND,
  128. POPUP_ITALY,
  129. POPUP_GERMANY,
  130. POPUP_FRANCE,
  131. POPUP_TURKEY,
  132. POPUP_HOUSELIST, // House selection list.
  133. POPUP_SELLABLE, // Allowed to sell.
  134. POPUP_REBUILDABLE, // Allowed to rebuild.
  135. POPUP_MISSIONLIST, // list box for missions
  136. POPUP_HEALTHGAUGE, // health of object
  137. POPUP_FACINGDIAL, // object's facing
  138. POPUP_BASEPERCENT, // Base's percent-built slider
  139. MAP_AREA, // map as a click-able thingy
  140. BUTTON_FLAG=0x8000
  141. };
  142. class TeamTypeClass;
  143. class MapEditClass : public MouseClass
  144. {
  145. /*
  146. ** Public Interface
  147. */
  148. public:
  149. /*
  150. ** mapedit.cpp
  151. */
  152. MapEditClass(void);
  153. MapEditClass(NoInitClass const & x) : MouseClass(x) {};
  154. bool Get_Waypoint_Name(char wayptname[]);
  155. void Update_Waypoint(int waypt_index);
  156. virtual void One_Time(void); // One-time init
  157. virtual void Init_IO(void); // Inits button list
  158. virtual void AI(KeyNumType &input, int x, int y);
  159. virtual void Draw_It(bool forced = true);
  160. virtual bool Scroll_Map(DirType facing, int & distance, bool really=true);
  161. virtual void Read_INI(CCINIClass & ini);
  162. virtual void Write_INI(CCINIClass & ini);
  163. virtual void Detach(ObjectClass * object);
  164. void Detach(TARGET target, bool all=true) {MouseClass::Detach(target, all);}
  165. void Clear_List(void);
  166. bool Add_To_List(ObjectTypeClass const *object);
  167. void Main_Menu(void);
  168. void AI_Menu(void);
  169. bool Mouse_Moved(void);
  170. bool Verify_House(HousesType house, ObjectTypeClass const * objtype);
  171. HousesType Cycle_House(HousesType curhouse, ObjectTypeClass const * objtype);
  172. // int Trigger_Needs_Team(TriggerClass *trigger);
  173. void Fatal(int txt);
  174. /*
  175. ** mapeddlg.cpp
  176. */
  177. int New_Scenario(void);
  178. int Load_Scenario(void);
  179. int Save_Scenario(void);
  180. int Pick_Scenario(char const * caption, int & scen_nump, ScenarioPlayerType & playerp, ScenarioDirType & dirp, ScenarioVarType & varp);
  181. int Size_Map(int x, int y, int w, int h);
  182. int Scenario_Dialog(void);
  183. void Handle_Triggers(void);
  184. int Select_Trigger(void);
  185. /*
  186. ** mapedplc.cpp
  187. */
  188. int Placement_Dialog(void);
  189. void Start_Placement(void);
  190. int Place_Object(void);
  191. void Cancel_Placement(void);
  192. void Place_Next(void);
  193. void Place_Prev(void);
  194. void Place_Next_Category(void);
  195. void Place_Prev_Category(void);
  196. void Place_Home(void);
  197. void Toggle_House(void);
  198. void Set_House_Buttons(HousesType house, GadgetClass *btnlist, int base_id);
  199. void Start_Trigger_Placement(void);
  200. void Stop_Trigger_Placement(void);
  201. void Place_Trigger(void);
  202. void Start_Base_Building(void);
  203. void Cancel_Base_Building(void);
  204. void Build_Base_To(int percent);
  205. /*
  206. ** mapedsel.cpp
  207. */
  208. int Select_Object(void);
  209. void Select_Next(void);
  210. void Popup_Controls(void);
  211. void Grab_Object(void);
  212. int Move_Grabbed_Object(void);
  213. bool Change_House(HousesType newhouse);
  214. /*
  215. ** mapedtm.cpp
  216. */
  217. void Draw_Member(TechnoTypeClass const * ptr, int index, int quant, HousesType house);
  218. void Handle_Teams(char const * caption);
  219. int Select_Team(char const * caption);
  220. int Team_Members(HousesType house);
  221. /*
  222. ** Private Interface
  223. */
  224. private:
  225. /*
  226. ** This is the last-requested variation of a loaded/saved/new scenario.
  227. */
  228. // ScenarioVarType ScenVar;
  229. /*
  230. ** Array of all TypeClasses the user can add to the map; cleared by
  231. ** Clear_List(), added to by Add_To_List()
  232. */
  233. ObjectTypeClass const * Objects[MAX_EDIT_OBJECTS];
  234. int ObjCount; // # of objects in the Objects array
  235. /*
  236. ** Last-selected object to place, and last-selected house of object
  237. */
  238. int LastChoice; // index of item user picked last
  239. HousesType LastHouse; // house of last item picked
  240. /*
  241. ** Variables for grabbing/moving objects
  242. */
  243. ObjectClass * GrabbedObject; // object "grabbed" with mouse
  244. CELL GrabOffset; // offset to grabbed obj's upper-left
  245. unsigned long LastClickTime; // time of last LMOUSE click
  246. /*
  247. ** Number of each type of object in Objects, so we can switch categories
  248. */
  249. int NumType[NUM_EDIT_CLASSES]; // # of each type of class:
  250. // 0 = Template
  251. // 1 = Overlay
  252. // 2 = Smudge
  253. // 3 = Terrain
  254. // 4 = Unit
  255. // 5 = Infantry
  256. // 6 = Vessels
  257. // 7 = Building
  258. // 8 = Aircraft
  259. /*
  260. ** The offset of each type of object within the Objects[] array
  261. */
  262. int TypeOffset[NUM_EDIT_CLASSES]; // offsets within Objects[]
  263. /*
  264. ** The "current" trigger for point-and-click trigger setting
  265. */
  266. TriggerTypeClass * CurTrigger; // current trigger
  267. /*
  268. ** The "current" team type for editing & associating with a trigger
  269. */
  270. TeamTypeClass * CurTeam; // current team
  271. /*
  272. ** Bitfields for flags & such
  273. */
  274. unsigned Changed : 1; // 1 = changes are unsaved
  275. unsigned LMouseDown : 1; // 1 = left mouse is held down
  276. unsigned BaseBuilding : 1; // 1 = we're in base-building mode
  277. /*
  278. ** Variables for pre-building a base
  279. */
  280. // int BasePercent; // Percentage the base will be built
  281. /*
  282. ** Variables for supporting the object-editing controls at screen bottom
  283. */
  284. ListClass * HouseList;
  285. ListClass * MissionList;
  286. TriColorGaugeClass *HealthGauge;
  287. Dial8Class *FacingDial;
  288. ControlClass *MapArea;
  289. TextLabelClass *HealthText;
  290. TextButtonClass * Sellable;
  291. TextButtonClass * Rebuildable;
  292. static char HealthBuf[20];
  293. GaugeClass *BaseGauge;
  294. TextLabelClass *BaseLabel;
  295. static MissionType MapEditMissions[];
  296. };
  297. #endif