Fix d2k naming style nits.
This commit is contained in:
@@ -45,8 +45,8 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
readonly World world;
|
readonly World world;
|
||||||
readonly OrderManager orderManager;
|
readonly OrderManager orderManager;
|
||||||
|
|
||||||
ProductionQueue CurrentQueue;
|
ProductionQueue currentQueue;
|
||||||
List<ProductionQueue> VisibleQueues;
|
List<ProductionQueue> visibleQueues;
|
||||||
|
|
||||||
bool paletteOpen = false;
|
bool paletteOpen = false;
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
cantBuild = new Animation(world, "clock");
|
cantBuild = new Animation(world, "clock");
|
||||||
cantBuild.PlayFetchIndex("idle", () => 0);
|
cantBuild.PlayFetchIndex("idle", () => 0);
|
||||||
clock = new Animation(world, "clock");
|
clock = new Animation(world, "clock");
|
||||||
VisibleQueues = new List<ProductionQueue>();
|
visibleQueues = new List<ProductionQueue>();
|
||||||
CurrentQueue = null;
|
currentQueue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize(WidgetArgs args)
|
public override void Initialize(WidgetArgs args)
|
||||||
@@ -92,25 +92,25 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
|
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
VisibleQueues.Clear();
|
visibleQueues.Clear();
|
||||||
|
|
||||||
var queues = world.ActorsWithTrait<ProductionQueue>()
|
var queues = world.ActorsWithTrait<ProductionQueue>()
|
||||||
.Where(p => p.Actor.Owner == world.LocalPlayer)
|
.Where(p => p.Actor.Owner == world.LocalPlayer)
|
||||||
.Select(p => p.Trait);
|
.Select(p => p.Trait);
|
||||||
|
|
||||||
if (CurrentQueue != null && CurrentQueue.Actor.Destroyed)
|
if (currentQueue != null && currentQueue.Actor.Destroyed)
|
||||||
CurrentQueue = null;
|
currentQueue = null;
|
||||||
|
|
||||||
foreach (var queue in queues)
|
foreach (var queue in queues)
|
||||||
{
|
{
|
||||||
if (queue.AllItems().Any())
|
if (queue.AllItems().Any())
|
||||||
VisibleQueues.Add(queue);
|
visibleQueues.Add(queue);
|
||||||
else if (CurrentQueue == queue)
|
else if (currentQueue == queue)
|
||||||
CurrentQueue = null;
|
currentQueue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentQueue == null)
|
if (currentQueue == null)
|
||||||
CurrentQueue = VisibleQueues.FirstOrDefault();
|
currentQueue = visibleQueues.FirstOrDefault();
|
||||||
|
|
||||||
TickPaletteAnimation(world);
|
TickPaletteAnimation(world);
|
||||||
}
|
}
|
||||||
@@ -152,7 +152,7 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
paletteAnimating = true;
|
paletteAnimating = true;
|
||||||
|
|
||||||
paletteOpen = true;
|
paletteOpen = true;
|
||||||
CurrentQueue = queue;
|
currentQueue = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleKeyPress(KeyInput e)
|
public override bool HandleKeyPress(KeyInput e)
|
||||||
@@ -200,7 +200,7 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: fix
|
// TODO: fix
|
||||||
DrawPalette(CurrentQueue);
|
DrawPalette(currentQueue);
|
||||||
DrawBuildTabs(world);
|
DrawBuildTabs(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,8 +350,8 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
|
|
||||||
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
|
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
|
||||||
var wasOpen = paletteOpen;
|
var wasOpen = paletteOpen;
|
||||||
paletteOpen = CurrentQueue != queue || !wasOpen;
|
paletteOpen = currentQueue != queue || !wasOpen;
|
||||||
CurrentQueue = queue;
|
currentQueue = queue;
|
||||||
if (wasOpen != paletteOpen)
|
if (wasOpen != paletteOpen)
|
||||||
paletteAnimating = true;
|
paletteAnimating = true;
|
||||||
};
|
};
|
||||||
@@ -370,16 +370,16 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
void HandleBuildPalette(World world, string item, bool isLmb)
|
void HandleBuildPalette(World world, string item, bool isLmb)
|
||||||
{
|
{
|
||||||
var unit = world.Map.Rules.Actors[item];
|
var unit = world.Map.Rules.Actors[item];
|
||||||
var producing = CurrentQueue.AllQueued().FirstOrDefault(a => a.Item == item);
|
var producing = currentQueue.AllQueued().FirstOrDefault(a => a.Item == item);
|
||||||
|
|
||||||
if (isLmb)
|
if (isLmb)
|
||||||
{
|
{
|
||||||
if (producing != null && producing == CurrentQueue.CurrentItem())
|
if (producing != null && producing == currentQueue.CurrentItem())
|
||||||
{
|
{
|
||||||
if (producing.Done)
|
if (producing.Done)
|
||||||
{
|
{
|
||||||
if (unit.Traits.Contains<BuildingInfo>())
|
if (unit.Traits.Contains<BuildingInfo>())
|
||||||
world.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue, item);
|
world.OrderGenerator = new PlaceBuildingOrderGenerator(currentQueue, item);
|
||||||
else
|
else
|
||||||
StartProduction(world, item);
|
StartProduction(world, item);
|
||||||
return;
|
return;
|
||||||
@@ -387,21 +387,21 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
|
|
||||||
if (producing.Paused)
|
if (producing.Paused)
|
||||||
{
|
{
|
||||||
world.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, item, false));
|
world.IssueOrder(Order.PauseProduction(currentQueue.Actor, item, false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check if the item's build-limit has already been reached
|
// Check if the item's build-limit has already been reached
|
||||||
var queued = CurrentQueue.AllQueued().Count(a => a.Item == unit.Name);
|
var queued = currentQueue.AllQueued().Count(a => a.Item == unit.Name);
|
||||||
var inWorld = world.ActorsWithTrait<Buildable>().Count(a => a.Actor.Info.Name == unit.Name && a.Actor.Owner == world.LocalPlayer);
|
var inWorld = world.ActorsWithTrait<Buildable>().Count(a => a.Actor.Info.Name == unit.Name && a.Actor.Owner == world.LocalPlayer);
|
||||||
var buildLimit = unit.Traits.Get<BuildableInfo>().BuildLimit;
|
var buildLimit = unit.Traits.Get<BuildableInfo>().BuildLimit;
|
||||||
|
|
||||||
if (!((buildLimit != 0) && (inWorld + queued >= buildLimit)))
|
if (!((buildLimit != 0) && (inWorld + queued >= buildLimit)))
|
||||||
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", currentQueue.Info.QueuedAudio, world.LocalPlayer.Country.Race);
|
||||||
else
|
else
|
||||||
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.BlockedAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", currentQueue.Info.BlockedAudio, world.LocalPlayer.Country.Race);
|
||||||
}
|
}
|
||||||
|
|
||||||
StartProduction(world, item);
|
StartProduction(world, item);
|
||||||
@@ -413,15 +413,15 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
// instant cancel of things we havent really started yet, and things that are finished
|
// instant cancel of things we havent really started yet, and things that are finished
|
||||||
if (producing.Paused || producing.Done || producing.TotalCost == producing.RemainingCost)
|
if (producing.Paused || producing.Done || producing.TotalCost == producing.RemainingCost)
|
||||||
{
|
{
|
||||||
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", currentQueue.Info.CancelledAudio, world.LocalPlayer.Country.Race);
|
||||||
var numberToCancel = Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1;
|
var numberToCancel = Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1;
|
||||||
|
|
||||||
world.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, item, numberToCancel));
|
world.IssueOrder(Order.CancelProduction(currentQueue.Actor, item, numberToCancel));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, world.LocalPlayer.Country.Race);
|
Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Speech", currentQueue.Info.OnHoldAudio, world.LocalPlayer.Country.Race);
|
||||||
world.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, item, true));
|
world.IssueOrder(Order.PauseProduction(currentQueue.Actor, item, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,29 +429,29 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
|
|
||||||
void StartProduction(World world, string item)
|
void StartProduction(World world, string item)
|
||||||
{
|
{
|
||||||
world.IssueOrder(Order.StartProduction(CurrentQueue.Actor, item,
|
world.IssueOrder(Order.StartProduction(currentQueue.Actor, item,
|
||||||
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
|
Game.GetModifierKeys().HasModifier(Modifiers.Shift) ? 5 : 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBuildTabs(World world)
|
void DrawBuildTabs(World world)
|
||||||
{
|
{
|
||||||
const int tabWidth = 24;
|
const int TabWidth = 24;
|
||||||
const int tabHeight = 40;
|
const int TabHeight = 40;
|
||||||
var x = paletteOrigin.X - tabWidth;
|
var x = paletteOrigin.X - TabWidth;
|
||||||
var y = paletteOrigin.Y + 9;
|
var y = paletteOrigin.Y + 9;
|
||||||
|
|
||||||
tabs.Clear();
|
tabs.Clear();
|
||||||
|
|
||||||
foreach (var queue in VisibleQueues)
|
foreach (var queue in visibleQueues)
|
||||||
{
|
{
|
||||||
string[] tabKeys = { "normal", "ready", "selected" };
|
string[] tabKeys = { "normal", "ready", "selected" };
|
||||||
var producing = queue.CurrentItem();
|
var producing = queue.CurrentItem();
|
||||||
var index = queue == CurrentQueue ? 2 : (producing != null && producing.Done) ? 1 : 0;
|
var index = queue == currentQueue ? 2 : (producing != null && producing.Done) ? 1 : 0;
|
||||||
|
|
||||||
var race = world.LocalPlayer.Country.Race;
|
var race = world.LocalPlayer.Country.Race;
|
||||||
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("tabs-" + tabKeys[index], race + "-" + queue.Info.Type), new float2(x, y));
|
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("tabs-" + tabKeys[index], race + "-" + queue.Info.Type), new float2(x, y));
|
||||||
|
|
||||||
var rect = new Rectangle((int)x, (int)y, tabWidth, tabHeight);
|
var rect = new Rectangle((int)x, (int)y, TabWidth, TabHeight);
|
||||||
tabs.Add(Pair.New(rect, HandleTabClick(queue, world)));
|
tabs.Add(Pair.New(rect, HandleTabClick(queue, world)));
|
||||||
|
|
||||||
if (rect.Contains(Viewport.LastMousePos))
|
if (rect.Contains(Viewport.LastMousePos))
|
||||||
@@ -466,7 +466,7 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
font.DrawText(text, new float2(rect.Left - sz.X - 20, rect.Top + 12), Color.White);
|
font.DrawText(text, new float2(rect.Left - sz.X - 20, rect.Top + 12), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
y += tabHeight;
|
y += TabHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
var tooltip = info.Traits.Get<TooltipInfo>();
|
var tooltip = info.Traits.Get<TooltipInfo>();
|
||||||
var buildable = info.Traits.Get<BuildableInfo>();
|
var buildable = info.Traits.Get<BuildableInfo>();
|
||||||
var cost = info.Traits.Get<ValuedInfo>().Cost;
|
var cost = info.Traits.Get<ValuedInfo>().Cost;
|
||||||
var canBuildThis = CurrentQueue.CanBuild(info);
|
var canBuildThis = currentQueue.CanBuild(info);
|
||||||
|
|
||||||
var longDescSize = Game.Renderer.Fonts["Regular"].Measure(tooltip.Description.Replace("\\n", "\n")).Y;
|
var longDescSize = Game.Renderer.Fonts["Regular"].Measure(tooltip.Description.Replace("\\n", "\n")).Y;
|
||||||
if (!canBuildThis) longDescSize += 8;
|
if (!canBuildThis) longDescSize += 8;
|
||||||
@@ -505,8 +505,8 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
resources.DisplayCash + resources.DisplayResources >= cost ? Color.White : Color.Red);
|
resources.DisplayCash + resources.DisplayResources >= cost ? Color.White : Color.Red);
|
||||||
|
|
||||||
var lowpower = power.PowerState != PowerState.Normal;
|
var lowpower = power.PowerState != PowerState.Normal;
|
||||||
var time = CurrentQueue.GetBuildTime(info.Name)
|
var time = currentQueue.GetBuildTime(info.Name)
|
||||||
* (lowpower ? CurrentQueue.Info.LowPowerSlowdown : 1);
|
* (lowpower ? currentQueue.Info.LowPowerSlowdown : 1);
|
||||||
DrawRightAligned(WidgetUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red : Color.White);
|
DrawRightAligned(WidgetUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red : Color.White);
|
||||||
|
|
||||||
var pis = info.Traits.WithInterface<PowerInfo>().Where(i => i.UpgradeMinEnabledLevel < 1);
|
var pis = info.Traits.WithInterface<PowerInfo>().Where(i => i.UpgradeMinEnabledLevel < 1);
|
||||||
@@ -535,7 +535,7 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
bool DoBuildingHotkey(KeyInput e, World world)
|
bool DoBuildingHotkey(KeyInput e, World world)
|
||||||
{
|
{
|
||||||
if (!paletteOpen) return false;
|
if (!paletteOpen) return false;
|
||||||
if (CurrentQueue == null) return false;
|
if (currentQueue == null) return false;
|
||||||
|
|
||||||
var key = Hotkey.FromKeyInput(e);
|
var key = Hotkey.FromKeyInput(e);
|
||||||
var ks = Game.Settings.Keys;
|
var ks = Game.Settings.Keys;
|
||||||
@@ -549,7 +549,7 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var allBuildables = CurrentQueue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder).ToArray();
|
var allBuildables = currentQueue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder).ToArray();
|
||||||
var toBuild = allBuildables.ElementAtOrDefault(slot);
|
var toBuild = allBuildables.ElementAtOrDefault(slot);
|
||||||
if (toBuild != null)
|
if (toBuild != null)
|
||||||
{
|
{
|
||||||
@@ -565,10 +565,10 @@ namespace OpenRA.Mods.D2k.Widgets
|
|||||||
bool ChangeTab(bool reverse)
|
bool ChangeTab(bool reverse)
|
||||||
{
|
{
|
||||||
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
|
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null);
|
||||||
var queues = VisibleQueues.Concat(VisibleQueues);
|
var queues = visibleQueues.Concat(visibleQueues);
|
||||||
if (reverse)
|
if (reverse)
|
||||||
queues = queues.Reverse();
|
queues = queues.Reverse();
|
||||||
var nextQueue = queues.SkipWhile(q => q != CurrentQueue)
|
var nextQueue = queues.SkipWhile(q => q != currentQueue)
|
||||||
.ElementAtOrDefault(1);
|
.ElementAtOrDefault(1);
|
||||||
if (nextQueue != null)
|
if (nextQueue != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user