diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 1cb028b145..c969802aae 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -192,6 +192,7 @@
+
diff --git a/OpenRA.Mods.RA/Widgets/ObserverStatsGraphWidget.cs b/OpenRA.Game/Widgets/GraphWidget.cs
similarity index 75%
rename from OpenRA.Mods.RA/Widgets/ObserverStatsGraphWidget.cs
rename to OpenRA.Game/Widgets/GraphWidget.cs
index 11b16f6966..6eddb55c90 100644
--- a/OpenRA.Mods.RA/Widgets/ObserverStatsGraphWidget.cs
+++ b/OpenRA.Game/Widgets/GraphWidget.cs
@@ -16,10 +16,9 @@ using OpenRA.FileFormats;
namespace OpenRA.Widgets
{
- public class ObserverStatsGraphWidget : Widget
+ public class GraphWidget : Widget
{
public Func>>> GetDataSource;
- public Func GetDataScale;
public Func GetValueFormat;
public Func GetXAxisValueFormat;
public Func GetYAxisValueFormat;
@@ -27,7 +26,9 @@ namespace OpenRA.Widgets
public Func GetYAxisSize;
public Func GetXAxisLabel;
public Func GetYAxisLabel;
- public Func GetDisplayYAxisZero;
+ public Func GetDisplayFirstYAxisValue;
+ public Func GetLabelFont;
+ public Func GetAxisFont;
public string ValueFormat = "{0}";
public string XAxisValueFormat = "{0}";
public string YAxisValueFormat = "{0}";
@@ -35,9 +36,11 @@ namespace OpenRA.Widgets
public int YAxisSize = 10;
public string XAxisLabel = "";
public string YAxisLabel = "";
- public bool DisplayYAxisZero = true;
+ public bool DisplayFirstYAxisValue = false;
+ public string LabelFont;
+ public string AxisFont;
- public ObserverStatsGraphWidget()
+ public GraphWidget()
: base()
{
GetValueFormat = () => ValueFormat;
@@ -47,10 +50,12 @@ namespace OpenRA.Widgets
GetYAxisSize = () => YAxisSize;
GetXAxisLabel = () => XAxisLabel;
GetYAxisLabel = () => YAxisLabel;
- GetDisplayYAxisZero = () => DisplayYAxisZero;
+ GetDisplayFirstYAxisValue = () => DisplayFirstYAxisValue;
+ GetLabelFont = () => LabelFont;
+ GetAxisFont = () => AxisFont;
}
- protected ObserverStatsGraphWidget(ObserverStatsGraphWidget other)
+ protected GraphWidget(GraphWidget other)
: base(other)
{
GetDataSource = other.GetDataSource;
@@ -61,7 +66,9 @@ namespace OpenRA.Widgets
GetYAxisSize = other.GetYAxisSize;
GetXAxisLabel = other.GetXAxisLabel;
GetYAxisLabel = other.GetYAxisLabel;
- GetDisplayYAxisZero = other.GetDisplayYAxisZero;
+ GetDisplayFirstYAxisValue = other.GetDisplayFirstYAxisValue;
+ GetLabelFont = other.GetLabelFont;
+ GetAxisFont = other.GetAxisFont;
ValueFormat = other.ValueFormat;
XAxisValueFormat = other.XAxisValueFormat;
YAxisValueFormat = other.YAxisValueFormat;
@@ -69,12 +76,16 @@ namespace OpenRA.Widgets
YAxisSize = other.YAxisSize;
XAxisLabel = other.XAxisLabel;
YAxisLabel = other.YAxisLabel;
- DisplayYAxisZero = other.DisplayYAxisZero;
+ DisplayFirstYAxisValue = other.DisplayFirstYAxisValue;
+ LabelFont = other.LabelFont;
+ AxisFont = other.AxisFont;
}
public override void Draw()
{
- if (GetDataSource == null || !GetDataSource().Any())
+ if (GetDataSource == null || !GetDataSource().Any()
+ || GetLabelFont == null || GetLabelFont() == null
+ || GetAxisFont == null || GetAxisFont() == null)
{
return;
}
@@ -89,8 +100,8 @@ namespace OpenRA.Widgets
Game.Renderer.LineRenderer.DrawLine(origin + new float2(width, 0), origin + new float2(width, -height), Color.White, Color.White);
Game.Renderer.LineRenderer.DrawLine(origin + new float2(0, -height), origin + new float2(width, -height), Color.White, Color.White);
- var tinyBold = Game.Renderer.Fonts["TinyBold"];
- var bold = Game.Renderer.Fonts["Bold"];
+ var tiny = Game.Renderer.Fonts[GetLabelFont()];
+ var bold = Game.Renderer.Fonts[GetAxisFont()];
var xAxisSize = GetXAxisSize();
var yAxisSize = GetYAxisSize();
@@ -109,15 +120,15 @@ namespace OpenRA.Widgets
for (int n = visibleNodeStart, x = 0; n <= visibleNodeEnd; n++, x += xStep)
{
Game.Renderer.LineRenderer.DrawLine(origin + new float2(x, 0), origin + new float2(x, -5), Color.White, Color.White);
- tinyBold.DrawText(GetXAxisValueFormat().F(n), origin + new float2(x, 2), Color.White);
+ tiny.DrawText(GetXAxisValueFormat().F(n), origin + new float2(x, 2), Color.White);
}
bold.DrawText(GetXAxisLabel(), origin + new float2(width / 2, 20), Color.White);
- for (var y = (GetDisplayYAxisZero() ? 0f : yStep); y <= height; y += yStep)
+ for (var y = (GetDisplayFirstYAxisValue() ? 0f : yStep); y <= height; y += yStep)
{
var value = y / scale;
Game.Renderer.LineRenderer.DrawLine(origin + new float2(width - 5, -y), origin + new float2(width, -y), Color.White, Color.White);
- tinyBold.DrawText(GetYAxisValueFormat().F(value), origin + new float2(width + 2, -y), Color.White);
+ tiny.DrawText(GetYAxisValueFormat().F(value), origin + new float2(width + 2, -y), Color.White);
}
bold.DrawText(GetYAxisLabel(), origin + new float2(width + 40, -(height / 2)), Color.White);
@@ -146,18 +157,18 @@ namespace OpenRA.Widgets
if (value != 0)
{
var scaledValue = value * scale;
- tinyBold.DrawText(GetValueFormat().F(value), origin + new float2(x, -scaledValue - 2), color);
+ tiny.DrawText(GetValueFormat().F(value), origin + new float2(x, -scaledValue - 2), color);
}
}
- tinyBold.DrawText(player.PlayerName, new float2(rect.Left, rect.Top) + new float2(5, 10 * playerNameOffset + 3), color);
+ tiny.DrawText(player.PlayerName, new float2(rect.Left, rect.Top) + new float2(5, 10 * playerNameOffset + 3), color);
playerNameOffset++;
}
}
public override Widget Clone()
{
- return new ObserverStatsGraphWidget(this);
+ return new GraphWidget(this);
}
}
}
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 8a6771b0fc..cf1c60aa84 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -384,7 +384,6 @@
-
diff --git a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs
index d6a6dff840..03fb7fb9c4 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs
@@ -151,7 +151,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
earnedThisMinuteGraphHeaders.Visible = true;
var template = earnedThisMinuteGraphTemplate.Clone();
- var graph = template.Get("EARNED_THIS_MIN_GRAPH");
+ var graph = template.Get("EARNED_THIS_MIN_GRAPH");
graph.GetDataSource = () => players.Select(p => Pair.New(p, p.PlayerActor.Trait().EarnedSamples.Select(s => (float)s)));
playerStatsPanel.AddChild(template);
diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml
index 929dbe0175..7446384b43 100644
--- a/mods/ra/chrome/ingame.yaml
+++ b/mods/ra/chrome/ingame.yaml
@@ -865,7 +865,7 @@ Container@OBSERVER_ROOT:
Width:PARENT_RIGHT-100
Height:PARENT_BOTTOM-50
Children:
- ObserverStatsGraph@EARNED_THIS_MIN_GRAPH:
+ Graph@EARNED_THIS_MIN_GRAPH:
X:0
Y:0
Width:PARENT_RIGHT
@@ -878,6 +878,8 @@ Container@OBSERVER_ROOT:
XAxisLabel:m
YAxisLabel:$
DisplayYAxisZero:false
+ LabelFont:TinyBold
+ AxisFont:Bold
Background@FMVPLAYER:
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM