-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add Statistics options hotkeys #13781
Conversation
Updated to use new hotkeys design. |
if (e.Event == KeyInputEvent.Down && !e.IsRepeat) | ||
{ | ||
var h = Hotkey.FromKeyInput(e); | ||
if (h == Game.Settings.Keys.StatisticsBasicKey) |
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 need to be pulled from the chrome logic args (see 12c5d05#diff-9c03e754ef92a76206eb1b2c35d8dfaeR68) because these hardcoded Game.Settings.Keys.*
fields are all going away -- this is the key part of the hotkey rework.
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.
sorry, I pushed only rebased stuff, forgot to commit staged changes. I don't use Keys.StatisticsBasicKey,... anymore.
Updated again, pushed only rebased stuff before. Now pushed also with adaptations for new hotkey design. |
Note for reviewing: ddfb601?w=1 is the meat of this PR, ignoring the whitespace and my prereq changes. The code changes look good, but I haven't yet reviewed the behavior or choice of keys. |
@rob-v can this be prepped for Next+1? |
if (e.Event == KeyInputEvent.Down && !e.IsRepeat) | ||
{ | ||
var h = Hotkey.FromKeyInput(e); | ||
if (h == statisticsBasicKey.GetValue()) |
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.
If you put these keys in an array then you could reduce duplication by looping over them. Compare with #13966.
Updated with hotkeys array as suggested. |
Sorry, but this needs a rebase to avoid another #14028 situation. |
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, just two minor points (of which one is my fault) and a scope creep:
This feature would be much more useful if the tab hotkeys worked directly from the world without opening the panel first. It shouldn't be too hard to adapt:
var stats = widget.GetOrNull<MenuButtonWidget>("OBSERVER_STATS_BUTTON"); | |
if (stats != null) | |
{ | |
stats.IsDisabled = () => disableSystemButtons || world.Map.Visibility.HasFlag(MapVisibility.MissionSelector); | |
stats.OnClick = () => OpenMenuPanel(stats); | |
} |
to open from any of the keys by following the approach of:
OpenRA/OpenRA.Mods.Common/Widgets/Logic/Ingame/CommandBarLogic.cs
Lines 205 to 220 in d99a472
var keyOverrides = widget.GetOrNull<LogicKeyListenerWidget>("MODIFIER_OVERRIDES"); | |
if (keyOverrides != null) | |
{ | |
keyOverrides.AddHandler(e => | |
{ | |
// HACK: enable attack move to be triggered if the ctrl key is pressed | |
var modified = new Hotkey(e.Key, e.Modifiers & ~Modifiers.Ctrl); | |
if (attackMoveButton.Key.GetValue() == modified) | |
{ | |
attackMoveButton.OnKeyPress(e); | |
return true; | |
} | |
return false; | |
}); | |
} |
@@ -146,6 +118,9 @@ public ObserverStatsLogic(World world, WorldRenderer worldRenderer, Widget widge | |||
Ui.Root.RemoveChild(widget); | |||
onExit(); | |||
}; | |||
|
|||
var keyhandler = statsDropDown.Get<LogicKeyListenerWidget>("STATS_DROPDOWN_KEYHANDLER"); | |||
keyhandler.OnKeyPress = HandleKeyPress; |
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 needs to change to keyhandler.AddHandler(HandleKeyPress);
@@ -501,7 +501,12 @@ Action InitInputPanel(Widget panel) | |||
{ "ReplaySpeedSlowKey", "Slow speed" }, | |||
{ "ReplaySpeedRegularKey", "Regular speed" }, | |||
{ "ReplaySpeedFastKey", "Fast speed" }, | |||
{ "ReplaySpeedMaxKey", "Maximum speed" } | |||
{ "ReplaySpeedMaxKey", "Maximum speed" }, | |||
{ "StatisticsBasicKey", "Statistics Basic" }, |
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.
Can we please change these to "Basic Statistics tab" and so on, so they read as proper english?
Updated. |
{ | ||
var ks = Game.Settings.Keys; | ||
var key = new Hotkey(e.Key, e.Modifiers); | ||
Hotkey[] statsKeys = { ks.StatisticsBasicKey, ks.StatisticsEconomyKey, ks.StatisticsProductionKey, ks.StatisticsCombatKey, ks.StatisticsGraphKey }; |
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.
Can you please use NamedHotkey instead? These hardcoded ks.* fields are about to move to yaml.
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 am not sure how to do it.
- move
Statistics<name>Key
from ObserverStatsLogic to MenuButtonsChromeLogic and then pass them to ObserverStatsLogic - use ObserverStatsLogic.StatsHotkeys in MenuButtonsChromeLogic. Trying to find now how to get reference to this Logic object in MenuButtonsChromeLogic
- ?
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.
Hmm, good question. I think the best approach here will be to define/accept the same Statistics*Key args in MenuButtonsChromeLogic
that you use in ObserverStatsLogic
-- define them in both places rather than reference or try to pass them between classes.
Updated. |
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, thanks. Just two more minor nits, and then can you also change the OBSERVER_STATS_BUTTON
Key:
's to use StatisticsBasic
instead of hardcoding F1
?
} | ||
|
||
var keyListener = widget.GetOrNull<LogicKeyListenerWidget>("OBSERVER_KEY_LISTENER"); | ||
if (keyListener != null) |
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.
Style nit: if a single statement includes its own inner blocks, then the outer block should have braces to avoid ambiguity.
readonly IEnumerable<Player> players; | ||
readonly World world; | ||
readonly WorldRenderer worldRenderer; | ||
readonly List<StatsDropDownOption> statsDropDownOptions; |
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 can be an array instead of a list.
Updated. All good ideas. Now much more useful to use hotkeys ingame to open directly a stats tab, though it is little annoying (discouraging to use) that it takes second(s) (since latest playtests) to open a/Stats dialog. Re OBSERVER_STATS_BUTTON's Key - I removed it, as StatisticsBasicKey already works without this now. Is it ok or you prefer to keep it? |
What do you mean? Is this a recent regression?
Keep it please so that it will show the hotkey in the tooltip. |
Updated. |
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.
Sorry, a couple more and hopefully final set of polish issues:
{ "StatisticsEconomyKey", "Economy Statistics" }, | ||
{ "StatisticsProductionKey", "Production Statistics" }, | ||
{ "StatisticsCombatKey", "Combat Statistics" }, | ||
{ "StatisticsGraphKey", "Graph Statistics" } |
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.
"Graph Statistics" doesn't make sense. Can you please change this to "Economy Graph" or "Statistics Graph"?
@@ -502,7 +502,12 @@ Action InitInputPanel(Widget panel) | |||
{ "ReplaySpeedSlowKey", "Slow speed" }, | |||
{ "ReplaySpeedRegularKey", "Regular speed" }, | |||
{ "ReplaySpeedFastKey", "Fast speed" }, | |||
{ "ReplaySpeedMaxKey", "Maximum speed" } | |||
{ "ReplaySpeedMaxKey", "Maximum speed" }, | |||
{ "StatisticsBasicKey", "Basic Statistics" }, |
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.
Please use lower case "s" for consistency with (most of) the other definitions.
Don't worry about the other ones (e.g. "All Players"), I'll fix those in the pr that pulls these out to the yaml.
mods/ts/chrome/ingame-observer.yaml
Outdated
@@ -18,7 +25,6 @@ Container@OBSERVER_WIDGETS: | |||
Height: 25 | |||
Text: Statistics (F1) |
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.
Can you please remove the "(F1)" from here too?
Updated. |
Hm, so this was merged 3 weeks ago but didn't get into release? |
This was merged to bleed, not prep. |
yes, @abcdefg30 already explained it in discord. So it will be re-checked for the future playtests, right? I suppose there is a list of bleed PRs that you go through before proceeding with bug-clearing the coming release? |
This PR, the same as all other PRs merged into bleed until a new prep branch is split off, go into the next playtest, yes. |
Closes #13743
New hotkeys for Statistics dialog: