SPECIAL.CPP 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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\special.cpv 1.4 16 Oct 1995 16:50:06 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 : SPECIAL.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 05/27/95 *
  30. * *
  31. * Last Update : May 27, 1995 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #include "function.h"
  37. #define OPTION_WIDTH 236
  38. #define OPTION_HEIGHT 162
  39. #define OPTION_X ((320 - OPTION_WIDTH) / 2)
  40. #define OPTION_Y (200 - OPTION_HEIGHT) / 2
  41. void Special_Dialog(void)
  42. {
  43. SpecialClass oldspecial = Special;
  44. GadgetClass * buttons = NULL;
  45. static struct {
  46. int Description;
  47. int Setting;
  48. CheckBoxClass * Button;
  49. } _options[] = {
  50. // {TXT_DEFENDER_ADVANTAGE, 0, 0},
  51. {TXT_SEPARATE_HELIPAD, 0, 0},
  52. {TXT_VISIBLE_TARGET, 0, 0},
  53. {TXT_TREE_TARGET, 0, 0},
  54. {TXT_MCV_DEPLOY, 0, 0},
  55. {TXT_SMART_DEFENCE, 0, 0},
  56. {TXT_THREE_POINT, 0, 0},
  57. // {TXT_TIBERIUM_GROWTH, 0, 0},
  58. // {TXT_TIBERIUM_SPREAD, 0, 0},
  59. {TXT_TIBERIUM_FAST, 0, 0},
  60. {TXT_ROAD_PIECES, 0, 0},
  61. {TXT_SCATTER, 0, 0},
  62. {TXT_SHOW_NAMES, 0, 0},
  63. };
  64. TextButtonClass ok(200, TXT_OK, TPF_6PT_GRAD|TPF_NOSHADOW, OPTION_X+5, OPTION_Y+OPTION_HEIGHT-15);
  65. TextButtonClass cancel(201, TXT_CANCEL, TPF_6PT_GRAD|TPF_NOSHADOW, OPTION_X+OPTION_WIDTH-50, OPTION_Y+OPTION_HEIGHT-15);
  66. buttons = &ok;
  67. cancel.Add(*buttons);
  68. for (int index = 0; index < sizeof(_options)/sizeof(_options[0]); index++) {
  69. _options[index].Button = new CheckBoxClass(100+index, OPTION_X+7, OPTION_Y+20+(index*10));
  70. if (_options[index].Button) {
  71. _options[index].Button->Add(*buttons);
  72. bool value = false;
  73. switch (_options[index].Description) {
  74. case TXT_SEPARATE_HELIPAD:
  75. value = Special.IsSeparate;
  76. break;
  77. case TXT_SHOW_NAMES:
  78. value = Special.IsNamed;
  79. break;
  80. case TXT_DEFENDER_ADVANTAGE:
  81. value = Special.IsDefenderAdvantage;
  82. break;
  83. case TXT_VISIBLE_TARGET:
  84. value = Special.IsVisibleTarget;
  85. break;
  86. case TXT_TREE_TARGET:
  87. value = Special.IsTreeTarget;
  88. break;
  89. case TXT_MCV_DEPLOY:
  90. value = Special.IsMCVDeploy;
  91. break;
  92. case TXT_SMART_DEFENCE:
  93. value = Special.IsSmartDefense;
  94. break;
  95. case TXT_THREE_POINT:
  96. value = Special.IsThreePoint;
  97. break;
  98. case TXT_TIBERIUM_GROWTH:
  99. value = Special.IsTGrowth;
  100. break;
  101. case TXT_TIBERIUM_SPREAD:
  102. value = Special.IsTSpread;
  103. break;
  104. case TXT_TIBERIUM_FAST:
  105. value = Special.IsTFast;
  106. break;
  107. case TXT_ROAD_PIECES:
  108. value = Special.IsRoad;
  109. break;
  110. case TXT_SCATTER:
  111. value = Special.IsScatter;
  112. break;
  113. }
  114. _options[index].Setting = value;
  115. if (value) {
  116. _options[index].Button->Turn_On();
  117. } else {
  118. _options[index].Button->Turn_Off();
  119. }
  120. }
  121. }
  122. Map.Override_Mouse_Shape(MOUSE_NORMAL);
  123. Set_Logic_Page(SeenBuff);
  124. bool recalc = true;
  125. bool display = true;
  126. bool process = true;
  127. while (process) {
  128. /*
  129. ** If we have just received input focus again after running in the background then
  130. ** we need to redraw.
  131. */
  132. if (AllSurfaces.SurfacesRestored){
  133. AllSurfaces.SurfacesRestored=FALSE;
  134. display=TRUE;
  135. }
  136. if (GameToPlay == GAME_NORMAL) {
  137. Call_Back();
  138. } else {
  139. if (Main_Loop()) {
  140. process = false;
  141. }
  142. }
  143. if (display) {
  144. display = false;
  145. Hide_Mouse();
  146. Dialog_Box(OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT);
  147. Draw_Caption(TXT_SPECIAL_OPTIONS, OPTION_X, OPTION_Y, OPTION_WIDTH);
  148. for (index = 0; index < sizeof(_options)/sizeof(_options[0]); index++) {
  149. Fancy_Text_Print(_options[index].Description, _options[index].Button->X+10, _options[index].Button->Y, CC_GREEN, TBLACK, TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
  150. }
  151. buttons->Draw_All();
  152. Show_Mouse();
  153. }
  154. KeyNumType input = buttons->Input();
  155. switch (input) {
  156. case KN_ESC:
  157. case 200|KN_BUTTON:
  158. process = false;
  159. for (index = 0; index < sizeof(_options)/sizeof(_options[0]); index++) {
  160. switch (_options[index].Description) {
  161. case TXT_SEPARATE_HELIPAD:
  162. oldspecial.IsSeparate = _options[index].Setting;
  163. break;
  164. case TXT_SHOW_NAMES:
  165. oldspecial.IsNamed = _options[index].Setting;
  166. break;
  167. case TXT_DEFENDER_ADVANTAGE:
  168. oldspecial.IsDefenderAdvantage = _options[index].Setting;
  169. break;
  170. case TXT_VISIBLE_TARGET:
  171. oldspecial.IsVisibleTarget = _options[index].Setting;
  172. break;
  173. case TXT_TREE_TARGET:
  174. oldspecial.IsTreeTarget = _options[index].Setting;
  175. break;
  176. case TXT_MCV_DEPLOY:
  177. oldspecial.IsMCVDeploy = _options[index].Setting;
  178. break;
  179. case TXT_SMART_DEFENCE:
  180. oldspecial.IsSmartDefense = _options[index].Setting;
  181. break;
  182. case TXT_THREE_POINT:
  183. oldspecial.IsThreePoint = _options[index].Setting;
  184. break;
  185. case TXT_TIBERIUM_GROWTH:
  186. oldspecial.IsTGrowth = _options[index].Setting;
  187. break;
  188. case TXT_TIBERIUM_SPREAD:
  189. oldspecial.IsTSpread = _options[index].Setting;
  190. break;
  191. case TXT_TIBERIUM_FAST:
  192. oldspecial.IsTFast = _options[index].Setting;
  193. break;
  194. case TXT_ROAD_PIECES:
  195. oldspecial.IsRoad = _options[index].Setting;
  196. break;
  197. case TXT_SCATTER:
  198. oldspecial.IsScatter = _options[index].Setting;
  199. break;
  200. }
  201. }
  202. OutList.Add(EventClass(oldspecial));
  203. break;
  204. case 201|KN_BUTTON:
  205. process = false;
  206. break;
  207. case KN_NONE:
  208. break;
  209. default:
  210. index = (input & ~KN_BUTTON) - 100;
  211. if ((unsigned)index < sizeof(_options)/sizeof(_options[0])) {
  212. _options[index].Setting = (_options[index].Setting == false);
  213. if (_options[index].Setting) {
  214. _options[index].Button->Turn_On();
  215. } else {
  216. _options[index].Button->Turn_Off();
  217. }
  218. }
  219. break;
  220. }
  221. }
  222. Map.Revert_Mouse_Shape();
  223. HiddenPage.Clear();
  224. Map.Flag_To_Redraw(true);
  225. Map.Render();
  226. }