Interface Control.c 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  1. #ifdef PRECOMPILEDHEADERS
  2. #include "Tactical All.h"
  3. #else
  4. #include <stdio.h>
  5. #include <stdarg.h>
  6. #include <time.h>
  7. #include "sgp.h"
  8. #include "gameloop.h"
  9. #include "himage.h"
  10. #include "vobject.h"
  11. #include "sysutil.h"
  12. #include "overhead.h"
  13. #include "mousesystem.h"
  14. #include "Button System.h"
  15. #include "interface.h"
  16. #include "vsurface.h"
  17. #include "wcheck.h"
  18. #include "input.h"
  19. #include "Handle UI.h"
  20. #include "Animation Control.h"
  21. #include "Animation Data.h"
  22. #include "renderworld.h"
  23. #include "sys globals.h"
  24. #include "cursors.h"
  25. #include "radar screen.h"
  26. #include "worldman.h"
  27. #include "Font Control.h"
  28. #include "render dirty.h"
  29. #include "utilities.h"
  30. #include "interface cursors.h"
  31. #include "Sound Control.h"
  32. #include "lighting.h"
  33. #include "Interface Panels.h"
  34. #include "pathai.h"
  35. #include "vobject_blitters.h"
  36. #include "faces.h"
  37. #include "Handle UI Plan.h"
  38. #include "interface control.h"
  39. #include "interface items.h"
  40. #include "interface dialogue.h"
  41. #include "interactive tiles.h"
  42. #include "Game Clock.h"
  43. #include "Strategic Exit GUI.h"
  44. #include "PopUpBox.h"
  45. #include "Assignments.h"
  46. #include "spread burst.h"
  47. #include "squads.h"
  48. #include "line.h"
  49. #endif
  50. #define CLOCK_X 554
  51. #define CLOCK_Y 459
  52. SGPRect gOldClippingRect, gOldDirtyClippingRect;
  53. UINT32 guiTacticalInterfaceFlags;
  54. UINT16 gusUICurIntTileEffectIndex;
  55. INT16 gsUICurIntTileEffectGridNo;
  56. UINT8 gsUICurIntTileOldShade;
  57. BOOLEAN gfRerenderInterfaceFromHelpText = FALSE;
  58. MOUSE_REGION gLockPanelOverlayRegion;
  59. extern void RenderTownIDString( );
  60. extern BOOLEAN gfUIOverItemPool;
  61. extern INT16 gfUIOverItemPoolGridNo;
  62. extern BOOLEAN gfInMovementMenu;
  63. extern BOOLEAN gfInItemPickupMenu;
  64. extern BOOLEAN gfInOpenDoorMenu;
  65. extern UINT32 guiUIMessageTimeDelay;
  66. BOOLEAN gfPausedTacticalRenderInterfaceFlags = FALSE;
  67. BOOLEAN gfPausedTacticalRenderFlags = FALSE;
  68. // which assignment menu can be shown?
  69. extern void DetermineWhichAssignmentMenusCanBeShown( void );
  70. extern void HandleAnyMercInSquadHasCompatibleStuff( UINT8 ubSquad, OBJECTTYPE *pObject, BOOLEAN fReset );
  71. extern BOOLEAN RemoveFlashItemSlot( ITEM_POOL *pItemPool );
  72. void SetTacticalInterfaceFlags( UINT32 uiFlags )
  73. {
  74. guiTacticalInterfaceFlags = uiFlags;
  75. }
  76. void HandleTacticalPanelSwitch( )
  77. {
  78. if ( gfSwitchPanel )
  79. {
  80. SetCurrentInterfacePanel( gbNewPanel );
  81. SetCurrentTacticalPanelCurrentMerc( gubNewPanelParam );
  82. gfSwitchPanel = FALSE;
  83. if ( (!guiTacticalInterfaceFlags & INTERFACE_NORENDERBUTTONS ) && !( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) )
  84. {
  85. RenderButtons( );
  86. }
  87. }
  88. }
  89. void RenderTacticalInterface( )
  90. {
  91. // handle paused render of tactical
  92. HandlePausedTacticalRender( );
  93. if ( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  94. {
  95. HandleFlashingItems( );
  96. HandleMultiPurposeLocator( );
  97. }
  98. // Handle degrading new items...
  99. DegradeNewlyAddedItems( );
  100. switch( gsCurInterfacePanel )
  101. {
  102. case SM_PANEL:
  103. RenderSMPanel( &fInterfacePanelDirty );
  104. break;
  105. case TEAM_PANEL:
  106. RenderTEAMPanel( fInterfacePanelDirty );
  107. break;
  108. }
  109. // Handle faces
  110. if( !(guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) )
  111. HandleAutoFaces( );
  112. }
  113. void HandlePausedTacticalRender( void )
  114. {
  115. // for a one frame paused render of tactical
  116. if( gfPausedTacticalRenderFlags )
  117. {
  118. gRenderFlags|=gfPausedTacticalRenderFlags;
  119. gfPausedTacticalRenderFlags = FALSE;
  120. }
  121. if ( gfPausedTacticalRenderInterfaceFlags )
  122. {
  123. fInterfacePanelDirty = gfPausedTacticalRenderInterfaceFlags;
  124. gfPausedTacticalRenderInterfaceFlags = FALSE;
  125. }
  126. return;
  127. }
  128. void RenderTacticalInterfaceWhileScrolling( )
  129. {
  130. RenderButtons( );
  131. switch( gsCurInterfacePanel )
  132. {
  133. case SM_PANEL:
  134. RenderSMPanel( &fInterfacePanelDirty );
  135. break;
  136. case TEAM_PANEL:
  137. RenderTEAMPanel( fInterfacePanelDirty );
  138. break;
  139. }
  140. // Handle faces
  141. HandleAutoFaces( );
  142. }
  143. void SetUpInterface( )
  144. {
  145. SOLDIERTYPE *pSoldier;
  146. LEVELNODE *pIntTile;
  147. if ( ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  148. {
  149. return;
  150. }
  151. DrawUICursor( );
  152. SetupPhysicsTrajectoryUI( );
  153. if ( giUIMessageOverlay != -1 )
  154. {
  155. if ( ( GetJA2Clock( ) - guiUIMessageTime ) > guiUIMessageTimeDelay )
  156. {
  157. EndUIMessage( );
  158. }
  159. }
  160. if ( gusSelectedSoldier != NO_SOLDIER )
  161. {
  162. GetSoldier( &pSoldier, gusSelectedSoldier );
  163. }
  164. if ( gCurrentUIMode == OPENDOOR_MENU_MODE )
  165. {
  166. HandleOpenDoorMenu( );
  167. }
  168. HandleTalkingMenu( );
  169. if ( gCurrentUIMode == EXITSECTORMENU_MODE )
  170. {
  171. HandleSectorExitMenu( );
  172. }
  173. // FOR THE MOST PART - SHUTDOWN INTERFACE WHEN IT'S THE ENEMY'S TURN
  174. if ( gTacticalStatus.ubCurrentTeam != gbPlayerNum )
  175. {
  176. return;
  177. }
  178. HandleInterfaceBackgrounds( );
  179. if ( gfUIHandleSelection == NONSELECTED_GUY_SELECTION )
  180. {
  181. if ( gsSelectedLevel > 0 )
  182. {
  183. AddRoofToHead( gsSelectedGridNo, GOODRING1 );
  184. gpWorldLevelData[gsSelectedGridNo].pRoofHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  185. gpWorldLevelData[gsSelectedGridNo].pRoofHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  186. }
  187. else
  188. {
  189. AddObjectToHead( gsSelectedGridNo, GOODRING1 );
  190. gpWorldLevelData[gsSelectedGridNo].pObjectHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  191. gpWorldLevelData[gsSelectedGridNo].pObjectHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  192. }
  193. }
  194. if ( gfUIHandleSelection == SELECTED_GUY_SELECTION )
  195. {
  196. if ( gsSelectedLevel > 0 )
  197. {
  198. //AddRoofToHead( gsSelectedGridNo, SELRING1 );
  199. AddRoofToHead( gsSelectedGridNo, FIRSTPOINTERS2 );
  200. gpWorldLevelData[gsSelectedGridNo].pRoofHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  201. gpWorldLevelData[gsSelectedGridNo].pRoofHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  202. }
  203. else
  204. {
  205. //AddObjectToHead( gsSelectedGridNo, SELRING1 );
  206. AddObjectToHead( gsSelectedGridNo, FIRSTPOINTERS2 );
  207. gpWorldLevelData[gsSelectedGridNo].pObjectHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  208. gpWorldLevelData[gsSelectedGridNo].pObjectHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  209. }
  210. }
  211. if ( gfUIHandleSelection == ENEMY_GUY_SELECTION )
  212. {
  213. if ( gsSelectedLevel > 0 )
  214. {
  215. AddRoofToHead( gsSelectedGridNo, FIRSTPOINTERS2 );
  216. gpWorldLevelData[gsSelectedGridNo].pRoofHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  217. gpWorldLevelData[gsSelectedGridNo].pRoofHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  218. }
  219. else
  220. {
  221. AddObjectToHead( gsSelectedGridNo, FIRSTPOINTERS2 );
  222. gpWorldLevelData[gsSelectedGridNo].pObjectHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  223. gpWorldLevelData[gsSelectedGridNo].pObjectHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  224. }
  225. }
  226. if ( gfUIHandleShowMoveGrid )
  227. {
  228. if ( gusSelectedSoldier != NOBODY )
  229. {
  230. if ( MercPtrs[ gusSelectedSoldier ]->sGridNo != gsUIHandleShowMoveGridLocation )
  231. {
  232. if ( gfUIHandleShowMoveGrid == 2 )
  233. {
  234. AddTopmostToHead( gsUIHandleShowMoveGridLocation, GetSnapCursorIndex( FIRSTPOINTERS4 ) );
  235. gpWorldLevelData[gsUIHandleShowMoveGridLocation].pTopmostHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  236. gpWorldLevelData[gsUIHandleShowMoveGridLocation].pTopmostHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  237. }
  238. else
  239. {
  240. if ( MercPtrs[ gusSelectedSoldier ]->bStealthMode )
  241. {
  242. AddTopmostToHead( gsUIHandleShowMoveGridLocation, GetSnapCursorIndex( FIRSTPOINTERS9 ) );
  243. gpWorldLevelData[gsUIHandleShowMoveGridLocation].pTopmostHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  244. gpWorldLevelData[gsUIHandleShowMoveGridLocation].pTopmostHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  245. }
  246. else
  247. {
  248. AddTopmostToHead( gsUIHandleShowMoveGridLocation, GetSnapCursorIndex( FIRSTPOINTERS2 ) );
  249. gpWorldLevelData[gsUIHandleShowMoveGridLocation].pTopmostHead->ubShadeLevel=DEFAULT_SHADE_LEVEL;
  250. gpWorldLevelData[gsUIHandleShowMoveGridLocation].pTopmostHead->ubNaturalShadeLevel=DEFAULT_SHADE_LEVEL;
  251. }
  252. }
  253. }
  254. }
  255. }
  256. // Check if we are over an interactive tile...
  257. if ( gfUIShowCurIntTile )
  258. {
  259. pIntTile = GetCurInteractiveTileGridNo( &gsUICurIntTileEffectGridNo );
  260. if ( pIntTile != NULL )
  261. {
  262. gusUICurIntTileEffectIndex = pIntTile->usIndex;
  263. // Shade green
  264. gsUICurIntTileOldShade = pIntTile->ubShadeLevel;
  265. pIntTile->ubShadeLevel = 0;
  266. pIntTile->uiFlags |= LEVELNODE_DYNAMIC;
  267. }
  268. }
  269. }
  270. void ResetInterface( )
  271. {
  272. LEVELNODE *pNode;
  273. if ( ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  274. {
  275. return;
  276. }
  277. // find out if we need to show any menus
  278. DetermineWhichAssignmentMenusCanBeShown();
  279. CreateDestroyAssignmentPopUpBoxes( );
  280. HideUICursor( );
  281. ResetPhysicsTrajectoryUI( );
  282. if ( gfUIHandleSelection )
  283. {
  284. if ( gsSelectedLevel > 0 )
  285. {
  286. RemoveRoof( gsSelectedGridNo, GOODRING1 );
  287. RemoveRoof( gsSelectedGridNo, FIRSTPOINTERS2 );
  288. }
  289. else
  290. {
  291. RemoveObject( gsSelectedGridNo, FIRSTPOINTERS2 );
  292. RemoveObject( gsSelectedGridNo, GOODRING1 );
  293. }
  294. }
  295. if ( gfUIHandleShowMoveGrid )
  296. {
  297. RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS4 );
  298. RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS9 );
  299. RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS2 );
  300. RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS13 );
  301. RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS15 );
  302. RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS19 );
  303. RemoveTopmost( gsUIHandleShowMoveGridLocation, FIRSTPOINTERS20 );
  304. }
  305. if ( fInterfacePanelDirty )
  306. {
  307. fInterfacePanelDirty = FALSE;
  308. }
  309. // Reset int tile cursor stuff
  310. if ( gfUIShowCurIntTile )
  311. {
  312. if ( gsUICurIntTileEffectGridNo != NOWHERE )
  313. {
  314. //Find our tile!
  315. pNode = gpWorldLevelData[ gsUICurIntTileEffectGridNo].pStructHead;
  316. while( pNode != NULL )
  317. {
  318. if ( pNode->usIndex == gusUICurIntTileEffectIndex )
  319. {
  320. pNode->ubShadeLevel = gsUICurIntTileOldShade;
  321. pNode->uiFlags &= (~LEVELNODE_DYNAMIC);
  322. break;
  323. }
  324. pNode = pNode->pNext;
  325. }
  326. }
  327. }
  328. }
  329. extern BOOLEAN AnyItemsVisibleOnLevel( ITEM_POOL *pItemPool, INT8 bZLevel );
  330. UINT32 guiColors[ 12 ] =
  331. {
  332. FROMRGB( 198, 163, 0 ),
  333. FROMRGB( 185, 150, 0 ),
  334. FROMRGB( 172, 136, 0 ),
  335. FROMRGB( 159, 123, 0 ),
  336. FROMRGB( 146, 110, 0 ),
  337. FROMRGB( 133, 96, 0 ),
  338. FROMRGB( 120, 83, 0 ),
  339. FROMRGB( 133, 96, 0 ),
  340. FROMRGB( 146, 110, 0 ),
  341. FROMRGB( 159, 123, 0 ),
  342. FROMRGB( 172, 136, 0 ),
  343. FROMRGB( 185, 150, 0 )
  344. };
  345. void RenderRubberBanding( )
  346. {
  347. UINT16 usLineColor;
  348. UINT32 uiDestPitchBYTES;
  349. UINT8 *pDestBuf;
  350. INT16 iLeft, iRight, iTop, iBottom;
  351. INT32 iBack = -1;
  352. static INT32 iFlashColor = 0;
  353. static INT32 uiTimeOfLastUpdate = 0;
  354. if ( !gRubberBandActive )
  355. return;
  356. iLeft = (INT16)gRubberBandRect.iLeft;
  357. iRight = (INT16)gRubberBandRect.iRight;
  358. iTop = (INT16)gRubberBandRect.iTop;
  359. iBottom = (INT16)gRubberBandRect.iBottom;
  360. if ( iLeft == iRight && iTop == iBottom )
  361. {
  362. return;
  363. }
  364. if ( ( GetJA2Clock( ) - uiTimeOfLastUpdate ) > 60 )
  365. {
  366. uiTimeOfLastUpdate = GetJA2Clock( );
  367. iFlashColor++;
  368. if ( iFlashColor == 12 )
  369. {
  370. iFlashColor = 0;
  371. }
  372. }
  373. // Draw rectangle.....
  374. pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
  375. SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, gsVIEWPORT_END_X, gsVIEWPORT_WINDOW_END_Y );
  376. usLineColor = Get16BPPColor( guiColors[ iFlashColor ] );
  377. if ( ( iRight - iLeft ) > 0 )
  378. {
  379. LineDraw( TRUE, iLeft, iTop, iRight, iTop, usLineColor, pDestBuf );
  380. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iLeft, iTop, (INT16)( iRight + 1 ), (INT16)( iTop + 1 ) );
  381. }
  382. else if ( ( iRight - iLeft ) < 0 )
  383. {
  384. LineDraw( TRUE, iLeft, iTop, iRight, iTop, usLineColor, pDestBuf );
  385. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iRight, iTop, (INT16)( iLeft + 1 ), (INT16)( iTop + 1 ) );
  386. }
  387. if ( iBack != -1 )
  388. {
  389. SetBackgroundRectFilled( iBack );
  390. }
  391. iBack = -1;
  392. if ( ( iRight - iLeft ) > 0 )
  393. {
  394. LineDraw( TRUE, iLeft, iBottom, iRight, iBottom, usLineColor, pDestBuf );
  395. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iLeft, iBottom, (INT16)( iRight +1 ), (INT16)( iBottom + 1 ) );
  396. }
  397. else if ( ( iRight - iLeft ) < 0 )
  398. {
  399. LineDraw( TRUE, iLeft, iBottom, iRight, iBottom, usLineColor, pDestBuf );
  400. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iRight, iBottom, (INT16)( iLeft + 1 ), (INT16)( iBottom + 1 ) );
  401. }
  402. if ( iBack != -1 )
  403. {
  404. SetBackgroundRectFilled( iBack );
  405. }
  406. iBack = -1;
  407. if ( ( iBottom - iTop ) > 0 )
  408. {
  409. LineDraw( TRUE, iLeft, iTop, iLeft, iBottom, usLineColor, pDestBuf );
  410. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iLeft, iTop, (INT16)( iLeft +1 ), iBottom );
  411. }
  412. else if ( ( iBottom - iTop ) < 0 )
  413. {
  414. LineDraw( TRUE, iLeft, iTop, iLeft, iBottom, usLineColor, pDestBuf );
  415. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iLeft, iBottom, (INT16)( iLeft + 1 ), iTop );
  416. }
  417. if ( iBack != -1 )
  418. {
  419. SetBackgroundRectFilled( iBack );
  420. }
  421. iBack = -1;
  422. if ( ( iBottom - iTop ) > 0 )
  423. {
  424. LineDraw( TRUE, iRight, iTop, iRight, iBottom, usLineColor, pDestBuf );
  425. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iRight, iTop, (INT16)( iRight +1 ), iBottom );
  426. }
  427. else if ( ( iBottom - iTop ) < 0 )
  428. {
  429. LineDraw( TRUE, iRight, iTop, iRight, iBottom, usLineColor, pDestBuf );
  430. iBack = RegisterBackgroundRect( BGND_FLAG_SINGLE, NULL, iRight, iBottom, (INT16)( iRight + 1 ), iTop );
  431. }
  432. if ( iBack != -1 )
  433. {
  434. SetBackgroundRectFilled( iBack );
  435. }
  436. UnLockVideoSurface( FRAME_BUFFER );
  437. }
  438. void RenderTopmostTacticalInterface( )
  439. {
  440. SOLDIERTYPE *pSoldier;
  441. UINT32 cnt;
  442. static UINT32 uiBogTarget = 0;
  443. VOBJECT_DESC VObjectDesc;
  444. INT16 sX, sY;
  445. INT16 sOffsetX, sOffsetY, sTempY_S, sTempX_S;
  446. UINT16 usMapPos;
  447. ITEM_POOL *pItemPool;
  448. if ( gfRerenderInterfaceFromHelpText == TRUE )
  449. {
  450. fInterfacePanelDirty = DIRTYLEVEL2;
  451. switch( gsCurInterfacePanel )
  452. {
  453. case SM_PANEL:
  454. RenderSMPanel( &fInterfacePanelDirty );
  455. break;
  456. case TEAM_PANEL:
  457. RenderTEAMPanel( fInterfacePanelDirty );
  458. break;
  459. }
  460. gfRerenderInterfaceFromHelpText = FALSE;
  461. }
  462. if ( ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) )
  463. {
  464. if ( !(guiTacticalInterfaceFlags & INTERFACE_NORENDERBUTTONS ) )
  465. {
  466. // If we want to rederaw whole screen, dirty all buttons!
  467. if ( fInterfacePanelDirty == DIRTYLEVEL2 )
  468. {
  469. MarkButtonsDirty( );
  470. }
  471. RenderButtons( );
  472. }
  473. return;
  474. }
  475. if ( InItemStackPopup( ) )
  476. {
  477. if ( fInterfacePanelDirty == DIRTYLEVEL2 )
  478. {
  479. RenderItemStackPopup( TRUE );
  480. }
  481. else
  482. {
  483. RenderItemStackPopup( FALSE );
  484. }
  485. }
  486. if( ( InKeyRingPopup() ) && ( !InItemDescriptionBox( ) ) )
  487. {
  488. RenderKeyRingPopup( ( BOOLEAN )( fInterfacePanelDirty == DIRTYLEVEL2 ) );
  489. }
  490. if ( gfInMovementMenu )
  491. {
  492. RenderMovementMenu( );
  493. }
  494. // if IN PLAN MODE AND WE HAVE TARGETS, draw black targets!
  495. if ( InUIPlanMode( ) )
  496. {
  497. // Zero out any planned soldiers
  498. for( cnt = MAX_NUM_SOLDIERS; cnt < TOTAL_SOLDIERS; cnt++ )
  499. {
  500. if ( MercPtrs[ cnt ]->bActive )
  501. {
  502. if ( MercPtrs[ cnt ]->sPlannedTargetX != -1 )
  503. {
  504. // Blit bogus target
  505. if ( uiBogTarget == 0 )
  506. {
  507. //Loadup cursor!
  508. VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
  509. FilenameForBPP( "CURSORS\\targblak.sti", VObjectDesc.ImageFile);
  510. AddVideoObject( &VObjectDesc, &uiBogTarget );
  511. }
  512. if ( GridNoOnScreen( (INT16)MAPROWCOLTOPOS( ( MercPtrs[ cnt ]->sPlannedTargetY/CELL_Y_SIZE), ( MercPtrs[ cnt ]->sPlannedTargetX / CELL_X_SIZE ) ) ) )
  513. {
  514. // GET SCREEN COORDINATES
  515. sOffsetX = (MercPtrs[ cnt ]->sPlannedTargetX - gsRenderCenterX);
  516. sOffsetY = (MercPtrs[ cnt ]->sPlannedTargetY - gsRenderCenterY);
  517. FromCellToScreenCoordinates( sOffsetX, sOffsetY, &sTempX_S, &sTempY_S );
  518. sX = ( ( gsVIEWPORT_END_X - gsVIEWPORT_START_X ) /2 ) + sTempX_S;
  519. sY = ( ( gsVIEWPORT_END_Y - gsVIEWPORT_START_Y ) /2 ) + sTempY_S;
  520. // Adjust for offset position on screen
  521. sX -= gsRenderWorldOffsetX;
  522. sY -= gsRenderWorldOffsetY;
  523. sX -= 10;
  524. sY -= 10;
  525. BltVideoObjectFromIndex( FRAME_BUFFER, uiBogTarget, 0, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL );
  526. InvalidateRegion( sX, sY, sX + 20, sY + 20 );
  527. }
  528. }
  529. }
  530. }
  531. }
  532. if ( gfUIInDeadlock )
  533. {
  534. SetFont( LARGEFONT1 );
  535. SetFontBackground( FONT_MCOLOR_BLACK );
  536. SetFontForeground( FONT_MCOLOR_WHITE );
  537. gprintfdirty( 0, 300, L"OPPONENT %d DEADLOCKED - 'Q' TO DEBUG, <ALT><ENTER> END OPP TURN", gUIDeadlockedSoldier );
  538. mprintf( 0, 300, L"OPPONENT %d DEADLOCKED - 'Q' TO DEBUG, <ALT><ENTER> END OPP TURN", gUIDeadlockedSoldier );
  539. }
  540. // Syncronize for upcoming soldier counters
  541. SYNCTIMECOUNTER( );
  542. // Setup system for video overlay ( text and blitting ) Sets clipping rects, etc
  543. StartViewportOverlays( );
  544. RenderTopmostFlashingItems( );
  545. RenderTopmostMultiPurposeLocator( );
  546. RenderAccumulatedBurstLocations( );
  547. // Loop through all mercs and make go
  548. for ( cnt = 0; cnt < guiNumMercSlots; cnt++ )
  549. {
  550. pSoldier = MercSlots[ cnt ];
  551. if (pSoldier != NULL )
  552. {
  553. if ( pSoldier->ubID == gsSelectedGuy && gfUIHandleSelectionAboveGuy )
  554. {
  555. }
  556. else
  557. {
  558. DrawSelectedUIAboveGuy((UINT16)pSoldier->ubID);
  559. }
  560. if ( pSoldier->fDisplayDamage )
  561. {
  562. // Display damage
  563. // Use world coordinates!
  564. INT16 sMercScreenX, sMercScreenY, sOffsetX, sOffsetY, sDamageX, sDamageY;
  565. if ( pSoldier->sGridNo != NOWHERE && pSoldier->bVisible != -1 )
  566. {
  567. GetSoldierScreenPos( pSoldier, &sMercScreenX, &sMercScreenY );
  568. GetSoldierAnimOffsets( pSoldier, &sOffsetX, &sOffsetY );
  569. if ( pSoldier->ubBodyType == QUEENMONSTER )
  570. {
  571. sDamageX = sMercScreenX + pSoldier->sDamageX - pSoldier->sBoundingBoxOffsetX;
  572. sDamageY = sMercScreenY + pSoldier->sDamageY - pSoldier->sBoundingBoxOffsetY;
  573. sDamageX += 25;
  574. sDamageY += 10;
  575. }
  576. else
  577. {
  578. sDamageX = pSoldier->sDamageX + (INT16)(sMercScreenX + ( 2 * 30 / 3 ) );
  579. sDamageY = pSoldier->sDamageY + (INT16)(sMercScreenY - 5 );
  580. sDamageX -= sOffsetX;
  581. sDamageY -= sOffsetY;
  582. if ( sDamageY < gsVIEWPORT_WINDOW_START_Y )
  583. {
  584. sDamageY = ( sMercScreenY - sOffsetY );
  585. }
  586. }
  587. SetFont( TINYFONT1 );
  588. SetFontBackground( FONT_MCOLOR_BLACK );
  589. SetFontForeground( FONT_MCOLOR_WHITE );
  590. gprintfdirty( sDamageX, sDamageY, L"-%d", pSoldier->sDamage );
  591. mprintf( sDamageX, sDamageY, L"-%d", pSoldier->sDamage );
  592. }
  593. }
  594. }
  595. }
  596. if ( gusSelectedSoldier != NOBODY )
  597. {
  598. DrawSelectedUIAboveGuy( gusSelectedSoldier );
  599. }
  600. if ( gfUIHandleSelectionAboveGuy && gsSelectedGuy != NOBODY )
  601. {
  602. DrawSelectedUIAboveGuy((UINT16)gsSelectedGuy );
  603. }
  604. // FOR THE MOST PART, DISABLE INTERFACE STUFF WHEN IT'S ENEMY'S TURN
  605. if ( gTacticalStatus.ubCurrentTeam == gbPlayerNum )
  606. {
  607. RenderArrows( );
  608. }
  609. RenderAimCubeUI( );
  610. EndViewportOverlays( );
  611. RenderRubberBanding( );
  612. if ( !gfInItemPickupMenu && gpItemPointer == NULL )
  613. {
  614. HandleAnyMercInSquadHasCompatibleStuff( (INT8) CurrentSquad( ), NULL, TRUE );
  615. }
  616. // CHECK IF OUR CURSOR IS OVER AN INV POOL
  617. if( GetMouseMapPos( &usMapPos) )
  618. {
  619. if ( gfUIOverItemPool )
  620. {
  621. if( GetSoldier( &pSoldier, gusSelectedSoldier ) )
  622. {
  623. // Check if we are over an item pool
  624. if ( GetItemPool( gfUIOverItemPoolGridNo, &pItemPool, pSoldier->bLevel ) )
  625. {
  626. STRUCTURE *pStructure = NULL;
  627. INT16 sIntTileGridNo;
  628. INT8 bZLevel = 0;
  629. INT16 sActionGridNo = usMapPos;
  630. // Get interactive tile...
  631. if ( ConditionalGetCurInteractiveTileGridNoAndStructure( &sIntTileGridNo , &pStructure, FALSE ) )
  632. {
  633. sActionGridNo = sIntTileGridNo;
  634. }
  635. bZLevel = GetZLevelOfItemPoolGivenStructure( sActionGridNo, pSoldier->bLevel, pStructure );
  636. if ( AnyItemsVisibleOnLevel( pItemPool, bZLevel ) )
  637. {
  638. DrawItemPoolList( pItemPool, gfUIOverItemPoolGridNo , ITEMLIST_DISPLAY, bZLevel, gusMouseXPos, gusMouseYPos );
  639. // ATE: If over items, remove locator....
  640. RemoveFlashItemSlot( pItemPool );
  641. }
  642. }
  643. else
  644. {
  645. INT8 bCheckLevel;
  646. // ATE: Allow to see list if a different level....
  647. if ( pSoldier->bLevel == 0 )
  648. {
  649. bCheckLevel = 1;
  650. }
  651. else
  652. {
  653. bCheckLevel = 0;
  654. }
  655. // Check if we are over an item pool
  656. if ( GetItemPool( gfUIOverItemPoolGridNo, &pItemPool, bCheckLevel ) )
  657. {
  658. STRUCTURE *pStructure = NULL;
  659. INT16 sIntTileGridNo;
  660. INT8 bZLevel = 0;
  661. INT16 sActionGridNo = usMapPos;
  662. // Get interactive tile...
  663. if ( ConditionalGetCurInteractiveTileGridNoAndStructure( &sIntTileGridNo , &pStructure, FALSE ) )
  664. {
  665. sActionGridNo = sIntTileGridNo;
  666. }
  667. bZLevel = GetZLevelOfItemPoolGivenStructure( sActionGridNo, bCheckLevel, pStructure );
  668. if ( AnyItemsVisibleOnLevel( pItemPool, bZLevel ) )
  669. {
  670. DrawItemPoolList( pItemPool, gfUIOverItemPoolGridNo , ITEMLIST_DISPLAY, bZLevel, gusMouseXPos, gusMouseYPos );
  671. // ATE: If over items, remove locator....
  672. RemoveFlashItemSlot( pItemPool );
  673. }
  674. }
  675. }
  676. }
  677. }
  678. }
  679. // Check if we should render item selection window
  680. if ( gCurrentUIMode == GETTINGITEM_MODE )
  681. {
  682. SetItemPickupMenuDirty( DIRTYLEVEL2 );
  683. // Handle item pickup will return true if it's been closed
  684. RenderItemPickupMenu( );
  685. }
  686. // Check if we should render item selection window
  687. if ( gCurrentUIMode == OPENDOOR_MENU_MODE )
  688. {
  689. RenderOpenDoorMenu( );
  690. }
  691. if ( gfInTalkPanel )
  692. {
  693. SetTalkingMenuDirty( DIRTYLEVEL2 );
  694. // Handle item pickup will return true if it's been closed
  695. RenderTalkingMenu( );
  696. }
  697. if ( gfInSectorExitMenu )
  698. {
  699. RenderSectorExitMenu( );
  700. }
  701. if( fRenderRadarScreen == TRUE )
  702. {
  703. // Render clock
  704. RenderClock( CLOCK_X, CLOCK_Y );
  705. RenderTownIDString( );
  706. CreateMouseRegionForPauseOfClock( CLOCK_REGION_START_X, CLOCK_REGION_START_Y );
  707. }
  708. else
  709. {
  710. RemoveMouseRegionForPauseOfClock( );
  711. }
  712. if ( !(guiTacticalInterfaceFlags & INTERFACE_NORENDERBUTTONS ) )
  713. {
  714. // If we want to rederaw whole screen, dirty all buttons!
  715. if ( fInterfacePanelDirty == DIRTYLEVEL2 )
  716. {
  717. MarkButtonsDirty( );
  718. }
  719. RenderButtons( );
  720. RenderPausedGameBox( );
  721. }
  722. // mark all pop ups as dirty
  723. MarkAllBoxesAsAltered( );
  724. HandleShowingOfTacticalInterfaceFastHelpText( );
  725. HandleShadingOfLinesForAssignmentMenus( );
  726. DetermineBoxPositions( );
  727. DisplayBoxes( FRAME_BUFFER );
  728. }
  729. void StartViewportOverlays( )
  730. {
  731. // Set Clipping Rect to be the viewscreen
  732. // Save old one
  733. memcpy( &gOldClippingRect, &ClippingRect, sizeof( gOldClippingRect ) );
  734. // Save old dirty clipping rect
  735. memcpy( &gOldDirtyClippingRect, &ClippingRect, sizeof( gOldDirtyClippingRect ) );
  736. // Set bottom clipping value for blitter clipping rect
  737. ClippingRect.iLeft = INTERFACE_START_X;
  738. ClippingRect.iTop = gsVIEWPORT_WINDOW_START_Y;
  739. ClippingRect.iRight = 640;
  740. ClippingRect.iBottom = gsVIEWPORT_WINDOW_END_Y;
  741. // Set values for dirty rect clipping rect
  742. gDirtyClipRect.iLeft = INTERFACE_START_X;
  743. gDirtyClipRect.iTop = gsVIEWPORT_WINDOW_START_Y;
  744. gDirtyClipRect.iRight = 640;
  745. gDirtyClipRect.iBottom = gsVIEWPORT_WINDOW_END_Y;
  746. SaveFontSettings( );
  747. SetFontDestBuffer( FRAME_BUFFER, 0, gsVIEWPORT_WINDOW_START_Y, 640, gsVIEWPORT_WINDOW_END_Y, FALSE );
  748. }
  749. void EndViewportOverlays( )
  750. {
  751. // Reset clipping rect
  752. memcpy( &ClippingRect, &gOldClippingRect, sizeof( gOldClippingRect ) );
  753. memcpy( &gDirtyClipRect, &gOldDirtyClippingRect, sizeof( gOldDirtyClippingRect ) );
  754. RestoreFontSettings( );
  755. }
  756. void LockTacticalInterface( )
  757. {
  758. // OK, check and see if we are not locked, if so
  759. // 1) create a mouse region over the entrie interface panel
  760. // 2) set flag for use in tactical to indicate we are locked
  761. if ( !(guiTacticalInterfaceFlags & INTERFACE_LOCKEDLEVEL1 ) )
  762. {
  763. MSYS_DefineRegion( &gLockPanelOverlayRegion, 0, gsVIEWPORT_WINDOW_END_Y ,640, 480, MSYS_PRIORITY_HIGHEST,
  764. CURSOR_NORMAL, MSYS_NO_CALLBACK, MSYS_NO_CALLBACK );
  765. // Add region
  766. MSYS_AddRegion( &gLockPanelOverlayRegion);
  767. guiTacticalInterfaceFlags |= INTERFACE_LOCKEDLEVEL1;
  768. }
  769. }
  770. void UnLockTacticalInterface( )
  771. {
  772. if ( (guiTacticalInterfaceFlags & INTERFACE_LOCKEDLEVEL1 ) )
  773. {
  774. // Remove region
  775. MSYS_RemoveRegion( &gLockPanelOverlayRegion);
  776. guiTacticalInterfaceFlags &= (~INTERFACE_LOCKEDLEVEL1);
  777. }
  778. }
  779. void EraseInterfaceMenus( BOOLEAN fIgnoreUIUnLock )
  780. {
  781. // ATE: If we are currently talking, setup this flag so that the
  782. // automatic handler in handledialogue doesn't adjust the UI setting
  783. if ( ( gTacticalStatus.uiFlags & ENGAGED_IN_CONV ) && fIgnoreUIUnLock )
  784. {
  785. gTacticalStatus.uiFlags |= IGNORE_ENGAGED_IN_CONV_UI_UNLOCK;
  786. }
  787. // Remove item pointer if one active
  788. CancelItemPointer( );
  789. ShutDownQuoteBoxIfActive( );
  790. PopDownMovementMenu( );
  791. PopDownOpenDoorMenu( );
  792. DeleteTalkingMenu( );
  793. }
  794. BOOLEAN AreWeInAUIMenu( )
  795. {
  796. if ( gfInMovementMenu || gfInOpenDoorMenu || gfInItemPickupMenu || gfInSectorExitMenu || gfInTalkPanel )
  797. {
  798. return( TRUE );
  799. }
  800. else
  801. {
  802. return( FALSE );
  803. }
  804. }
  805. void ResetInterfaceAndUI( )
  806. {
  807. // Erase menus
  808. EraseInterfaceMenus( FALSE );
  809. EraseRenderArrows( );
  810. EndRubberBanding( );
  811. //ResetMultiSelection( );
  812. if ( giUIMessageOverlay != -1 )
  813. {
  814. RemoveVideoOverlay( giUIMessageOverlay );
  815. giUIMessageOverlay = -1;
  816. }
  817. // Set UI back to movement...
  818. guiPendingOverrideEvent = M_ON_TERRAIN;
  819. HandleTacticalUI( );
  820. }
  821. BOOLEAN InterfaceOKForMeanwhilePopup()
  822. {
  823. if ( gfSwitchPanel )
  824. {
  825. return( FALSE );
  826. }
  827. return( TRUE );
  828. }