Updated the observer ui

This commit is contained in:
teinarss
2019-05-22 14:56:52 +02:00
committed by Paul Chote
parent b90b3095a6
commit 9fc8b829e4
23 changed files with 3773 additions and 2076 deletions

View File

@@ -12,13 +12,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Common.Lint;
using OpenRA.Mods.Common.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
[ChromeLogicArgsHotkeys("StatisticsBasicKey", "StatisticsEconomyKey", "StatisticsProductionKey", "StatisticsCombatKey", "StatisticsGraphKey", "StatisticsArmyGraphKey")]
public class MenuButtonsChromeLogic : ChromeLogic
{
readonly World world;
@@ -38,10 +36,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
menuRoot = Ui.Root.Get("MENU_ROOT");
MiniYaml yaml;
string[] keyNames = Enum.GetNames(typeof(ObserverStatsPanel));
var statsHotkeys = new HotkeyReference[keyNames.Length];
for (var i = 0; i < keyNames.Length; i++)
statsHotkeys[i] = logicArgs.TryGetValue("Statistics" + keyNames[i] + "Key", out yaml) ? modData.Hotkeys[yaml.Value] : new HotkeyReference();
// System buttons
var options = widget.GetOrNull<MenuButtonWidget>("OPTIONS_BUTTON");
@@ -91,35 +85,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
});
}
var stats = widget.GetOrNull<MenuButtonWidget>("OBSERVER_STATS_BUTTON");
if (stats != null)
{
stats.IsDisabled = () => disableSystemButtons || world.Map.Visibility.HasFlag(MapVisibility.MissionSelector);
stats.OnClick = () => OpenMenuPanel(stats, new WidgetArgs() { { "activePanel", ObserverStatsPanel.Basic } });
}
var keyListener = widget.GetOrNull<LogicKeyListenerWidget>("OBSERVER_KEY_LISTENER");
if (keyListener != null)
{
keyListener.AddHandler(e =>
{
if (e.Event == KeyInputEvent.Down && !e.IsRepeat)
{
for (var i = 0; i < statsHotkeys.Length; i++)
{
if (statsHotkeys[i].IsActivatedBy(e))
{
Game.Sound.PlayNotification(modData.DefaultRules, null, "Sounds", clickSound, null);
OpenMenuPanel(stats, new WidgetArgs() { { "activePanel", i } });
return true;
}
}
}
return false;
});
}
if (logicArgs.TryGetValue("ClickSound", out yaml))
clickSound = yaml.Value;
}