forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 162
refactor(preferences): Move OptionPreferences class into separate files #1840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bobtista
wants to merge
4
commits into
TheSuperHackers:main
Choose a base branch
from
bobtista:bobtista/separate-option-preferences-files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,032
−1,728
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fc4b7fe
refactor(Common): Separate OptionPreferences into its own files in Core
bobtista a81afb4
nit: cleanup whitespaces in OptionPreferences
bobtista 94efa42
refactor(Common): Move CursorCaptureMode and ScreenEdgeScrollMode enu…
bobtista 0c3f843
fix: Move OptionPreferences.cpp to correct section in CMakeLists.txt
bobtista File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| /* | ||
| ** Command & Conquer Generals Zero Hour(tm) | ||
| ** Copyright 2025 Electronic Arts Inc. | ||
| ** | ||
| ** This program is free software: you can redistribute it and/or modify | ||
| ** it under the terms of the GNU General Public License as published by | ||
| ** the Free Software Foundation, either version 3 of the License, or | ||
| ** (at your option) any later version. | ||
| ** | ||
| ** This program is distributed in the hope that it will be useful, | ||
| ** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| ** GNU General Public License for more details. | ||
| ** | ||
| ** You should have received a copy of the GNU General Public License | ||
| ** along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| //////////////////////////////////////////////////////////////////////////////// | ||
| // // | ||
| // (c) 2001-2003 Electronic Arts Inc. // | ||
| // // | ||
| //////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| /////////////////////////////////////////////////////////////////////////////////////// | ||
| // FILE: OptionPreferences.h | ||
| // Author: Matthew D. Campbell, April 2002 | ||
| // Description: Saving/Loading of option preferences | ||
| /////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "Common/UserPreferences.h" | ||
|
|
||
| typedef UnsignedInt CursorCaptureMode; | ||
| enum CursorCaptureMode_ CPP_11(: CursorCaptureMode) | ||
| { | ||
| CursorCaptureMode_EnabledInWindowedGame = 1<<0, | ||
| CursorCaptureMode_EnabledInWindowedMenu = 1<<1, | ||
| CursorCaptureMode_EnabledInFullscreenGame = 1<<2, | ||
| CursorCaptureMode_EnabledInFullscreenMenu = 1<<3, | ||
|
|
||
| CursorCaptureMode_Default = | ||
| CursorCaptureMode_EnabledInWindowedGame | | ||
| CursorCaptureMode_EnabledInFullscreenGame | | ||
| CursorCaptureMode_EnabledInFullscreenMenu, | ||
| }; | ||
|
|
||
| typedef UnsignedInt ScreenEdgeScrollMode; | ||
| enum ScreenEdgeScrollMode_ CPP_11(: ScreenEdgeScrollMode) | ||
| { | ||
| ScreenEdgeScrollMode_EnabledInWindowedApp = 1<<0, | ||
| ScreenEdgeScrollMode_EnabledInFullscreenApp = 1<<1, | ||
|
|
||
| ScreenEdgeScrollMode_Default = ScreenEdgeScrollMode_EnabledInFullscreenApp, | ||
| }; | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| // OptionPreferences options menu class | ||
| //----------------------------------------------------------------------------- | ||
| class OptionPreferences : public UserPreferences | ||
| { | ||
| public: | ||
| OptionPreferences(); | ||
| virtual ~OptionPreferences(); | ||
|
|
||
| Bool loadFromIniFile(); | ||
|
|
||
| UnsignedInt getLANIPAddress(void); // convenience function | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While at it, perhaps remove this useless comments |
||
| UnsignedInt getOnlineIPAddress(void); // convenience function | ||
| void setLANIPAddress(AsciiString IP); // convenience function | ||
| void setOnlineIPAddress(AsciiString IP); // convenience function | ||
| void setLANIPAddress(UnsignedInt IP); // convenience function | ||
| void setOnlineIPAddress(UnsignedInt IP); // convenience function | ||
| Bool getArchiveReplaysEnabled() const; // convenience function | ||
| Bool getAlternateMouseModeEnabled(void); // convenience function | ||
| Bool getRetaliationModeEnabled(); // convenience function | ||
| Bool getDoubleClickAttackMoveEnabled(void); // convenience function | ||
| Real getScrollFactor(void); // convenience function | ||
| Bool getDrawScrollAnchor(void); | ||
| Bool getMoveScrollAnchor(void); | ||
| Bool getCursorCaptureEnabledInWindowedGame() const; | ||
| Bool getCursorCaptureEnabledInWindowedMenu() const; | ||
| Bool getCursorCaptureEnabledInFullscreenGame() const; | ||
| Bool getCursorCaptureEnabledInFullscreenMenu() const; | ||
| CursorCaptureMode getCursorCaptureMode() const; | ||
| Bool getScreenEdgeScrollEnabledInWindowedApp() const; | ||
| Bool getScreenEdgeScrollEnabledInFullscreenApp() const; | ||
| ScreenEdgeScrollMode getScreenEdgeScrollMode() const; | ||
| Bool getSendDelay(void); // convenience function | ||
| Int getFirewallBehavior(void); // convenience function | ||
| Short getFirewallPortAllocationDelta(void); // convenience function | ||
| UnsignedShort getFirewallPortOverride(void); // convenience function | ||
| Bool getFirewallNeedToRefresh(void); // convenience function | ||
| Bool usesSystemMapDir(void); // convenience function | ||
| AsciiString getPreferred3DProvider(void); // convenience function | ||
| AsciiString getSpeakerType(void); // convenience function | ||
| Real getSoundVolume(void); // convenience function | ||
| Real get3DSoundVolume(void); // convenience function | ||
| Real getSpeechVolume(void); // convenience function | ||
| Real getMusicVolume(void); // convenience function | ||
| Real getMoneyTransactionVolume(void) const; | ||
| Bool saveCameraInReplays(void); | ||
| Bool useCameraInReplays(void); | ||
| Bool getPlayerObserverEnabled() const; | ||
| Int getStaticGameDetail(void); // detail level selected by the user. | ||
| Int getIdealStaticGameDetail(void); // detail level detected for user. | ||
| Real getGammaValue(void); | ||
| Int getTextureReduction(void); | ||
| void getResolution(Int *xres, Int *yres); | ||
| Bool get3DShadowsEnabled(void); | ||
| Bool get2DShadowsEnabled(void); | ||
| Bool getCloudShadowsEnabled(void); | ||
| Bool getLightmapEnabled(void); | ||
| Bool getSmoothWaterEnabled(void); | ||
| Bool getTreesEnabled(void); | ||
| Bool getExtraAnimationsDisabled(void); | ||
| Bool getUseHeatEffects(void); | ||
| Bool getDynamicLODEnabled(void); | ||
| Bool getFPSLimitEnabled(void); | ||
| Bool getNoDynamicLODEnabled(void); | ||
| Bool getBuildingOcclusionEnabled(void); | ||
| Int getParticleCap(void); | ||
|
|
||
| Int getCampaignDifficulty(void); | ||
| void setCampaignDifficulty( Int diff ); | ||
|
|
||
| Int getNetworkLatencyFontSize(void); | ||
| Int getRenderFpsFontSize(void); | ||
| Int getSystemTimeFontSize(void); | ||
| Int getGameTimeFontSize(void); | ||
| Int getPlayerInfoListFontSize(void); | ||
|
|
||
| Real getResolutionFontAdjustment(void); | ||
|
|
||
| Bool getShowMoneyPerMinute(void) const; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,8 +36,6 @@ | |
| #include "Common/STLTypedefs.h" | ||
|
|
||
| class Money; | ||
| typedef UnsignedInt CursorCaptureMode; | ||
| typedef UnsignedInt ScreenEdgeScrollMode; | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| // PUBLIC TYPES /////////////////////////////////////////////////////////////// | ||
|
|
@@ -72,87 +70,6 @@ class UserPreferences : public PreferenceMap | |
| AsciiString m_filename; | ||
| }; | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now this moved away, I think you can remove the forward declarations above. |
||
| // OptionsPreferences options menu class | ||
| //----------------------------------------------------------------------------- | ||
| class OptionPreferences : public UserPreferences | ||
| { | ||
| public: | ||
| OptionPreferences( ); | ||
| virtual ~OptionPreferences(); | ||
|
|
||
| Bool loadFromIniFile(); | ||
|
|
||
| UnsignedInt getLANIPAddress(void); // convenience function | ||
| UnsignedInt getOnlineIPAddress(void); // convenience function | ||
| void setLANIPAddress(AsciiString IP); // convenience function | ||
| void setOnlineIPAddress(AsciiString IP); // convenience function | ||
| void setLANIPAddress(UnsignedInt IP); // convenience function | ||
| void setOnlineIPAddress(UnsignedInt IP); // convenience function | ||
| Bool getArchiveReplaysEnabled() const; // convenience function | ||
| Bool getAlternateMouseModeEnabled(void); // convenience function | ||
| Bool getRetaliationModeEnabled(); // convenience function | ||
| Bool getDoubleClickAttackMoveEnabled(void); // convenience function | ||
| Real getScrollFactor(void); // convenience function | ||
| Bool getDrawScrollAnchor(void); | ||
| Bool getMoveScrollAnchor(void); | ||
| Bool getCursorCaptureEnabledInWindowedGame() const; | ||
| Bool getCursorCaptureEnabledInWindowedMenu() const; | ||
| Bool getCursorCaptureEnabledInFullscreenGame() const; | ||
| Bool getCursorCaptureEnabledInFullscreenMenu() const; | ||
| CursorCaptureMode getCursorCaptureMode() const; | ||
| Bool getScreenEdgeScrollEnabledInWindowedApp() const; | ||
| Bool getScreenEdgeScrollEnabledInFullscreenApp() const; | ||
| ScreenEdgeScrollMode getScreenEdgeScrollMode() const; | ||
| Bool getSendDelay(void); // convenience function | ||
| Int getFirewallBehavior(void); // convenience function | ||
| Short getFirewallPortAllocationDelta(void); // convenience function | ||
| UnsignedShort getFirewallPortOverride(void); // convenience function | ||
| Bool getFirewallNeedToRefresh(void); // convenience function | ||
| Bool usesSystemMapDir(void); // convenience function | ||
| AsciiString getPreferred3DProvider(void); // convenience function | ||
| AsciiString getSpeakerType(void); // convenience function | ||
| Real getSoundVolume(void); // convenience function | ||
| Real get3DSoundVolume(void); // convenience function | ||
| Real getSpeechVolume(void); // convenience function | ||
| Real getMusicVolume(void); // convenience function | ||
| Real getMoneyTransactionVolume(void) const; | ||
| Bool saveCameraInReplays(void); | ||
| Bool useCameraInReplays(void); | ||
| Bool getPlayerObserverEnabled() const; | ||
| Int getStaticGameDetail(void); // detail level selected by the user. | ||
| Int getIdealStaticGameDetail(void); // detail level detected for user. | ||
| Real getGammaValue(void); | ||
| Int getTextureReduction(void); | ||
| void getResolution(Int *xres, Int *yres); | ||
| Bool get3DShadowsEnabled(void); | ||
| Bool get2DShadowsEnabled(void); | ||
| Bool getCloudShadowsEnabled(void); | ||
| Bool getLightmapEnabled(void); | ||
| Bool getSmoothWaterEnabled(void); | ||
| Bool getTreesEnabled(void); | ||
| Bool getExtraAnimationsDisabled(void); | ||
| Bool getUseHeatEffects(void); | ||
| Bool getDynamicLODEnabled(void); | ||
| Bool getFPSLimitEnabled(void); | ||
| Bool getNoDynamicLODEnabled(void); | ||
| Bool getBuildingOcclusionEnabled(void); | ||
| Int getParticleCap(void); | ||
|
|
||
| Int getCampaignDifficulty(void); | ||
| void setCampaignDifficulty( Int diff ); | ||
|
|
||
| Int getNetworkLatencyFontSize(void); | ||
| Int getRenderFpsFontSize(void); | ||
| Int getSystemTimeFontSize(void); | ||
| Int getGameTimeFontSize(void); | ||
| Int getPlayerInfoListFontSize(void); | ||
|
|
||
| Real getResolutionFontAdjustment(void); | ||
|
|
||
| Bool getShowMoneyPerMinute(void) const; | ||
| }; | ||
|
|
||
| //----------------------------------------------------------------------------- | ||
| // LANPreferences class | ||
bobtista marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| //----------------------------------------------------------------------------- | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These enum definitions should not be moved to this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So OptionPreferences.cpp uses CursorCaptureMode_* and ScreenEdgeScrollMode_* constants (in Mouse.h and LookAtXlat.h). Since Core shouldn't depend on upper layers, what would you suggest? eg local constants in OptionPreferences.cpp that mirror the values from Mouse.h/LookAtXlat.h? Create a shared header in Core (eg InputModeDefs.h) that both Core and Generals/GeneralsMD use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core can happily use files from Generals and GeneralsMD