fix trailing whitespace everywhere
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#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
|
||||
* 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.
|
||||
@@ -25,21 +25,21 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
{
|
||||
public int Columns = 3;
|
||||
public int Rows = 5;
|
||||
|
||||
|
||||
ProductionQueue CurrentQueue;
|
||||
List<ProductionQueue> VisibleQueues;
|
||||
|
||||
bool paletteOpen = false;
|
||||
Dictionary<string, Sprite> iconSprites;
|
||||
|
||||
|
||||
float2 paletteOpenOrigin = new float2(Game.viewport.Width - 215, 280);
|
||||
float2 paletteClosedOrigin = new float2(Game.viewport.Width - 16, 280);
|
||||
float2 paletteOrigin;
|
||||
|
||||
|
||||
int paletteAnimationLength = 7;
|
||||
int paletteAnimationFrame = 0;
|
||||
bool paletteAnimating = false;
|
||||
|
||||
|
||||
List<Pair<Rectangle, Action<MouseInput>>> buttons = new List<Pair<Rectangle,Action<MouseInput>>>();
|
||||
List<Pair<Rectangle, Action<MouseInput>>> tabs = new List<Pair<Rectangle, Action<MouseInput>>>();
|
||||
Animation cantBuild;
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
{
|
||||
this.world = world;
|
||||
this.worldRenderer = worldRenderer;
|
||||
|
||||
|
||||
cantBuild = new Animation("clock");
|
||||
cantBuild.PlayFetchIndex("idle", () => 0);
|
||||
ready = new Animation("pips");
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
paletteOrigin = paletteClosedOrigin;
|
||||
VisibleQueues = new List<ProductionQueue>();
|
||||
CurrentQueue = null;
|
||||
|
||||
|
||||
iconSprites = Rules.Info.Values
|
||||
.Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
|
||||
.ToDictionary(
|
||||
@@ -74,23 +74,23 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
u => Game.modData.SpriteLoader.LoadAllSprites(
|
||||
u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);
|
||||
}
|
||||
|
||||
|
||||
public override Rectangle EventBounds
|
||||
{
|
||||
get { return new Rectangle((int)(paletteOrigin.X) - 24, (int)(paletteOrigin.Y), 215, Math.Max(48 * numActualRows, 40 * tabs.Count + 9)); }
|
||||
}
|
||||
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
VisibleQueues.Clear();
|
||||
|
||||
|
||||
var queues = world.ActorsWithTrait<ProductionQueue>()
|
||||
.Where(p => p.Actor.Owner == world.LocalPlayer)
|
||||
.Select(p => p.Trait);
|
||||
|
||||
|
||||
if (CurrentQueue != null && CurrentQueue.self.Destroyed)
|
||||
CurrentQueue = null;
|
||||
|
||||
|
||||
foreach (var queue in queues)
|
||||
{
|
||||
if (queue.AllItems().Count() > 0)
|
||||
@@ -100,12 +100,12 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
}
|
||||
if (CurrentQueue == null)
|
||||
CurrentQueue = VisibleQueues.FirstOrDefault();
|
||||
|
||||
|
||||
TickPaletteAnimation(world);
|
||||
}
|
||||
|
||||
|
||||
void TickPaletteAnimation(World world)
|
||||
{
|
||||
{
|
||||
if (!paletteAnimating)
|
||||
return;
|
||||
|
||||
@@ -114,11 +114,11 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
paletteAnimationFrame++;
|
||||
else
|
||||
paletteAnimationFrame--;
|
||||
|
||||
|
||||
// Calculate palette position
|
||||
if (paletteAnimationFrame <= paletteAnimationLength)
|
||||
paletteOrigin = float2.Lerp(paletteClosedOrigin, paletteOpenOrigin, paletteAnimationFrame * 1.0f / paletteAnimationLength);
|
||||
|
||||
|
||||
// Play palette-open sound at the start of the activate anim (open)
|
||||
if (paletteAnimationFrame == 1 && paletteOpen)
|
||||
Sound.Play(BuildPaletteOpen);
|
||||
@@ -134,12 +134,12 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
paletteAnimating = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetCurrentTab(ProductionQueue queue)
|
||||
{
|
||||
if (!paletteOpen)
|
||||
paletteAnimating = true;
|
||||
|
||||
|
||||
paletteOpen = true;
|
||||
CurrentQueue = queue;
|
||||
}
|
||||
@@ -155,53 +155,53 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
return DoBuildingHotkey(e.KeyName, world);
|
||||
}
|
||||
|
||||
|
||||
public override bool HandleMouseInput(MouseInput mi)
|
||||
{
|
||||
{
|
||||
if (mi.Event != MouseInputEvent.Down)
|
||||
return false;
|
||||
|
||||
|
||||
var action = tabs.Where(a => a.First.Contains(mi.Location))
|
||||
.Select(a => a.Second).FirstOrDefault();
|
||||
if (action == null && paletteOpen)
|
||||
action = buttons.Where(a => a.First.Contains(mi.Location))
|
||||
.Select(a => a.Second).FirstOrDefault();
|
||||
|
||||
|
||||
if (action == null)
|
||||
return false;
|
||||
|
||||
|
||||
action(mi);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
{
|
||||
if (!IsVisible()) return;
|
||||
// todo: fix
|
||||
|
||||
|
||||
int paletteHeight = DrawPalette(CurrentQueue);
|
||||
DrawBuildTabs(world, paletteHeight);
|
||||
}
|
||||
|
||||
|
||||
int numActualRows = 5;
|
||||
int DrawPalette(ProductionQueue queue)
|
||||
{
|
||||
buttons.Clear();
|
||||
|
||||
|
||||
string paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
|
||||
float2 origin = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
|
||||
if (queue != null)
|
||||
{
|
||||
var buildableItems = queue.BuildableItems().ToArray();
|
||||
var allBuildables = queue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder).ToArray();
|
||||
|
||||
|
||||
var overlayBits = new List<Pair<Sprite, float2>>();
|
||||
var textBits = new List<Pair<float2, string>>();
|
||||
numActualRows = Math.Max((allBuildables.Count() + Columns - 1) / Columns, Rows);
|
||||
|
||||
|
||||
// Palette Background
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "top"), new float2(origin.X - 9, origin.Y - 9));
|
||||
for (var w = 0; w < numActualRows; w++)
|
||||
@@ -210,8 +210,8 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
new float2(origin.X - 9, origin.Y + 48 * w));
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "bottom"),
|
||||
new float2(origin.X - 9, origin.Y - 1 + 48 * numActualRows));
|
||||
|
||||
|
||||
|
||||
|
||||
// Icons
|
||||
string tooltipItem = null;
|
||||
foreach (var item in allBuildables)
|
||||
@@ -219,14 +219,14 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
var rect = new RectangleF(origin.X + x * 64, origin.Y + 48 * y, 64, 48);
|
||||
var drawPos = new float2(rect.Location);
|
||||
WidgetUtils.DrawSHP(iconSprites[item.Name], drawPos, worldRenderer);
|
||||
|
||||
|
||||
var firstOfThis = queue.AllQueued().FirstOrDefault(a => a.Item == item.Name);
|
||||
|
||||
|
||||
if (rect.Contains(Viewport.LastMousePos))
|
||||
tooltipItem = item.Name;
|
||||
|
||||
|
||||
var overlayPos = drawPos + new float2(32, 16);
|
||||
|
||||
|
||||
if (firstOfThis != null)
|
||||
{
|
||||
clock.PlayFetchIndex("idle",
|
||||
@@ -234,10 +234,10 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
* (clock.CurrentSequence.Length - 1) / firstOfThis.TotalTime);
|
||||
clock.Tick();
|
||||
WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer);
|
||||
|
||||
|
||||
if (queue.CurrentItem() == firstOfThis)
|
||||
textBits.Add( Pair.New( overlayPos, GetOverlayForItem(firstOfThis) ) );
|
||||
|
||||
|
||||
var repeats = queue.AllQueued().Count(a => a.Item == item.Name);
|
||||
if (repeats > 1 || queue.CurrentItem() != firstOfThis)
|
||||
{
|
||||
@@ -258,11 +258,11 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
var closureName = buildableItems.Any(a => a.Name == item.Name) ? item.Name : null;
|
||||
buttons.Add(Pair.New(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), HandleClick(closureName, world)));
|
||||
|
||||
|
||||
if (++x == Columns) { x = 0; y++; }
|
||||
}
|
||||
if (x != 0) y++;
|
||||
|
||||
|
||||
foreach (var ob in overlayBits)
|
||||
WidgetUtils.DrawSHP(ob.First, ob.Second, worldRenderer);
|
||||
|
||||
@@ -276,10 +276,10 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
// Tooltip
|
||||
if (tooltipItem != null && !paletteAnimating && paletteOpen)
|
||||
DrawProductionTooltip(world, tooltipItem,
|
||||
DrawProductionTooltip(world, tooltipItem,
|
||||
new float2(Game.viewport.Width, origin.Y + numActualRows * 48 + 9).ToInt2());
|
||||
}
|
||||
|
||||
|
||||
// Palette Dock
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
|
||||
new float2(Game.viewport.Width - 14, origin.Y - 23));
|
||||
@@ -305,18 +305,18 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
{
|
||||
return mi => {
|
||||
Sound.Play(TabClick);
|
||||
|
||||
|
||||
if (name != null)
|
||||
HandleBuildPalette(world, name, (mi.Button == MouseButton.Left));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Action<MouseInput> HandleTabClick(ProductionQueue queue, World world)
|
||||
{
|
||||
return mi => {
|
||||
if (mi.Button != MouseButton.Left)
|
||||
return;
|
||||
|
||||
|
||||
Sound.Play(TabClick);
|
||||
var wasOpen = paletteOpen;
|
||||
paletteOpen = (CurrentQueue == queue && wasOpen) ? false : true;
|
||||
@@ -325,7 +325,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
paletteAnimating = true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
static string Description( string a )
|
||||
{
|
||||
// hack hack hack - going to die soon anyway
|
||||
@@ -337,15 +337,15 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
return "Tech Center";
|
||||
if (a == "anypower")
|
||||
return "Power Plant";
|
||||
|
||||
|
||||
ActorInfo ai;
|
||||
Rules.Info.TryGetValue(a.ToLowerInvariant(), out ai);
|
||||
if (ai != null && ai.Traits.Contains<TooltipInfo>())
|
||||
return ai.Traits.Get<TooltipInfo>().Name;
|
||||
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
void HandleBuildPalette( World world, string item, bool isLmb )
|
||||
{
|
||||
var unit = Rules.Info[item];
|
||||
@@ -393,32 +393,32 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void StartProduction( World world, string item )
|
||||
{
|
||||
Sound.Play(CurrentQueue.Info.QueuedAudio);
|
||||
world.IssueOrder(Order.StartProduction(CurrentQueue.self, item,
|
||||
world.IssueOrder(Order.StartProduction(CurrentQueue.self, item,
|
||||
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
|
||||
}
|
||||
|
||||
|
||||
void DrawBuildTabs( World world, int paletteHeight)
|
||||
{
|
||||
const int tabWidth = 24;
|
||||
const int tabHeight = 40;
|
||||
var x = paletteOrigin.X - tabWidth;
|
||||
var y = paletteOrigin.Y + 9;
|
||||
|
||||
|
||||
tabs.Clear();
|
||||
|
||||
foreach (var queue in VisibleQueues)
|
||||
{
|
||||
{
|
||||
string[] tabKeys = { "normal", "ready", "selected" };
|
||||
var producing = queue.CurrentItem();
|
||||
var index = queue == CurrentQueue ? 2 : (producing != null && producing.Done) ? 1 : 0;
|
||||
|
||||
|
||||
var race = world.LocalPlayer.Country.Race;
|
||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("tabs-"+tabKeys[index], race+"-"+queue.Info.Type), new float2(x, y));
|
||||
|
||||
|
||||
var rect = new Rectangle((int)x,(int)y,(int)tabWidth,(int)tabHeight);
|
||||
tabs.Add(Pair.New(rect, HandleTabClick(queue, world)));
|
||||
|
||||
@@ -456,12 +456,12 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
var buildable = info.Traits.Get<BuildableInfo>();
|
||||
var cost = info.Traits.Get<ValuedInfo>().Cost;
|
||||
var canBuildThis = CurrentQueue.CanBuild(info);
|
||||
|
||||
|
||||
var longDescSize = Game.Renderer.Fonts["Regular"].Measure(tooltip.Description.Replace("\\n", "\n")).Y;
|
||||
if (!canBuildThis) longDescSize += 8;
|
||||
|
||||
WidgetUtils.DrawPanel("dialog4", new Rectangle(Game.viewport.Width - 300, pos.Y, 300, longDescSize + 65));
|
||||
|
||||
|
||||
Game.Renderer.Fonts["Bold"].DrawText(
|
||||
tooltip.Name + ((buildable.Hotkey != null)? " ({0})".F(buildable.Hotkey.ToUpper()) : ""),
|
||||
p.ToInt2() + new int2(5, 5), Color.White);
|
||||
@@ -471,9 +471,9 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
DrawRightAligned("${0}".F(cost), pos + new int2(-5, 5),
|
||||
(resources.DisplayCash + resources.DisplayOre >= cost ? Color.White : Color.Red ));
|
||||
|
||||
|
||||
var lowpower = power.PowerState != PowerState.Normal;
|
||||
var time = CurrentQueue.GetBuildTime(info.Name)
|
||||
var time = CurrentQueue.GetBuildTime(info.Name)
|
||||
* ((lowpower)? CurrentQueue.Info.LowPowerSlowdown : 1);
|
||||
DrawRightAligned(WidgetUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red: Color.White);
|
||||
|
||||
@@ -481,14 +481,14 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
if (bi != null)
|
||||
DrawRightAligned("{1}{0}".F(bi.Power, bi.Power > 0 ? "+" : ""), pos + new int2(-5, 20),
|
||||
((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red);
|
||||
|
||||
|
||||
p += new int2(5, 35);
|
||||
if (!canBuildThis)
|
||||
{
|
||||
var prereqs = buildable.Prerequisites
|
||||
.Select( a => Description( a ) );
|
||||
Game.Renderer.Fonts["Regular"].DrawText(
|
||||
"Requires {0}".F(string.Join(", ", prereqs.ToArray())),
|
||||
"Requires {0}".F(string.Join(", ", prereqs.ToArray())),
|
||||
p.ToInt2(),
|
||||
Color.White);
|
||||
|
||||
@@ -496,7 +496,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
}
|
||||
|
||||
p += new int2(0, 15);
|
||||
Game.Renderer.Fonts["Regular"].DrawText(tooltip.Description.Replace("\\n", "\n"),
|
||||
Game.Renderer.Fonts["Regular"].DrawText(tooltip.Description.Replace("\\n", "\n"),
|
||||
p.ToInt2(), Color.White);
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void TabChange(bool shift)
|
||||
{
|
||||
var queues = VisibleQueues.Concat(VisibleQueues);
|
||||
|
||||
Reference in New Issue
Block a user