Skip to content

Commit

Permalink
Updated the observer ui
Browse files Browse the repository at this point in the history
  • Loading branch information
teinarss committed May 21, 2019
1 parent 909e5f5 commit 9de4ef2
Show file tree
Hide file tree
Showing 22 changed files with 3,821 additions and 2,077 deletions.
5 changes: 5 additions & 0 deletions OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs
Expand Up @@ -236,6 +236,11 @@ public virtual bool IsProducing(ProductionItem item)
return Queue.Count > 0 && Queue[0] == item;
}

public ProductionItem CurrentItem()
{
return Queue.ElementAtOrDefault(0);
}

public virtual IEnumerable<ProductionItem> AllQueued()
{
return Queue;
Expand Down
8 changes: 4 additions & 4 deletions OpenRA.Mods.Common/Widgets/LineGraphWidget.cs
Expand Up @@ -148,19 +148,19 @@ public override void Draw()
for (int n = pointStart, x = 0; n <= pointEnd; n++, x += xStep)
{
cr.DrawLine(origin + new float2(x, 0), origin + new float2(x, -5), 1, Color.White);
tiny.DrawText(GetXAxisValueFormat().F(n), origin + new float2(x, 2), Color.White);
tiny.DrawTextWithShadow(GetXAxisValueFormat().F(n), origin + new float2(x, 2), Color.White, BackgroundColorDark, BackgroundColorLight, 1);
}

bold.DrawText(GetXAxisLabel(), origin + new float2(width / 2, 20), Color.White);
bold.DrawTextWithShadow(GetXAxisLabel(), origin + new float2(width / 2, 20), Color.White, BackgroundColorDark, BackgroundColorLight, 1);

for (var y = GetDisplayFirstYAxisValue() ? 0 : yStep; y <= height; y += yStep)
{
var yValue = y / scale;
cr.DrawLine(origin + new float2(width - 5, -y), origin + new float2(width, -y), 1, Color.White);
tiny.DrawText(GetYAxisValueFormat().F(yValue), origin + new float2(width + 2, -y), Color.White);
tiny.DrawTextWithShadow(GetYAxisValueFormat().F(yValue), origin + new float2(width + 2, -y), Color.White, BackgroundColorDark, BackgroundColorLight, 1);
}

bold.DrawText(GetYAxisLabel(), origin + new float2(width + 40, -(height / 2)), Color.White);
bold.DrawTextWithShadow(GetYAxisLabel(), origin + new float2(width + 40, -(height / 2)), Color.White, BackgroundColorDark, BackgroundColorLight, 1);

cr.DrawLine(origin, origin + new float2(width, 0), 1, Color.White);
cr.DrawLine(origin, origin + new float2(0, -height), 1, Color.White);
Expand Down
35 changes: 0 additions & 35 deletions OpenRA.Mods.Common/Widgets/Logic/Ingame/MenuButtonsChromeLogic.cs
Expand Up @@ -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;
Expand All @@ -38,10 +36,6 @@ public MenuButtonsChromeLogic(Widget widget, ModData modData, World world, Dicti
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");
Expand Down Expand Up @@ -91,35 +85,6 @@ public MenuButtonsChromeLogic(Widget widget, ModData modData, World world, Dicti
});
}

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;
}
Expand Down

0 comments on commit 9de4ef2

Please sign in to comment.