Skip to content
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

Merged
merged 1 commit into from
Sep 24, 2017
Merged

Add Statistics options hotkeys #13781

merged 1 commit into from
Sep 24, 2017

Conversation

rob-v
Copy link
Contributor

@rob-v rob-v commented Aug 6, 2017

Closes #13743
New hotkeys for Statistics dialog:

image

@pchote
Copy link
Member

pchote commented Aug 6, 2017

#13706 and #13711 rework the way hotkeys are defined and used. Can you please update this to use the new system?

@rob-v
Copy link
Contributor Author

rob-v commented Aug 6, 2017

Updated to use new hotkeys design.

if (e.Event == KeyInputEvent.Down && !e.IsRepeat)
{
var h = Hotkey.FromKeyInput(e);
if (h == Game.Settings.Keys.StatisticsBasicKey)
Copy link
Member

@pchote pchote Aug 6, 2017

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.

Copy link
Contributor Author

@rob-v rob-v Aug 6, 2017

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.

@rob-v
Copy link
Contributor Author

rob-v commented Aug 6, 2017

Updated again, pushed only rebased stuff before. Now pushed also with adaptations for new hotkey design.

@pchote
Copy link
Member

pchote commented Aug 6, 2017

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.

@netnazgul
Copy link
Contributor

@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())
Copy link
Member

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.

@rob-v
Copy link
Contributor Author

rob-v commented Sep 4, 2017

Updated with hotkeys array as suggested.

@pchote
Copy link
Member

pchote commented Sep 16, 2017

Sorry, but this needs a rebase to avoid another #14028 situation.

Copy link
Member

@pchote pchote left a 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:

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;
Copy link
Member

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" },
Copy link
Member

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?

@rob-v
Copy link
Contributor Author

rob-v commented Sep 16, 2017

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 };
Copy link
Member

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.

Copy link
Contributor Author

@rob-v rob-v Sep 16, 2017

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.

  1. move Statistics<name>Key from ObserverStatsLogic to MenuButtonsChromeLogic and then pass them to ObserverStatsLogic
  2. use ObserverStatsLogic.StatsHotkeys in MenuButtonsChromeLogic. Trying to find now how to get reference to this Logic object in MenuButtonsChromeLogic
  3. ?

Copy link
Member

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.

@rob-v
Copy link
Contributor Author

rob-v commented Sep 17, 2017

Updated.

Copy link
Member

@pchote pchote left a 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)
Copy link
Member

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;
Copy link
Member

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.

@rob-v
Copy link
Contributor Author

rob-v commented Sep 17, 2017

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?

@pchote
Copy link
Member

pchote commented Sep 17, 2017

though it is little annoying (discouraging to use) that it takes second(s) (since latest playtests) to open a/Stats dialog.

What do you mean? Is this a recent regression?

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?

Keep it please so that it will show the hotkey in the tooltip.

@rob-v
Copy link
Contributor Author

rob-v commented Sep 17, 2017

Updated.
I assumed it is well known, but didn't see more comments about this... #13526
Right, tooltip.

Copy link
Member

@pchote pchote left a 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" }
Copy link
Member

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" },
Copy link
Member

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.

@@ -18,7 +25,6 @@ Container@OBSERVER_WIDGETS:
Height: 25
Text: Statistics (F1)
Copy link
Member

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?

@rob-v
Copy link
Contributor Author

rob-v commented Sep 17, 2017

Updated.

@reaperrr reaperrr merged commit c9b4568 into OpenRA:bleed Sep 24, 2017
@netnazgul
Copy link
Contributor

Hm, so this was merged 3 weeks ago but didn't get into release?

@pchote
Copy link
Member

pchote commented Oct 16, 2017

This was merged to bleed, not prep.

@netnazgul
Copy link
Contributor

netnazgul commented Oct 17, 2017

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?

@abcdefg30
Copy link
Member

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.

@rob-v rob-v deleted the AddStatisticTabsHotkeys branch October 18, 2017 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants