Hook up tib storage bar
This commit is contained in:
@@ -91,6 +91,7 @@
|
|||||||
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
<Compile Include="Widgets\Logic\CncIngameMenuLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
<Compile Include="Widgets\Logic\CncConquestObjectivesLogic.cs" />
|
||||||
<Compile Include="Widgets\PowerBarWidget.cs" />
|
<Compile Include="Widgets\PowerBarWidget.cs" />
|
||||||
|
<Compile Include="Widgets\SiloBarWidget.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
providedFrac*b.Height);
|
providedFrac*b.Height);
|
||||||
Game.Renderer.LineRenderer.FillRect(rect, color);
|
Game.Renderer.LineRenderer.FillRect(rect, color);
|
||||||
|
|
||||||
var indicator = ChromeProvider.GetImage("powerbar-bits", "indicator");
|
var indicator = ChromeProvider.GetImage("sidebar-bits", "left-indicator");
|
||||||
|
|
||||||
var drainedFrac = pm.PowerDrained / powerScaleBy;
|
var drainedFrac = pm.PowerDrained / powerScaleBy;
|
||||||
lastDrainedFrac = drainedFrac = float2.Lerp(lastDrainedFrac.GetValueOrDefault(drainedFrac), drainedFrac, .3f);
|
lastDrainedFrac = drainedFrac = float2.Lerp(lastDrainedFrac.GetValueOrDefault(drainedFrac), drainedFrac, .3f);
|
||||||
|
|||||||
65
OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs
Executable file
65
OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Widgets
|
||||||
|
{
|
||||||
|
public class SiloBarWidget : Widget
|
||||||
|
{
|
||||||
|
public float LowStorageThreshold = 0.8f;
|
||||||
|
float? lastCapacityFrac;
|
||||||
|
float? lastStoredFrac;
|
||||||
|
|
||||||
|
readonly PlayerResources pr;
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public SiloBarWidget( [ObjectCreator.Param] World world )
|
||||||
|
{
|
||||||
|
pr = world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawInner()
|
||||||
|
{
|
||||||
|
float scaleBy = 100;
|
||||||
|
var max = Math.Max(pr.OreCapacity, pr.Ore);
|
||||||
|
while (max >= scaleBy) scaleBy *= 2;
|
||||||
|
|
||||||
|
// Current capacity
|
||||||
|
var capacityFrac = pr.OreCapacity / scaleBy;
|
||||||
|
lastCapacityFrac = capacityFrac = float2.Lerp(lastCapacityFrac.GetValueOrDefault(capacityFrac), capacityFrac, .3f);
|
||||||
|
|
||||||
|
var color = Color.LimeGreen;
|
||||||
|
if (pr.Ore >= LowStorageThreshold*pr.OreCapacity)
|
||||||
|
color = Color.Orange;
|
||||||
|
if (pr.Ore == pr.OreCapacity)
|
||||||
|
color = Color.Red;
|
||||||
|
|
||||||
|
var b = RenderBounds;
|
||||||
|
var rect = new RectangleF(Game.viewport.Location.X + b.X,
|
||||||
|
Game.viewport.Location.Y + b.Y + (1-capacityFrac)*b.Height,
|
||||||
|
(float)b.Width,
|
||||||
|
capacityFrac*b.Height);
|
||||||
|
Game.Renderer.LineRenderer.FillRect(rect, color);
|
||||||
|
|
||||||
|
var indicator = ChromeProvider.GetImage("sidebar-bits", "right-indicator");
|
||||||
|
|
||||||
|
var storedFrac = pr.Ore / scaleBy;
|
||||||
|
lastStoredFrac = storedFrac = float2.Lerp(lastStoredFrac.GetValueOrDefault(storedFrac), storedFrac, .3f);
|
||||||
|
|
||||||
|
float2 pos = new float2(b.X, b.Y + (1-storedFrac)*b.Height - indicator.size.Y / 2);
|
||||||
|
|
||||||
|
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,8 +55,8 @@
|
|||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="11.313708"
|
inkscape:zoom="11.313708"
|
||||||
inkscape:cx="324.81809"
|
inkscape:cx="331.88915"
|
||||||
inkscape:cy="470.28486"
|
inkscape:cy="473.8204"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
showgrid="false"
|
showgrid="false"
|
||||||
@@ -105,14 +105,6 @@
|
|||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
id="layer1"
|
id="layer1"
|
||||||
transform="translate(0,-540.3622)">
|
transform="translate(0,-540.3622)">
|
||||||
<rect
|
|
||||||
style="fill:#31312e;fill-opacity:1;stroke:#c8b9ff;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
|
|
||||||
id="rect3946"
|
|
||||||
width="275.13324"
|
|
||||||
height="150.9407"
|
|
||||||
x="244.65895"
|
|
||||||
y="-22.546127"
|
|
||||||
transform="translate(0,540.3622)" />
|
|
||||||
<rect
|
<rect
|
||||||
y="572.86218"
|
y="572.86218"
|
||||||
x="352.5"
|
x="352.5"
|
||||||
@@ -782,5 +774,11 @@
|
|||||||
height="2"
|
height="2"
|
||||||
x="323"
|
x="323"
|
||||||
y="583.36224" />
|
y="583.36224" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||||
|
d="m 336,580.3622 -4,4 0,0 4,4 z"
|
||||||
|
id="path3952"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccccc" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 40 KiB |
@@ -380,5 +380,6 @@ strategic: strategic.png
|
|||||||
enemy_owned: 32,32,32,32
|
enemy_owned: 32,32,32,32
|
||||||
player_owned: 96,0,32,32
|
player_owned: 96,0,32,32
|
||||||
|
|
||||||
powerbar-bits: chrome.png
|
sidebar-bits: chrome.png
|
||||||
indicator: 320,40,11,8
|
left-indicator: 320,40,11,8
|
||||||
|
right-indicator: 325,40,11,8
|
||||||
|
|||||||
@@ -155,6 +155,12 @@ Container@INGAME_ROOT:
|
|||||||
Width:10
|
Width:10
|
||||||
Height:152
|
Height:152
|
||||||
Background:panel-black
|
Background:panel-black
|
||||||
|
Children:
|
||||||
|
SiloBar:
|
||||||
|
X:1
|
||||||
|
Y:1
|
||||||
|
Width:PARENT_RIGHT-2
|
||||||
|
Height:PARENT_BOTTOM-2
|
||||||
Label@SILOICON:
|
Label@SILOICON:
|
||||||
X:171
|
X:171
|
||||||
Y:170
|
Y:170
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 37 KiB |
Reference in New Issue
Block a user