Add customizable properties to observer clocks.

This commit is contained in:
Zimmermann Gyula
2015-09-01 16:03:01 +02:00
parent bbdd597917
commit 1358024b38
4 changed files with 531 additions and 7 deletions

View File

@@ -29,6 +29,10 @@ namespace OpenRA.Mods.Common.Widgets
public int IconHeight = 24; public int IconHeight = 24;
public int IconSpacing = 8; public int IconSpacing = 8;
public string ClockAnimation = "clock";
public string ClockSequence = "idle";
public string ClockPalette = "chrome";
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer) public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer)
{ {
@@ -44,6 +48,14 @@ namespace OpenRA.Mods.Common.Widgets
world = other.world; world = other.world;
worldRenderer = other.worldRenderer; worldRenderer = other.worldRenderer;
clocks = other.clocks; clocks = other.clocks;
IconWidth = other.IconWidth;
IconHeight = other.IconHeight;
IconSpacing = other.IconSpacing;
ClockAnimation = other.ClockAnimation;
ClockSequence = other.ClockSequence;
ClockPalette = other.ClockPalette;
} }
public override void Draw() public override void Draw()
@@ -58,7 +70,7 @@ namespace OpenRA.Mods.Common.Widgets
foreach (var queue in queues) foreach (var queue in queues)
if (!clocks.ContainsKey(queue.Trait)) if (!clocks.ContainsKey(queue.Trait))
clocks.Add(queue.Trait, new Animation(world, "clock")); clocks.Add(queue.Trait, new Animation(world, ClockAnimation));
var iconSize = new float2(IconWidth, IconHeight); var iconSize = new float2(IconWidth, IconHeight);
foreach (var queue in queues) foreach (var queue in queues)
@@ -85,11 +97,11 @@ namespace OpenRA.Mods.Common.Widgets
worldRenderer.Palette(pio.Palette()), 0.5f * pio.Scale()); worldRenderer.Palette(pio.Palette()), 0.5f * pio.Scale());
var clock = clocks[queue.Trait]; var clock = clocks[queue.Trait];
clock.PlayFetchIndex("idle", clock.PlayFetchIndex(ClockSequence,
() => current.TotalTime == 0 ? 0 : ((current.TotalTime - current.RemainingTime) () => current.TotalTime == 0 ? 0 : ((current.TotalTime - current.RemainingTime)
* (clock.CurrentSequence.Length - 1) / current.TotalTime)); * (clock.CurrentSequence.Length - 1) / current.TotalTime));
clock.Tick(); clock.Tick();
WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(bi.IconPalette), 0.5f); WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(ClockPalette), 0.5f);
var tiny = Game.Renderer.Fonts["Tiny"]; var tiny = Game.Renderer.Fonts["Tiny"];
var text = GetOverlayForItem(current, world.Timestep); var text = GetOverlayForItem(current, world.Timestep);

View File

@@ -30,6 +30,10 @@ namespace OpenRA.Mods.Common.Widgets
public int IconHeight = 24; public int IconHeight = 24;
public int IconSpacing = 8; public int IconSpacing = 8;
public string ClockAnimation = "clock";
public string ClockSequence = "idle";
public string ClockPalette = "chrome";
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ObserverSupportPowerIconsWidget(World world, WorldRenderer worldRenderer) public ObserverSupportPowerIconsWidget(World world, WorldRenderer worldRenderer)
{ {
@@ -47,6 +51,14 @@ namespace OpenRA.Mods.Common.Widgets
world = other.world; world = other.world;
worldRenderer = other.worldRenderer; worldRenderer = other.worldRenderer;
clocks = other.clocks; clocks = other.clocks;
IconWidth = other.IconWidth;
IconHeight = other.IconHeight;
IconSpacing = other.IconSpacing;
ClockAnimation = other.ClockAnimation;
ClockSequence = other.ClockSequence;
ClockPalette = other.ClockPalette;
} }
public override void Draw() public override void Draw()
@@ -60,7 +72,7 @@ namespace OpenRA.Mods.Common.Widgets
foreach (var power in powers) foreach (var power in powers)
{ {
if (!clocks.ContainsKey(power.a.Key)) if (!clocks.ContainsKey(power.a.Key))
clocks.Add(power.a.Key, new Animation(world, "clock")); clocks.Add(power.a.Key, new Animation(world, ClockAnimation));
} }
var iconSize = new float2(IconWidth, IconHeight); var iconSize = new float2(IconWidth, IconHeight);
@@ -75,11 +87,11 @@ namespace OpenRA.Mods.Common.Widgets
WidgetUtils.DrawSHPCentered(icon.Image, location + 0.5f * iconSize, worldRenderer.Palette(item.Info.IconPalette), 0.5f); WidgetUtils.DrawSHPCentered(icon.Image, location + 0.5f * iconSize, worldRenderer.Palette(item.Info.IconPalette), 0.5f);
var clock = clocks[power.a.Key]; var clock = clocks[power.a.Key];
clock.PlayFetchIndex("idle", clock.PlayFetchIndex(ClockSequence,
() => item.TotalTime == 0 ? 0 : ((item.TotalTime - item.RemainingTime) () => item.TotalTime == 0 ? 0 : ((item.TotalTime - item.RemainingTime)
* (clock.CurrentSequence.Length - 1) / item.TotalTime)); * (clock.CurrentSequence.Length - 1) / item.TotalTime));
clock.Tick(); clock.Tick();
WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(item.Info.IconPalette), 0.5f); WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(ClockPalette), 0.5f);
var tiny = Game.Renderer.Fonts["Tiny"]; var tiny = Game.Renderer.Fonts["Tiny"];
var text = GetOverlayForItem(item, world.Timestep); var text = GetOverlayForItem(item, world.Timestep);

