CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

MAPEDIT.H (13863B)


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