UserPreferences.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. ** Command & Conquer Generals(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. ///////////////////////////////////////////////////////////////////////////////////////
  24. // FILE: UserPreferences.h
  25. // Author: Matthew D. Campbell, April 2002
  26. // Description: Saving/Loading of user preferences
  27. ///////////////////////////////////////////////////////////////////////////////////////
  28. #pragma once
  29. #ifndef __USERPREFERENCES_H__
  30. #define __USERPREFERENCES_H__
  31. //-----------------------------------------------------------------------------
  32. // USER INCLUDES //////////////////////////////////////////////////////////////
  33. //-----------------------------------------------------------------------------
  34. #include "Common/STLTypedefs.h"
  35. //-----------------------------------------------------------------------------
  36. // PUBLIC TYPES ///////////////////////////////////////////////////////////////
  37. //-----------------------------------------------------------------------------
  38. typedef std::map<AsciiString, AsciiString> PreferenceMap;
  39. //-----------------------------------------------------------------------------
  40. // UserPreferences base class
  41. //-----------------------------------------------------------------------------
  42. class UserPreferences : public PreferenceMap
  43. {
  44. public:
  45. UserPreferences();
  46. virtual ~UserPreferences();
  47. virtual Bool load(AsciiString fname);
  48. virtual Bool write(void);
  49. Bool getBool(AsciiString key, Bool defaultValue) const;
  50. Real getReal(AsciiString key, Real defaultValue) const;
  51. Int getInt(AsciiString key, Int defaultValue) const;
  52. AsciiString getAsciiString(AsciiString key, AsciiString defaultValue) const;
  53. void setBool(AsciiString key, Bool val);
  54. void setReal(AsciiString key, Real val);
  55. void setInt(AsciiString key, Int val);
  56. void setAsciiString(AsciiString key, AsciiString val);
  57. protected:
  58. AsciiString m_filename;
  59. };
  60. //-----------------------------------------------------------------------------
  61. // OptionsPreferences options menu class
  62. //-----------------------------------------------------------------------------
  63. class OptionPreferences : public UserPreferences
  64. {
  65. public:
  66. OptionPreferences( );
  67. virtual ~OptionPreferences();
  68. UnsignedInt getLANIPAddress(void); // convenience function
  69. UnsignedInt getOnlineIPAddress(void); // convenience function
  70. void setLANIPAddress(AsciiString IP); // convenience function
  71. void setOnlineIPAddress(AsciiString IP); // convenience function
  72. void setLANIPAddress(UnsignedInt IP); // convenience function
  73. void setOnlineIPAddress(UnsignedInt IP); // convenience function
  74. Bool getAlternateMouseModeEnabled(void); // convenience function
  75. Real getScrollFactor(void); // convenience function
  76. Bool getSendDelay(void); // convenience function
  77. Int getFirewallBehavior(void); // convenience function
  78. Short getFirewallPortAllocationDelta(void); // convenience function
  79. UnsignedShort getFirewallPortOverride(void); // convenience function
  80. Bool getFirewallNeedToRefresh(void); // convenience function
  81. Bool usesSystemMapDir(void); // convenience function
  82. AsciiString getPreferred3DProvider(void); // convenience function
  83. AsciiString getSpeakerType(void); // convenience function
  84. Real getSoundVolume(void); // convenience function
  85. Real get3DSoundVolume(void); // convenience function
  86. Real getSpeechVolume(void); // convenience function
  87. Real getMusicVolume(void); // convenience function
  88. Bool saveCameraInReplays(void);
  89. Bool useCameraInReplays(void);
  90. Int getStaticGameDetail(void); // detail level selected by the user.
  91. Int getIdealStaticGameDetail(void); // detail level detected for user.
  92. Real getGammaValue(void);
  93. Int getTextureReduction(void);
  94. void getResolution(Int *xres, Int *yres);
  95. Bool get3DShadowsEnabled(void);
  96. Bool get2DShadowsEnabled(void);
  97. Bool getCloudShadowsEnabled(void);
  98. Bool getLightmapEnabled(void);
  99. Bool getSmoothWaterEnabled(void);
  100. Bool getTreesEnabled(void);
  101. Bool getExtraAnimationsDisabled(void);
  102. Bool getDynamicLODEnabled(void);
  103. Bool getFPSLimitEnabled(void);
  104. Bool getNoDynamicLODEnabled(void);
  105. Bool getBuildingOcclusionEnabled(void);
  106. Int getParticleCap(void);
  107. Int getCampaignDifficulty(void);
  108. void setCampaignDifficulty( Int diff );
  109. };
  110. //-----------------------------------------------------------------------------
  111. // LANPreferences class
  112. //-----------------------------------------------------------------------------
  113. class LANPreferences : public UserPreferences
  114. {
  115. public:
  116. LANPreferences();
  117. virtual ~LANPreferences();
  118. UnicodeString getUserName(void); // convenience function
  119. Int getPreferredFaction(void); // convenience function
  120. Int getPreferredColor(void); // convenience function
  121. AsciiString getPreferredMap(void); // convenience function
  122. Bool usesSystemMapDir(void); // convenience function
  123. Int getNumRemoteIPs(void); // convenience function
  124. UnicodeString getRemoteIPEntry(Int i); // convenience function
  125. };
  126. #endif // __USERPREFERENCES_H__