refactor(preferences): Move OptionPreferences class into separate files#1840
refactor(preferences): Move OptionPreferences class into separate files#1840bobtista wants to merge 4 commits intoTheSuperHackers:mainfrom
Conversation
0b163bd to
32c7126
Compare
10f65f6 to
f7e888b
Compare
xezon
left a comment
There was a problem hiding this comment.
The opening post says that files were added to Core, but that is not correct. And they cant be added to Core, because the files are not yet merged.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
Outdated
Show resolved
Hide resolved
| @@ -72,82 +72,8 @@ class UserPreferences : public PreferenceMap | |||
| AsciiString m_filename; | |||
| }; | |||
|
|
|||
| //----------------------------------------------------------------------------- | |||
There was a problem hiding this comment.
Now this moved away, I think you can remove the forward declarations above.
|
I think it would be good to merge and move user preferences to Core first, but it will require merging #2180 first. |
|
I have merged the UserPreferences code and moved it to Core with #2182. So when that is merged you can directly split off to Core and do not need 2 copies for it. |
|
This pull can be advanced. |
f7e888b to
a82300b
Compare
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/Common/OptionPreferences.h | New header defining OptionPreferences class and related enums (CursorCaptureMode, ScreenEdgeScrollMode) moved from Generals-specific headers to Core for proper layering |
| Core/GameEngine/Source/Common/OptionPreferences.cpp | Implementation moved from OptionsMenu.cpp to Core, now properly accesses enum constants defined in the header |
| Core/GameEngine/CMakeLists.txt | Added new header and source files in correct alphabetical positions |
| Core/GameEngine/Include/Common/UserPreferences.h | Removed OptionPreferences class declaration and related typedefs, now defined in dedicated header |
| Generals/Code/GameEngine/Include/GameClient/Mouse.h | Removed CursorCaptureMode enum definition (moved to Core), now includes OptionPreferences.h |
| Generals/Code/GameEngine/Include/GameClient/LookAtXlat.h | Removed ScreenEdgeScrollMode enum definition (moved to Core), now includes OptionPreferences.h |
| Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | Removed ~800 lines of OptionPreferences implementation (moved to Core), updated includes |
| GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | Removed ~800 lines of OptionPreferences implementation (moved to Core), updated includes |
Flowchart
flowchart TD
A[UserPreferences.h in Core] -->|Before: Contains| B[OptionPreferences class]
C[OptionsMenu.cpp in Generals] -->|Before: Contains| D[OptionPreferences implementation]
E[Mouse.h in Generals/MD] -->|Before: Defines| F[CursorCaptureMode enum]
G[LookAtXlat.h in Generals/MD] -->|Before: Defines| H[ScreenEdgeScrollMode enum]
I[New: OptionPreferences.h in Core] -->|After: Contains| J[OptionPreferences class]
I -->|After: Defines| K[CursorCaptureMode enum]
I -->|After: Defines| L[ScreenEdgeScrollMode enum]
M[New: OptionPreferences.cpp in Core] -->|After: Contains| N[OptionPreferences implementation]
O[Mouse.h in Generals/MD] -->|After: Includes| I
P[LookAtXlat.h in Generals/MD] -->|After: Includes| I
Q[OptionsMenu.cpp in Generals/MD] -->|After: Includes| I
style I fill:#90EE90
style M fill:#90EE90
style J fill:#ADD8E6
style K fill:#ADD8E6
style L fill:#ADD8E6
style N fill:#ADD8E6
Last reviewed commit: 0c3f843
858cab4 to
94efa42
Compare
|
|
||
| Bool loadFromIniFile(); | ||
|
|
||
| UnsignedInt getLANIPAddress(void); // convenience function |
There was a problem hiding this comment.
While at it, perhaps remove this useless comments
| }; | ||
|
|
||
| typedef UnsignedInt ScreenEdgeScrollMode; | ||
| enum ScreenEdgeScrollMode_ CPP_11(: ScreenEdgeScrollMode) |
There was a problem hiding this comment.
These enum definitions should not be moved to this file.
There was a problem hiding this comment.
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.
Core can happily use files from Generals and GeneralsMD
|
|
||
| #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine | ||
|
|
||
| #include "Common/OptionPreferences.h" |
There was a problem hiding this comment.
Are all these new includes really necessary to compile or was this blanket added everywhere?
There was a problem hiding this comment.
I could try including it somewhere else eg userpreferences but didn't want a circular dependency, I'll see how I can make it simpler
There was a problem hiding this comment.
Right so OptionPreferences.h needs to include UserPreferences.h, right? Then replace UserPreferences.h with OptionPreferences.h where applicable.
Separates the
OptionPreferencesclass fromUserPreferences.handOptionsMenu.cppinto dedicated files in Core.Changes
New files created in Core:
Core/GameEngine/Include/Common/OptionPreferences.h- Class declarationCore/GameEngine/Source/Common/OptionPreferences.cpp- Implementation (uses GeneralsMD version which has the superset of methods)