1 #ifndef MAP_SCREEN_INTERFACE_H
2 #define MAP_SCREEN_INTERFACE_H
3 
4 #include "MessageBoxScreen.h"
5 #include "MouseSystem.h"
6 #include "ScreenIDs.h"
7 #include "Soldier_Control.h"
8 #include "Types.h"
9 #include "UILayout.h"
10 #include <string_theory/string>
11 
12 class SGPVObject;
13 class SGPVSurface;
14 struct GROUP;
15 struct OBJECTTYPE;
16 
17 
18 // char breath and life position
19 #define BAR_INFO_X (STD_SCREEN_X + 66)
20 #define BAR_INFO_Y (STD_SCREEN_Y + 61)
21 
22 // merc icon position
23 #define CHAR_ICON_CONTRACT_Y (STD_SCREEN_Y + 64)
24 #define CHAR_ICON_X (STD_SCREEN_X + 187)
25 #define CHAR_ICON_WIDTH 10
26 #define CHAR_ICON_HEIGHT 10
27 #define CHAR_ICON_SPACING 13
28 
29 // max number of characters
30 //Character List Length
31 #define MAX_CHARACTER_COUNT 20
32 
33 // map screen font
34 #define MAP_SCREEN_FONT BLOCKFONT2
35 
36 // characterlist regions
37 #define Y_START               (STD_SCREEN_Y + 146)
38 #define MAP_START_KEYRING_Y   (STD_SCREEN_Y + 107)
39 #define Y_SIZE                GetFontHeight(MAP_SCREEN_FONT)
40 
41 
42 // attribute menu defines (must match NUM_TRAINABLE_STATS defines, and pAttributeMenuStrings )
43 enum {
44 	ATTRIB_MENU_STR=0,
45 	ATTRIB_MENU_DEX,
46 	ATTRIB_MENU_AGI,
47 	ATTRIB_MENU_HEA,
48 	ATTRIB_MENU_MARK,
49 	ATTRIB_MENU_MED,
50 	ATTRIB_MENU_MECH,
51 	ATTRIB_MENU_LEAD,
52 	ATTRIB_MENU_EXPLOS,
53 	ATTRIB_MENU_CANCEL,
54 	MAX_ATTRIBUTE_STRING_COUNT,
55 };
56 
57 // the epc assignment menu
58 enum{
59 	EPC_MENU_ON_DUTY = 0,
60 	EPC_MENU_PATIENT,
61 	EPC_MENU_VEHICLE,
62 	EPC_MENU_REMOVE,
63 	EPC_MENU_CANCEL,
64 	MAX_EPC_MENU_STRING_COUNT,
65 };
66 
67 // assignment menu defines
68 enum {
69 	ASSIGN_MENU_ON_DUTY=0,
70 	ASSIGN_MENU_DOCTOR,
71 	ASSIGN_MENU_PATIENT,
72 	ASSIGN_MENU_VEHICLE,
73 	ASSIGN_MENU_REPAIR,
74 	ASSIGN_MENU_TRAIN,
75 	ASSIGN_MENU_CANCEL,
76 	MAX_ASSIGN_STRING_COUNT,
77 };
78 
79 
80 // training assignment menu defines
81 enum {
82 	TRAIN_MENU_SELF,
83 	TRAIN_MENU_TOWN,
84 	TRAIN_MENU_TEAMMATES,
85 	TRAIN_MENU_TRAIN_BY_OTHER,
86 	TRAIN_MENU_CANCEL,
87 	MAX_TRAIN_STRING_COUNT,
88 };
89 
90 
91 // the remove merc from team pop up box strings
92 enum{
93 	REMOVE_MERC = 0,
94 	REMOVE_MERC_CANCEL,
95 	MAX_REMOVE_MERC_COUNT,
96 };
97 
98 
99 // squad menu defines
100 enum{
101 	SQUAD_MENU_1,
102 	SQUAD_MENU_2,
103 	SQUAD_MENU_3,
104 	SQUAD_MENU_4,
105 	SQUAD_MENU_5,
106 	SQUAD_MENU_6,
107 	SQUAD_MENU_7,
108 	SQUAD_MENU_8,
109 	SQUAD_MENU_9,
110 	SQUAD_MENU_10,
111 	SQUAD_MENU_11,
112 	SQUAD_MENU_12,
113 	SQUAD_MENU_13,
114 	SQUAD_MENU_14,
115 	SQUAD_MENU_15,
116 	SQUAD_MENU_16,
117 	SQUAD_MENU_17,
118 	SQUAD_MENU_18,
119 	SQUAD_MENU_19,
120 	SQUAD_MENU_20,
121 	SQUAD_MENU_CANCEL,
122 	MAX_SQUAD_MENU_STRING_COUNT,
123 };
124 
125 
126 // contract menu defines
127 enum{
128 	CONTRACT_MENU_CURRENT_FUNDS = 0,
129 	CONTRACT_MENU_SPACE,
130 	CONTRACT_MENU_DAY,
131 	CONTRACT_MENU_WEEK,
132 	CONTRACT_MENU_TWO_WEEKS,
133 	CONTRACT_MENU_TERMINATE,
134 	CONTRACT_MENU_CANCEL,
135 	MAX_CONTRACT_MENU_STRING_COUNT,
136 };
137 
138 
139 enum UpdateBoxReason
140 {
141 	NO_REASON_FOR_UPDATE = 0,
142 	CONTRACT_FINISHED_FOR_UPDATE,
143 	ASSIGNMENT_FINISHED_FOR_UPDATE,
144 	ASSIGNMENT_RETURNING_FOR_UPDATE,
145 	ASLEEP_GOING_AUTO_FOR_UPDATE,
146 	CONTRACT_EXPIRE_WARNING_REASON,
147 };
148 
149 
150 // dimensions and offset for merc update box
151 #define UPDATE_MERC_FACE_X_WIDTH 50
152 #define UPDATE_MERC_FACE_X_HEIGHT 50
153 #define UPDATE_MERC_FACE_X_OFFSET 2
154 #define UPDATE_MERC_FACE_Y_OFFSET 2
155 #define WIDTH_OF_UPDATE_PANEL_BLOCKS  50
156 #define HEIGHT_OF_UPDATE_PANEL_BLOCKS 50
157 #define UPDATE_MERC_Y_OFFSET 4
158 #define UPDATE_MERC_X_OFFSET 4
159 
160 
161 // dimensions and offset for merc update box
162 #define TACT_UPDATE_MERC_FACE_X_WIDTH 70
163 #define TACT_UPDATE_MERC_FACE_X_HEIGHT 49
164 #define TACT_UPDATE_MERC_FACE_X_OFFSET 8
165 #define TACT_UPDATE_MERC_FACE_Y_OFFSET 6
166 #define TACT_WIDTH_OF_UPDATE_PANEL_BLOCKS  70
167 #define TACT_HEIGHT_OF_UPDATE_PANEL_BLOCKS 49
168 #define TACT_UPDATE_MERC_Y_OFFSET 4
169 #define TACT_UPDATE_MERC_X_OFFSET 4
170 
171 
172 // the first vehicle slot int he list
173 #define FIRST_VEHICLE 18
174 
175 
176 extern BOOLEAN fShowAssignmentMenu;
177 extern BOOLEAN fShowTrainingMenu ;
178 extern BOOLEAN fShowAttributeMenu;
179 extern BOOLEAN fShowSquadMenu ;
180 extern BOOLEAN fShowContractMenu ;
181 
182 // The character data structure
183 struct MapScreenCharacterSt
184 {
185 	SOLDIERTYPE* merc;
186 	BOOLEAN      selected;
187 };
188 
189 
190 // map screen character structure list, contrains soldier ids into menptr
191 extern MapScreenCharacterSt gCharactersList[ ];
192 
193 #define BASE_FOR_EACH_IN_CHAR_LIST(type, iter)                                               \
194 	for (type* iter = gCharactersList; iter != gCharactersList + MAX_CHARACTER_COUNT; ++iter) \
195 		if (Assert(iter->merc == NULL || iter->merc->bActive), iter->merc == NULL) continue; else
196 #define FOR_EACH_IN_CHAR_LIST(iter)  BASE_FOR_EACH_IN_CHAR_LIST(      MapScreenCharacterSt, iter)
197 #define CFOR_EACH_IN_CHAR_LIST(iter) BASE_FOR_EACH_IN_CHAR_LIST(const MapScreenCharacterSt, iter)
198 
199 #define BASE_FOR_EACH_SELECTED_IN_CHAR_LIST(type, iter)                                      \
200 	for (type* iter = gCharactersList; iter != gCharactersList + MAX_CHARACTER_COUNT; ++iter) \
201 		if (Assert(!iter->selected || iter->merc != NULL), Assert(iter->merc == NULL || iter->merc->bActive), !iter->selected) continue; else
202 #define FOR_EACH_SELECTED_IN_CHAR_LIST(iter)  BASE_FOR_EACH_SELECTED_IN_CHAR_LIST(      MapScreenCharacterSt, iter)
203 #define CFOR_EACH_SELECTED_IN_CHAR_LIST(iter) BASE_FOR_EACH_SELECTED_IN_CHAR_LIST(const MapScreenCharacterSt, iter)
204 
205 
206 // highlighted lines
207 extern INT32 giHighLine;
208 extern INT32 giAssignHighLine;
209 extern INT32 giDestHighLine;
210 extern INT32 giContractHighLine;
211 extern INT32 giSleepHighLine;
212 
213 extern SGPVObject* guiUpdatePanelTactical;
214 extern BOOLEAN fShowUpdateBox;
215 
216 #define ContractPosition                (g_ui.m_contractPosition)
217 #define AttributePosition               (g_ui.m_attributePosition)
218 #define TrainPosition                   (g_ui.m_trainPosition)
219 #define VehiclePosition                 (g_ui.m_vehiclePosition)
220 #define RepairPosition                  (g_ui.m_repairPosition)
221 #define AssignmentPosition              (g_ui.m_assignmentPosition )
222 #define SquadPosition                   (g_ui.m_squadPosition )
223 
224 // disble team info panel due to showing of battle roster
225 extern BOOLEAN fDisableDueToBattleRoster;
226 
227 extern BOOLEAN gfAtLeastOneMercWasHired;
228 
229 // curtrent map sector z that is being displayed in the mapscreen
230 extern INT32 iCurrentMapSectorZ;
231 
232 // y position of the pop up box
233 extern INT32 giBoxY;
234 
235 // pop up box textures
236 extern SGPVSurface* guiPOPUPTEX;
237 extern SGPVObject* guiPOPUPBORDERS;
238 
239 extern BOOLEAN fShowMapScreenMovementList;
240 
241 // do we need to rebuild the mapscreen characterlist?
242 extern BOOLEAN fReBuildCharacterList;
243 
244 // init vehicle and characters list
245 void InitalizeVehicleAndCharacterList( void );
246 
247 // set this entry to as selected
248 void SetEntryInSelectedCharacterList( INT8 bEntry );
249 // set this entry to as unselected
250 void ResetEntryForSelectedList( INT8 bEntry );
251 
252 // reset selected list
253 void ResetSelectedListForMapScreen(void);
254 
255 // build a selected list from a to b, inclusive
256 void BuildSelectedListFromAToB( INT8 bA, INT8 bB );
257 
258 // isa this entry int he selected character list set?
259 BOOLEAN IsEntryInSelectedListSet( INT8 bEntry );
260 
261 // is there more than one person selected?
262 BOOLEAN MultipleCharacterListEntriesSelected( void );
263 
264 // toggle this entry on or off
265 void ToggleEntryInSelectedList( INT8 bEntry );
266 
267 void ResetAssignmentsForMercsTrainingUnpaidSectorsInSelectedList();
268 
269 void RestoreBackgroundForAssignmentGlowRegionList( void );
270 void RestoreBackgroundForDestinationGlowRegionList( void );
271 void RestoreBackgroundForContractGlowRegionList( void );
272 void RestoreBackgroundForSleepGlowRegionList( void );
273 
274 // play click when we are entering a glow region
275 void PlayGlowRegionSound( void );
276 
277 // is this character in the action of plotting a path?
278 BOOLEAN CharacterIsGettingPathPlotted(INT16 sCharNumber);
279 
280 // disable team info panels
281 void DisableTeamInfoPanels( void );
282 
283 // enable team info panels
284 void EnableTeamInfoPanels( void );
285 
286 // do mapscreen message box
287 void DoMapMessageBox(MessageBoxStyleID ubStyle, const ST::string& str, ScreenID uiExitScreen, MessageBoxFlags usFlags, MSGBOX_CALLBACK ReturnCallback);
288 
289 // hop up one leve,l int he map screen level interface
290 void GoUpOneLevelInMap( void );
291 
292 // go down one level in the mapscreen map interface
293 void GoDownOneLevelInMap( void );
294 
295 // jump to this level on the map
296 void JumpToLevel( INT32 iLevel );
297 
298 // check to see if we need to update the screen
299 void CheckAndUpdateBasedOnContractTimes( void );
300 
301 // Display a red arrow by the name of each selected merc
302 void HandleDisplayOfSelectedMercArrows();
303 
304 // check which guys can move with this guy
305 void DeselectSelectedListMercsWhoCantMoveWithThisGuy(const SOLDIERTYPE* s);
306 
307 // get morale string for this grunt given this morale level
308 ST::string GetMoraleString(SOLDIERTYPE const& s);
309 
310 // handle leaving of equipment in sector
311 void HandleLeavingOfEquipmentInCurrentSector(SOLDIERTYPE&);
312 
313 // set up a linked list of items being dropped and post an event to later drop them
314 void HandleMercLeavingEquipment(SOLDIERTYPE&, bool in_drassen);
315 
316 // actually drop the stored list of items
317 void HandleEquipmentLeftInOmerta( UINT32 uiSlotIndex );
318 void HandleEquipmentLeftInDrassen( UINT32 uiSlotIndex );
319 
320 // init/shutdown leave item lists
321 void InitLeaveList( void );
322 void ShutDownLeaveList( void );
323 
324 // add item to leave equip index
325 void AddItemToLeaveIndex(const OBJECTTYPE* o, UINT32 uiIndex);
326 
327 // handle a group about to arrive in a sector
328 void HandleGroupAboutToArrive( void );
329 
330 
331 // create and destroy the status bars mouse region
332 void CreateMapStatusBarsRegion( void );
333 void RemoveMapStatusBarsRegion( void );
334 void UpdateCharRegionHelpText( void );
335 
336 // find this soldier in mapscreen character list and set as contract
337 void FindAndSetThisContractSoldier( SOLDIERTYPE *pSoldier );
338 
339 // lose the cursor, re-render
340 void HandleMAPUILoseCursorFromOtherScreen( void );
341 
342 void RenderMapRegionBackground( void );
343 
344 // update mapscreen assignment positions
345 void UpdateMapScreenAssignmentPositions( void );
346 
347 // get the umber of valid mercs in the mapscreen character list
348 INT32 GetNumberOfPeopleInCharacterList( void );
349 
350 // the next and previous people in the mapscreen
351 void GoToPrevCharacterInList( void );
352 void GoToNextCharacterInList( void );
353 
354 // this does the whole miner giving player info speil
355 void HandleMinerEvent(ProfileID ubMinerProfileID, INT16 sQuoteNumber, BOOLEAN fForceMapscreen);
356 
357 void TurnOnSectorLocator( UINT8 ubProfileID );
358 void TurnOffSectorLocator(void);
359 
360 extern INT16 gsSectorLocatorX;
361 extern INT16 gsSectorLocatorY;
362 extern UINT8 gubBlitSectorLocatorCode;
363 
364 enum
365 {
366 	LOCATOR_COLOR_NONE,
367 	LOCATOR_COLOR_RED,
368 	LOCATOR_COLOR_YELLOW
369 };
370 
371 void HandleBlitOfSectorLocatorIcon( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ, UINT8 ubLocatorID );
372 
373 
374 // the tactical version
375 
376 // handle the actual showingof the list
377 void HandleShowingOfTacticalInterfaceFastHelpText( void );
378 
379 // start showing the list
380 void StartShowingInterfaceFastHelpText( void );
381 
382 // is the list active?
383 BOOLEAN IsTheInterfaceFastHelpTextActive( void );
384 
385 /* This will setup a fast help text region that is unrelated to mouse regions.
386  * The user is to pass in the x,y position of the box, the width to wrap the
387  * string and the string itself */
388 void SetUpFastHelpRegion(INT32 x, INT32 y, INT32 width, const ST::string& str);
389 
390 
391 // reset assignment for mercs trainign militia in this sector
392 void ResetAssignmentOfMercsThatWereTrainingMilitiaInThisSector( INT16 sSectorX, INT16 sSectorY );
393 
394 
395 // the sector move box
396 void CreateDestroyMovementBox( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ );
397 void SetUpMovingListsForSector(INT16 x, INT16 y, INT16 z);
398 void ReBuildMoveBox( void );
399 BOOLEAN IsCharacterSelectedForAssignment( INT16 sCharNumber );
400 BOOLEAN IsCharacterSelectedForSleep( INT16 sCharNumber );
401 
402 // the update box
403 void CreateDestroyTheUpdateBox( void );
404 void DisplaySoldierUpdateBox(void);
405 
406 
407 // Set up the timers for the move menu in mapscreen for double click detection.
408 void InitTimersForMoveMenuMouseRegions();
409 
410 // the screen mask
411 void CreateScreenMaskForMoveBox( void );
412 void RemoveScreenMaskForMoveBox( void );
413 
414 
415 // help text to show user merc has insurance
416 void UpdateHelpTextForMapScreenMercIcons( void );
417 void CreateDestroyInsuranceMouseRegionForMercs( BOOLEAN fCreate );
418 
419 
420 // stuff to deal with player just starting the game
421 BOOLEAN HandleTimeCompressWithTeamJackedInAndGearedToGo( void );
422 
423 // handle sector being taken over uncontested
424 void NotifyPlayerWhenEnemyTakesControlOfImportantSector(INT16 x, INT16 y, INT8 z);
425 
426 // handle notifying player of invasion by enemy
427 void NotifyPlayerOfInvasionByEnemyForces( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, MSGBOX_CALLBACK ReturnCallback );
428 
429 void ShutDownUserDefineHelpTextRegions( void );
430 
431 // add special events
432 void AddSoldierToWaitingListQueue(SOLDIERTYPE&);
433 void AddReasonToWaitingListQueue(UpdateBoxReason);
434 void AddDisplayBoxToWaitingQueue( void );
435 
436 enum MoveError
437 {
438 	ME_CUSTOM          = -99,
439 	ME_OK              =   0,
440 	ME_UNDERGROUND     =   1,
441 	ME_ENEMY           =   2,
442 	ME_BUSY            =   3,
443 	ME_POW             =   5,
444 	ME_TRANSIT         =   8,
445 	ME_AIR_RAID        =  10, /** unused **/
446 	ME_COMBAT          =  11,
447 	ME_VEHICLE_EMPTY   =  32,
448 	ME_MUSEUM          =  34,
449 	ME_VEHICLE_NO_GAS  =  42,
450 	ME_VEHICLE_DAMAGED =  47,
451 	ME_ROBOT_ALONE     =  49
452 };
453 
454 // can this group move it out
455 MoveError CanEntireMovementGroupMercIsInMove(SOLDIERTYPE&);
456 void ReportMapScreenMovementError( INT8 bErrorNumber );
457 
458 void HandleRebuildingOfMapScreenCharacterList( void );
459 
460 void RequestToggleTimeCompression( void );
461 void RequestIncreaseInTimeCompression( void );
462 void RequestDecreaseInTimeCompression( void );
463 
464 void SelectUnselectedMercsWhoMustMoveWithThisGuy( void );
465 
466 void LoadLeaveItemList(HWFILE);
467 void SaveLeaveItemList(HWFILE);
468 
469 BOOLEAN CheckIfSalaryIncreasedAndSayQuote( SOLDIERTYPE *pSoldier, BOOLEAN fTriggerContractMenu );
470 
471 void EndUpdateBox( BOOLEAN fContinueTimeCompression );
472 
473 BOOLEAN MapscreenCanPassItemToChar(const SOLDIERTYPE*);
474 
475 INT32 GetNumberOfMercsInUpdateList();
476 
477 extern MOUSE_REGION gMapStatusBarsRegion;
478 
479 void RandomMercInGroupSaysQuote(GROUP const&, UINT16 quote_num);
480 
481 void MakeDialogueEventShowContractMenu(SOLDIERTYPE&);
482 
483 void LoadMapScreenInterfaceGraphics();
484 void DeleteMapScreenInterfaceGraphics();
485 
486 #endif
487