DESCDLG.CPP 6.0 KB

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