-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Split settings panels logic and add support for custom panels #18948
Conversation
Good idea. How about putting these in a |
7e2d0bb
to
a93ede9
Compare
Update: moved classes to a |
a93ede9
to
f6f67a8
Compare
Can you please start bugging me on Discord every couple of days until I review this? We should try and merge this before anyone else wants to touch the settings menu. |
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.
@pchote I added some comments over the code to guide the review. The diff is quite large but that's mostly because of splitting and moving things around.
}; | ||
} | ||
|
||
public void RegisterSettingsPanel(string panelID, string label, Func<Widget, Action> init, Func<Widget, Action> reset) |
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.
This method keeps the same logic as before only now each separate chrome logic class registers itself.
Button@BUTTON_TEMPLATE: | ||
Width: 110 | ||
Height: 35 |
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.
Tab buttons are created from a template.
ImageName: enabled | ||
IgnoreMouseOver: True | ||
Container@ADVANCED_PANEL: | ||
Container@PANEL_TEMPLATE: |
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.
Tab panes are created from a template.
|
||
namespace OpenRA.Mods.Common.Widgets.Logic | ||
{ | ||
public static class SettingsUtils |
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.
I moved the common methods for binding inputs to a static class.
f6f67a8
to
55ca9f5
Compare
Update: Cleaned up unnecessary usings and constructor arguments and addressed #18948 (comment) |
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.
Looks good overall. I diffed the split files versus the original and have confirmed that nothing has been unexpectedly dropped, or changed during rebases etc.
IMO having the panels reach into SettingsLogic to modify NeedsRestart isn't great - what do you think about doing this instead: ccef396 ?
mods/cnc/chrome/settings.yaml
Outdated
Types: Music | ||
ButtonStride: 120, 0 | ||
Panels: | ||
Display: |
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 keys don't seem to be used at all?
How about using a straight dictionary?
Panels:
DISPLAY_PANEL: Display
AUDIO_PANEL: Audio
INPUT_PANEL: Input
HOTKEYS_PANEL: Hotkeys
ADVANCED_PANEL: Advanced
?
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.
Yes, this is more concise and straight-forward 👍
readonly int2 buttonStride; | ||
readonly List<ButtonWidget> buttons = new List<ButtonWidget>(); | ||
readonly List<Tuple<string, string>> panels = new List<Tuple<string, string>>(); | ||
string activePanel = ""; |
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.
Cleaner if this defaulted to null?
55ca9f5
to
dd05089
Compare
Update:
I will squash the commits once this is approved. |
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.
LGTM once the fixups are squashed.
dd05089
to
cfdd336
Compare
Update: squashed fixups. |
pinging for a second review. |
cfdd336
to
c2da1c5
Compare
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.
Rebased and updated the dates to 2021.
This PR:
SettingsLogic
into chrome logic classes for each panelsettings.yaml
into a wrapper for the settings window and containers for each panelWhy:
SettingsLogic
had become very large and difficult to maintain