DESCDLG.CPP 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. ** Command & Conquer Red Alert(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: /CounterStrike/DESCDLG.CPP 1 3/03/97 10:24a 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 : DESCDLG.CPP *
  26. * *
  27. * Programmer : Maria del Mar McCready Legg *
  28. * Joe L. Bostic *
  29. * *
  30. * Start Date : Jan 26, 1995 *
  31. * *
  32. * Last Update : Jan 26, 1995 [MML] *
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * DescriptionClass::Process -- Handles all the options graphic interface. *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "function.h"
  39. #include "descdlg.h"
  40. /***********************************************************************************************
  41. * DescriptionClass::Process -- Handles all the options graphic interface. *
  42. * *
  43. * This dialog uses an edit box to "fill-out" a description. *
  44. * *
  45. * INPUT: char *string - return answer here. *
  46. * OUTPUT: none *
  47. * WARNINGS: none *
  48. * HISTORY: 12/31/1994 MML : Created. *
  49. *=============================================================================================*/
  50. void DescriptionClass::Process(char * string)
  51. {
  52. /*
  53. ** Set up the window. Window x-coords are in bytes not pixels.
  54. */
  55. Set_Window(WINDOW_EDITOR, OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT);
  56. Set_Logic_Page(SeenBuff);
  57. /*
  58. ** Create Buttons. Button coords are in pixels, but are window-relative.
  59. */
  60. TextButtonClass optionsbtn(BUTTON_OPTIONS, TXT_OK, TPF_BUTTON, 0, BUTTON_Y);
  61. TextButtonClass cancelbtn(BUTTON_CANCEL, TXT_CANCEL, TPF_BUTTON, 0, BUTTON_Y);
  62. cancelbtn.X = OPTION_X + ((OPTION_WIDTH - optionsbtn.Width)/3)*2;
  63. optionsbtn.X = OPTION_X + ((OPTION_WIDTH - optionsbtn.Width)/3);
  64. optionsbtn.Add_Tail(cancelbtn);
  65. EditClass edit(
  66. BUTTON_EDIT,
  67. string,
  68. 31,
  69. TPF_6PT_GRAD,
  70. 0,
  71. EDIT_Y,
  72. EDIT_W);
  73. edit.Set_Focus();
  74. edit.X = OPTION_X + (OPTION_WIDTH - edit.Width)/2,
  75. optionsbtn.Add_Tail(edit);
  76. /*
  77. ** This causes left mouse button clicking within the confines of the dialog to
  78. ** be ignored if it wasn't recognized by any other button or slider.
  79. */
  80. GadgetClass dialog(OPTION_X, OPTION_Y, OPTION_WIDTH, OPTION_HEIGHT, GadgetClass::LEFTPRESS);
  81. optionsbtn.Add_Tail(dialog);
  82. /*
  83. ** This causes a right click anywhere or a left click outside the dialog region
  84. ** to be equivalent to clicking on the return to options dialog.
  85. */
  86. ControlClass background(BUTTON_OPTIONS, 0, 0, 320, 200, GadgetClass::LEFTPRESS|GadgetClass::RIGHTPRESS);
  87. optionsbtn.Add_Tail(background);
  88. /*
  89. ** Main Processing Loop
  90. */
  91. bool display = true;
  92. bool process = true;
  93. while (process) {
  94. /*
  95. ** Invoke game callback
  96. */
  97. Call_Back();
  98. /*
  99. ** Refresh display if needed
  100. */
  101. if (display) {
  102. Window_Hide_Mouse(WINDOW_EDITOR);
  103. /*
  104. ** Draw the background
  105. */
  106. Window_Box (WINDOW_EDITOR, BOXSTYLE_BORDER); // has border, raised up
  107. Draw_Caption(TXT_MISSION_DESCRIPTION, OPTION_X, OPTION_Y, OPTION_WIDTH);
  108. /*
  109. ** Draw the titles
  110. */
  111. optionsbtn.Draw_All();
  112. Window_Show_Mouse();
  113. display = false;
  114. }
  115. /*
  116. ** Get user input
  117. */
  118. KeyNumType input = optionsbtn.Input();
  119. /*
  120. ** Process Input
  121. */
  122. switch (input) {
  123. case KN_RETURN:
  124. case KeyNumType(BUTTON_OPTIONS|KN_BUTTON):
  125. strtrim(string);
  126. process = false;
  127. break;
  128. case KN_ESC:
  129. case KeyNumType(BUTTON_CANCEL|KN_BUTTON):
  130. string[0]= NULL;
  131. strtrim(string);
  132. process = false;
  133. break;
  134. case KeyNumType(BUTTON_EDIT|KN_BUTTON):
  135. break;
  136. default:
  137. break;
  138. }
  139. }
  140. }