Kill PowerBarWidget. Fixes #3446.
This commit is contained in:
@@ -102,7 +102,6 @@
|
|||||||
<Compile Include="Widgets\Logic\CncPerfDebugLogic.cs" />
|
<Compile Include="Widgets\Logic\CncPerfDebugLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\CncSettingsLogic.cs" />
|
<Compile Include="Widgets\Logic\CncSettingsLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\ProductionTooltipLogic.cs" />
|
<Compile Include="Widgets\Logic\ProductionTooltipLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\SimpleTooltipLogic.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\SupportPowerTooltipLogic.cs" />
|
<Compile Include="Widgets\Logic\SupportPowerTooltipLogic.cs" />
|
||||||
<Compile Include="Widgets\Logic\WorldTooltipLogic.cs" />
|
<Compile Include="Widgets\Logic\WorldTooltipLogic.cs" />
|
||||||
<Compile Include="Widgets\ProductionPaletteWidget.cs" />
|
<Compile Include="Widgets\ProductionPaletteWidget.cs" />
|
||||||
@@ -110,7 +109,6 @@
|
|||||||
<Compile Include="Widgets\SupportPowersWidget.cs" />
|
<Compile Include="Widgets\SupportPowersWidget.cs" />
|
||||||
<Compile Include="WithFire.cs" />
|
<Compile Include="WithFire.cs" />
|
||||||
<Compile Include="WithRoof.cs" />
|
<Compile Include="WithRoof.cs" />
|
||||||
<Compile Include="Widgets\ResourceBarWidget.cs" />
|
|
||||||
<Compile Include="Widgets\Logic\ProductionTabsLogic.cs" />
|
<Compile Include="Widgets\Logic\ProductionTabsLogic.cs" />
|
||||||
<Compile Include="Widgets\ProductionTypeButtonWidget.cs" />
|
<Compile Include="Widgets\ProductionTypeButtonWidget.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -125,11 +125,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
siloBar.GetProvided = () => playerResources.OreCapacity;
|
siloBar.GetProvided = () => playerResources.OreCapacity;
|
||||||
siloBar.GetUsed = () => playerResources.Ore;
|
siloBar.GetUsed = () => playerResources.Ore;
|
||||||
siloBar.TooltipFormat = "Silo Usage: {0}/{1}";
|
siloBar.TooltipFormat = "Silo Usage: {0}/{1}";
|
||||||
siloBar.RightIndicator = true;
|
|
||||||
siloBar.GetBarColor = () =>
|
siloBar.GetBarColor = () =>
|
||||||
{
|
{
|
||||||
if (playerResources.Ore == playerResources.OreCapacity) return Color.Red;
|
if (playerResources.Ore == playerResources.OreCapacity)
|
||||||
if (playerResources.Ore >= 0.8 * playerResources.OreCapacity) return Color.Orange;
|
return Color.Red;
|
||||||
|
if (playerResources.Ore >= 0.8 * playerResources.OreCapacity)
|
||||||
|
return Color.Orange;
|
||||||
return Color.LimeGreen;
|
return Color.LimeGreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -137,11 +138,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
powerBar.GetProvided = () => powerManager.PowerProvided;
|
powerBar.GetProvided = () => powerManager.PowerProvided;
|
||||||
powerBar.GetUsed = () => powerManager.PowerDrained;
|
powerBar.GetUsed = () => powerManager.PowerDrained;
|
||||||
powerBar.TooltipFormat = "Power Usage: {0}/{1}";
|
powerBar.TooltipFormat = "Power Usage: {0}/{1}";
|
||||||
powerBar.RightIndicator = false;
|
|
||||||
powerBar.GetBarColor = () =>
|
powerBar.GetBarColor = () =>
|
||||||
{
|
{
|
||||||
if (powerManager.PowerState == PowerState.Critical) return Color.Red;
|
if (powerManager.PowerState == PowerState.Critical)
|
||||||
if (powerManager.PowerState == PowerState.Low) return Color.Orange;
|
return Color.Red;
|
||||||
|
if (powerManager.PowerState == PowerState.Low)
|
||||||
|
return Color.Orange;
|
||||||
return Color.LimeGreen;
|
return Color.LimeGreen;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
#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.FileFormats;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
|
||||||
{
|
|
||||||
public class ResourceBarWidget : Widget
|
|
||||||
{
|
|
||||||
public readonly string TooltipTemplate = "SIMPLE_TOOLTIP";
|
|
||||||
public readonly string TooltipContainer;
|
|
||||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
|
||||||
|
|
||||||
public float LowStorageThreshold = 0.8f;
|
|
||||||
EWMA providedLerp = new EWMA(0.3f);
|
|
||||||
EWMA usedLerp = new EWMA(0.3f);
|
|
||||||
|
|
||||||
public Func<float> GetProvided = () => 0;
|
|
||||||
public Func<float> GetUsed = () => 0;
|
|
||||||
public string TooltipFormat = "";
|
|
||||||
public bool RightIndicator = false;
|
|
||||||
public Func<Color> GetBarColor = () => Color.White;
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public ResourceBarWidget(World world)
|
|
||||||
{
|
|
||||||
tooltipContainer = Lazy.New(() =>
|
|
||||||
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void MouseEntered()
|
|
||||||
{
|
|
||||||
if (TooltipContainer == null) return;
|
|
||||||
Func<string> getText = () => TooltipFormat.F(GetUsed(), GetProvided());
|
|
||||||
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "getText", getText }});
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void MouseExited()
|
|
||||||
{
|
|
||||||
if (TooltipContainer == null) return;
|
|
||||||
tooltipContainer.Value.RemoveTooltip();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Draw()
|
|
||||||
{
|
|
||||||
var scaleBy = 100.0f;
|
|
||||||
var provided = GetProvided();
|
|
||||||
var used = GetUsed();
|
|
||||||
var max = Math.Max(provided, used);
|
|
||||||
while (max >= scaleBy) scaleBy *= 2;
|
|
||||||
|
|
||||||
var providedFrac = providedLerp.Update(provided/scaleBy);
|
|
||||||
var usedFrac = usedLerp.Update(used/scaleBy);
|
|
||||||
|
|
||||||
var color = GetBarColor();
|
|
||||||
|
|
||||||
var b = RenderBounds;
|
|
||||||
var rect = new RectangleF(b.X, float2.Lerp( b.Bottom, b.Top, providedFrac ),
|
|
||||||
b.Width, providedFrac*b.Height);
|
|
||||||
Game.Renderer.LineRenderer.FillRect(rect, color);
|
|
||||||
|
|
||||||
var indicator = ChromeProvider.GetImage("sidebar-bits",
|
|
||||||
RightIndicator ? "right-indicator" : "left-indicator");
|
|
||||||
|
|
||||||
var indicatorX = RightIndicator ? (b.Right - indicator.size.X) : b.Left;
|
|
||||||
|
|
||||||
var pos = new float2(indicatorX, float2.Lerp( b.Bottom, b.Top, usedFrac ) - indicator.size.Y / 2);
|
|
||||||
|
|
||||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -408,7 +408,6 @@
|
|||||||
<Compile Include="Widgets\ObserverProductionIconsWidget.cs" />
|
<Compile Include="Widgets\ObserverProductionIconsWidget.cs" />
|
||||||
<Compile Include="Widgets\ObserverSupportPowerIconsWidget.cs" />
|
<Compile Include="Widgets\ObserverSupportPowerIconsWidget.cs" />
|
||||||
<Compile Include="Widgets\OrderButtonWidget.cs" />
|
<Compile Include="Widgets\OrderButtonWidget.cs" />
|
||||||
<Compile Include="Widgets\PowerBinWidget.cs" />
|
|
||||||
<Compile Include="Widgets\RadarWidget.cs" />
|
<Compile Include="Widgets\RadarWidget.cs" />
|
||||||
<Compile Include="Widgets\StrategicProgressWidget.cs" />
|
<Compile Include="Widgets\StrategicProgressWidget.cs" />
|
||||||
<Compile Include="Widgets\SupportPowerBinWidget.cs" />
|
<Compile Include="Widgets\SupportPowerBinWidget.cs" />
|
||||||
@@ -456,6 +455,8 @@
|
|||||||
<Compile Include="Render\WithResources.cs" />
|
<Compile Include="Render\WithResources.cs" />
|
||||||
<Compile Include="Render\WithHarvestAnimation.cs" />
|
<Compile Include="Render\WithHarvestAnimation.cs" />
|
||||||
<Compile Include="Widgets\SlidingContainerWidget.cs" />
|
<Compile Include="Widgets\SlidingContainerWidget.cs" />
|
||||||
|
<Compile Include="Widgets\ResourceBarWidget.cs" />
|
||||||
|
<Compile Include="Widgets\Logic\SimpleTooltipLogic.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
|
using OpenRA.Mods.RA.Buildings;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -119,6 +120,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
radarBin.Get<ImageWidget>("RADAR_BIN_BG").GetImageCollection = () => "chrome-"+world.LocalPlayer.Country.Race;
|
radarBin.Get<ImageWidget>("RADAR_BIN_BG").GetImageCollection = () => "chrome-"+world.LocalPlayer.Country.Race;
|
||||||
|
|
||||||
|
var powerManager = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
||||||
|
var powerBar = radarBin.Get<ResourceBarWidget>("POWERBAR");
|
||||||
|
powerBar.IndicatorCollection = "power-"+world.LocalPlayer.Country.Race;
|
||||||
|
powerBar.GetProvided = () => powerManager.PowerProvided;
|
||||||
|
powerBar.GetUsed = () => powerManager.PowerDrained;
|
||||||
|
powerBar.TooltipFormat = "Power Usage: {0}/{1}";
|
||||||
|
powerBar.GetBarColor = () =>
|
||||||
|
{
|
||||||
|
if (powerManager.PowerState == PowerState.Critical)
|
||||||
|
return Color.Red;
|
||||||
|
if (powerManager.PowerState == PowerState.Low)
|
||||||
|
return Color.Orange;
|
||||||
|
return Color.LimeGreen;
|
||||||
|
};
|
||||||
|
|
||||||
var sidebarTicker = playerWidgets.Get<LogicTickerWidget>("SIDEBAR_TICKER");
|
var sidebarTicker = playerWidgets.Get<LogicTickerWidget>("SIDEBAR_TICKER");
|
||||||
sidebarTicker.OnTick = () =>
|
sidebarTicker.OnTick = () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.RA.Widgets.Logic
|
||||||
{
|
{
|
||||||
public class SimpleTooltipLogic
|
public class SimpleTooltipLogic
|
||||||
{
|
{
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
#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.Mods.RA.Buildings;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Widgets
|
|
||||||
{
|
|
||||||
public class PowerBinWidget : Widget
|
|
||||||
{
|
|
||||||
// Power bar
|
|
||||||
float2 powerOrigin = new float2(42, 205); // Relative to radarOrigin
|
|
||||||
Size powerSize = new Size(138, 5);
|
|
||||||
|
|
||||||
float? lastPowerProvidedPos;
|
|
||||||
float? lastPowerDrainedPos;
|
|
||||||
string powerCollection;
|
|
||||||
|
|
||||||
readonly string RadarBin = "INGAME_RADAR_BIN";
|
|
||||||
readonly PowerManager power;
|
|
||||||
readonly World world;
|
|
||||||
|
|
||||||
[ObjectCreator.UseCtor]
|
|
||||||
public PowerBinWidget(World world)
|
|
||||||
{
|
|
||||||
this.world = world;
|
|
||||||
|
|
||||||
if (world.LocalPlayer != null)
|
|
||||||
power = world.LocalPlayer.PlayerActor.Trait<PowerManager>();
|
|
||||||
}
|
|
||||||
|
|
||||||
static Color GetPowerColor(PowerManager pm)
|
|
||||||
{
|
|
||||||
if (pm.PowerState == PowerState.Critical) return Color.Red;
|
|
||||||
if (pm.PowerState == PowerState.Low) return Color.Orange;
|
|
||||||
return Color.LimeGreen;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float PowerBarLerpFactor = .2f;
|
|
||||||
|
|
||||||
public override void Draw()
|
|
||||||
{
|
|
||||||
if( world.LocalPlayer == null ) return;
|
|
||||||
if( world.LocalPlayer.WinState != WinState.Undefined ) return;
|
|
||||||
|
|
||||||
var radarBin = Ui.Root.Get<SlidingContainerWidget>(RadarBin);
|
|
||||||
|
|
||||||
powerCollection = "power-" + world.LocalPlayer.Country.Race;
|
|
||||||
|
|
||||||
// Nothing to draw
|
|
||||||
if (power.PowerProvided == 0 && power.PowerDrained == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Draw bar horizontally
|
|
||||||
var barStart = powerOrigin + radarBin.ChildOrigin;
|
|
||||||
var barEnd = barStart + new float2(powerSize.Width, 0);
|
|
||||||
|
|
||||||
float powerScaleBy = 100;
|
|
||||||
var maxPower = Math.Max(power.PowerProvided, power.PowerDrained);
|
|
||||||
|
|
||||||
while (maxPower >= powerScaleBy) powerScaleBy *= 2;
|
|
||||||
|
|
||||||
// Current power supply
|
|
||||||
var powerLevelTemp = barStart.X + (barEnd.X - barStart.X) * (power.PowerProvided / powerScaleBy);
|
|
||||||
lastPowerProvidedPos = float2.Lerp(lastPowerProvidedPos.GetValueOrDefault(powerLevelTemp), powerLevelTemp, PowerBarLerpFactor);
|
|
||||||
var powerLevel = new float2(lastPowerProvidedPos.Value, barStart.Y);
|
|
||||||
|
|
||||||
var color = GetPowerColor(power);
|
|
||||||
|
|
||||||
var colorDark = Exts.ColorLerp(0.25f, color, Color.Black);
|
|
||||||
for (int i = 0; i < powerSize.Height; i++)
|
|
||||||
{
|
|
||||||
color = (i - 1 < powerSize.Height / 2) ? color : colorDark;
|
|
||||||
var leftOffset = new float2(0, i);
|
|
||||||
var rightOffset = new float2(0, i);
|
|
||||||
// Indent corners
|
|
||||||
if ((i == 0 || i == powerSize.Height - 1) && powerLevel.X - barStart.X > 1)
|
|
||||||
{
|
|
||||||
leftOffset.X += 1;
|
|
||||||
rightOffset.X -= 1;
|
|
||||||
}
|
|
||||||
Game.Renderer.LineRenderer.DrawLine(barStart + leftOffset, powerLevel + rightOffset, color, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Power usage indicator
|
|
||||||
var indicator = ChromeProvider.GetImage( powerCollection, "power-indicator");
|
|
||||||
var powerDrainedTemp = barStart.X + (barEnd.X - barStart.X) * (power.PowerDrained / powerScaleBy);
|
|
||||||
lastPowerDrainedPos = float2.Lerp(lastPowerDrainedPos.GetValueOrDefault(powerDrainedTemp), powerDrainedTemp, PowerBarLerpFactor);
|
|
||||||
var powerDrainLevel = new float2(lastPowerDrainedPos.Value - indicator.size.X / 2, barStart.Y - 1);
|
|
||||||
|
|
||||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, powerDrainLevel);
|
|
||||||
|
|
||||||
// Render the tooltip
|
|
||||||
var rect = new Rectangle((int) barStart.X, (int) barStart.Y, powerSize.Width, powerSize.Height);
|
|
||||||
|
|
||||||
if (rect.InflateBy(0, 5, 0, 5).Contains(Viewport.LastMousePos))
|
|
||||||
{
|
|
||||||
var pos = new int2(rect.Left + 5, rect.Top + 5);
|
|
||||||
|
|
||||||
var border = WidgetUtils.GetBorderSizes("dialog4");
|
|
||||||
WidgetUtils.DrawPanel("dialog4", rect.InflateBy(0, 0, 0, 50 + border[1]));
|
|
||||||
|
|
||||||
Game.Renderer.Fonts["Bold"].DrawText("Power", pos, Color.White);
|
|
||||||
pos += new int2(0, 20);
|
|
||||||
Game.Renderer.Fonts["Regular"].DrawText("Provided: {0}\nDrained: {1}".F(power.PowerProvided, power.PowerDrained), pos, Color.White);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
138
OpenRA.Mods.RA/Widgets/ResourceBarWidget.cs
Executable file
138
OpenRA.Mods.RA/Widgets/ResourceBarWidget.cs
Executable file
@@ -0,0 +1,138 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2013 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.FileFormats;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA.Widgets
|
||||||
|
{
|
||||||
|
public enum ResourceBarOrientation { Vertical, Horizontal }
|
||||||
|
public enum ResourceBarStyle { Flat, Bevelled }
|
||||||
|
public class ResourceBarWidget : Widget
|
||||||
|
{
|
||||||
|
public readonly string TooltipTemplate = "SIMPLE_TOOLTIP";
|
||||||
|
public readonly string TooltipContainer;
|
||||||
|
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||||
|
|
||||||
|
public string TooltipFormat = "";
|
||||||
|
public ResourceBarOrientation Orientation = ResourceBarOrientation.Vertical;
|
||||||
|
public ResourceBarStyle Style = ResourceBarStyle.Flat;
|
||||||
|
public string IndicatorCollection = "sidebar-bits";
|
||||||
|
public string IndicatorImage = "indicator";
|
||||||
|
|
||||||
|
public Func<float> GetProvided = () => 0;
|
||||||
|
public Func<float> GetUsed = () => 0;
|
||||||
|
public Func<Color> GetBarColor = () => Color.White;
|
||||||
|
EWMA providedLerp = new EWMA(0.3f);
|
||||||
|
EWMA usedLerp = new EWMA(0.3f);
|
||||||
|
|
||||||
|
[ObjectCreator.UseCtor]
|
||||||
|
public ResourceBarWidget(World world)
|
||||||
|
{
|
||||||
|
tooltipContainer = Lazy.New(() =>
|
||||||
|
Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseEntered()
|
||||||
|
{
|
||||||
|
if (TooltipContainer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Func<string> getText = () => TooltipFormat.F(GetUsed(), GetProvided());
|
||||||
|
tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "getText", getText }});
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseExited()
|
||||||
|
{
|
||||||
|
if (TooltipContainer == null)
|
||||||
|
return;
|
||||||
|
tooltipContainer.Value.RemoveTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
var scaleBy = 100.0f;
|
||||||
|
var provided = GetProvided();
|
||||||
|
var used = GetUsed();
|
||||||
|
var max = Math.Max(provided, used);
|
||||||
|
while (max >= scaleBy)
|
||||||
|
scaleBy *= 2;
|
||||||
|
|
||||||
|
var providedFrac = providedLerp.Update(provided/scaleBy);
|
||||||
|
var usedFrac = usedLerp.Update(used/scaleBy);
|
||||||
|
|
||||||
|
var b = RenderBounds;
|
||||||
|
var indicator = ChromeProvider.GetImage(IndicatorCollection, IndicatorImage);
|
||||||
|
|
||||||
|
var color = GetBarColor();
|
||||||
|
if (Orientation == ResourceBarOrientation.Vertical)
|
||||||
|
{
|
||||||
|
if (Style == ResourceBarStyle.Bevelled)
|
||||||
|
{
|
||||||
|
var colorDark = Exts.ColorLerp(0.25f, color, Color.Black);
|
||||||
|
for (var i = 0; i < b.Height; i++)
|
||||||
|
{
|
||||||
|
color = (i - 1 < b.Height / 2) ? color : colorDark;
|
||||||
|
var bottom = new float2(b.Left + i, b.Bottom);
|
||||||
|
var top = new float2(b.Left + i, b.Bottom + providedFrac*b.Height);
|
||||||
|
|
||||||
|
// Indent corners
|
||||||
|
if ((i == 0 || i == b.Width - 1) && providedFrac*b.Height > 1)
|
||||||
|
{
|
||||||
|
bottom.Y += 1;
|
||||||
|
top.Y -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Game.Renderer.LineRenderer.DrawLine(bottom, top, color, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac),
|
||||||
|
b.Width, (int)(providedFrac*b.Height)), color);
|
||||||
|
|
||||||
|
var x = (b.Left + b.Right - indicator.size.X) / 2;
|
||||||
|
var y = float2.Lerp(b.Bottom, b.Top, usedFrac) - indicator.size.Y / 2;
|
||||||
|
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, new float2(x, y));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Style == ResourceBarStyle.Bevelled)
|
||||||
|
{
|
||||||
|
var colorDark = Exts.ColorLerp(0.25f, color, Color.Black);
|
||||||
|
for (var i = 0; i < b.Height; i++)
|
||||||
|
{
|
||||||
|
color = (i - 1 < b.Height / 2) ? color : colorDark;
|
||||||
|
var left = new float2(b.Left, b.Top + i);
|
||||||
|
var right = new float2(b.Left + providedFrac*b.Width, b.Top + i);
|
||||||
|
|
||||||
|
// Indent corners
|
||||||
|
if ((i == 0 || i == b.Height - 1) && providedFrac*b.Width > 1)
|
||||||
|
{
|
||||||
|
left.X += 1;
|
||||||
|
right.X -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Game.Renderer.LineRenderer.DrawLine(left, right, color, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, b.Y, (int)(providedFrac*b.Width), b.Height), color);
|
||||||
|
|
||||||
|
var x = float2.Lerp(b.Left, b.Right, usedFrac) - indicator.size.X / 2;
|
||||||
|
var y = (b.Bottom + b.Top - indicator.size.Y) / 2;
|
||||||
|
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, new float2(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -99,9 +99,9 @@
|
|||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="15.999999"
|
inkscape:zoom="5.6568539"
|
||||||
inkscape:cx="385.97751"
|
inkscape:cx="371.83537"
|
||||||
inkscape:cy="397.09537"
|
inkscape:cy="425.37964"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="svg2"
|
inkscape:current-layer="svg2"
|
||||||
showgrid="false"
|
showgrid="false"
|
||||||
@@ -205,13 +205,6 @@
|
|||||||
</cc:Work>
|
</cc:Work>
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</metadata>
|
</metadata>
|
||||||
<rect
|
|
||||||
style="fill:#768bd7;fill-opacity:1;stroke:none"
|
|
||||||
id="rect3200"
|
|
||||||
width="767.91803"
|
|
||||||
height="742.46216"
|
|
||||||
x="-195.16148"
|
|
||||||
y="-169.65097" />
|
|
||||||
<g
|
<g
|
||||||
inkscape:label="Layer 1"
|
inkscape:label="Layer 1"
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
@@ -877,21 +870,15 @@
|
|||||||
sodipodi:nodetypes="ccccc"
|
sodipodi:nodetypes="ccccc"
|
||||||
inkscape:connector-curvature="0"
|
inkscape:connector-curvature="0"
|
||||||
id="path3948"
|
id="path3948"
|
||||||
d="m 320,580.3622 4,4 0,0 -4,4 z"
|
d="m 400,588.3622 4,4 0,0 -4,4 z"
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
||||||
<rect
|
<rect
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||||
id="rect3950"
|
id="rect3950"
|
||||||
width="10"
|
width="10"
|
||||||
height="2"
|
height="2"
|
||||||
x="323"
|
x="403"
|
||||||
y="583.36224" />
|
y="591.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" />
|
|
||||||
<rect
|
<rect
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
style="fill:#ffffff;fill-opacity:1;stroke:none"
|
||||||
id="rect3167"
|
id="rect3167"
|
||||||
@@ -1355,6 +1342,19 @@
|
|||||||
id="path3993"
|
id="path3993"
|
||||||
inkscape:connector-curvature="0"
|
inkscape:connector-curvature="0"
|
||||||
sodipodi:nodetypes="ccccc" />
|
sodipodi:nodetypes="ccccc" />
|
||||||
|
<rect
|
||||||
|
y="599.36224"
|
||||||
|
x="403"
|
||||||
|
height="2"
|
||||||
|
width="10"
|
||||||
|
id="rect3206"
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
||||||
|
<path
|
||||||
|
sodipodi:nodetypes="ccccc"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path3208"
|
||||||
|
d="m 416,596.3622 -4,4 0,0 4,4 z"
|
||||||
|
style="fill:#ffffff;fill-opacity:1;stroke:none" />
|
||||||
</g>
|
</g>
|
||||||
<g
|
<g
|
||||||
inkscape:groupmode="layer"
|
inkscape:groupmode="layer"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
@@ -422,8 +422,8 @@ strategic: strategic.png
|
|||||||
player_owned: 96,0,32,32
|
player_owned: 96,0,32,32
|
||||||
|
|
||||||
sidebar-bits: chrome.png
|
sidebar-bits: chrome.png
|
||||||
left-indicator: 320,40,11,8
|
indicator-left: 400,48,16,8
|
||||||
right-indicator: 325,40,11,8
|
indicator-right: 400,56,16,8
|
||||||
|
|
||||||
production-icons: chrome.png
|
production-icons: chrome.png
|
||||||
building: 384,0,16,16
|
building: 384,0,16,16
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
Width:PARENT_RIGHT-2
|
Width:PARENT_RIGHT-2
|
||||||
Height:PARENT_BOTTOM-2
|
Height:PARENT_BOTTOM-2
|
||||||
TooltipContainer:TOOLTIP_CONTAINER
|
TooltipContainer:TOOLTIP_CONTAINER
|
||||||
|
IndicatorImage:indicator-left
|
||||||
Background@SILOBAR_PANEL:
|
Background@SILOBAR_PANEL:
|
||||||
X:180
|
X:180
|
||||||
Y:5
|
Y:5
|
||||||
@@ -178,6 +179,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
Width:PARENT_RIGHT-2
|
Width:PARENT_RIGHT-2
|
||||||
Height:PARENT_BOTTOM-2
|
Height:PARENT_BOTTOM-2
|
||||||
TooltipContainer:TOOLTIP_CONTAINER
|
TooltipContainer:TOOLTIP_CONTAINER
|
||||||
|
IndicatorImage:indicator-right
|
||||||
Label@CASH:
|
Label@CASH:
|
||||||
Y:170
|
Y:170
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
@@ -1,3 +1,14 @@
|
|||||||
|
Background@SIMPLE_TOOLTIP:
|
||||||
|
Logic:SimpleTooltipLogic
|
||||||
|
Background:dialog3
|
||||||
|
Height:31
|
||||||
|
Children:
|
||||||
|
Label@LABEL:
|
||||||
|
X:5
|
||||||
|
Y:3
|
||||||
|
Height:23
|
||||||
|
Font:Bold
|
||||||
|
|
||||||
Background@SPAWN_TOOLTIP:
|
Background@SPAWN_TOOLTIP:
|
||||||
Logic:SpawnSelectorTooltipLogic
|
Logic:SpawnSelectorTooltipLogic
|
||||||
Background:dialog3
|
Background:dialog3
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ Container@INGAME_ROOT:
|
|||||||
Y:205
|
Y:205
|
||||||
Width:170
|
Width:170
|
||||||
Height:40
|
Height:40
|
||||||
|
TooltipContainer@TOOLTIP_CONTAINER:
|
||||||
|
|
||||||
Container@PLAYER_WIDGETS:
|
Container@PLAYER_WIDGETS:
|
||||||
Children:
|
Children:
|
||||||
@@ -95,7 +96,15 @@ Container@PLAYER_WIDGETS:
|
|||||||
X:9
|
X:9
|
||||||
Width:192
|
Width:192
|
||||||
Height:192
|
Height:192
|
||||||
PowerBin@INGAME_POWER_BIN:
|
ResourceBar@POWERBAR:
|
||||||
|
X:42
|
||||||
|
Y:205
|
||||||
|
Width:138
|
||||||
|
Height:5
|
||||||
|
TooltipContainer:TOOLTIP_CONTAINER
|
||||||
|
IndicatorImage:power-indicator
|
||||||
|
Orientation:Horizontal
|
||||||
|
Style:Bevelled
|
||||||
MoneyBin@INGAME_MONEY_BIN:
|
MoneyBin@INGAME_MONEY_BIN:
|
||||||
X:WINDOW_RIGHT - WIDTH
|
X:WINDOW_RIGHT - WIDTH
|
||||||
Y:0
|
Y:0
|
||||||
|
|||||||
@@ -1,3 +1,14 @@
|
|||||||
|
Background@SIMPLE_TOOLTIP:
|
||||||
|
Logic:SimpleTooltipLogic
|
||||||
|
Background:dialog4
|
||||||
|
Height:29
|
||||||
|
Children:
|
||||||
|
Label@LABEL:
|
||||||
|
X:7
|
||||||
|
Y:2
|
||||||
|
Height:23
|
||||||
|
Font:Bold
|
||||||
|
|
||||||
Background@SPAWN_TOOLTIP:
|
Background@SPAWN_TOOLTIP:
|
||||||
Logic:SpawnSelectorTooltipLogic
|
Logic:SpawnSelectorTooltipLogic
|
||||||
Background:dialog4
|
Background:dialog4
|
||||||
|
|||||||
Reference in New Issue
Block a user