EXPAND.CPP 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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$ */
  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 : EXPAND.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 11/03/95 *
  30. * *
  31. * Last Update : November 3, 1995 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #include "function.h"
  37. #ifdef NEWMENU
  38. bool Expansion_Present(void)
  39. {
  40. CCFileClass file("EXPAND.DAT");
  41. return(file.Is_Available());
  42. }
  43. class EListClass : public ListClass
  44. {
  45. public:
  46. EListClass(int id, int x, int y, int w, int h, TextPrintType flags, void const * up, void const * down) :
  47. ListClass(id, x, y, w, h, flags, up, down) {};
  48. protected:
  49. virtual void Draw_Entry(int index, int x, int y, int width, int selected);
  50. };
  51. void EListClass::Draw_Entry(int index, int x, int y, int width, int selected)
  52. {
  53. if (TextFlags & TPF_6PT_GRAD) {
  54. TextPrintType flags = TextFlags;
  55. if (selected) {
  56. flags = flags | TPF_BRIGHT_COLOR;
  57. LogicPage->Fill_Rect (x, y, x + width - 1, y + LineHeight - 1, CC_GREEN_SHADOW);
  58. } else {
  59. if (!(flags & TPF_USE_GRAD_PAL)) {
  60. flags = flags | TPF_MEDIUM_COLOR;
  61. }
  62. }
  63. Conquer_Clip_Text_Print(List[index]+sizeof(int), x, y, CC_GREEN, TBLACK, flags, width, Tabs);
  64. } else {
  65. Conquer_Clip_Text_Print(List[index]+sizeof(int), x, y, (selected ? BLUE : WHITE), TBLACK, TextFlags, width, Tabs);
  66. }
  67. }
  68. bool Expansion_Dialog(void)
  69. {
  70. int factor = (SeenBuff.Get_Width() == 320) ? 1 : 2;
  71. int option_width = 236 * factor;
  72. int option_height = 162 * factor;
  73. int option_x = (320*factor - option_width) /2;
  74. int option_y = (200*factor - option_height) /2;
  75. GadgetClass * buttons = NULL;
  76. void const *up_button;
  77. void const *down_button;
  78. if (InMainLoop){
  79. up_button = Hires_Retrieve("BTN-UP.SHP");
  80. down_button = Hires_Retrieve("BTN-DN.SHP");
  81. }else{
  82. up_button = Hires_Retrieve("BTN-UP2.SHP");
  83. down_button = Hires_Retrieve("BTN-DN2.SHP");
  84. }
  85. TextButtonClass ok(200, TXT_OK, TPF_6PT_GRAD|TPF_NOSHADOW, option_x+25*factor, option_y+option_height-15*factor);
  86. TextButtonClass cancel(201, TXT_CANCEL, TPF_6PT_GRAD|TPF_NOSHADOW, option_x+option_width-50*factor, option_y+option_height-15*factor);
  87. EListClass list(202, option_x+10*factor, option_y+20*factor, option_width-20*factor, option_height-40*factor, TPF_6PT_GRAD|TPF_NOSHADOW, up_button, down_button);
  88. buttons = &ok;
  89. cancel.Add(*buttons);
  90. list.Add(*buttons);
  91. /*
  92. ** Add in all the expansion scenarios.
  93. */
  94. char * sbuffer = (char*)_ShapeBuffer;
  95. for (int index = 20; index < 60; index++) {
  96. char buffer[128];
  97. CCFileClass file;
  98. Set_Scenario_Name(buffer, index, SCEN_PLAYER_GDI, SCEN_DIR_EAST, SCEN_VAR_A);
  99. strcat(buffer, ".INI");
  100. file.Set_Name(buffer);
  101. if (file.Is_Available()) {
  102. file.Read(sbuffer, 1000);
  103. sbuffer[1000] = '\r';
  104. sbuffer[1000+1] = '\n';
  105. sbuffer[1000+2] = '\0';
  106. WWGetPrivateProfileString("Basic", "Name", "x", buffer, sizeof(buffer), sbuffer);
  107. char * data = new char [strlen(buffer)+1+sizeof(int)+25];
  108. *((int*)&data[0]) = index;
  109. strcpy(&data[sizeof(int)], "GDI: ");
  110. strcat(&data[sizeof(int)], buffer);
  111. list.Add_Item(data);
  112. }
  113. }
  114. for (index = 20; index < 60; index++) {
  115. char buffer[128];
  116. CCFileClass file;
  117. Set_Scenario_Name(buffer, index, SCEN_PLAYER_NOD, SCEN_DIR_EAST, SCEN_VAR_A);
  118. strcat(buffer, ".INI");
  119. file.Set_Name(buffer);
  120. if (file.Is_Available()) {
  121. file.Read(sbuffer, 1000);
  122. sbuffer[1000] = '\r';
  123. sbuffer[1000+1] = '\n';
  124. sbuffer[1000+2] = '\0';
  125. WWGetPrivateProfileString("Basic", "Name", "x", buffer, sizeof(buffer), sbuffer);
  126. char * data = new char [strlen(buffer)+1+sizeof(int)+25];
  127. *((int*)&data[0]) = index;
  128. strcpy(&data[sizeof(int)], "NOD: ");
  129. strcat(&data[sizeof(int)], buffer);
  130. list.Add_Item(data);
  131. }
  132. }
  133. Set_Logic_Page(SeenBuff);
  134. bool recalc = true;
  135. bool display = true;
  136. bool process = true;
  137. bool okval = true;
  138. while (process) {
  139. Call_Back();
  140. /*
  141. ** If we have just received input focus again after running in the background then
  142. ** we need to redraw.
  143. */
  144. if (AllSurfaces.SurfacesRestored){
  145. AllSurfaces.SurfacesRestored=FALSE;
  146. display=TRUE;
  147. }
  148. if (display) {
  149. display = false;
  150. Hide_Mouse();
  151. /*
  152. ** Load the background picture.
  153. */
  154. Load_Title_Screen("HTITLE.PCX", &HidPage, Palette);
  155. HidPage.Blit(SeenBuff);
  156. Dialog_Box(option_x, option_y, option_width, option_height);
  157. Draw_Caption(TXT_MISSION_DESCRIPTION, option_x, option_y, option_width);
  158. buttons->Draw_All();
  159. Show_Mouse();
  160. }
  161. KeyNumType input = buttons->Input();
  162. switch (input) {
  163. case KN_RETURN:
  164. case 200|KN_BUTTON:
  165. if (list.Current_Item()[sizeof(int)] == 'G') {
  166. ScenPlayer = SCEN_PLAYER_GDI;
  167. } else {
  168. ScenPlayer = SCEN_PLAYER_NOD;
  169. }
  170. ScenDir = SCEN_DIR_EAST;
  171. Whom = HOUSE_GOOD;
  172. Scenario = *(int *)list.Current_Item();
  173. process = false;
  174. okval = true;
  175. break;
  176. case KN_ESC:
  177. case 201|KN_BUTTON:
  178. ScenPlayer = SCEN_PLAYER_GDI;
  179. ScenDir = SCEN_DIR_EAST;
  180. Whom = HOUSE_GOOD;
  181. Scenario = *(int *)list.Current_Item();
  182. process = false;
  183. okval = false;
  184. break;
  185. default:
  186. break;
  187. }
  188. }
  189. /*
  190. ** Free up the allocations for the text lines in the list box.
  191. */
  192. for (index = 0; index < list.Count(); index++) {
  193. delete [] (char *)list.Get_Item(index);
  194. }
  195. return(okval);
  196. }
  197. /***********************************************************************************************
  198. * Bonus_Dialog -- Asks the user which bonus mission he wants to play *
  199. * *
  200. * *
  201. * *
  202. * INPUT: Nothing *
  203. * *
  204. * OUTPUT: Nothing *
  205. * *
  206. * WARNINGS: None *
  207. * *
  208. * HISTORY: *
  209. * 3/26/97 11:07AM ST : Created *
  210. *=============================================================================================*/
  211. bool Bonus_Dialog(void)
  212. {
  213. int factor = (SeenBuff.Get_Width() == 320) ? 1 : 2;
  214. int option_width = 236 * factor;
  215. int option_height = 162 * factor;
  216. int option_x = (320*factor - option_width) /2;
  217. int option_y = (200*factor - option_height) /2;
  218. GadgetClass * buttons = NULL;
  219. void const *up_button;
  220. void const *down_button;
  221. if (InMainLoop){
  222. up_button = Hires_Retrieve("BTN-UP.SHP");
  223. down_button = Hires_Retrieve("BTN-DN.SHP");
  224. }else{
  225. up_button = Hires_Retrieve("BTN-UP2.SHP");
  226. down_button = Hires_Retrieve("BTN-DN2.SHP");
  227. }
  228. TextButtonClass ok(200, TXT_OK, TPF_6PT_GRAD|TPF_NOSHADOW, option_x+25*factor, option_y+option_height-15*factor);
  229. TextButtonClass cancel(201, TXT_CANCEL, TPF_6PT_GRAD|TPF_NOSHADOW, option_x+option_width-50*factor, option_y+option_height-15*factor);
  230. EListClass list(202, option_x+10*factor, option_y+20*factor, option_width-20*factor, option_height-40*factor, TPF_6PT_GRAD|TPF_NOSHADOW, up_button, down_button);
  231. buttons = &ok;
  232. cancel.Add(*buttons);
  233. list.Add(*buttons);
  234. /*
  235. ** Add in all the expansion scenarios.
  236. */
  237. char * sbuffer = (char*)_ShapeBuffer;
  238. int gdi_scen_names[3]={
  239. TXT_BONUS_MISSION_1,
  240. TXT_BONUS_MISSION_2,
  241. TXT_BONUS_MISSION_3
  242. };
  243. int nod_scen_names[2]={
  244. TXT_BONUS_MISSION_4,
  245. TXT_BONUS_MISSION_5
  246. };
  247. for (int index = 60; index < 63; index++) {
  248. char buffer[128];
  249. CCFileClass file;
  250. Set_Scenario_Name(buffer, index, SCEN_PLAYER_GDI, SCEN_DIR_EAST, SCEN_VAR_A);
  251. strcat(buffer, ".INI");
  252. file.Set_Name(buffer);
  253. if (file.Is_Available()) {
  254. memcpy (buffer, Text_String (gdi_scen_names[index-60]), 1+strlen(Text_String (gdi_scen_names[index-60])));
  255. char * data = new char [strlen(buffer)+1+sizeof(int)+25];
  256. *((int*)&data[0]) = index;
  257. strcpy(&data[sizeof(int)], "GDI: ");
  258. strcat(&data[sizeof(int)], buffer);
  259. list.Add_Item(data);
  260. }
  261. }
  262. for (index = 60; index < 62; index++) {
  263. char buffer[128];
  264. CCFileClass file;
  265. Set_Scenario_Name(buffer, index, SCEN_PLAYER_NOD, SCEN_DIR_EAST, SCEN_VAR_A);
  266. strcat(buffer, ".INI");
  267. file.Set_Name(buffer);
  268. if (file.Is_Available()) {
  269. memcpy (buffer, Text_String (nod_scen_names[index-60]), 1+strlen(Text_String (nod_scen_names[index-60])));
  270. char * data = new char [strlen(buffer)+1+sizeof(int)+25];
  271. *((int*)&data[0]) = index;
  272. strcpy(&data[sizeof(int)], "NOD: ");
  273. strcat(&data[sizeof(int)], buffer);
  274. list.Add_Item(data);
  275. }
  276. }
  277. Set_Logic_Page(SeenBuff);
  278. bool recalc = true;
  279. bool display = true;
  280. bool process = true;
  281. bool okval = true;
  282. while (process) {
  283. Call_Back();
  284. /*
  285. ** If we have just received input focus again after running in the background then
  286. ** we need to redraw.
  287. */
  288. if (AllSurfaces.SurfacesRestored){
  289. AllSurfaces.SurfacesRestored=FALSE;
  290. display=TRUE;
  291. }
  292. if (display) {
  293. display = false;
  294. Hide_Mouse();
  295. /*
  296. ** Load the background picture.
  297. */
  298. Load_Title_Screen("HTITLE.PCX", &HidPage, Palette);
  299. HidPage.Blit(SeenBuff);
  300. Dialog_Box(option_x, option_y, option_width, option_height);
  301. Draw_Caption(TXT_BONUS_MISSIONS, option_x, option_y, option_width);
  302. buttons->Draw_All();
  303. Show_Mouse();
  304. }
  305. KeyNumType input = buttons->Input();
  306. switch (input) {
  307. case KN_RETURN:
  308. case 200|KN_BUTTON:
  309. if (list.Current_Item()[sizeof(int)] == 'G') {
  310. ScenPlayer = SCEN_PLAYER_GDI;
  311. } else {
  312. ScenPlayer = SCEN_PLAYER_NOD;
  313. }
  314. ScenDir = SCEN_DIR_EAST;
  315. Whom = HOUSE_GOOD;
  316. Scenario = *(int *)list.Current_Item();
  317. process = false;
  318. okval = true;
  319. break;
  320. case KN_ESC:
  321. case 201|KN_BUTTON:
  322. ScenPlayer = SCEN_PLAYER_GDI;
  323. ScenDir = SCEN_DIR_EAST;
  324. Whom = HOUSE_GOOD;
  325. Scenario = *(int *)list.Current_Item();
  326. process = false;
  327. okval = false;
  328. break;
  329. default:
  330. break;
  331. }
  332. }
  333. /*
  334. ** Free up the allocations for the text lines in the list box.
  335. */
  336. for (index = 0; index < list.Count(); index++) {
  337. delete [] (char *)list.Get_Item(index);
  338. }
  339. return(okval);
  340. }
  341. #endif