CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

SPECIAL.CPP (8170B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header:   F:\projects\c&c\vcs\code\special.cpv   1.4   16 Oct 1995 16:50:06   JOE_BOSTIC  $ */
     17 /***********************************************************************************************
     18  ***              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               ***
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : SPECIAL.CPP                                                  *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 05/27/95                                                     *
     28  *                                                                                             *
     29  *                  Last Update : May 27, 1995 [JLB]                                           *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #include	"function.h"
     36 
     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 
     42 void Special_Dialog(void)
     43 {
     44 	SpecialClass oldspecial = Special;
     45 	GadgetClass * buttons = NULL;
     46 	static struct {
     47 		int Description;
     48 		int Setting;
     49 		CheckBoxClass * Button;
     50 	} _options[] = {
     51 //		{TXT_DEFENDER_ADVANTAGE, 0, 0},
     52 		{TXT_SEPARATE_HELIPAD, 0, 0},
     53 		{TXT_VISIBLE_TARGET, 0, 0},
     54 		{TXT_TREE_TARGET, 0, 0},
     55 		{TXT_MCV_DEPLOY, 0, 0},
     56 		{TXT_SMART_DEFENCE, 0, 0},
     57 		{TXT_THREE_POINT, 0, 0},
     58 //		{TXT_TIBERIUM_GROWTH, 0, 0},
     59 //		{TXT_TIBERIUM_SPREAD, 0, 0},
     60 		{TXT_TIBERIUM_FAST, 0, 0},
     61 		{TXT_ROAD_PIECES, 0, 0},
     62 		{TXT_SCATTER, 0, 0},
     63 		{TXT_SHOW_NAMES, 0, 0},
     64 	};
     65 
     66 	TextButtonClass ok(200, TXT_OK, TPF_6PT_GRAD|TPF_NOSHADOW, OPTION_X+5, OPTION_Y+OPTION_HEIGHT-15);
     67 	TextButtonClass cancel(201, TXT_CANCEL, TPF_6PT_GRAD|TPF_NOSHADOW, OPTION_X+OPTION_WIDTH-50, OPTION_Y+OPTION_HEIGHT-15);
     68 	buttons = &ok;
     69 	cancel.Add(*buttons);
     70 	int index;
     71 	for (index = 0; index < sizeof(_options)/sizeof(_options[0]); index++) {
     72 		_options[index].Button = new CheckBoxClass(100+index, OPTION_X+7, OPTION_Y+20+(index*10));
     73 		if (_options[index].Button) {
     74 			_options[index].Button->Add(*buttons);
     75 
     76 			bool value = false;
     77 			switch (_options[index].Description) {
     78 				case TXT_SEPARATE_HELIPAD:
     79 					value = Special.IsSeparate;
     80 					break;
     81 
     82 				case TXT_SHOW_NAMES:
     83 					value = Special.IsNamed;
     84 					break;
     85 
     86 				case TXT_DEFENDER_ADVANTAGE:
     87 					value = Special.IsDefenderAdvantage;
     88 					break;
     89 
     90 				case TXT_VISIBLE_TARGET:
     91 					value = Special.IsVisibleTarget;
     92 					break;
     93 
     94 				case TXT_TREE_TARGET:
     95 					value = Special.IsTreeTarget;
     96 					break;
     97 
     98 				case TXT_MCV_DEPLOY:
     99 					value = Special.IsMCVDeploy;
    100 					break;
    101 
    102 				case TXT_SMART_DEFENCE:
    103 					value = Special.IsSmartDefense;
    104 					break;
    105 
    106 				case TXT_THREE_POINT:
    107 					value = Special.IsThreePoint;
    108 					break;
    109 
    110 				case TXT_TIBERIUM_GROWTH:
    111 					value = Special.IsTGrowth;
    112 					break;
    113 
    114 				case TXT_TIBERIUM_SPREAD:
    115 					value = Special.IsTSpread;
    116 					break;
    117 
    118 				case TXT_TIBERIUM_FAST:
    119 					value = Special.IsTFast;
    120 					break;
    121 
    122 				case TXT_ROAD_PIECES:
    123 					value = Special.IsRoad;
    124 					break;
    125 
    126 				case TXT_SCATTER:
    127 					value = Special.IsScatter;
    128 					break;
    129 			}
    130 
    131 			_options[index].Setting = value;
    132 			if (value) {
    133 				_options[index].Button->Turn_On();
    134 			} else {
    135 				_options[index].Button->Turn_Off();
    136 			}
    137 		}
    138 	}
    139 
    140 	Map.Override_Mouse_Shape(MOUSE_NORMAL);
    141 	Set_Logic_Page(SeenBuff);
    142 	bool recalc = true;
    143 	bool display = true;
    144 	bool process = true;
    145 	while (process) {
    146 
    147 		/*
    148 		** If we have just received input focus again after running in the background then
    149 		** we need to redraw.
    150 		*/
    151 		if (AllSurfaces.SurfacesRestored){
    152 			AllSurfaces.SurfacesRestored=FALSE;
    153 			display=TRUE;
    154 		}
    155 
    156 		if (GameToPlay == GAME_NORMAL) {
    157 			Call_Back();
    158 		} else {
    159 			if (Main_Loop()) {
    160 				process = false;
    161 			}
    162 		}
    163 
    164 		if (display) {
    165 			display = false;
    166 
    167 			Hide_Mouse();
    168 			Dialog_Box(OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT);
    169 			Draw_Caption(TXT_SPECIAL_OPTIONS, OPTION_X, OPTION_Y, OPTION_WIDTH);
    170 
    171 			for (index = 0; index < sizeof(_options)/sizeof(_options[0]); index++) {
    172 				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);
    173 			}
    174 			buttons->Draw_All();
    175 			Show_Mouse();
    176 		}
    177 
    178 		KeyNumType input = buttons->Input();
    179 		switch (input) {
    180 			case KN_ESC:
    181 			case 200|KN_BUTTON:
    182 				process = false;
    183 				for (index = 0; index < sizeof(_options)/sizeof(_options[0]); index++) {
    184 					switch (_options[index].Description) {
    185 						case TXT_SEPARATE_HELIPAD:
    186 							oldspecial.IsSeparate = _options[index].Setting;
    187 							break;
    188 
    189 						case TXT_SHOW_NAMES:
    190 							oldspecial.IsNamed = _options[index].Setting;
    191 							break;
    192 
    193 						case TXT_DEFENDER_ADVANTAGE:
    194 							oldspecial.IsDefenderAdvantage = _options[index].Setting;
    195 							break;
    196 
    197 						case TXT_VISIBLE_TARGET:
    198 							oldspecial.IsVisibleTarget = _options[index].Setting;
    199 							break;
    200 
    201 						case TXT_TREE_TARGET:
    202 							oldspecial.IsTreeTarget = _options[index].Setting;
    203 							break;
    204 
    205 						case TXT_MCV_DEPLOY:
    206 							oldspecial.IsMCVDeploy = _options[index].Setting;
    207 							break;
    208 
    209 						case TXT_SMART_DEFENCE:
    210 							oldspecial.IsSmartDefense = _options[index].Setting;
    211 							break;
    212 
    213 						case TXT_THREE_POINT:
    214 							oldspecial.IsThreePoint = _options[index].Setting;
    215 							break;
    216 
    217 						case TXT_TIBERIUM_GROWTH:
    218 							oldspecial.IsTGrowth = _options[index].Setting;
    219 							break;
    220 
    221 						case TXT_TIBERIUM_SPREAD:
    222 							oldspecial.IsTSpread = _options[index].Setting;
    223 							break;
    224 
    225 						case TXT_TIBERIUM_FAST:
    226 							oldspecial.IsTFast = _options[index].Setting;
    227 							break;
    228 
    229 						case TXT_ROAD_PIECES:
    230 							oldspecial.IsRoad = _options[index].Setting;
    231 							break;
    232 
    233 						case TXT_SCATTER:
    234 							oldspecial.IsScatter = _options[index].Setting;
    235 							break;
    236 					}
    237 				}
    238 				OutList.Add(EventClass(oldspecial));
    239 				break;
    240 
    241 			case 201|KN_BUTTON:
    242 				process = false;
    243 				break;
    244 
    245 			case KN_NONE:
    246 				break;
    247 
    248 			default:
    249 				index = (input & ~KN_BUTTON) - 100;
    250 				if ((unsigned)index < sizeof(_options)/sizeof(_options[0])) {
    251 					_options[index].Setting = (_options[index].Setting == false);
    252 					if (_options[index].Setting) {
    253 						_options[index].Button->Turn_On();
    254 					} else {
    255 						_options[index].Button->Turn_Off();
    256 					}
    257 				}
    258 				break;
    259 		}
    260 	}
    261 
    262 	Map.Revert_Mouse_Shape();
    263 	HiddenPage.Clear();
    264 	Map.Flag_To_Redraw(true);
    265 	Map.Render();
    266 }
    267 
    268 
    269 
    270 
    271