View File

@@ -0,0 +1,500 @@
Background@INGAME_OBSERVERSTATS_BG:
Logic: ObserverStatsLogic
X: 25
Y: 50
Width: 950
Height: 500
Background: dialog
Children:
Container@BACKGROUND:
Width: PARENT_RIGHT
Height: PARENT_BOTTOM - 35
Children:
Label@TITLE:
X: 0
Y: 15
Width: PARENT_RIGHT
Height: 25
Font: Bold
Align: Center
Text: Statistics
DropDownButton@STATS_DROPDOWN:
X: PARENT_RIGHT-200
Y: 15
Width: 185
Height: 25
Font: Bold
Container@BASIC_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 85
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@CASH_HEADER:
X: 245
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Cash
Label@EARNED_MIN_HEADER:
X: 325
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned/min
Label@POWER_HEADER:
X: 425
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Power
Label@KILLS_HEADER:
X: 505
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Kills
Align: Right
Label@DEATHS_HEADER:
X: 565
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Deaths
Align: Right
Label@KD_RATIO_HEADER:
X: 625
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Kills/Deaths
Align: Right
Label@ACTIONS_MIN_HEADER:
X: 755
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Actions/min
Align: Right
Container@ECONOMY_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 85
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@CASH_HEADER:
X: 245
Y: 40
Width: 80
Height: 25
Font: Bold
Text: Cash
Label@EARNED_MIN_HEADER:
X: 325
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned/min
Label@EARNED_THIS_MIN_HEADER:
X: 425
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned this min
Label@ASSETS_HEADER:
X: 565
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Assets
Label@EARNED_HEADER:
X: 645
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Earned
Label@SPENT_HEADER:
X: 725
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Spent
Label@HARVESTERS_HEADER:
X: 805
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Harvesters
Align: Right
Container@PRODUCTION_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 85
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@PRODUCTION_HEADER:
X: 245
Y: 40
Width: 320
Height: 25
Font: Bold
Text: Production
Label@SUPPORT_POWERS_HEADER:
X: 565
Y: 40
Width: 320
Height: 25
Font: Bold
Text: Support Powers
Container@COMBAT_STATS_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@PLAYER_HEADER:
X: 85
Y: 40
Width: 160
Height: 25
Font: Bold
Text: Player
Label@KILLS_COST_HEADER:
X: 245
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Kills
Label@DEATHS_COST_HEADER:
X: 325
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Deaths
Label@UNITS_KILLED_HEADER:
X: 425
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Units Killed
Align: Right
Label@UNITS_DEAD_HEADER:
X: 525
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Units Lost
Align: Right
Label@BUILDINGS_KILLED_HEADER:
X: 645
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Bldg Killed
Align: Right
Label@BUILDINGS_DEAD_HEADER:
X: 745
Y: 40
Width: 40
Height: 25
Font: Bold
Text: Bldg Lost
Align: Right
Container@EARNED_THIS_MIN_GRAPH_HEADERS:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Children:
Label@EARNED_THIS_MIN_HEADER:
X: 0
Y: 40
Width: PARENT_RIGHT
Height: 25
Font: Bold
Text: Earnings received each minute
Align: Center
ScrollPanel@PLAYER_STATS_PANEL:
X: 25
Y: 70
Width: PARENT_RIGHT-50
Height: PARENT_BOTTOM-45-50
TopBottomSpacing: 5
ItemSpacing: 5
Children:
ScrollItem@TEAM_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Label@TEAM:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
Font: Bold
ScrollItem@BASIC_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
Label@CASH:
X: 215
Y: 0
Width: 80
Height: PARENT_BOTTOM
Label@EARNED_MIN:
X: 295
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@POWER:
X: 395
Y: 0
Width: 80
Height: PARENT_BOTTOM
Label@KILLS:
X: 475
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@DEATHS:
X: 535
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@KD_RATIO:
X: 595
Y: 0
Width: 80
Height: PARENT_BOTTOM
Align: Right
Label@ACTIONS_MIN:
X: 725
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
ScrollItem@ECONOMY_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
Label@CASH:
X: 215
Y: 0
Width: 80
Height: PARENT_BOTTOM
Label@EARNED_MIN:
X: 295
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@EARNED_THIS_MIN:
X: 395
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@ASSETS:
X: 535
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@EARNED:
X: 615
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@SPENT:
X: 695
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@HARVESTERS:
X: 775
Y: 0
Width: 60
Height: PARENT_BOTTOM
Align: Right
ScrollItem@PRODUCTION_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
ObserverProductionIcons@PRODUCTION_ICONS:
X: 215
Y: 0
Width: 320
Height: PARENT_BOTTOM
ClockPalette: iconclock
ObserverSupportPowerIcons@SUPPORT_POWER_ICONS:
X: 535
Y: 0
Width: 320
Height: PARENT_BOTTOM
ClockPalette: iconclock
ScrollItem@COMBAT_PLAYER_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-35
Height: 25
Children:
Image@FLAG:
X: 20
Y: 5
Width: 35
Height: PARENT_BOTTOM-5
ImageName: random
ImageCollection: flags
Label@PLAYER:
X: 55
Y: 0
Width: 160
Height: PARENT_BOTTOM
Font: Bold
Label@KILLS_COST:
X: 215
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@DEATHS_COST:
X: 295
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@UNITS_KILLED:
X: 395
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@UNITS_DEAD:
X: 495
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@BUILDINGS_KILLED:
X: 615
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Label@BUILDINGS_DEAD:
X: 715
Y: 0
Width: 40
Height: PARENT_BOTTOM
Align: Right
Container@EARNED_THIS_MIN_GRAPH_TEMPLATE:
X: 0
Y: 0
Width: PARENT_RIGHT-100
Height: PARENT_BOTTOM-50
Children:
LineGraph@EARNED_THIS_MIN_GRAPH:
X: 0
Y: 0
Width: PARENT_RIGHT
Height: PARENT_BOTTOM
ValueFormat: ${0}
XAxisValueFormat: {0}
YAxisValueFormat: ${0:F0}
XAxisSize: 20
YAxisSize: 10
XAxisLabel: m
YAxisLabel: $
LabelFont: TinyBold
AxisFont: Bold
Button@CLOSE:
X: PARENT_RIGHT - 145
Y: PARENT_BOTTOM - 45
Width: 120
Height: 25
Text: Close
Key: escape
Font: Bold

View File

@@ -143,7 +143,7 @@ ChromeLayout:
./mods/ra/chrome/ingame-infoobjectives.yaml ./mods/ra/chrome/ingame-infoobjectives.yaml
./mods/ra/chrome/ingame-infostats.yaml ./mods/ra/chrome/ingame-infostats.yaml
./mods/d2k/chrome/ingame-observer.yaml ./mods/d2k/chrome/ingame-observer.yaml
./mods/ra/chrome/ingame-observerstats.yaml ./mods/ts/chrome/ingame-observerstats.yaml
./mods/ts/chrome/ingame-player.yaml ./mods/ts/chrome/ingame-player.yaml
./mods/ra/chrome/ingame-perf.yaml ./mods/ra/chrome/ingame-perf.yaml
./mods/ra/chrome/ingame-debug.yaml ./mods/ra/chrome/ingame-debug.yaml