MAPEDIT.H 11 KB

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