RADAR.CPP 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960
  1. /*
  2. ** Command & Conquer(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: F:\projects\c&c\vcs\code\radar.cpv 2.17 16 Oct 1995 16:49:28 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 : RADAR.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 12/15/94 *
  30. * *
  31. * Last Update : November 17, 1995 [PWG] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * Get_Multi_Color -- Get the multi color offset number *
  36. * RadarClass::AI -- Processes radar input (non-tactical). *
  37. * RadarClass::Cell_On_Radar -- Determines if a cell is currently visible on radar. *
  38. * RadarClass::Click_Cell_Calc -- Determines what cell the pixel coordinate is over. *
  39. * RadarClass::Click_In_Radar -- Check to see if a click is in radar map *
  40. * RadarClass::Click_In_Radar -- Converts a radar click into cell X and Y coordinate. *
  41. * RadarClass::Draw_It -- Displays the radar map of the terrain. *
  42. * RadarClass::Draw_Names -- draws players' names on the radar map *
  43. * RadarClass::Init_Clear -- Sets the radar map to a known state *
  44. * RadarClass::Map_Cell -- Updates radar map when a cell becomes mapped. *
  45. * RadarClass::One_Time -- Handles one time processing for the radar map. *
  46. * RadarClass::Player_Names -- toggles the Player-Names mode of the radar map *
  47. * RadarClass::Plot_Radar_Pixel -- Updates the radar map with a terrain pixel. *
  48. * RadarClass::RadarClass -- Default constructor for RadarClass object. *
  49. * RadarClass::Radar_Activate -- Controls radar activation. *
  50. * RadarClass::Radar_Anim -- Renders current frame of radar animation *
  51. * RadarClass::Radar_Cursor -- Adjust the position of the radar map cursor. *
  52. * RadarClass::Radar_Pixel -- Mark a cell to be rerendered on the radar map. *
  53. * RadarClass::Radar_Position -- Returns with the current position of the radar map. *
  54. * RadarClass::Refresh_Cells -- Intercepts refresh request and updates radar if needed *
  55. * RadarClass::Render_Infantry -- Displays objects on the radar map. *
  56. * RadarClass::Render_Overlay -- Renders an icon for given overlay *
  57. * RadarClass::Render_Terrain -- Render the terrain over the given cell *
  58. * RadarClass::Set_Map_Dimensions -- Sets the tactical map dimensions. *
  59. * RadarClass::Set_Radar_Position -- Sets the radar map coordinates. *
  60. * RadarClass::Set_Radar_Position -- Sets the radar position to center around specified cell.*
  61. * RadarClass::Set_Tactical_Position -- Called when setting the tactical display position. *
  62. * RadarClass::Set_Tactical_Position -- Called when setting the tactical display position. *
  63. * RadarClass::TacticalClass::Action -- I/O function for the radar map. *
  64. * RadarClass::Zoom_Mode(void) -- Handles toggling zoom on the map *
  65. * RadarClass::Set_Tactical_Position -- Sets the map's tactical position and adjusts radar to*
  66. * RadarClass::Coord_To_Radar_Pixel -- Converts a coordinate to a radar pixel position *
  67. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  68. #include "function.h"
  69. #include <stdlib.h>
  70. //void const * RadarClass::CoverShape;
  71. RadarClass::TacticalClass RadarClass::RadarButton;
  72. void const * RadarClass::RadarAnim = NULL;
  73. static bool FullRedraw = false;
  74. #define _MAX_NAME 13
  75. static GraphicBufferClass _IconStage(3,3);
  76. static GraphicBufferClass _TileStage(24,24);
  77. /***********************************************************************************************
  78. * RadarClass::RadarClass -- Default constructor for RadarClass object. *
  79. * *
  80. * This default constructor merely sets the radar specific values to default settings. The *
  81. * radar must be deliberately activated in order for it to be displayed. *
  82. * *
  83. * INPUT: none *
  84. * *
  85. * OUTPUT: none *
  86. * *
  87. * WARNINGS: none *
  88. * *
  89. * HISTORY: *
  90. * 12/16/1994 JLB : Created. *
  91. *=============================================================================================*/
  92. RadarClass::RadarClass(void)
  93. {
  94. IsZoomed = true;
  95. IsRadarActive = false;
  96. IsToRedraw = false;
  97. RadarCursorRedraw = false;
  98. PixelPtr = 0;
  99. SpecialRadarFrame = 0;
  100. IsPlayerNames = false;
  101. }
  102. /***********************************************************************************************
  103. * RadarClass::One_Time -- Handles one time processing for the radar map. *
  104. * *
  105. * This routine handles any one time processing required in order for the radar map to *
  106. * function. This actually only requires an allocation of the radar staging buffer. This *
  107. * buffer is needed for those cases where the radar area of the page is being destroyed *
  108. * and it needs to be destroyed. *
  109. * *
  110. * INPUT: none *
  111. * *
  112. * OUTPUT: none *
  113. * *
  114. * WARNINGS: Be sure to call this routine only ONCE. *
  115. * *
  116. * HISTORY: *
  117. * 12/22/1994 JLB : Created. *
  118. *=============================================================================================*/
  119. void RadarClass::One_Time(void)
  120. {
  121. int factor = Get_Resolution_Factor();
  122. RadWidth = 80 << factor;
  123. RadHeight = 70 << factor;
  124. RadX = SeenBuff.Get_Width() - RadWidth;
  125. RadY = Map.Get_Tab_Height() - (1 << factor);
  126. RadPWidth = 64 << factor;
  127. RadPHeight = 64 << factor;
  128. if ( factor ) {
  129. RadOffX = 16;
  130. RadOffY = 7;
  131. RadIWidth = 128;
  132. RadIHeight = 128;
  133. } else {
  134. RadOffX = 4 << factor;
  135. RadOffY = 1 << factor;
  136. RadIWidth = 72 << factor;
  137. RadIHeight = 69 << factor;
  138. }
  139. DisplayClass::One_Time();
  140. RadarButton.X = RadX+RadOffX;
  141. RadarButton.Y = RadY+RadOffY;
  142. RadarButton.Width = RadIWidth;
  143. RadarButton.Height = RadIHeight;
  144. }
  145. /***********************************************************************************************
  146. * RadarClass::Init_Clear -- Sets the radar map to a known state. *
  147. * *
  148. * This routine is used to initialize the radar map at the start of the scenario. It *
  149. * sets the radar map position and starts it in the disabled state. *
  150. * *
  151. * INPUT: theater -- The theater that the scenario is starting (unused by this routine). *
  152. * *
  153. * OUTPUT: none *
  154. * *
  155. * WARNINGS: none *
  156. * *
  157. * HISTORY: *
  158. * 12/22/1994 JLB : Created. *
  159. *=============================================================================================*/
  160. void RadarClass::Init_Clear(void)
  161. {
  162. DisplayClass::Init_Clear();
  163. IsRadarActive = false;
  164. IsToRedraw = true;
  165. RadarCursorRedraw = true;
  166. IsRadarActivating = false;
  167. IsRadarDeactivating = false;
  168. DoesRadarExist = false;
  169. PixelPtr = 0;
  170. IsPlayerNames = false;
  171. /*
  172. ** If we have a valid map lets make sure that we set it correctly
  173. */
  174. if (MapCellWidth || MapCellHeight) {
  175. IsZoomed = false;
  176. Zoom_Mode(Coord_Cell(Map.TacticalCoord));
  177. }
  178. }
  179. /***********************************************************************************************
  180. * RadarClass::Radar_Activate -- Controls radar activation. *
  181. * *
  182. * Use this routine to turn the radar map on or off. *
  183. * *
  184. * INPUT: control -- What to do with the radar map: *
  185. * 0 = Turn radar off. *
  186. * 1 = Turn radar on. *
  187. * 2 = Remove Radar Gadgets *
  188. * 3 = Add Radar Gadgets *
  189. * 4 = Remove radar. *
  190. * -1= Toggle radar on or off. *
  191. * *
  192. * OUTPUT: bool; Was the radar map already on? *
  193. * *
  194. * WARNINGS: none *
  195. * *
  196. * HISTORY: *
  197. * 12/11/1994 JLB : Created. *
  198. *=============================================================================================*/
  199. bool RadarClass::Radar_Activate(int control)
  200. {
  201. bool old = IsRadarActive;
  202. switch (control) {
  203. /*
  204. ** Toggle the state of the radar map on or off.
  205. */
  206. case -1:
  207. {
  208. int temp = (IsRadarActive == false);
  209. if (temp) {
  210. Radar_Activate(1);
  211. } else {
  212. Radar_Activate(0);
  213. }
  214. }
  215. break;
  216. /*
  217. ** Turn the radar map off properly.
  218. */
  219. case 0:
  220. if (Map.IsSidebarActive) {
  221. if (IsRadarActive && !IsRadarDeactivating) {
  222. Sound_Effect(VOC_RADAR_OFF);
  223. IsRadarDeactivating = true;
  224. IsRadarActive = false;
  225. if (IsRadarActivating == true) {
  226. IsRadarActivating = false;
  227. } else {
  228. RadarAnimFrame = RADAR_ACTIVATED_FRAME;
  229. }
  230. }
  231. } else {
  232. Radar_Activate(2);
  233. }
  234. return(old);
  235. case 1:
  236. if (Map.IsSidebarActive) {
  237. if (!IsRadarActivating && !IsRadarActive) {
  238. Sound_Effect(VOC_RADAR_ON);
  239. IsRadarActivating = true;
  240. if (IsRadarDeactivating == true) {
  241. IsRadarDeactivating = false;
  242. } else {
  243. if (DoesRadarExist) {
  244. RadarAnimFrame = MAX_RADAR_FRAMES;
  245. } else {
  246. RadarAnimFrame = 0;
  247. }
  248. }
  249. }
  250. } else {
  251. Radar_Activate(3);
  252. }
  253. return(old);
  254. case 2:
  255. if (GameToPlay==GAME_NORMAL) {
  256. Map.Zoom.Disable();
  257. }
  258. IsRadarActive = false;
  259. IsRadarActivating = false;
  260. IsRadarDeactivating = false;
  261. break;
  262. case 3:
  263. if (GameToPlay==GAME_NORMAL) {
  264. Map.Zoom.Enable();
  265. }
  266. IsRadarActive = true;
  267. IsRadarActivating = false;
  268. IsRadarDeactivating = false;
  269. break;
  270. case 4:
  271. IsRadarActive = false;
  272. IsRadarActivating = false;
  273. IsRadarDeactivating = false;
  274. DoesRadarExist = false;
  275. Flag_To_Redraw(false);
  276. IsToRedraw = true;
  277. break;
  278. }
  279. if (IsRadarActive != old) {
  280. IsToRedraw = true;
  281. Flag_To_Redraw(false);
  282. }
  283. FullRedraw = IsRadarActive;
  284. return(old);
  285. }
  286. /***********************************************************************************************
  287. * RadarClass::Draw_It -- Displays the radar map of the terrain. *
  288. * *
  289. * This is used to display the radar map that appears in the lower *
  290. * right corner. The main changes to this map are the vehicles and *
  291. * structure pixels. *
  292. * *
  293. * INPUT: none *
  294. * *
  295. * OUTPUT: none *
  296. * *
  297. * WARNINGS: none *
  298. * *
  299. * HISTORY: *
  300. * 04/24/1991 JLB : Created. *
  301. * 05/08/1994 JLB : Converted to member function. *
  302. *=============================================================================================*/
  303. void RadarClass::Draw_It(bool forced)
  304. {
  305. DisplayClass::Draw_It(forced);
  306. // if (!In_Debugger) while (!HidPage.Lock()) {}
  307. /*
  308. ** Don't perform any rendering if none is requested.
  309. */
  310. if (!forced && !IsToRedraw && !FullRedraw) return;
  311. static HousesType _house = HOUSE_NONE;
  312. if (PlayerPtr->ActLike != _house) {
  313. char name[_MAX_NAME + _MAX_EXT];
  314. if (Special.IsJurassic && AreThingiesEnabled) {
  315. strcpy(name, "RADAR.JP");
  316. } else {
  317. _makepath(name, NULL, NULL, "RADAR", HouseTypeClass::As_Reference(PlayerPtr->ActLike).Suffix);
  318. }
  319. RadarAnim = Hires_Retrieve(name);
  320. _house = PlayerPtr->ActLike;
  321. }
  322. /*
  323. ** If in player name mode, just draw player names
  324. */
  325. if (IsPlayerNames) {
  326. Draw_Names();
  327. IsToRedraw = false;
  328. return;
  329. }
  330. if (IsRadarActivating || IsRadarDeactivating) {
  331. Radar_Anim();
  332. IsToRedraw = false;
  333. return;
  334. }
  335. if (Map.IsSidebarActive) {
  336. if (IsRadarActive) {
  337. //HidPage.Lock();
  338. // ST 8/13/96 2:24PM
  339. //forced = true;
  340. /*
  341. ** If only a few of the radar pixels need to be redrawn, then find and redraw
  342. ** only these.
  343. */
  344. if (!forced && IsToRedraw && !FullRedraw) {
  345. IsToRedraw = false;
  346. if (PixelPtr) {
  347. /*
  348. ** Render all pixels in the "to redraw" stack.
  349. */
  350. for (int index = 0; index < PixelPtr; index++) {
  351. CELL cell = PixelStack[index];
  352. if (Cell_On_Radar(cell)) {
  353. (*this)[cell].IsPlot = false;
  354. Plot_Radar_Pixel(cell);
  355. RadarCursorRedraw |= (*this)[cell].IsRadarCursor;
  356. }
  357. }
  358. /*
  359. ** Refill the stack if there is pending pixels yet to be plotted.
  360. ** This should only process in sections for speed reasons
  361. */
  362. if (PixelPtr == PIXELSTACK) {
  363. PixelPtr = 0;
  364. for (int y = 0; y < MapCellHeight; y++) {
  365. for (int x = 0; x < MapCellWidth; x++) {
  366. CELL cell = XY_Cell(MapCellX + x, MapCellY + y);
  367. if (Cell_On_Radar(cell)) {
  368. if ((*this)[cell].IsPlot) {
  369. PixelStack[PixelPtr++] = cell;
  370. IsToRedraw = true;
  371. if (PixelPtr == PIXELSTACK) break;
  372. }
  373. }
  374. }
  375. if (PixelPtr == PIXELSTACK) break;
  376. }
  377. } else {
  378. PixelPtr = 0;
  379. }
  380. }
  381. Radar_Cursor(RadarCursorRedraw);
  382. } else {
  383. GraphicViewPortClass *oldpage = Set_Logic_Page(HidPage);
  384. // if (LogicPage->Lock()) {
  385. CC_Draw_Shape(RadarAnim, RADAR_ACTIVATED_FRAME, RadX, RadY+1, WINDOW_MAIN, SHAPE_NORMAL);
  386. if (BaseX || BaseY) {
  387. LogicPage->Fill_Rect( RadX + RadOffX,
  388. RadY + RadOffY,
  389. RadX + RadOffX + RadIWidth - 1,
  390. RadY + RadOffY + RadIHeight - 1,
  391. DKGREY);
  392. } else {
  393. LogicPage->Fill_Rect( RadX + RadOffX,
  394. RadY + RadOffY,
  395. RadX + RadOffX + RadIWidth - 1,
  396. RadY + RadOffY + RadIHeight - 1,
  397. BLACK);
  398. }
  399. /*
  400. ** Draw the entire radar map.
  401. */
  402. for (int index = 0; index < MAP_CELL_TOTAL; index++) {
  403. Plot_Radar_Pixel(index);
  404. }
  405. Radar_Cursor(true);
  406. FullRedraw = false;
  407. IsToRedraw = false;
  408. LogicPage->Unlock();
  409. if (oldpage == &SeenBuff) {
  410. Hide_Mouse();
  411. LogicPage->Blit(SeenBuff, RadX, RadY, RadX, RadY, RadWidth, RadHeight);
  412. Show_Mouse();
  413. }
  414. // Set_Logic_Page(oldpage);
  415. // }
  416. }
  417. } else {
  418. /*
  419. ** If the radar is not active, then only draw the cover plate if forced to do so.
  420. */
  421. // if (forced) {
  422. int val = (DoesRadarExist) ? MAX_RADAR_FRAMES : 0;
  423. CC_Draw_Shape(RadarAnim, val, RadX, RadY + 1, WINDOW_MAIN, SHAPE_NORMAL);
  424. FullRedraw = false;
  425. IsToRedraw = false;
  426. // }
  427. }
  428. //HidPage.Unlock();
  429. // Map.Activator.Draw_Me(true);
  430. }
  431. }
  432. /***************************************************************************
  433. * RadarClass::Render_Terrain -- Render the terrain over the given cell *
  434. * *
  435. * INPUT: *
  436. * *
  437. * OUTPUT: *
  438. * *
  439. * WARNINGS: *
  440. * *
  441. * HISTORY: *
  442. * 04/12/1995 PWG : Created. *
  443. *=========================================================================*/
  444. void RadarClass::Render_Terrain(CELL cell, int x, int y, int size)
  445. {
  446. TerrainClass *list[4];
  447. int listidx = 0;
  448. int lp,lp2;
  449. ObjectClass *obj = Map[cell].Cell_Occupier();
  450. /*
  451. ** If the cell is occupied by a terrain type, add it to the sortable
  452. ** list.
  453. */
  454. if (obj && obj->What_Am_I() == RTTI_TERRAIN)
  455. list[listidx++] = (TerrainClass *)obj;
  456. /*
  457. ** Now loop through all the occupiers and add them to the list if they
  458. ** are terrain type.
  459. */
  460. for (lp = 0; lp < 3; lp ++) {
  461. obj = Map[cell].Overlapper[lp];
  462. if (obj && obj->What_Am_I() == RTTI_TERRAIN)
  463. list[listidx++] = (TerrainClass *)obj;
  464. }
  465. /*
  466. ** If there are no entrys in our list then just get out.
  467. */
  468. if (!listidx) return;
  469. /*
  470. ** If there is terrain in this cell then draw a dark pixel to
  471. ** represent it.
  472. */
  473. if (size == 1) {
  474. LogicPage->Put_Pixel(x, y, 60);
  475. return;
  476. }
  477. /*
  478. ** Sort the list by its sort Y value so that we can render in the proper
  479. ** order.
  480. */
  481. for (lp = 0; lp < listidx - 1; lp ++) {
  482. for (lp2 = lp + 1; lp2 < listidx; lp2++) {
  483. if (list[lp]->Sort_Y() > list[lp2]->Sort_Y()) {
  484. TerrainClass *terrain = list[lp];
  485. list[lp] = list[lp2];
  486. list[lp2] = terrain;
  487. }
  488. }
  489. }
  490. /*
  491. ** loop through the list and take care of rendering the correct icon.
  492. */
  493. for (lp = 0; lp < listidx; lp ++) {
  494. unsigned char *icon = list[lp]->Radar_Icon(cell);
  495. if (!icon) continue;
  496. Buffer_To_Page(0, 0, 3, 3, icon, _IconStage);
  497. _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, ZoomFactor, ZoomFactor, TRUE, (char *)&FadingBrighten[0]);
  498. }
  499. }
  500. /***********************************************************************************************
  501. * RadarClass::Render_Infantry -- Displays objects on the radar map. *
  502. * *
  503. * This routine will display an object imagery at the location specified according to the *
  504. * condition of the specified cell. *
  505. * *
  506. * INPUT: cell -- The cell to use as reference when drawing the radar pixel. *
  507. * *
  508. * x,y -- The pixel coordinate to render the radar "pixel" at. *
  509. * *
  510. * size -- The size of the "pixel". When zoomed in, this value will be "3". *
  511. * *
  512. * OUTPUT: none *
  513. * *
  514. * WARNINGS: none *
  515. * *
  516. * HISTORY: *
  517. * 08/17/1995 JLB : Created. *
  518. *=============================================================================================*/
  519. void RadarClass::Render_Infantry(CELL cell, int x, int y, int size)
  520. {
  521. ObjectClass *obj;
  522. int xoff,yoff;
  523. obj = (ObjectClass *)Map[cell].Cell_Occupier();
  524. while (obj) {
  525. if (obj->Is_Techno() && (((TechnoClass *)obj)->Cloak != CLOAKED || ((TechnoClass *)obj)->House->Is_Ally(PlayerPtr))) {
  526. switch (obj->What_Am_I()) {
  527. case RTTI_INFANTRY:
  528. {
  529. //int divisor = 255 / ZoomFactor;
  530. int divisor = 86;
  531. if ( ZoomFactor >= 3 ) {
  532. xoff = Coord_XLepton(obj->Coord) / divisor;
  533. yoff = Coord_YLepton(obj->Coord) / divisor;
  534. if ( ZoomFactor >= 6 ) {
  535. xoff<<=1;
  536. yoff<<=1;
  537. }
  538. } else {
  539. xoff = 0;
  540. yoff = 0;
  541. }
  542. LogicPage->Put_Pixel(x+xoff, y+yoff, ((InfantryClass *)obj)->House->Class->BrightColor);
  543. }
  544. break;
  545. case RTTI_UNIT:
  546. case RTTI_AIRCRAFT:
  547. // PWG: Slowdown?
  548. //if (LogicPage->Lock()){
  549. Fat_Put_Pixel(x, y, ((UnitClass *)obj)->House->Class->BrightColor, size, *LogicPage);
  550. //LogicPage->Unlock();
  551. //}
  552. break;
  553. }
  554. }
  555. obj = obj->Next;
  556. }
  557. }
  558. /***************************************************************************
  559. * RadarClass::Render_Overlay -- Renders an icon for given overlay *
  560. * *
  561. * INPUT: *
  562. * *
  563. * OUTPUT: *
  564. * *
  565. * WARNINGS: *
  566. * *
  567. * HISTORY: *
  568. * 04/18/1995 PWG : Created. *
  569. *=========================================================================*/
  570. void RadarClass::Render_Overlay(CELL cell, int x, int y, int size)
  571. {
  572. OverlayType overlay = (*this)[cell].Overlay;
  573. if (overlay != OVERLAY_NONE) {
  574. OverlayTypeClass const * otype = &OverlayTypeClass::As_Reference(overlay);
  575. if (otype->IsRadarVisible) {
  576. unsigned char *icon = otype->Radar_Icon((*this)[cell].OverlayData);
  577. if (!icon) return;
  578. Buffer_To_Page(0, 0, 3, 3, icon, _IconStage);
  579. if (otype->IsTiberium) {
  580. _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, size, size, TRUE, (char *)&FadingGreen[0]);
  581. } else {
  582. _IconStage.Scale(*LogicPage, 0, 0, x, y, 3, 3, size, size, TRUE, (char *)&FadingBrighten[0]);
  583. }
  584. }
  585. }
  586. }
  587. /***************************************************************************
  588. * RadarClass::Zoom_Mode -- Handles toggling zoom on the map *
  589. * *
  590. * INPUT: none *
  591. * *
  592. * OUTPUT: none *
  593. * *
  594. * HISTORY: *
  595. * 05/29/1995 PWG : Created. *
  596. *=========================================================================*/
  597. void RadarClass::Zoom_Mode(CELL cell)
  598. {
  599. int map_c_width;
  600. int map_c_height;
  601. /*
  602. ** Set all of the initial zoom mode variables to the correct
  603. ** setting.
  604. */
  605. IsZoomed = !IsZoomed;
  606. BaseX = 0;
  607. BaseY = 0;
  608. /*
  609. ** Figure out exactly what size we need to zoom the map to.
  610. */
  611. if ( !IsZoomed ) {
  612. int xfactor = RadIWidth / MapCellWidth;
  613. int yfactor = RadIHeight / MapCellHeight;
  614. ZoomFactor = MIN(xfactor,yfactor);
  615. map_c_width = MapCellWidth;
  616. map_c_height = MapCellHeight;
  617. } else {
  618. ZoomFactor = 6;
  619. map_c_width = RadIWidth / ZoomFactor;
  620. map_c_height = RadIHeight / ZoomFactor;
  621. }
  622. /*
  623. ** Make sure we do not show more cell then are on the map.
  624. */
  625. map_c_width = MIN(map_c_width, 62);
  626. map_c_height = MIN(map_c_height, 62);
  627. /*
  628. ** Find the amount of remainder because this will let us calculate
  629. ** how to center the thing.
  630. */
  631. int rem_x = RadIWidth - (map_c_width * ZoomFactor);
  632. int rem_y = RadIHeight - (map_c_height * ZoomFactor);
  633. /*
  634. ** Finally mark the map so it shows just as much as it is supposed
  635. ** to.
  636. */
  637. BaseX = rem_x / 2;
  638. BaseY = rem_y / 2;
  639. RadarCellWidth = map_c_width;
  640. RadarCellHeight = map_c_height;
  641. RadarWidth = RadIWidth - rem_x;
  642. RadarHeight = RadIWidth - rem_y;
  643. /*
  644. ** Set the radar position to the current cell.
  645. */
  646. Set_Radar_Position(cell);
  647. /*
  648. ** When zoom mode changes then we need to redraw the radar
  649. ** area.
  650. */
  651. IsToRedraw = true;
  652. /*
  653. ** Notify the map that we need to redraw a portion
  654. */
  655. Flag_To_Redraw(false);
  656. /*
  657. ** Since we have made a vast change we must redraw everything
  658. */
  659. FullRedraw = true;
  660. }
  661. /***********************************************************************************************
  662. * RadarClass::Plot_Radar_Pixel -- Updates the radar map with a terrain pixel. *
  663. * *
  664. * This will update the radar map with a pixel. It is used to display *
  665. * vehicle positions on the radar map. *
  666. * *
  667. * INPUT: unit -- Pointer to unit to render at the given position. If *
  668. * NULL is passed in, then the underlying terrain is *
  669. * displayed instead. *
  670. * *
  671. * pos -- Position on the map to update. *
  672. * *
  673. * OUTPUT: none *
  674. * *
  675. * WARNINGS: This routine does NOT hide the mouse. It is up to you to *
  676. * do so. *
  677. * *
  678. * HISTORY: *
  679. * 06/04/1991 JLB : Created. *
  680. * 06/21/1991 JLB : Large blips for units & buildings. *
  681. * 02/14/1994 JLB : Revamped. *
  682. * 04/17/1995 PWG : Created. *
  683. * 04/18/1995 PWG : Created. *
  684. *=============================================================================================*/
  685. void RadarClass::Plot_Radar_Pixel(CELL cell)
  686. {
  687. if (cell == -1) cell = 1;
  688. int x,y; // Coordinate of cell location.
  689. /*
  690. ** Perform any clipping on the cell coordinate.
  691. */
  692. if (!IsRadarActive || (unsigned)cell > MAP_CELL_TOTAL) return;
  693. if (!In_Radar(cell) || !Cell_On_Radar(cell)) {
  694. return;
  695. }
  696. /*
  697. ** If we are zoomed in then calculate the pixel based off of the portion
  698. ** of the map the radar is viewing.
  699. */
  700. x = Cell_X(cell) - RadarX;
  701. y = Cell_Y(cell) - RadarY;
  702. if (LogicPage->Lock()) {
  703. CellClass * cellptr = &(*this)[cell];
  704. x = RadX + RadOffX + BaseX + (x * ZoomFactor);
  705. y = RadY + RadOffY + BaseY + (y * ZoomFactor);
  706. /*
  707. ** Determine what (if any) vehicle or unit should be rendered in this blip.
  708. */
  709. int color=TBLACK; // Color of the pixel to plot.
  710. if ((*this)[cell].IsVisible || Debug_Unshroud) {
  711. color = cellptr->Cell_Color(true);
  712. } else {
  713. color = BLACK;
  714. }
  715. // ST 8/13/96 2:24PM
  716. //if (cellptr->IsRadarCursor){
  717. // color = WHITE;
  718. //}
  719. /*
  720. ** If no color override occurs for this cell, then render the underlying
  721. ** terrain.
  722. */
  723. if (color == TBLACK) {
  724. if (ZoomFactor > 1) {
  725. void const *ptr;
  726. long offset;
  727. int icon;
  728. if (cellptr->TType != TEMPLATE_NONE) {
  729. ptr = TemplateTypeClass::As_Reference(cellptr->TType).Get_Image_Data();
  730. icon = cellptr->TIcon;
  731. } else {
  732. ptr = TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1).Get_Image_Data();
  733. icon = cellptr->Clear_Icon();
  734. }
  735. /*
  736. ** Convert the logical icon number into the actual icon number.
  737. */
  738. Mem_Copy(Add_Long_To_Pointer((void *)ptr, 28), &offset, sizeof(offset));
  739. Mem_Copy(Add_Long_To_Pointer((void *)ptr, offset+icon), &icon, sizeof(char));
  740. icon &= 0x00FF;
  741. Mem_Copy(Add_Long_To_Pointer((void *)ptr, 12), &offset, sizeof(offset));
  742. ptr = Add_Long_To_Pointer((void *)ptr, offset + icon*(24*24));
  743. unsigned char * data = (unsigned char *)ptr;
  744. Buffer_To_Page(0, 0, 24, 24, data, _TileStage);
  745. _TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE);
  746. } else {
  747. if (LogicPage->Lock()){
  748. Fat_Put_Pixel(x, y, cellptr->Cell_Color(false), ZoomFactor, *LogicPage);
  749. LogicPage->Unlock();
  750. }
  751. }
  752. } else {
  753. if (LogicPage->Lock()){
  754. Fat_Put_Pixel(x, y, color, ZoomFactor, *LogicPage);
  755. LogicPage->Unlock();
  756. }
  757. }
  758. if (color != BLACK) {
  759. Render_Overlay(cell, x, y, ZoomFactor);
  760. Render_Terrain(cell, x, y, ZoomFactor);
  761. Render_Infantry(cell, x, y, ZoomFactor);
  762. }
  763. LogicPage->Unlock();
  764. }
  765. }
  766. /***********************************************************************************************
  767. * RadarClass::Radar_Pixel -- Mark a cell to be rerendered on the radar map. *
  768. * *
  769. * This routine is used to inform the system that a pixel needs to be *
  770. * rerendered on the radar map. The pixel(s) will be rendered the *
  771. * next time the map is refreshed. *
  772. * *
  773. * INPUT: cell -- The map cell to be rerendered. *
  774. * *
  775. * OUTPUT: none *
  776. * *
  777. * WARNINGS: none *
  778. * *
  779. * HISTORY: *
  780. * 07/12/1992 JLB : Created. *
  781. * 05/08/1994 JLB : Converted to member function. *
  782. *=============================================================================================*/
  783. void RadarClass::Radar_Pixel(CELL cell)
  784. {
  785. if (IsRadarActive && Map.IsSidebarActive && Cell_On_Radar(cell)) {
  786. IsToRedraw = true;
  787. (*this)[cell].IsPlot = true;
  788. if (PixelPtr < PIXELSTACK) {
  789. PixelStack[PixelPtr++] = cell;
  790. }
  791. }
  792. }
  793. /***********************************************************************************************
  794. * RadarClass::Click_In_Radar -- Converts a radar click into cell X and Y coordinate. *
  795. * *
  796. * This routine will examine the X and Y coordinate and convert them into the X and Y *
  797. * cell coordinate value that cooresponds to the location. *
  798. * *
  799. * INPUT: x,y -- The X and Y moouse coordinate already normalized to the radar upper left *
  800. * corner. *
  801. * *
  802. * OUTPUT: Returns with success rating in addition, the X and Y values will now hold the *
  803. * cell coordinates of the cell the pixel offsets indicated. *
  804. * Result 1 = click was in radar region *
  805. * Result 0 = click was outside radar region completly *
  806. * Result-1 = click in radar area but not on clickable reagion of radar. *
  807. * *
  808. * WARNINGS: none *
  809. * *
  810. * HISTORY: *
  811. * 05/30/1995 PWG : Created. *
  812. * 07/16/1995 JLB : Recognizes when sidebar is closed now. *
  813. *=============================================================================================*/
  814. int RadarClass::Click_In_Radar(int &ptr_x, int &ptr_y, bool change)
  815. {
  816. int x = ptr_x;
  817. int y = ptr_y;
  818. /*
  819. ** If radar is not active the click could have been on a radar point
  820. */
  821. if (!IsRadarActive || !Map.IsSidebarActive) return(0);
  822. x -= (RadX + RadOffX);
  823. y -= (RadY + RadOffY);
  824. if ((unsigned)x < RadIWidth && (unsigned)y < RadIHeight) {
  825. x -= BaseX;
  826. y -= BaseY;
  827. if ((unsigned)x < RadarWidth && (unsigned)y < RadarHeight) {
  828. x = RadarX + (x / ZoomFactor);
  829. y = RadarY + (y / ZoomFactor);
  830. if (change) {
  831. ptr_x = x;
  832. ptr_y = y;
  833. }
  834. return(1);
  835. }
  836. return(-1);
  837. }
  838. return(0);
  839. }
  840. /***********************************************************************************************
  841. * RadarClass::Click_Cell_Calc -- Determines what cell the pixel coordinate is over. *
  842. * *
  843. * This routine will examine the pixel coordinate provided and determine what cell it *
  844. * represents. If the radar map is not active or the coordinates are not positioned over *
  845. * the radar map, then it will fall into the base class corresponding routine. *
  846. * *
  847. * INPUT: x,y -- The pixel coordinate to convert into a cell number. *
  848. * *
  849. * OUTPUT: Returns with the cell number that the coordinate is over or -1 if not over any *
  850. * cell. *
  851. * *
  852. * WARNINGS: none *
  853. * *
  854. * HISTORY: *
  855. * 12/22/1994 JLB : Created. *
  856. *=============================================================================================*/
  857. CELL RadarClass::Click_Cell_Calc(int x, int y)
  858. {
  859. int result = Click_In_Radar(x, y, true);
  860. switch (result) {
  861. case 1:
  862. return(XY_Cell(x, y));
  863. case -1:
  864. return(-1);
  865. }
  866. return(DisplayClass::Click_Cell_Calc(x, y));
  867. }
  868. /***********************************************************************************************
  869. * RadarClass::Map_Cell -- Updates radar map when a cell becomes mapped. *
  870. * *
  871. * This routine will update the radar map if a cell becomes mapped. *
  872. * *
  873. * INPUT: cell -- The cell that is being mapped. *
  874. * *
  875. * house -- The house that is doing the mapping. *
  876. * *
  877. * OUTPUT: bool; Was the cell mapped (for the first time) by this routine? *
  878. * *
  879. * WARNINGS: none *
  880. * *
  881. * HISTORY: *
  882. * 12/22/1994 JLB : Created. *
  883. *=============================================================================================*/
  884. bool RadarClass::Map_Cell(CELL cell, HouseClass * house)
  885. {
  886. if (DisplayClass::Map_Cell(cell, house)) {
  887. Radar_Pixel(cell);
  888. return(true);
  889. }
  890. return(false);
  891. }
  892. void RadarClass::Cursor_Cell(CELL cell, int value)
  893. {
  894. int temp = (*this)[cell].IsRadarCursor;
  895. /*
  896. ** If this cell is not on the radar don't botther doing anything.
  897. */
  898. if (In_Radar(cell) && temp != value) {
  899. /*
  900. ** Record the new state of this cell.
  901. */
  902. (*this)[cell].IsRadarCursor = value;
  903. /*
  904. ** If we are erasing then erase the cell.
  905. */
  906. ////// ST 8/13/96 2:23PM
  907. if (value == FALSE) {
  908. Plot_Radar_Pixel(cell);
  909. //////
  910. }
  911. }
  912. }
  913. void RadarClass::Mark_Radar(int x1, int y1, int x2, int y2, int value, int barlen)
  914. {
  915. int x, y;
  916. /*
  917. ** First step is to convert pixel coordinates back to a CellX and CellY.
  918. */
  919. x1 = RadarX + (x1 / ZoomFactor);
  920. y1 = RadarY + (y1 / ZoomFactor);
  921. x2 = RadarX + (x2 / ZoomFactor);
  922. y2 = RadarY + (y2 / ZoomFactor);
  923. /*
  924. ** Now we need to convert the Pixel length to a cell length.
  925. */
  926. barlen = (barlen / ZoomFactor)+1;
  927. /*
  928. ** Now lets loop through and mark the map with the proper value.
  929. */
  930. for (int lp = 0; lp <= barlen; lp++) {
  931. /*
  932. ** Do Horizontal action to upper and lower left corners.
  933. */
  934. x = x1 + lp;
  935. Cursor_Cell(XY_Cell(x,y1), value);
  936. Cursor_Cell(XY_Cell(x,y2), value);
  937. /*
  938. ** Do Horizontal Action to upper and lower right corners
  939. */
  940. x = x2 - lp;
  941. Cursor_Cell(XY_Cell(x,y1), value);
  942. Cursor_Cell(XY_Cell(x,y2), value);
  943. /*
  944. ** Do Vertical Action to left and right upper corners
  945. */
  946. y = y1 + lp;
  947. Cursor_Cell(XY_Cell(x1,y), value);
  948. Cursor_Cell(XY_Cell(x2,y), value);
  949. /*
  950. ** Do Vertical action to left and right lower corners.
  951. */
  952. y = y2 - lp;
  953. Cursor_Cell(XY_Cell(x1,y), value);
  954. Cursor_Cell(XY_Cell(x2,y), value);
  955. }
  956. }
  957. /***********************************************************************************************
  958. * RadarClass::Cell_XY_To_Radar_Pixel-- Adjust the position of the radar map cursor. *
  959. * *
  960. * This routine will adjust the location (and visibility) of the radar *
  961. * map cursor. It handles all restoration, drawing, and flashing. *
  962. * *
  963. * INPUT: pos - Cell position for the cursor. If the value is -1 then *
  964. * the cursor will be hidden. If the value is equal to *
  965. * the last value passed in then cursor flashing will *
  966. * be maintained. *
  967. * *
  968. * OUTPUT: none *
  969. * *
  970. * WARNINGS: none *
  971. * *
  972. * HISTORY: *
  973. * 05/22/1991 JLB : Created. *
  974. * 11/17/1995 PWG : Created. *
  975. *=============================================================================================*/
  976. void RadarClass::Cell_XY_To_Radar_Pixel(int cellx, int celly, int &x, int &y)
  977. {
  978. x = (cellx - RadarX) * ZoomFactor;
  979. y = (celly - RadarY) * ZoomFactor;
  980. }
  981. /***********************************************************************************************
  982. * RadarClass::Radar_Cursor -- Adjust the position of the radar map cursor. *
  983. * *
  984. * This routine will adjust the location (and visibility) of the radar *
  985. * map cursor. It handles all restoration, drawing, and flashing. *
  986. * *
  987. * INPUT: pos - Cell position for the cursor. If the value is -1 then *
  988. * the cursor will be hidden. If the value is equal to *
  989. * the last value passed in then cursor flashing will *
  990. * be maintained. *
  991. * *
  992. * OUTPUT: none *
  993. * *
  994. * WARNINGS: none *
  995. * *
  996. * HISTORY: *
  997. * 05/22/1991 JLB : Created. *
  998. * 11/17/1995 PWG : Created. *
  999. *=============================================================================================*/
  1000. #pragma argsused
  1001. void RadarClass::Radar_Cursor(int forced)
  1002. {
  1003. static _last_pos = -1;
  1004. static _last_frame = -1;
  1005. GraphicViewPortClass *oldpage;
  1006. int x1, y1, x2, y2;
  1007. /*
  1008. ** figure out these function calls as we will need to call them multiple times.
  1009. */
  1010. int tac_cell = Coord_Cell(TacticalCoord);
  1011. int tac_cell_x = Cell_X(tac_cell);
  1012. int tac_cell_y = Cell_Y(tac_cell);
  1013. int barlen = 6;
  1014. /*
  1015. ** If the current tactical cell is invalid or we haven't moved and we are not forced to redraw then
  1016. ** just skip the redraw process.
  1017. */
  1018. if (tac_cell != -1 && _last_pos == tac_cell && _last_frame == SpecialRadarFrame && !forced) return;
  1019. if ( _last_pos != -1 ) {
  1020. /*
  1021. ** The first thing we need to do is take care of erasing the last radar cell position. We do this
  1022. ** by converting to pixel coordinates, then adjusting for the pixel coords for the current frame and
  1023. ** finally taking care of calling the erase procedure which will convert the pixel coordinates back
  1024. ** to the cells that need to be redraw.
  1025. **/
  1026. int last_cell_x = Cell_X(_last_pos);
  1027. int last_cell_y = Cell_Y(_last_pos);
  1028. Cell_XY_To_Radar_Pixel(last_cell_x, last_cell_y, x1, y1);
  1029. Cell_XY_To_Radar_Pixel(last_cell_x + Lepton_To_Cell(TacLeptonWidth), last_cell_y + Lepton_To_Cell(TacLeptonHeight), x2, y2);
  1030. x2--;
  1031. y2--;
  1032. /*
  1033. ** Adjust the current coordinates based on the last animation frame.
  1034. */
  1035. x1-= _last_frame;
  1036. y1-= _last_frame;
  1037. x2+= _last_frame;
  1038. y2+= _last_frame;
  1039. /*
  1040. ** Finally mark the map (actually remove the marks that indicate the radar cursor was there
  1041. */
  1042. Mark_Radar(x1, y1, x2, y2, FALSE, barlen);
  1043. }
  1044. /*
  1045. ** find the upper left and lower right corners of the radar cursor. Remember to adjust x2 and y2 back
  1046. ** by one pixel as they will not be pointing to the right value otherwise. They point one cell ahead
  1047. ** of where they should.
  1048. */
  1049. Cell_XY_To_Radar_Pixel(tac_cell_x, tac_cell_y, x1, y1);
  1050. Cell_XY_To_Radar_Pixel(tac_cell_x + Lepton_To_Cell(TacLeptonWidth), tac_cell_y + Lepton_To_Cell(TacLeptonHeight), x2, y2);
  1051. x2--;
  1052. y2--;
  1053. /*
  1054. ** Adjust the coordinates based on the current frame of radar animation.
  1055. */
  1056. x1-= SpecialRadarFrame;
  1057. y1-= SpecialRadarFrame;
  1058. x2+= SpecialRadarFrame;
  1059. y2+= SpecialRadarFrame;
  1060. Mark_Radar(x1, y1, x2, y2, TRUE, barlen);
  1061. /*
  1062. ** setup a graphic view port class so we can write all the pixels relative
  1063. ** to 0,0 rather than relative to full screen coordinates.
  1064. */
  1065. oldpage = Set_Logic_Page(HidPage);
  1066. GraphicViewPortClass draw_window(LogicPage->Get_Graphic_Buffer(),
  1067. RadX + RadOffX + BaseX + LogicPage->Get_XPos(),
  1068. RadY + RadOffY + BaseY + LogicPage->Get_YPos(),
  1069. RadarWidth,
  1070. RadarHeight);
  1071. draw_window.Draw_Line(x1, y1, x1 + barlen, y1, LTGREEN);
  1072. draw_window.Draw_Line(x1, y1, x1, y1 + barlen, LTGREEN);
  1073. // Draw upper right hand corner
  1074. draw_window.Draw_Line(x2 - barlen, y1, x2, y1, LTGREEN);
  1075. draw_window.Draw_Line(x2, y1, x2, y1 + barlen, LTGREEN);
  1076. // Draw lower left hand corner
  1077. draw_window.Draw_Line(x1, y2 - barlen, x1, y2, LTGREEN);
  1078. draw_window.Draw_Line(x1, y2, x1 + barlen, y2, LTGREEN);
  1079. // Draw lower right hand corner
  1080. draw_window.Draw_Line(x2, y2 - barlen, x2, y2, LTGREEN);
  1081. draw_window.Draw_Line(x2 - barlen, y2, x2, y2, LTGREEN);
  1082. #if(0)
  1083. draw_window.Draw_Rect(x1, y1, x2, y2, WHITE);
  1084. #endif
  1085. #if(FALSE)
  1086. if (oldpage == &SeenBuff) {
  1087. Hide_Mouse();
  1088. HidPage.Blit( SeenBuff,
  1089. (int)(RadX + RadOffX + BaseX),
  1090. (int)(RadY + RadOffY + BaseY),
  1091. (int)(RadX + RadOffX + BaseX),
  1092. (int)(RadY + RadOffY + BaseY),
  1093. (int)draw_window.Get_Width(),
  1094. (int)draw_window.Get_Height(),
  1095. (BOOL)FALSE);
  1096. Show_Mouse();
  1097. }
  1098. #endif
  1099. Set_Logic_Page(oldpage);
  1100. _last_pos = tac_cell;
  1101. _last_frame = SpecialRadarFrame;
  1102. RadarCursorRedraw = FALSE;
  1103. }
  1104. /***************************************************************************
  1105. * RadarClass::Radar_Anim -- Renders current frame of radar animation *
  1106. * *
  1107. * *
  1108. * *
  1109. * INPUT: *
  1110. * *
  1111. * OUTPUT: *
  1112. * *
  1113. * WARNINGS: *
  1114. * *
  1115. * HISTORY: *
  1116. * 04/19/1995 PWG : Created. *
  1117. *=========================================================================*/
  1118. void RadarClass::Radar_Anim(void)
  1119. {
  1120. /*
  1121. ** Do nothing if we're in player-name mode
  1122. */
  1123. if (IsPlayerNames)
  1124. return;
  1125. if (!Map.IsSidebarActive) return;
  1126. GraphicViewPortClass *oldpage= Set_Logic_Page(HidPage);
  1127. GraphicViewPortClass draw_window(LogicPage->Get_Graphic_Buffer(),
  1128. RadX + RadOffX + LogicPage->Get_XPos(),
  1129. RadY + RadOffY + LogicPage->Get_YPos(),
  1130. RadIWidth,
  1131. RadIHeight);
  1132. Draw_Box(RadX+RadOffX-1, RadY+RadOffY-1, RadIWidth+2, RadIHeight+2, BOXSTYLE_RAISED, true);
  1133. draw_window.Clear();
  1134. CC_Draw_Shape(RadarAnim, RadarAnimFrame, RadX, RadY+1, WINDOW_MAIN, SHAPE_NORMAL);
  1135. Flag_To_Redraw(false);
  1136. Set_Logic_Page(oldpage);
  1137. }
  1138. /***********************************************************************************************
  1139. * RadarClass::AI -- Processes radar input (non-tactical). *
  1140. * *
  1141. * This routine intercepts any player input that concerns the radar map, but not those *
  1142. * areas that represent the tactical map. These are handled by the tactical map AI *
  1143. * processor. Primarily, this routine handles the little buttons that border the radar *
  1144. * map. *
  1145. * *
  1146. * INPUT: input -- The player input code. *
  1147. * *
  1148. * x,y -- Mouse coordinate parameters to use. *
  1149. * *
  1150. * OUTPUT: none *
  1151. * *
  1152. * WARNINGS: none *
  1153. * *
  1154. * HISTORY: *
  1155. * 12/23/1994 JLB : Created. *
  1156. * 12/26/1994 JLB : Moves tactical map with click or drag. *
  1157. * 12/31/1994 JLB : Uses mouse coordinate parameters. *
  1158. *=============================================================================================*/
  1159. void RadarClass::AI(KeyNumType & input, int x, int y)
  1160. {
  1161. /*
  1162. ** Check to see if we need to animate the radar cursor
  1163. */
  1164. if (IsRadarActive && Map.IsSidebarActive && SpecialRadarFrame) {
  1165. SpecialRadarFrame--;
  1166. RadarCursorRedraw = TRUE;
  1167. IsToRedraw = TRUE;
  1168. Flag_To_Redraw(FALSE);
  1169. }
  1170. /*
  1171. ** Check goes here to see if there is enough power to run the radar
  1172. */
  1173. if (IsRadarActivating) {
  1174. if (!DoesRadarExist) {
  1175. RadarAnimFrame++;
  1176. if (RadarAnimFrame < RADAR_ACTIVATED_FRAME) {
  1177. IsToRedraw = true;
  1178. Flag_To_Redraw(false);
  1179. } else {
  1180. DoesRadarExist = true;
  1181. Radar_Activate(3);
  1182. }
  1183. } else {
  1184. RadarAnimFrame--;
  1185. if (RadarAnimFrame > RADAR_ACTIVATED_FRAME) {
  1186. IsToRedraw = true;
  1187. Flag_To_Redraw(false);
  1188. } else {
  1189. Radar_Activate(3);
  1190. }
  1191. }
  1192. }
  1193. if (IsRadarDeactivating) {
  1194. RadarAnimFrame++;
  1195. if (RadarAnimFrame == MAX_RADAR_FRAMES) {
  1196. IsRadarDeactivating = false;
  1197. } else {
  1198. IsToRedraw = true;
  1199. Flag_To_Redraw(false);
  1200. }
  1201. }
  1202. DisplayClass::AI(input, x, y);
  1203. }
  1204. /***********************************************************************************************
  1205. * RadarClass::TacticalClass::Action -- I/O function for the radar map. *
  1206. * *
  1207. * This is the main action function for handling player I/O on the radar map. It processes *
  1208. * mouse clicks as well as mouse moves. *
  1209. * *
  1210. * INPUT: flags -- The event flags that trigger this function call. *
  1211. * *
  1212. * key -- Reference the keyboard event that applies to the trigger event. *
  1213. * *
  1214. * OUTPUT: Should further processing of the input list be aborted? *
  1215. * *
  1216. * WARNINGS: none *
  1217. * *
  1218. * HISTORY: *
  1219. * 05/08/1995 JLB : Created. *
  1220. *=============================================================================================*/
  1221. int RadarClass::TacticalClass::Action(unsigned flags, KeyNumType & key)
  1222. {
  1223. CELL cell; // cell num click happened over
  1224. int x,y; // Sub cell pixel coordinates.
  1225. int cellx,celly; // Sub cell pixel coordinates.
  1226. bool shadow; // is the cell in shadow or not
  1227. ObjectClass *object = 0; // what object is in the cell
  1228. ActionType action = ACTION_NONE; // Action possible with currently selected object.
  1229. /*
  1230. ** Force any help label to disappear when the mouse is held over the
  1231. ** radar map.
  1232. */
  1233. if (Map.IsSidebarActive) {
  1234. Map.Help_Text(TXT_NONE);
  1235. }
  1236. if (!Map.IsRadarActive) {
  1237. if (Map.IsSidebarActive) {
  1238. Map.Override_Mouse_Shape(MOUSE_NORMAL, true);
  1239. }
  1240. return(false);
  1241. }
  1242. /*
  1243. ** Disable processing if the player names are up
  1244. */
  1245. if (Map.Is_Player_Names()) {
  1246. GadgetClass::Action(0, key);
  1247. return(true);
  1248. }
  1249. /*
  1250. ** Set some working variables that depend on the mouse position. For the press
  1251. ** or release event, special mouse queuing storage variables are used. Other
  1252. ** events must use the current mouse position globals.
  1253. */
  1254. if (flags & (LEFTPRESS|LEFTRELEASE|RIGHTPRESS|RIGHTRELEASE)) {
  1255. x = _Kbd->MouseQX;
  1256. y = _Kbd->MouseQY;
  1257. } else {
  1258. x = Get_Mouse_X();
  1259. y = Get_Mouse_Y();
  1260. }
  1261. int result = Map.RadarClass::Click_In_Radar(x, y, false);
  1262. if (result == 1) {
  1263. cell = Map.RadarClass::Click_Cell_Calc(x, y);
  1264. if (cell != -1) {
  1265. shadow = (!Map[cell].IsVisible && !Debug_Unshroud);
  1266. cellx = 12;
  1267. celly = 12;
  1268. /*
  1269. ** Determine the object that the mouse is currently over.
  1270. */
  1271. if (!shadow) {
  1272. object = Map.Cell_Object(cell, cellx, celly);
  1273. }
  1274. /*
  1275. ** If there is a currently selected object, then the action to perform if
  1276. ** the left mouse button were clicked must be determined.
  1277. */
  1278. if (CurrentObject.Count()) {
  1279. if (object) {
  1280. action = CurrentObject[0]->What_Action(object);
  1281. } else {
  1282. action = CurrentObject[0]->What_Action(cell);
  1283. }
  1284. /*
  1285. ** If this is not a valid radar map action then we are not going to do
  1286. ** anything.
  1287. */
  1288. switch (action) {
  1289. case ACTION_MOVE:
  1290. case ACTION_NOMOVE:
  1291. case ACTION_ATTACK:
  1292. case ACTION_ENTER:
  1293. case ACTION_CAPTURE:
  1294. case ACTION_SABOTAGE:
  1295. break;
  1296. default:
  1297. action = ACTION_NONE;
  1298. object = NULL;
  1299. break;
  1300. }
  1301. /*
  1302. ** On the radar map the only reason we would want the normal cursor to
  1303. ** appear is if we were over one of our own selected units. Otherwise
  1304. ** we can't move there.
  1305. **/
  1306. if (action == ACTION_NONE) {
  1307. if (object && object->IsSelected) {
  1308. object = NULL;
  1309. } else {
  1310. action = ACTION_NOMOVE;
  1311. }
  1312. }
  1313. /*
  1314. ** A right mouse button press toggles the zoom mode.
  1315. */
  1316. if (flags & RIGHTPRESS) {
  1317. Map.Mouse_Right_Press();
  1318. }
  1319. /*
  1320. ** When the mouse buttons aren't pressed, only the mouse cursor shape is processed.
  1321. ** The shape changes depending on what object the mouse is currently over and what
  1322. ** object is currently selected.
  1323. */
  1324. if (flags & LEFTUP) {
  1325. Map.Mouse_Left_Up(shadow, object, action, true);
  1326. }
  1327. /*
  1328. ** Normal actions occur when the mouse button is released. The press event is
  1329. ** intercepted and possible rubber-band mode is flagged.
  1330. */
  1331. if (flags & LEFTPRESS) {
  1332. Map.Mouse_Left_Release(cell, cellx, celly, object, action, true);
  1333. }
  1334. } else {
  1335. Map.Set_Default_Mouse(MOUSE_RADAR_CURSOR, !Map.IsZoomed);
  1336. if (flags & LEFTPRESS) {
  1337. cell = Map.RadarClass::Click_Cell_Calc(x, y);
  1338. if (cell != -1) {
  1339. int cellx = Cell_X(cell);
  1340. int celly = Cell_Y(cell);
  1341. cellx -= Lepton_To_Cell(Map.TacLeptonWidth) / 2;
  1342. cellx = MAX(cellx, Map.MapCellX);
  1343. celly -= Lepton_To_Cell(Map.TacLeptonHeight) / 2;
  1344. celly = MAX(celly, Map.MapCellY);
  1345. cell = XY_Cell(cellx, celly);
  1346. shadow = (!Map[cell].IsVisible && !Debug_Unshroud);
  1347. Map.Set_Tactical_Position(Cell_Coord(cell));
  1348. cell = Coord_Cell(Map.DesiredTacticalCoord);
  1349. Map.DisplayClass::IsToRedraw = true;
  1350. //Map.Flag_To_Redraw(false);
  1351. Map.Flag_To_Redraw(true);
  1352. Map.SpecialRadarFrame = 4;
  1353. }
  1354. }
  1355. /*
  1356. ** A right mouse button press toggles the zoom mode.
  1357. */
  1358. if (flags & RIGHTPRESS) {
  1359. Map.Zoom_Mode(cell);
  1360. }
  1361. }
  1362. }
  1363. }
  1364. if (result == -1) {
  1365. Map.Override_Mouse_Shape(MOUSE_NORMAL, true);
  1366. }
  1367. GadgetClass::Action(0, key);
  1368. return(true);
  1369. }
  1370. /***********************************************************************************************
  1371. * RadarClass::Refresh_Cells -- Intercepts refresh request and updates radar if needed *
  1372. * *
  1373. * This routine intercepts the refresh cells request and if it detects that the sidebar *
  1374. * should be rerendered, it flags the radar map to redraw during the next draw operation. *
  1375. * *
  1376. * INPUT: cell -- The origin cell that the refresh cell offset list is based upon. *
  1377. * *
  1378. * list -- Pointer to the list of offsets from the origin cell that specifies the *
  1379. * cells to be flagged for redraw. If the list starts with the special *
  1380. * code to refresh the sidebar, then this routine recognizes it and flags *
  1381. * the radar map to be redrawn accordingly. *
  1382. * *
  1383. * OUTPUT: none *
  1384. * *
  1385. * WARNINGS: none *
  1386. * *
  1387. * HISTORY: *
  1388. * 01/01/1995 JLB : Created. *
  1389. *=============================================================================================*/
  1390. void RadarClass::Refresh_Cells(CELL cell, short const *list)
  1391. {
  1392. if (*list == REFRESH_SIDEBAR) {
  1393. IsToRedraw = true;
  1394. Flag_To_Redraw(false);
  1395. }
  1396. DisplayClass::Refresh_Cells(cell, list);
  1397. }
  1398. /***********************************************************************************************
  1399. * RadarClass::Set_Radar_Position -- Sets the radar position to center around specified cell. *
  1400. * *
  1401. * This routine will try to center the radar map around the cell position specified. *
  1402. * *
  1403. * INPUT: cell -- The cell to try and position the radar map around. *
  1404. * *
  1405. * OUTPUT: none *
  1406. * *
  1407. * WARNINGS: none *
  1408. * *
  1409. * HISTORY: *
  1410. * 05/08/1995 JLB : Created. *
  1411. *=============================================================================================*/
  1412. void RadarClass::Set_Radar_Position(CELL cell)
  1413. {
  1414. int oldx, oldy;
  1415. int newx, newy;
  1416. int newcell;
  1417. if (ZoomFactor != 1) {
  1418. #if(FALSE)
  1419. oldx = (Cell_X(cell) - MapCellX) - (RadarCellWidth / 2);
  1420. oldy = (Cell_Y(cell) - MapCellY) - (RadarCellHeight / 2);
  1421. #else
  1422. oldx = (Cell_X(cell) - MapCellX);
  1423. oldy = (Cell_Y(cell) - MapCellY);
  1424. #endif
  1425. } else {
  1426. oldx = 0;
  1427. oldy = 0;
  1428. }
  1429. Confine_Rect(&oldx, &oldy, RadarCellWidth, RadarCellHeight, MapCellWidth, MapCellHeight);
  1430. newx = oldx + MapCellX;
  1431. newy = oldy + MapCellY;
  1432. newcell = XY_Cell(newx, newy);
  1433. if (RadarCell != newcell) {
  1434. int forced = FALSE;
  1435. int xmod = newx;
  1436. int ymod = newy;
  1437. int radx = (Cell_X(RadarCell)) - xmod;
  1438. int rady = (Cell_Y(RadarCell)) - ymod;
  1439. RadarX = newx;
  1440. RadarY = newy;
  1441. RadarCell = newcell;
  1442. if (Map.IsSidebarActive&& Map.IsRadarActive) {
  1443. int radw = RadarCellWidth-ABS(radx); // Replicable width.
  1444. int radh = RadarCellHeight-ABS(rady); // Replicable height.
  1445. if (radw < 1) forced = true;
  1446. if (radh < 1) forced = true;
  1447. if (!forced && (radw != RadarWidth || radh != RadarHeight)) {
  1448. /*
  1449. ** Blit the section that is actually overlapping.
  1450. */
  1451. if (OverlappedVideoBlits || !HidPage.Get_IsDirectDraw()){
  1452. HidPage.Blit(HidPage,
  1453. (((radx < 0) ? -radx : 0) * ZoomFactor) + RadX + RadOffX + BaseX,
  1454. (((rady < 0) ? -rady : 0) * ZoomFactor) + RadY + RadOffY + BaseY,
  1455. (((radx < 0) ? 0 : radx) * ZoomFactor) + RadX+ RadOffX + BaseX,
  1456. (((rady < 0) ? 0 : rady) * ZoomFactor) + RadY + RadOffY + BaseY,
  1457. radw * ZoomFactor,
  1458. radh * ZoomFactor);
  1459. }else{
  1460. /*
  1461. ** System does not support overlapped blitting of video surfaces.
  1462. ** Blit it in 2 stages using an intermediate buffer.
  1463. */
  1464. GraphicBufferClass temp_surface;
  1465. temp_surface.Init((RadarWidth + 16) & 0xfffffff0,
  1466. (RadarHeight + 16) & 0xfffffff0,
  1467. NULL, 0, (GBC_Enum) GBC_VIDEOMEM);
  1468. HidPage.Blit(temp_surface, (((radx < 0) ? -radx : 0) * ZoomFactor) + RadX + RadOffX + BaseX,
  1469. (((rady < 0) ? -rady : 0) * ZoomFactor) + RadY + RadOffY + BaseY,
  1470. 0,
  1471. 0,
  1472. RadarWidth,
  1473. RadarHeight);
  1474. temp_surface.Blit (HidPage,0,
  1475. 0,
  1476. (((radx < 0) ? 0 : radx) * ZoomFactor) + RadX + RadOffX + BaseX,
  1477. (((rady < 0) ? 0 : rady) * ZoomFactor) + RadY + RadOffY + BaseY,
  1478. radw * ZoomFactor,
  1479. radh * ZoomFactor);
  1480. }
  1481. /*
  1482. ** Now we need to flag the section of the map that is going to redraw.
  1483. */
  1484. if ( radx != 0 ) {
  1485. int min;
  1486. int max;
  1487. if ( radx < 0 ) { // this mean regen the right edge
  1488. min = radw;
  1489. max = radw+ABS(radx);
  1490. } else { // this mean regen the left edge
  1491. min = 0;
  1492. max = radx;
  1493. }
  1494. for (int x = min; x < max; x++ ) {
  1495. for (int y = 0; y < RadarCellHeight; y++ ) {
  1496. Radar_Pixel(XY_Cell(newx + x, newy + y));
  1497. }
  1498. }
  1499. }
  1500. if ( newy != 0 ) {
  1501. int min;
  1502. int max;
  1503. if ( rady < 0 ) { // this mean regen the bottom edge
  1504. min = radh;
  1505. max = radh+ABS(rady);
  1506. } else { // this mean regen the top edge
  1507. min = 0;
  1508. max = rady;
  1509. }
  1510. for (int y = min; y < max; y++ ) {
  1511. for ( int x = 0; x < RadarCellWidth; x++ ) {
  1512. Radar_Pixel(XY_Cell(newx + x, newy + y));
  1513. }
  1514. }
  1515. }
  1516. }
  1517. }
  1518. RadarCursorRedraw = IsRadarActive;
  1519. IsToRedraw = IsRadarActive;
  1520. Flag_To_Redraw(false);
  1521. if (ZoomFactor > 4) {
  1522. FullRedraw = forced;
  1523. }
  1524. } else {
  1525. RadarCursorRedraw = IsRadarActive;
  1526. IsToRedraw = IsRadarActive;
  1527. Flag_To_Redraw(false);
  1528. }
  1529. }
  1530. /***********************************************************************************************
  1531. * RadarClass::Radar_Position -- Returns with the current position of the radar map. *
  1532. * *
  1533. * This returns the cell number of the upper left corner of the radar map. *
  1534. * *
  1535. * INPUT: none *
  1536. * *
  1537. * OUTPUT: Returns with the radar map upper left corner cell position. *
  1538. * *
  1539. * WARNINGS: none *
  1540. * *
  1541. * HISTORY: *
  1542. * 05/08/1995 JLB : Created. *
  1543. *=============================================================================================*/
  1544. CELL RadarClass::Radar_Position(void)
  1545. {
  1546. return(RadarCell);
  1547. }
  1548. /***********************************************************************************************
  1549. * RadarClass::Set_Map_Dimensions -- Sets the tactical map dimensions. *
  1550. * *
  1551. * This routine is called when the tactical map changes its dimensions. This occurs when *
  1552. * the tactical map moves and when the sidebar pops on or off. *
  1553. * *
  1554. * INPUT: x,y -- The cell coordinate of the upper left corner of the tactical map. *
  1555. * *
  1556. * w,y -- The cell width and height of the tactical map. *
  1557. * *
  1558. * OUTPUT: none *
  1559. * *
  1560. * WARNINGS: none *
  1561. * *
  1562. * HISTORY: *
  1563. * 05/08/1995 JLB : Created. *
  1564. *=============================================================================================*/
  1565. void RadarClass::Set_Map_Dimensions(int x, int y, int w, int h)
  1566. {
  1567. Set_Radar_Position(XY_Cell(x, y));
  1568. DisplayClass::Set_Map_Dimensions(x, y, w, h);
  1569. }
  1570. /***********************************************************************************************
  1571. * RadarClass::Set_Tactical_Position -- Sets the map's tactical position and adjusts radar to *
  1572. * *
  1573. * This routine is called when the tactical map is to change position. The radar map might *
  1574. * be adjusted as well by this routine. *
  1575. * *
  1576. * INPUT: coord -- The new coordinate to use for the upper left corner of the tactical *
  1577. * map. *
  1578. * *
  1579. * OUTPUT: none *
  1580. * *
  1581. * WARNINGS: none *
  1582. * *
  1583. * HISTORY: *
  1584. * 08/17/1995 JLB : Created. *
  1585. *=============================================================================================*/
  1586. void RadarClass::Set_Tactical_Position(COORDINATE coord)
  1587. {
  1588. DisplayClass::Set_Tactical_Position(coord);
  1589. Set_Radar_Position(Coord_Cell(DesiredTacticalCoord));
  1590. }
  1591. /***********************************************************************************************
  1592. * RadarClass::Cell_On_Radar -- Determines if a cell is currently visible on radar. *
  1593. * *
  1594. * This routine will examine the specified cell number and return whether it is visible *
  1595. * on the radar map. This depends on the radar map position. *
  1596. * *
  1597. * INPUT: cell -- The cell number to check. *
  1598. * *
  1599. * OUTPUT: Is the specified cell visible on the radar map currently? *
  1600. * *
  1601. * WARNINGS: none *
  1602. * *
  1603. * HISTORY: *
  1604. * 05/03/1995 JLB : Created. *
  1605. *=============================================================================================*/
  1606. bool RadarClass::Cell_On_Radar(CELL cell)
  1607. {
  1608. if ((unsigned)cell > MAP_CELL_TOTAL)
  1609. return(false);
  1610. int x = Cell_X(cell) - RadarX;
  1611. int y = Cell_Y(cell) - RadarY;
  1612. return (!((unsigned)x >= RadarCellWidth || (unsigned)y >= RadarCellHeight));
  1613. // if (!IsZoomed) {
  1614. // return(true);
  1615. // }
  1616. // return(!(((Cell_X(cell) - RadarX) > RadarCellWidth) || ((Cell_Y(cell) - RadarY) > RadarCellHeight)));
  1617. }
  1618. /***********************************************************************************************
  1619. * RadarClass::Player_Names -- toggles the Player-Names mode of the radar map *
  1620. * *
  1621. * INPUT: *
  1622. * on true = turn on; false = turn off *
  1623. * *
  1624. * OUTPUT: *
  1625. * none. *
  1626. * *
  1627. * WARNINGS: *
  1628. * none. *
  1629. * *
  1630. * HISTORY: *
  1631. * 06/07/1995 BRR : Created. *
  1632. *=============================================================================================*/
  1633. void RadarClass::Player_Names(bool on)
  1634. {
  1635. IsPlayerNames = on;
  1636. IsToRedraw = true;
  1637. if (on) {
  1638. Flag_To_Redraw(true);
  1639. // Flag_To_Redraw(false);
  1640. } else {
  1641. Flag_To_Redraw(true); // force drawing of the plate
  1642. }
  1643. }
  1644. /***********************************************************************************************
  1645. * Draw_Names -- draws players' names on the radar map *
  1646. * *
  1647. * INPUT: *
  1648. * none. *
  1649. * *
  1650. * OUTPUT: *
  1651. * none. *
  1652. * *
  1653. * WARNINGS: *
  1654. * none. *
  1655. * *
  1656. * HISTORY: *
  1657. * 06/07/1995 BRR : Created. *
  1658. *=============================================================================================*/
  1659. void RadarClass::Draw_Names(void)
  1660. {
  1661. int c_idx;
  1662. HousesType house;
  1663. HouseClass *ptr;
  1664. int y;
  1665. char txt[40];
  1666. unsigned char id;
  1667. int i;
  1668. HousesType h;
  1669. int kills;
  1670. int color;
  1671. TextPrintType style;
  1672. int factor = (SeenBuff.Get_Width() == 320) ? 1 : 2;
  1673. /*
  1674. ** Do nothing if the sidebar isn't there
  1675. */
  1676. if (!Map.IsSidebarActive) {
  1677. return;
  1678. }
  1679. CC_Draw_Shape(RadarAnim, RADAR_ACTIVATED_FRAME, RadX, RadY+1, WINDOW_MAIN, SHAPE_NORMAL);
  1680. LogicPage->Fill_Rect( RadX + RadOffX,
  1681. RadY + RadOffY,
  1682. RadX + RadOffX + RadIWidth - 1,
  1683. RadY + RadOffY + RadIHeight - 1,
  1684. BLACK);
  1685. y = RadY + RadOffY;
  1686. Fancy_Text_Print (TXT_NAME_COLON, RadX + RadOffX, y, LTGREY, TBLACK,
  1687. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW);
  1688. Fancy_Text_Print (TXT_KILLS_COLON, RadX + RadOffX + RadIWidth - 2, y,
  1689. LTGREY, TBLACK, TPF_RIGHT | TPF_6PT_GRAD | TPF_NOSHADOW | TPF_USE_GRAD_PAL);
  1690. y += 6*factor+1;
  1691. LogicPage->Draw_Line(RadX + RadOffX, y,
  1692. RadX + RadOffX + RadIWidth - 1, y, LTGREY);
  1693. y += 2*factor;
  1694. for (house = HOUSE_MULTI1; house < (HOUSE_MULTI1 + MPlayerMax); house++) {
  1695. ptr = HouseClass::As_Pointer(house);
  1696. if (!ptr)
  1697. continue;
  1698. /*
  1699. ** Decode this house's color
  1700. */
  1701. c_idx = ptr->RemapColor;
  1702. if (ptr->IsDefeated) {
  1703. color = GREY;
  1704. style = TPF_6PT_GRAD | TPF_NOSHADOW | TPF_USE_GRAD_PAL;
  1705. } else {
  1706. color = MPlayerTColors[c_idx];
  1707. style = TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW;
  1708. }
  1709. /*
  1710. ** Initialize our message
  1711. */
  1712. txt[0] = 0;
  1713. /*
  1714. ** If the house is non-human, generate the message
  1715. */
  1716. if (!ptr->IsHuman) {
  1717. sprintf(txt,"%s", Text_String(TXT_COMPUTER));
  1718. } else {
  1719. /*
  1720. ** For a human house:
  1721. ** - Compute the multiplayer ID for this house
  1722. ** - find the name for this player
  1723. */
  1724. id = Build_MPlayerID (c_idx,ptr->ActLike);
  1725. for (i = 0; i < MPlayerCount; i++) {
  1726. if (id == MPlayerID[i]) {
  1727. sprintf(txt,"%s",MPlayerNames[i]);
  1728. break;
  1729. }
  1730. }
  1731. }
  1732. /*
  1733. ** Print the player name, and the # of kills
  1734. */
  1735. if (strlen(txt)) {
  1736. if (strlen(txt) > 9) {
  1737. txt[9] = '.';
  1738. txt[10] = '\0';
  1739. }
  1740. Fancy_Text_Print (txt, RadX + RadOffX, y, color, BLACK, style);
  1741. kills = 0;
  1742. for (h = HOUSE_FIRST; h < HOUSE_COUNT; h++) {
  1743. kills += ptr->UnitsKilled[h];
  1744. kills += ptr->BuildingsKilled[h];
  1745. }
  1746. sprintf(txt, "%2d", kills);
  1747. Fancy_Text_Print (txt, RadX + RadOffX + RadIWidth - 2, y,
  1748. color, BLACK, style | TPF_RIGHT);
  1749. y += 6*factor+1;
  1750. }
  1751. }
  1752. }