systemsettings.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/systemsettings.h $*
  25. * *
  26. * $Author:: Steve_t $*
  27. * *
  28. * $Modtime:: 9/07/01 4:18p $*
  29. * *
  30. * $Revision:: 6 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef SYSTEMSETTINGS_H
  39. #define SYSTEMSETTINGS_H
  40. #include "vector.h"
  41. class SystemSettingEntry;
  42. class RegistryClass;
  43. //DEADMENU class MenuEntryClass;
  44. class ConsoleFunctionClass;
  45. //
  46. // System settings, not related to any particular game
  47. // The settings will exist without other underlying subsystems
  48. // ( Static Shadow Settings even when no Physics Scene is allocated )
  49. // but can be applied when the subsystem is available.
  50. // The settings will save and load in the registry.
  51. // The settings will be be made available to the console system.
  52. // The settings can be accessed from the menu system
  53. //
  54. class SystemSettings {
  55. public:
  56. static void Init( void );
  57. static void Shutdown( void );
  58. // List maintenance
  59. static void Add_Setting( SystemSettingEntry * entry ) { SettingList.Add( entry ); }
  60. static void Remove_Setting( SystemSettingEntry * entry ) { SettingList.Delete( entry ); }
  61. static void Apply_All( void );
  62. // Registry save and load
  63. static void Registry_Save( const char * sub_key );
  64. static void Registry_Load( const char * sub_key );
  65. // Menu Entry Access
  66. //DEADMENU static MenuEntryClass * Create_Menu_Entry( const char * setting_name );
  67. // Console Access
  68. static void Add_Console_Functions( DynamicVectorClass<ConsoleFunctionClass *> & list );
  69. private:
  70. static DynamicVectorClass<SystemSettingEntry *> SettingList;
  71. };
  72. //
  73. // System Settings Entries manage each of the different settings.
  74. // Each can apply itself to underlying subsystems
  75. // Each can save and load itself in the registry
  76. // Each can be accessed via the console system
  77. // Each can be accessed from the menu system
  78. //
  79. class SystemSettingEntry {
  80. public:
  81. virtual ~SystemSettingEntry(void){};
  82. virtual const char * Get_Name( void ) = 0;
  83. virtual const char * Get_Help( void ) = 0;
  84. virtual void Apply( void ) = 0;
  85. // Registry save and load
  86. virtual void Registry_Save( RegistryClass & registry ) = 0;
  87. virtual void Registry_Load( RegistryClass & registry ) = 0;
  88. // Menu Entry Access
  89. //DEADMENU virtual MenuEntryClass * Create_Menu_Entry( void ) = 0;
  90. // Console Access
  91. virtual ConsoleFunctionClass * Create_Console_Function() = 0;
  92. };
  93. /*
  94. ** Bool Entry
  95. */
  96. class SystemSettingEntryBool : public SystemSettingEntry {
  97. public:
  98. SystemSettingEntryBool( void );
  99. virtual void Apply( void );
  100. virtual void Registry_Save( RegistryClass & registry );
  101. virtual void Registry_Load( RegistryClass & registry );
  102. //DEADMENU virtual MenuEntryClass * Create_Menu_Entry( void );
  103. virtual ConsoleFunctionClass * Create_Console_Function();
  104. bool Get_State( void );
  105. void Set_State( bool state );
  106. protected:
  107. bool State;
  108. private:
  109. virtual bool Get_Bool( void ) = 0;
  110. virtual void Set_Bool( bool state ) = 0;
  111. };
  112. /*
  113. ** Slider Entry
  114. */
  115. class SystemSettingEntrySlider : public SystemSettingEntry {
  116. public:
  117. SystemSettingEntrySlider( void );
  118. virtual void Apply( void );
  119. virtual void Registry_Save( RegistryClass & registry );
  120. virtual void Registry_Load( RegistryClass & registry );
  121. //DEADMENU virtual MenuEntryClass * Create_Menu_Entry( void );
  122. virtual ConsoleFunctionClass * Create_Console_Function();
  123. int Get_Value( void );
  124. void Set_Value( int value );
  125. int Get_Step_Size( void ) { return StepSize; }
  126. protected:
  127. int Value;
  128. int Min;
  129. int Max;
  130. int StepSize;
  131. void Set_Range( int min, int max ) { Min = min; Max = max; }
  132. void Set_Step_Size( int step ) { StepSize = step; }
  133. private:
  134. virtual int Get_Slider( void ) = 0;
  135. virtual void Set_Slider( int value ) = 0;
  136. };
  137. /*
  138. ** Enum Entry
  139. */
  140. class SystemSettingEntryEnum : public SystemSettingEntry {
  141. public:
  142. SystemSettingEntryEnum( void );
  143. virtual ~SystemSettingEntryEnum(void){};
  144. virtual void Apply( void );
  145. virtual void Registry_Save( RegistryClass & registry );
  146. virtual void Registry_Load( RegistryClass & registry );
  147. //DEADMENU virtual MenuEntryClass * Create_Menu_Entry( void );
  148. virtual ConsoleFunctionClass * Create_Console_Function();
  149. int Get_Selection( void );
  150. void Set_Selection( int selection );
  151. void Set_Selection( const char * name );
  152. protected:
  153. int Selection;
  154. private:
  155. virtual int Get_Enum( void ) = 0;
  156. virtual void Set_Enum( int selection ) = 0;
  157. public:
  158. virtual int Get_Enum_Count( void ) = 0;
  159. virtual const char * Get_Enum_Name( int selection ) = 0;
  160. };
  161. #endif // SYSTEMSETTINGS_H