CONFDLG.CPP (8044B)
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&c0\vcs\code\confdlg.cpv 4.67 27 Aug 1996 15:46:52 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 : CONFDLG.CPP * 24 * * 25 * Programmer : Maria del Mar McCready Legg * 26 * Joe L. Bostic * 27 * * 28 * Start Date : Jan 30, 1995 * 29 * * 30 * Last Update : Jan 30, 1995 [MML] * 31 * * 32 *---------------------------------------------------------------------------------------------* 33 * Functions: * 34 * ConfirmationClass::Process -- Handles all the options graphic interface. * 35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 36 37 #include "function.h" 38 #include "confdlg.h" 39 40 41 bool ConfirmationClass::Process(int text) 42 { 43 text; 44 return true; 45 //return(Process(Text_String(text))); 46 } 47 48 #if (0) // ST - 5/8/2019 49 /*********************************************************************************************** 50 * ConfirmationClass::Process -- Handles all the options graphic interface. * 51 * * 52 * This dialog uses an edit box to confirm a deletion. * 53 * * 54 * INPUT: char * string - display in edit box. * 55 * * 56 * OUTPUT: none * 57 * * 58 * WARNINGS: none * 59 * * 60 * HISTORY: 12/31/1994 MML : Created. * 61 *=============================================================================================*/ 62 bool ConfirmationClass::Process(char const * string) 63 { 64 enum { 65 NUM_OF_BUTTONS = 2 66 }; 67 68 char buffer[80*3]; 69 int result = true; 70 int width; 71 int bwidth, bheight; // button width and height 72 int height; 73 int selection = 0; 74 bool pressed; 75 int curbutton; 76 TextButtonClass * buttons[NUM_OF_BUTTONS]; 77 78 /* 79 ** Set up the window. Window x-coords are in bytes not pixels. 80 */ 81 strcpy(buffer, string); 82 Fancy_Text_Print(TXT_NONE, 0, 0, TBLACK, TBLACK, TPF_6PT_GRAD | TPF_NOSHADOW); 83 Format_Window_String(buffer, 200, width, height); 84 width += 60; 85 height += 60; 86 int x = (320 - width) / 2; 87 int y = (200 - height) / 2; 88 89 Set_Logic_Page(SeenBuff); 90 91 /* 92 ** Create Buttons. Button coords are in pixels, but are window-relative. 93 */ 94 bheight = FontHeight + FontYSpacing + 2; 95 bwidth = max( (String_Pixel_Width( Text_String( TXT_YES ) ) + 8), 30); 96 97 TextButtonClass yesbtn(BUTTON_YES, TXT_YES, 98 TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW, 99 x + 10, y + height - (bheight + 5), bwidth ); 100 101 TextButtonClass nobtn(BUTTON_NO, TXT_NO, 102 TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW, 103 x + width - (bwidth + 10), 104 y + height - (bheight + 5), bwidth ); 105 106 nobtn.Add_Tail(yesbtn); 107 108 curbutton = 1; 109 buttons[0] = &yesbtn; 110 buttons[1] = &nobtn; 111 buttons[curbutton]->Turn_On(); 112 113 /* 114 ** This causes left mouse button clicking within the confines of the dialog to 115 ** be ignored if it wasn't recognized by any other button or slider. 116 */ 117 GadgetClass dialog(x, y, width, height, GadgetClass::LEFTPRESS); 118 dialog.Add_Tail(yesbtn); 119 120 /* 121 ** This causes a right click anywhere or a left click outside the dialog region 122 ** to be equivalent to clicking on the return to options dialog. 123 */ 124 ControlClass background(BUTTON_NO, 0, 0, 320, 200, GadgetClass::LEFTPRESS|GadgetClass::RIGHTPRESS); 125 background.Add_Tail(yesbtn); 126 127 /* 128 ** Main Processing Loop. 129 */ 130 bool display = true; 131 bool process = true; 132 pressed = false; 133 while (process) { 134 135 /* 136 ** Invoke game callback. 137 */ 138 if (Session.Type == GAME_NORMAL) { 139 Call_Back(); 140 } else { 141 if (Main_Loop()) { 142 process = false; 143 result = false; 144 } 145 } 146 147 /* 148 ** Refresh display if needed. 149 */ 150 if (display) { 151 Hide_Mouse(); 152 153 /* 154 ** Draw the background. 155 */ 156 Dialog_Box(x, y, width, height); 157 Draw_Caption(TXT_CONFIRMATION, x, y, width); 158 Fancy_Text_Print(buffer, x+20, y+30, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW); 159 160 /* 161 ** Draw the titles. 162 */ 163 yesbtn.Draw_All(); 164 Show_Mouse(); 165 display = false; 166 } 167 168 /* 169 ** Get user input. 170 */ 171 KeyNumType input = yesbtn.Input(); 172 173 /* 174 ** Process Input. 175 */ 176 switch (input) { 177 case KeyNumType(BUTTON_YES | KN_BUTTON): 178 selection = BUTTON_YES; 179 pressed = true; 180 break; 181 182 case (KN_ESC): 183 case KeyNumType(BUTTON_NO | KN_BUTTON): 184 selection = BUTTON_NO; 185 pressed = true; 186 break; 187 188 case (KN_LEFT): 189 buttons[curbutton]->Turn_Off(); 190 buttons[curbutton]->Flag_To_Redraw(); 191 192 curbutton--; 193 if (curbutton < 0) { 194 curbutton = NUM_OF_BUTTONS - 1; 195 } 196 197 buttons[curbutton]->Turn_On(); 198 buttons[curbutton]->Flag_To_Redraw(); 199 break; 200 201 case (KN_RIGHT): 202 buttons[curbutton]->Turn_Off(); 203 buttons[curbutton]->Flag_To_Redraw(); 204 205 curbutton++; 206 if (curbutton > (NUM_OF_BUTTONS - 1) ) { 207 curbutton = 0; 208 } 209 210 buttons[curbutton]->Turn_On(); 211 buttons[curbutton]->Flag_To_Redraw(); 212 break; 213 214 case (KN_RETURN): 215 selection = curbutton + BUTTON_YES; 216 pressed = true; 217 break; 218 219 default: 220 break; 221 } 222 223 if (pressed) { 224 switch (selection) { 225 case (BUTTON_YES): 226 result = true; 227 process = false; 228 break; 229 230 case (BUTTON_NO): 231 result = false; 232 process = false; 233 break; 234 235 default: 236 break; 237 } 238 239 pressed = false; 240 } 241 } 242 return(result); 243 } 244 #endif