Skip to content

Commit 8fa92a8

Browse files
authored
refactor(preferences): Move OptionPreferences class into separate files (TheSuperHackers#1840)
1 parent 3ddec3a commit 8fa92a8

40 files changed

Lines changed: 995 additions & 1705 deletions

Core/GameEngine/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ set(GAMEENGINE_SRC
8282
# Include/Common/MultiplayerSettings.h
8383
# Include/Common/NameKeyGenerator.h
8484
Include/Common/ObjectStatusTypes.h
85+
Include/Common/OptionPreferences.h
8586
# Include/Common/OSDisplay.h
8687
# Include/Common/Overridable.h
8788
# Include/Common/Override.h
@@ -613,6 +614,7 @@ set(GAMEENGINE_SRC
613614
# Source/Common/MiniLog.cpp
614615
# Source/Common/MultiplayerSettings.cpp
615616
# Source/Common/NameKeyGenerator.cpp
617+
Source/Common/OptionPreferences.cpp
616618
# Source/Common/PartitionSolver.cpp
617619
# Source/Common/PerfTimer.cpp
618620
Source/Common/RandomValue.cpp
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(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+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
///////////////////////////////////////////////////////////////////////////////////////
26+
// FILE: OptionPreferences.h
27+
// Author: Matthew D. Campbell, April 2002
28+
// Description: Saving/Loading of option preferences
29+
///////////////////////////////////////////////////////////////////////////////////////
30+
31+
#pragma once
32+
33+
#include "Common/UserPreferences.h"
34+
35+
typedef UnsignedInt CursorCaptureMode;
36+
typedef UnsignedInt ScreenEdgeScrollMode;
37+
38+
//-----------------------------------------------------------------------------
39+
// OptionsPreferences options menu class
40+
//-----------------------------------------------------------------------------
41+
class OptionPreferences : public UserPreferences
42+
{
43+
public:
44+
OptionPreferences();
45+
virtual ~OptionPreferences();
46+
47+
Bool loadFromIniFile();
48+
49+
UnsignedInt getLANIPAddress(void);
50+
UnsignedInt getOnlineIPAddress(void);
51+
void setLANIPAddress(AsciiString IP);
52+
void setOnlineIPAddress(AsciiString IP);
53+
void setLANIPAddress(UnsignedInt IP);
54+
void setOnlineIPAddress(UnsignedInt IP);
55+
Bool getArchiveReplaysEnabled() const;
56+
Bool getAlternateMouseModeEnabled(void);
57+
Bool getRetaliationModeEnabled();
58+
Bool getDoubleClickAttackMoveEnabled(void);
59+
Real getScrollFactor(void);
60+
Bool getDrawScrollAnchor(void);
61+
Bool getMoveScrollAnchor(void);
62+
Bool getCursorCaptureEnabledInWindowedGame() const;
63+
Bool getCursorCaptureEnabledInWindowedMenu() const;
64+
Bool getCursorCaptureEnabledInFullscreenGame() const;
65+
Bool getCursorCaptureEnabledInFullscreenMenu() const;
66+
CursorCaptureMode getCursorCaptureMode() const;
67+
Bool getScreenEdgeScrollEnabledInWindowedApp() const;
68+
Bool getScreenEdgeScrollEnabledInFullscreenApp() const;
69+
ScreenEdgeScrollMode getScreenEdgeScrollMode() const;
70+
Bool getSendDelay(void);
71+
Int getFirewallBehavior(void);
72+
Short getFirewallPortAllocationDelta(void);
73+
UnsignedShort getFirewallPortOverride(void);
74+
Bool getFirewallNeedToRefresh(void);
75+
Bool usesSystemMapDir(void);
76+
AsciiString getPreferred3DProvider(void);
77+
AsciiString getSpeakerType(void);
78+
Real getSoundVolume(void);
79+
Real get3DSoundVolume(void);
80+
Real getSpeechVolume(void);
81+
Real getMusicVolume(void);
82+
Real getMoneyTransactionVolume(void) const;
83+
Bool saveCameraInReplays(void);
84+
Bool useCameraInReplays(void);
85+
Bool getPlayerObserverEnabled() const;
86+
Int getStaticGameDetail(void);
87+
Int getIdealStaticGameDetail(void);
88+
Real getGammaValue(void);
89+
Int getTextureReduction(void);
90+
void getResolution(Int *xres, Int *yres);
91+
Bool get3DShadowsEnabled(void);
92+
Bool get2DShadowsEnabled(void);
93+
Bool getCloudShadowsEnabled(void);
94+
Bool getLightmapEnabled(void);
95+
Bool getSmoothWaterEnabled(void);
96+
Bool getTreesEnabled(void);
97+
Bool getExtraAnimationsDisabled(void);
98+
Bool getUseHeatEffects(void);
99+
Bool getDynamicLODEnabled(void);
100+
Bool getFPSLimitEnabled(void);
101+
Bool getBuildingOcclusionEnabled(void);
102+
Int getParticleCap(void);
103+
104+
Int getCampaignDifficulty(void);
105+
void setCampaignDifficulty(Int diff);
106+
107+
Int getNetworkLatencyFontSize(void);
108+
Int getRenderFpsFontSize(void);
109+
Int getSystemTimeFontSize(void);
110+
Int getGameTimeFontSize(void);
111+
Int getPlayerInfoListFontSize(void);
112+
113+
Real getResolutionFontAdjustment(void);
114+
115+
Bool getShowMoneyPerMinute(void) const;
116+
};

Core/GameEngine/Include/Common/UserPreferences.h

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#include "Common/STLTypedefs.h"
3737

3838
class Money;
39-
typedef UnsignedInt CursorCaptureMode;
40-
typedef UnsignedInt ScreenEdgeScrollMode;
4139

4240
//-----------------------------------------------------------------------------
4341
// PUBLIC TYPES ///////////////////////////////////////////////////////////////
@@ -72,87 +70,6 @@ class UserPreferences : public PreferenceMap
7270
AsciiString m_filename;
7371
};
7472

75-
//-----------------------------------------------------------------------------
76-
// OptionsPreferences options menu class
77-
//-----------------------------------------------------------------------------
78-
class OptionPreferences : public UserPreferences
79-
{
80-
public:
81-
OptionPreferences( );
82-
virtual ~OptionPreferences();
83-
84-
Bool loadFromIniFile();
85-
86-
UnsignedInt getLANIPAddress(void); // convenience function
87-
UnsignedInt getOnlineIPAddress(void); // convenience function
88-
void setLANIPAddress(AsciiString IP); // convenience function
89-
void setOnlineIPAddress(AsciiString IP); // convenience function
90-
void setLANIPAddress(UnsignedInt IP); // convenience function
91-
void setOnlineIPAddress(UnsignedInt IP); // convenience function
92-
Bool getArchiveReplaysEnabled() const; // convenience function
93-
Bool getAlternateMouseModeEnabled(void); // convenience function
94-
Bool getRetaliationModeEnabled(); // convenience function
95-
Bool getDoubleClickAttackMoveEnabled(void); // convenience function
96-
Real getScrollFactor(void); // convenience function
97-
Bool getDrawScrollAnchor(void);
98-
Bool getMoveScrollAnchor(void);
99-
Bool getCursorCaptureEnabledInWindowedGame() const;
100-
Bool getCursorCaptureEnabledInWindowedMenu() const;
101-
Bool getCursorCaptureEnabledInFullscreenGame() const;
102-
Bool getCursorCaptureEnabledInFullscreenMenu() const;
103-
CursorCaptureMode getCursorCaptureMode() const;
104-
Bool getScreenEdgeScrollEnabledInWindowedApp() const;
105-
Bool getScreenEdgeScrollEnabledInFullscreenApp() const;
106-
ScreenEdgeScrollMode getScreenEdgeScrollMode() const;
107-
Bool getSendDelay(void); // convenience function
108-
Int getFirewallBehavior(void); // convenience function
109-
Short getFirewallPortAllocationDelta(void); // convenience function
110-
UnsignedShort getFirewallPortOverride(void); // convenience function
111-
Bool getFirewallNeedToRefresh(void); // convenience function
112-
Bool usesSystemMapDir(void); // convenience function
113-
AsciiString getPreferred3DProvider(void); // convenience function
114-
AsciiString getSpeakerType(void); // convenience function
115-
Real getSoundVolume(void); // convenience function
116-
Real get3DSoundVolume(void); // convenience function
117-
Real getSpeechVolume(void); // convenience function
118-
Real getMusicVolume(void); // convenience function
119-
Real getMoneyTransactionVolume(void) const;
120-
Bool saveCameraInReplays(void);
121-
Bool useCameraInReplays(void);
122-
Bool getPlayerObserverEnabled() const;
123-
Int getStaticGameDetail(void); // detail level selected by the user.
124-
Int getIdealStaticGameDetail(void); // detail level detected for user.
125-
Real getGammaValue(void);
126-
Int getTextureReduction(void);
127-
void getResolution(Int *xres, Int *yres);
128-
Bool get3DShadowsEnabled(void);
129-
Bool get2DShadowsEnabled(void);
130-
Bool getCloudShadowsEnabled(void);
131-
Bool getLightmapEnabled(void);
132-
Bool getSmoothWaterEnabled(void);
133-
Bool getTreesEnabled(void);
134-
Bool getExtraAnimationsDisabled(void);
135-
Bool getUseHeatEffects(void);
136-
Bool getDynamicLODEnabled(void);
137-
Bool getFPSLimitEnabled(void);
138-
Bool getNoDynamicLODEnabled(void);
139-
Bool getBuildingOcclusionEnabled(void);
140-
Int getParticleCap(void);
141-
142-
Int getCampaignDifficulty(void);
143-
void setCampaignDifficulty( Int diff );
144-
145-
Int getNetworkLatencyFontSize(void);
146-
Int getRenderFpsFontSize(void);
147-
Int getSystemTimeFontSize(void);
148-
Int getGameTimeFontSize(void);
149-
Int getPlayerInfoListFontSize(void);
150-
151-
Real getResolutionFontAdjustment(void);
152-
153-
Bool getShowMoneyPerMinute(void) const;
154-
};
155-
15673
//-----------------------------------------------------------------------------
15774
// LANPreferences class
15875
//-----------------------------------------------------------------------------

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#include "Common/OSDisplay.h"
6060
#include "Common/Player.h"
6161
#include "Common/PlayerList.h"
62-
#include "Common/UserPreferences.h"
62+
#include "Common/OptionPreferences.h"
6363

6464
#include "GameClient/ControlBar.h"
6565
#include "GameClient/Drawable.h"

0 commit comments

Comments
 (0)