dialogmgr.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. ** Command & Conquer Renegade(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. /***********************************************************************************************
  19. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/dialogmgr.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/08/02 6:05p $*
  29. * *
  30. * $Revision:: 22 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __DIALOG_MGR_H
  39. #define __DIALOG_MGR_H
  40. #include "vector.h"
  41. #include "vector2.h"
  42. #include "vector3.h"
  43. #include "bittype.h"
  44. #include "wwuiinput.h"
  45. ////////////////////////////////////////////////////////////////
  46. // Forward declarations
  47. ////////////////////////////////////////////////////////////////
  48. class DialogBaseClass;
  49. class DialogControlClass;
  50. class DialogTransitionClass;
  51. class ToolTipClass;
  52. ////////////////////////////////////////////////////////////////
  53. // Public constants
  54. ////////////////////////////////////////////////////////////////
  55. enum
  56. {
  57. VKEY_PRESSED = 0x80,
  58. VKEY_TOGGLED = 0x01
  59. };
  60. ////////////////////////////////////////////////////////////////
  61. //
  62. // DialogMgrClass
  63. //
  64. ////////////////////////////////////////////////////////////////
  65. class DialogMgrClass
  66. {
  67. public:
  68. ////////////////////////////////////////////////////////////////
  69. // Public methods
  70. ////////////////////////////////////////////////////////////////
  71. //
  72. // Library management
  73. //
  74. static void Initialize (const char *stylemgr_ini);
  75. static void Shutdown (void);
  76. //
  77. // Per-frame processing
  78. //
  79. static void Render (void);
  80. static void On_Frame_Update (void);
  81. //
  82. // Input support
  83. //
  84. static void Install_Input (WWUIInputClass *instance) { REF_PTR_SET (Input, instance); }
  85. static IME::IMEManager* Get_IME(void)
  86. {return Input->GetIME();}
  87. static void Show_IME_Message(const wchar_t* message, uint32 duration);
  88. //
  89. // Keyboard Input
  90. //
  91. static BYTE * Get_Keyboard_State (void) { return KeyboardState; }
  92. static BYTE Get_VKey_State (BYTE index) { return KeyboardState[index]; }
  93. static void Reset (void);
  94. //
  95. // Mouse Input
  96. //
  97. // Note X,Y are screen coordinates, while the Z component is the mouse wheel
  98. // position.
  99. //
  100. static const Vector3 & Get_Mouse_Pos (void) { return Input->Get_Mouse_Pos (); }
  101. static void Set_Mouse_Pos (const Vector3 &pos) { Input->Set_Mouse_Pos (pos); }
  102. static const Vector3 & Get_Last_Mouse_Pos (void) { return LastMousePos; }
  103. static void Set_Last_Mouse_Pos (const Vector3 &pos){ LastMousePos = pos; }
  104. //
  105. // Mouse button input
  106. //
  107. static bool Is_Button_Down (int vk_mouse_button_id) { return Input->Is_Button_Down (vk_mouse_button_id); };
  108. static bool Was_Button_Down (int vk_mouse_button_id);
  109. //
  110. // Dialog registration
  111. //
  112. static void Register_Dialog (DialogBaseClass *dialog);
  113. static void UnRegister_Dialog (DialogBaseClass *dialog);
  114. static void Flush_Dialogs (void);
  115. static bool Is_Flushing_Dialogs(void);
  116. //
  117. // Timing support
  118. //
  119. static int Get_Time (void) { return CurrTime; }
  120. static int Get_Frame_Time (void) { return LastFrameTime; }
  121. //
  122. // Active dialog support
  123. //
  124. static DialogBaseClass* Find_Dialog(int dialogID);
  125. static void Set_Active_Dialog (DialogBaseClass *dialog);
  126. static DialogBaseClass * Get_Active_Dialog (void) { return ActiveDialog; }
  127. static void Rollback (DialogBaseClass *dialog);
  128. //
  129. // Control support
  130. //
  131. static DialogControlClass * Find_Control (const Vector2 &mouse_pos);
  132. //
  133. // Input capture
  134. //
  135. static void Set_Capture (DialogControlClass *control);
  136. static void Release_Capture (void);
  137. static DialogControlClass * Get_Capture (void) { return InputCapture; }
  138. //
  139. // Focus support
  140. //
  141. static void Set_Focus (DialogControlClass *control);
  142. static DialogControlClass * Get_Focus (void) { return FocusControl; }
  143. //
  144. // Transition support
  145. //
  146. static DialogBaseClass * Peek_Transitioning_Dialog (void) { return TransitionDialog; }
  147. //
  148. // Statistics
  149. //
  150. static int Get_Dialog_Count (void) { return DialogList.Count (); }
  151. private:
  152. ////////////////////////////////////////////////////////////////
  153. // Private constants
  154. ////////////////////////////////////////////////////////////////
  155. enum
  156. {
  157. MB_LBUTTON = 0,
  158. MB_MBUTTON,
  159. MB_RBUTTON,
  160. MB_COUNT,
  161. };
  162. ////////////////////////////////////////////////////////////////
  163. // Private methods
  164. ////////////////////////////////////////////////////////////////
  165. static void On_Dialog_Added (void);
  166. static void On_Dialog_Removed (void);
  167. static void Update_Transition (void);
  168. static void Reset_Inputs (void);
  169. static void Internal_Set_Active_Dialog (DialogBaseClass *dialog);
  170. //
  171. // Keyboard input
  172. //
  173. static bool On_Key_Down (uint32 key_id, uint32 key_data);
  174. static bool On_Key_Up (uint32 key_id);
  175. static void On_Unicode_Char(uint16 unicode);
  176. ////////////////////////////////////////////////////////////////
  177. // Private member data
  178. ////////////////////////////////////////////////////////////////
  179. static DynamicVectorClass<DialogBaseClass *> DialogList;
  180. static DialogBaseClass ** TestArray;
  181. static int TestArrayCount;
  182. static int TestArrayMaxCount;
  183. static bool IsFirstRender;
  184. static bool IsInMenuMode;
  185. static DialogBaseClass * ActiveDialog;
  186. static BYTE KeyboardState[256];
  187. static bool LastMouseButtonState[MB_COUNT];
  188. static DialogControlClass * InputCapture;
  189. static DialogControlClass * FocusControl;
  190. static WWUIInputClass * Input;
  191. static DialogTransitionClass * Transition;
  192. static DialogBaseClass * TransitionDialog;
  193. static DialogBaseClass * PendingActiveDialog;
  194. static uint32 CurrTime;
  195. static uint32 LastFrameTime;
  196. static Vector3 LastMousePos;
  197. static bool IsFlushing;
  198. static ToolTipClass* mIMEMessage;
  199. static uint32 mIMEMessageTime;
  200. ////////////////////////////////////////////////////////////////
  201. // Friend classes
  202. ////////////////////////////////////////////////////////////////
  203. friend WWUIInputClass;
  204. };
  205. #endif //__DIALOG_MGR_H