CONFDLG.CPP 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: F:\projects\c&c0\vcs\code\confdlg.cpv 4.67 27 Aug 1996 15:46:52 JOE_BOSTIC $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : CONFDLG.CPP *
  22. * *
  23. * Programmer : Maria del Mar McCready Legg *
  24. * Joe L. Bostic *
  25. * *
  26. * Start Date : Jan 30, 1995 *
  27. * *
  28. * Last Update : Jan 30, 1995 [MML] *
  29. * *
  30. *---------------------------------------------------------------------------------------------*
  31. * Functions: *
  32. * ConfirmationClass::Process -- Handles all the options graphic interface. *
  33. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  34. #include "function.h"
  35. #include "confdlg.h"
  36. bool ConfirmationClass::Process(int text)
  37. {
  38. text;
  39. return true;
  40. //return(Process(Text_String(text)));
  41. }
  42. #if (0) // ST - 5/8/2019
  43. /***********************************************************************************************
  44. * ConfirmationClass::Process -- Handles all the options graphic interface. *
  45. * *
  46. * This dialog uses an edit box to confirm a deletion. *
  47. * *
  48. * INPUT: char * string - display in edit box. *
  49. * *
  50. * OUTPUT: none *
  51. * *
  52. * WARNINGS: none *
  53. * *
  54. * HISTORY: 12/31/1994 MML : Created. *
  55. *=============================================================================================*/
  56. bool ConfirmationClass::Process(char const * string)
  57. {
  58. enum {
  59. NUM_OF_BUTTONS = 2
  60. };
  61. char buffer[80*3];
  62. int result = true;
  63. int width;
  64. int bwidth, bheight; // button width and height
  65. int height;
  66. int selection = 0;
  67. bool pressed;
  68. int curbutton;
  69. TextButtonClass * buttons[NUM_OF_BUTTONS];
  70. /*
  71. ** Set up the window. Window x-coords are in bytes not pixels.
  72. */
  73. strcpy(buffer, string);
  74. Fancy_Text_Print(TXT_NONE, 0, 0, TBLACK, TBLACK, TPF_6PT_GRAD | TPF_NOSHADOW);
  75. Format_Window_String(buffer, 200, width, height);
  76. width += 60;
  77. height += 60;
  78. int x = (320 - width) / 2;
  79. int y = (200 - height) / 2;
  80. Set_Logic_Page(SeenBuff);
  81. /*
  82. ** Create Buttons. Button coords are in pixels, but are window-relative.
  83. */
  84. bheight = FontHeight + FontYSpacing + 2;
  85. bwidth = max( (String_Pixel_Width( Text_String( TXT_YES ) ) + 8), 30);
  86. TextButtonClass yesbtn(BUTTON_YES, TXT_YES,
  87. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  88. x + 10, y + height - (bheight + 5), bwidth );
  89. TextButtonClass nobtn(BUTTON_NO, TXT_NO,
  90. TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_NOSHADOW,
  91. x + width - (bwidth + 10),
  92. y + height - (bheight + 5), bwidth );
  93. nobtn.Add_Tail(yesbtn);
  94. curbutton = 1;
  95. buttons[0] = &yesbtn;
  96. buttons[1] = &nobtn;
  97. buttons[curbutton]->Turn_On();
  98. /*
  99. ** This causes left mouse button clicking within the confines of the dialog to
  100. ** be ignored if it wasn't recognized by any other button or slider.
  101. */
  102. GadgetClass dialog(x, y, width, height, GadgetClass::LEFTPRESS);
  103. dialog.Add_Tail(yesbtn);
  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_NO, 0, 0, 320, 200, GadgetClass::LEFTPRESS|GadgetClass::RIGHTPRESS);
  109. background.Add_Tail(yesbtn);
  110. /*
  111. ** Main Processing Loop.
  112. */
  113. bool display = true;
  114. bool process = true;
  115. pressed = false;
  116. while (process) {
  117. /*
  118. ** Invoke game callback.
  119. */
  120. if (Session.Type == GAME_NORMAL) {
  121. Call_Back();
  122. } else {
  123. if (Main_Loop()) {
  124. process = false;
  125. result = false;
  126. }
  127. }
  128. /*
  129. ** Refresh display if needed.
  130. */
  131. if (display) {
  132. Hide_Mouse();
  133. /*
  134. ** Draw the background.
  135. */
  136. Dialog_Box(x, y, width, height);
  137. Draw_Caption(TXT_CONFIRMATION, x, y, width);
  138. Fancy_Text_Print(buffer, x+20, y+30, GadgetClass::Get_Color_Scheme(), TBLACK, TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
  139. /*
  140. ** Draw the titles.
  141. */
  142. yesbtn.Draw_All();
  143. Show_Mouse();
  144. display = false;
  145. }
  146. /*
  147. ** Get user input.
  148. */
  149. KeyNumType input = yesbtn.Input();
  150. /*
  151. ** Process Input.
  152. */
  153. switch (input) {
  154. case KeyNumType(BUTTON_YES | KN_BUTTON):
  155. selection = BUTTON_YES;
  156. pressed = true;
  157. break;
  158. case (KN_ESC):
  159. case KeyNumType(BUTTON_NO | KN_BUTTON):
  160. selection = BUTTON_NO;
  161. pressed = true;
  162. break;
  163. case (KN_LEFT):
  164. buttons[curbutton]->Turn_Off();
  165. buttons[curbutton]->Flag_To_Redraw();
  166. curbutton--;
  167. if (curbutton < 0) {
  168. curbutton = NUM_OF_BUTTONS - 1;
  169. }
  170. buttons[curbutton]->Turn_On();
  171. buttons[curbutton]->Flag_To_Redraw();
  172. break;
  173. case (KN_RIGHT):
  174. buttons[curbutton]->Turn_Off();
  175. buttons[curbutton]->Flag_To_Redraw();
  176. curbutton++;
  177. if (curbutton > (NUM_OF_BUTTONS - 1) ) {
  178. curbutton = 0;
  179. }
  180. buttons[curbutton]->Turn_On();
  181. buttons[curbutton]->Flag_To_Redraw();
  182. break;
  183. case (KN_RETURN):
  184. selection = curbutton + BUTTON_YES;
  185. pressed = true;
  186. break;
  187. default:
  188. break;
  189. }
  190. if (pressed) {
  191. switch (selection) {
  192. case (BUTTON_YES):
  193. result = true;
  194. process = false;
  195. break;
  196. case (BUTTON_NO):
  197. result = false;
  198. process = false;
  199. break;
  200. default:
  201. break;
  202. }
  203. pressed = false;
  204. }
  205. }
  206. return(result);
  207. }
  208. #endif