DESCDLG.CPP (6913B)
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\descdlg.cpv 2.17 16 Oct 1995 16:49:44 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 : DESCDLG.CPP * 24 * * 25 * Programmer : Maria del Mar McCready Legg * 26 * Joe L. Bostic * 27 * * 28 * Start Date : Jan 26, 1995 * 29 * * 30 * Last Update : Jan 26, 1995 [MML] * 31 * * 32 *---------------------------------------------------------------------------------------------* 33 * Functions: * 34 * DescriptionClass::Process -- Handles all the options graphic interface. * 35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 36 37 #include "function.h" 38 #include "descdlg.h" 39 40 41 /*********************************************************************************************** 42 * DescriptionClass::Process -- Handles all the options graphic interface. * 43 * * 44 * This dialog uses an edit box to "fill-out" a description. * 45 * * 46 * INPUT: char *string - return answer here. * 47 * OUTPUT: none * 48 * WARNINGS: none * 49 * HISTORY: 12/31/1994 MML : Created. * 50 *=============================================================================================*/ 51 void DescriptionClass::Process(char *string) 52 { 53 /* 54 ----------------------------------------------------------------- 55 Set up the window. Window x-coords are in bytes not pixels. 56 ----------------------------------------------------------------- 57 */ 58 Set_Window(WINDOW_EDITOR, OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT); 59 Set_Logic_Page(SeenBuff); 60 61 /* 62 ----------------------------------------------------------------------- 63 Create Buttons. Button coords are in pixels, but are window-relative. 64 ----------------------------------------------------------------------- 65 */ 66 TextButtonClass optionsbtn( 67 BUTTON_OPTIONS, 68 TXT_OK, 69 TPF_6PT_GRAD, 70 0, 71 BUTTON_Y); 72 73 TextButtonClass cancelbtn( 74 BUTTON_CANCEL, 75 TXT_CANCEL, 76 TPF_6PT_GRAD, 77 0, 78 BUTTON_Y); 79 80 cancelbtn.X = OPTION_X + ((OPTION_WIDTH - optionsbtn.Width)/3)*2; 81 optionsbtn.X = OPTION_X + ((OPTION_WIDTH - optionsbtn.Width)/3); 82 optionsbtn.Add_Tail(cancelbtn); 83 84 EditClass edit( 85 BUTTON_EDIT, 86 string, 87 31, 88 TPF_6PT_GRAD, 89 0, 90 EDIT_Y 91 ,EDIT_W); 92 93 edit.Set_Focus(); 94 edit.X = OPTION_X + (OPTION_WIDTH - edit.Width)/2, 95 optionsbtn.Add_Tail(edit); 96 97 /* 98 ** This causes left mouse button clicking within the confines of the dialog to 99 ** be ignored if it wasn't recognized by any other button or slider. 100 */ 101 GadgetClass dialog(OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT, GadgetClass::LEFTPRESS); 102 optionsbtn.Add_Tail(dialog); 103 104 /* 105 ** This causes a right click anywhere or a left click outside the dialog region 106 ** to be equivalent to clicking on the return to options dialog. 107 */ 108 ControlClass background(BUTTON_OPTIONS, 0, 0, SeenBuff.Get_Width(), SeenBuff.Get_Height(), GadgetClass::LEFTPRESS|GadgetClass::RIGHTPRESS); 109 optionsbtn.Add_Tail(background); 110 111 /* 112 ------------------- Main Processing Loop -------------------- 113 */ 114 bool display = true; 115 bool process = true; 116 while (process) { 117 118 /* 119 ** If we have just received input focus again after running in the background then 120 ** we need to redraw. 121 */ 122 if (AllSurfaces.SurfacesRestored){ 123 AllSurfaces.SurfacesRestored=FALSE; 124 display=TRUE; 125 } 126 127 /* 128 -------------- Invoke game callback ------------- 129 */ 130 Call_Back(); 131 132 /* 133 -------------- Refresh display if needed -------------- 134 */ 135 if (display) { 136 137 Window_Hide_Mouse(WINDOW_EDITOR); 138 139 /* 140 --------- Draw the background ----------- 141 */ 142 Window_Box (WINDOW_EDITOR, BOXSTYLE_GREEN_BORDER); // has border, raised up 143 Draw_Caption(TXT_MISSION_DESCRIPTION, OPTION_X, OPTION_Y, OPTION_WIDTH); 144 145 /* 146 --------- Draw the titles ----------- 147 */ 148 optionsbtn.Draw_All(); 149 Window_Show_Mouse(); 150 display = false; 151 } 152 153 /* 154 -------------- Get user input --------------- 155 */ 156 KeyNumType input = optionsbtn.Input(); 157 158 /* 159 -------------- Process Input ---------------- 160 */ 161 switch (input) { 162 163 case KN_RETURN: 164 case BUTTON_OPTIONS|KN_BUTTON: 165 strtrim(string); 166 process = false; 167 break; 168 169 case KN_ESC: 170 case BUTTON_CANCEL|KN_BUTTON: 171 string[0]= NULL; 172 strtrim(string); 173 process = false; 174 break; 175 176 case BUTTON_EDIT|KN_BUTTON: 177 break; 178 } 179 } 180 } 181