more general tidying in CNC widget code
This commit is contained in:
@@ -17,13 +17,14 @@ using OpenRA.Widgets;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
namespace OpenRA.Mods.Cnc.Widgets
|
||||||
{
|
{
|
||||||
|
public enum WorldTooltipType { None, Unexplored, Actor }
|
||||||
|
|
||||||
public class CncWorldInteractionControllerWidget : WorldInteractionControllerWidget
|
public class CncWorldInteractionControllerWidget : WorldInteractionControllerWidget
|
||||||
{
|
{
|
||||||
public readonly string TooltipTemplate = "WORLD_TOOLTIP";
|
public readonly string TooltipTemplate = "WORLD_TOOLTIP";
|
||||||
public readonly string TooltipContainer;
|
public readonly string TooltipContainer;
|
||||||
Lazy<TooltipContainerWidget> tooltipContainer;
|
Lazy<TooltipContainerWidget> tooltipContainer;
|
||||||
|
|
||||||
public enum WorldTooltipType { None, Unexplored, Actor }
|
|
||||||
public WorldTooltipType TooltipType { get; private set; }
|
public WorldTooltipType TooltipType { get; private set; }
|
||||||
public IToolTip ActorTooltip { get; private set; }
|
public IToolTip ActorTooltip { get; private set; }
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.Support;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
|
|||||||
@@ -8,10 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
|
|||||||
@@ -10,11 +10,9 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using OpenRA.Mods.RA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using OpenRA.Mods.RA;
|
|
||||||
using OpenRA.Mods.RA.Orders;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
|
using OpenRA.Mods.RA;
|
||||||
|
using OpenRA.Mods.RA.Widgets.Logic;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using OpenRA.Mods.RA;
|
|
||||||
using OpenRA.Mods.RA.Widgets.Logic;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,9 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|||||||
@@ -11,11 +11,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Support;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Widgets;
|
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using OpenRA.Support;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Support;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Support;
|
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using TooltipType = OpenRA.Mods.Cnc.Widgets.CncWorldInteractionControllerWidget.WorldTooltipType;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
{
|
{
|
||||||
@@ -21,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public WorldTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, CncWorldInteractionControllerWidget wic)
|
public WorldTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, CncWorldInteractionControllerWidget wic)
|
||||||
{
|
{
|
||||||
widget.IsVisible = () => wic.TooltipType != TooltipType.None;
|
widget.IsVisible = () => wic.TooltipType != WorldTooltipType.None;
|
||||||
var label = widget.GetWidget<LabelWidget>("LABEL");
|
var label = widget.GetWidget<LabelWidget>("LABEL");
|
||||||
var flag = widget.GetWidget<ImageWidget>("FLAG");
|
var flag = widget.GetWidget<ImageWidget>("FLAG");
|
||||||
var owner = widget.GetWidget<LabelWidget>("OWNER");
|
var owner = widget.GetWidget<LabelWidget>("OWNER");
|
||||||
@@ -39,10 +37,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
|
|
||||||
tooltipContainer.BeforeRender = () =>
|
tooltipContainer.BeforeRender = () =>
|
||||||
{
|
{
|
||||||
if (wic == null || wic.TooltipType == TooltipType.None)
|
if (wic == null || wic.TooltipType == WorldTooltipType.None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
labelText = wic.TooltipType == TooltipType.Unexplored ? "Unexplored Terrain" :
|
labelText = wic.TooltipType == WorldTooltipType.Unexplored ? "Unexplored Terrain" :
|
||||||
wic.ActorTooltip.Name();
|
wic.ActorTooltip.Name();
|
||||||
var textWidth = font.Measure(labelText).X;
|
var textWidth = font.Measure(labelText).X;
|
||||||
if (textWidth != cachedWidth)
|
if (textWidth != cachedWidth)
|
||||||
@@ -51,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
widget.Bounds.Width = 2*label.Bounds.X + textWidth;
|
widget.Bounds.Width = 2*label.Bounds.X + textWidth;
|
||||||
}
|
}
|
||||||
var o = wic.ActorTooltip != null ? wic.ActorTooltip.Owner() : null;
|
var o = wic.ActorTooltip != null ? wic.ActorTooltip.Owner() : null;
|
||||||
showOwner = wic.TooltipType == TooltipType.Actor && o != null && !o.NonCombatant;
|
showOwner = wic.TooltipType == WorldTooltipType.Actor && o != null && !o.NonCombatant;
|
||||||
|
|
||||||
if (showOwner)
|
if (showOwner)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -15,7 +16,6 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets
|
namespace OpenRA.Mods.Cnc.Widgets
|
||||||
{
|
{
|
||||||
@@ -184,6 +184,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
var allQueues = a.World.ActorsWithTrait<ProductionQueue>()
|
var allQueues = a.World.ActorsWithTrait<ProductionQueue>()
|
||||||
.Where(p => p.Actor.Owner == p.Actor.World.LocalPlayer && p.Actor.IsInWorld)
|
.Where(p => p.Actor.Owner == p.Actor.World.LocalPlayer && p.Actor.IsInWorld)
|
||||||
.Select(p => p.Trait).ToArray();
|
.Select(p => p.Trait).ToArray();
|
||||||
|
|
||||||
foreach (var g in Groups.Values)
|
foreach (var g in Groups.Values)
|
||||||
g.Update(allQueues);
|
g.Update(allQueues);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user