dlgevamaptab.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*
  2. ** Command & Conquer Renegade(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. /***********************************************************************************************
  19. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/commando/dlgevamaptab.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/09/02 1:54p $*
  29. * *
  30. * $Revision:: 14 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgevamaptab.h"
  36. #include "resource.h"
  37. #include "mapctrl.h"
  38. #include "combat.h"
  39. #include "soldier.h"
  40. #include "objectives.h"
  41. #include "translatedb.h"
  42. #include "translateobj.h"
  43. #include "listctrl.h"
  44. #include "mapmgr.h"
  45. #include "lineseg.h"
  46. #include "rendobj.h"
  47. #include "phys.h"
  48. #include "pscene.h"
  49. #include "coltype.h"
  50. #include "physcoltest.h"
  51. #include "gamemode.h"
  52. #include "gameinitmgr.h"
  53. #include "imagectrl.h"
  54. #include "string_ids.h"
  55. ////////////////////////////////////////////////////////////////
  56. //
  57. // On_Init_Dialog
  58. //
  59. ////////////////////////////////////////////////////////////////
  60. void
  61. EvaMapTabClass::On_Init_Dialog (void)
  62. {
  63. //
  64. // Set the map's title
  65. //
  66. Set_Dlg_Item_Text (IDC_MAP_TITLE, TRANSLATE (MapMgrClass::Get_Map_Title ()));
  67. MapCtrlClass *map_ctrl = (MapCtrlClass *)Get_Dlg_Item (IDC_MAP_CTRL);
  68. if (map_ctrl != NULL) {
  69. //
  70. // Configure the map
  71. //
  72. StringClass texture_filename;
  73. MapMgrClass::Get_Map_Texture_Filename (texture_filename);
  74. if (!texture_filename.Is_Empty()) {
  75. map_ctrl->Set_Map_Texture (texture_filename);
  76. }
  77. map_ctrl->Set_Marker_Texture ("MAPICONS.TGA");
  78. map_ctrl->Set_Map_Center (MapMgrClass::Get_Map_Center ());
  79. map_ctrl->Set_Map_Scale (MapMgrClass::Get_Map_Scale ());
  80. map_ctrl->Initialize_Cloud (MapMgrClass::CLOUD_WIDTH, MapMgrClass::CLOUD_HEIGHT);
  81. //
  82. // Do the cloud
  83. //
  84. for (int cell_x = 0; cell_x < MapMgrClass::CLOUD_WIDTH; cell_x ++) {
  85. for (int cell_y = 0; cell_y < MapMgrClass::CLOUD_HEIGHT; cell_y ++) {
  86. map_ctrl->Set_Cloud_Cell (cell_x, cell_y, MapMgrClass::Is_Cell_Visible (cell_x, cell_y));
  87. }
  88. }
  89. //
  90. // Now add a marker that represents Havoc to the map
  91. //
  92. if (COMBAT_STAR && MapMgrClass::Is_Player_Marker_Visible ()) {
  93. Vector3 pos;
  94. COMBAT_STAR->Get_Position (&pos);
  95. map_ctrl->Add_Marker (TRANSLATE (IDS_MENU_HAVOC), pos, RectClass (0, 0, 31, 31));
  96. }
  97. //
  98. // Add all the objective markers
  99. //
  100. int count = ObjectiveManager::Get_Objective_Count ();
  101. for (int index = 0; index < count; index ++) {
  102. Objective *objective = ObjectiveManager::Get_Objective (index);
  103. //
  104. // Is this an objective we should put on the map?
  105. //
  106. if ( objective != NULL &&
  107. objective->Status == ObjectiveManager::STATUS_IS_PENDING)
  108. {
  109. //
  110. // Now add a marker that represents this objective
  111. //
  112. int color = VRGB_TO_INT32 (objective->Type_To_Color ());
  113. int item_index = map_ctrl->Add_Marker (L"", objective->Position, RectClass (32, 0, 64, 32), color);
  114. map_ctrl->Set_Marker_Data (item_index, (uint32)objective);
  115. }
  116. }
  117. //
  118. // Make sure that Havoc is in view
  119. //
  120. if (COMBAT_STAR != NULL && MapMgrClass::Is_Player_Marker_Visible ()) {
  121. map_ctrl->Center_View_About_Marker (0);
  122. }
  123. }
  124. //
  125. // Configure the list control
  126. //
  127. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_OBJECT_DESC_LIST);
  128. if (list_ctrl != NULL) {
  129. list_ctrl->Add_Column (L"", 1.0F, Vector3 (1, 1, 1));
  130. }
  131. ChildDialogClass::On_Init_Dialog ();
  132. return ;
  133. }
  134. ////////////////////////////////////////////////////////////////
  135. //
  136. // On_MapCtrl_Marker_Hilighted
  137. //
  138. ////////////////////////////////////////////////////////////////
  139. void
  140. EvaMapTabClass::On_MapCtrl_Marker_Hilighted
  141. (
  142. MapCtrlClass * map_ctrl,
  143. int ctrl_id,
  144. int marker_index
  145. )
  146. {
  147. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_OBJECT_DESC_LIST);
  148. ImageCtrlClass *image_ctrl = (ImageCtrlClass *)Get_Dlg_Item (IDC_IMAGE);
  149. if (list_ctrl == NULL || image_ctrl == NULL) {
  150. return ;
  151. }
  152. //
  153. // Reset the objective description list
  154. //
  155. list_ctrl->Delete_All_Entries ();
  156. image_ctrl->Set_Texture (NULL);
  157. if (marker_index == 0) {
  158. //
  159. // Let the user know its Havoc
  160. //
  161. list_ctrl->Insert_Entry (0, TRANSLATE (IDS_MENU_NAME_HAVOC));
  162. } else if (marker_index > 0) {
  163. //
  164. // Display the objective information
  165. //
  166. Objective *objective = (Objective *)map_ctrl->Get_Marker_Data (marker_index);
  167. if (objective != NULL) {
  168. WideStringClass name = TRANSLATE (objective->ShortDescriptionID);
  169. WideStringClass string;
  170. string.Format (TRANSLATE (IDS_MENU_NAME_FORMAT), (const WCHAR *)name);
  171. list_ctrl->Insert_Entry (0, string);
  172. string.Format (TRANSLATE (IDS_MENU_PRIORITY_FORMAT), objective->Type_To_Name ());
  173. list_ctrl->Insert_Entry (1, string);
  174. list_ctrl->Set_Entry_Color (1, 0, objective->Type_To_Color ());
  175. string.Format (TRANSLATE (IDS_MENU_STATUS_FORMAT), objective->Status_To_Name ());
  176. list_ctrl->Insert_Entry (2, string);
  177. list_ctrl->Insert_Entry (3, L"");
  178. //
  179. // Lookup the translation object from the strings database
  180. //
  181. TDBObjClass *translate_obj = TranslateDBClass::Find_Object (objective->LongDescriptionID);
  182. if (translate_obj != NULL) {
  183. list_ctrl->Insert_Entry (4, translate_obj->Get_String ());
  184. }
  185. //
  186. // Configure the POG icon
  187. //
  188. image_ctrl->Set_Texture (objective->HUDPogTextureName);
  189. }
  190. }
  191. return ;
  192. }
  193. ////////////////////////////////////////////////////////////////
  194. //
  195. // On_MapCtrl_Pos_Clicked
  196. //
  197. ////////////////////////////////////////////////////////////////
  198. void
  199. EvaMapTabClass::On_MapCtrl_Pos_Clicked
  200. (
  201. MapCtrlClass * map_ctrl,
  202. int ctrl_id,
  203. const Vector3 & position
  204. )
  205. {
  206. float start_z = 1000;
  207. float end_z = -1000;
  208. //
  209. // Setup a raycast at this (x,y) position to find the z position
  210. //
  211. CastResultStruct result;
  212. LineSegClass ray (Vector3 (position.X, position.Y, start_z), Vector3 (position.X, position.Y, end_z));
  213. PhysRayCollisionTestClass raytest (ray, &result, 0, COLLISION_TYPE_PROJECTILE);
  214. PhysicsSceneClass::Get_Instance ()->Cast_Ray (raytest);
  215. Vector3 world_space_pos = position;
  216. //
  217. // Calculate what the z-position is
  218. //
  219. if (result.Fraction < 1.0F) {
  220. world_space_pos.Z = start_z + (end_z - start_z) * result.Fraction;
  221. }
  222. //
  223. // Warp the player to this position
  224. //
  225. COMBAT_STAR->Set_Position (world_space_pos);
  226. //
  227. // Return to the game
  228. //
  229. //extern void Continue_Game (void);
  230. //Continue_Game ();
  231. GameInitMgrClass::Continue_Game();
  232. return ;
  233. }