Moved SelectionDecorations to Mods.Common
And added more settings. Moved SelectionBoxRenderable to Mods.Common, too.
This commit is contained in:
@@ -114,13 +114,13 @@ namespace OpenRA
|
|||||||
|
|
||||||
visualBounds = Exts.Lazy(() =>
|
visualBounds = Exts.Lazy(() =>
|
||||||
{
|
{
|
||||||
var sd = Info.Traits.GetOrDefault<SelectionDecorationsInfo>();
|
var sd = Info.Traits.GetOrDefault<ISelectionDecorationsInfo>();
|
||||||
var size = (sd != null && sd.VisualBounds != null) ? new int2(sd.VisualBounds[0], sd.VisualBounds[1]) :
|
var size = (sd != null && sd.SelectionBoxBounds != null) ? new int2(sd.SelectionBoxBounds[0], sd.SelectionBoxBounds[1]) :
|
||||||
TraitsImplementing<IAutoSelectionSize>().Select(x => x.SelectionSize(this)).FirstOrDefault();
|
TraitsImplementing<IAutoSelectionSize>().Select(x => x.SelectionSize(this)).FirstOrDefault();
|
||||||
|
|
||||||
var offset = -size / 2;
|
var offset = -size / 2;
|
||||||
if (sd != null && sd.VisualBounds != null && sd.VisualBounds.Length > 2)
|
if (sd != null && sd.SelectionBoxBounds != null && sd.SelectionBoxBounds.Length > 2)
|
||||||
offset += new int2(sd.VisualBounds[2], sd.VisualBounds[3]);
|
offset += new int2(sd.SelectionBoxBounds[2], sd.SelectionBoxBounds[3]);
|
||||||
|
|
||||||
return new Rectangle(offset.X, offset.Y, size.X, size.Y);
|
return new Rectangle(offset.X, offset.Y, size.X, size.Y);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -180,7 +180,6 @@
|
|||||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||||
<Compile Include="Traits\RevealsShroud.cs" />
|
<Compile Include="Traits\RevealsShroud.cs" />
|
||||||
<Compile Include="Traits\Selectable.cs" />
|
<Compile Include="Traits\Selectable.cs" />
|
||||||
<Compile Include="Traits\SelectionDecorations.cs" />
|
|
||||||
<Compile Include="Traits\Target.cs" />
|
<Compile Include="Traits\Target.cs" />
|
||||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||||
<Compile Include="Traits\Util.cs" />
|
<Compile Include="Traits\Util.cs" />
|
||||||
@@ -235,7 +234,6 @@
|
|||||||
<Compile Include="Sound\OpenAlSound.cs" />
|
<Compile Include="Sound\OpenAlSound.cs" />
|
||||||
<Compile Include="Sound\NullSound.cs" />
|
<Compile Include="Sound\NullSound.cs" />
|
||||||
<Compile Include="Effects\SpriteEffect.cs" />
|
<Compile Include="Effects\SpriteEffect.cs" />
|
||||||
<Compile Include="Graphics\SelectionBoxRenderable.cs" />
|
|
||||||
<Compile Include="Graphics\SelectionBarsRenderable.cs" />
|
<Compile Include="Graphics\SelectionBarsRenderable.cs" />
|
||||||
<Compile Include="Graphics\TargetLineRenderable.cs" />
|
<Compile Include="Graphics\TargetLineRenderable.cs" />
|
||||||
<Compile Include="Graphics\UISpriteRenderable.cs" />
|
<Compile Include="Graphics\UISpriteRenderable.cs" />
|
||||||
|
|||||||
@@ -61,12 +61,6 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
public IEnumerable<IRenderable> RenderAfterWorld(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (!Info.Selectable)
|
|
||||||
yield break;
|
|
||||||
|
|
||||||
yield return new SelectionBoxRenderable(self, Color.White);
|
|
||||||
yield return new SelectionBarsRenderable(self);
|
|
||||||
|
|
||||||
if (self.World.LocalPlayer != null && self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug)
|
if (self.World.LocalPlayer != null && self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug)
|
||||||
yield return new TargetLineRenderable(ActivityTargetPath(), Color.Green);
|
yield return new TargetLineRenderable(ActivityTargetPath(), Color.Green);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,16 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public interface ISeedableResource { void Seed(Actor self); }
|
public interface ISeedableResource { void Seed(Actor self); }
|
||||||
|
|
||||||
|
public interface ISelectionDecorations
|
||||||
|
{
|
||||||
|
ISelectionDecorationsInfo SelectionDecorationsInfo { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ISelectionDecorationsInfo
|
||||||
|
{
|
||||||
|
int[] SelectionBoxBounds { get; }
|
||||||
|
}
|
||||||
|
|
||||||
public interface IVoiced
|
public interface IVoiced
|
||||||
{
|
{
|
||||||
string VoiceSet { get; }
|
string VoiceSet { get; }
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ using System.Drawing;
|
|||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Mods.Common.Graphics
|
||||||
{
|
{
|
||||||
public struct SelectionBoxRenderable : IRenderable, IFinalizedRenderable
|
public struct SelectionBoxRenderable : IRenderable, IFinalizedRenderable
|
||||||
{
|
{
|
||||||
@@ -171,6 +171,7 @@
|
|||||||
<Compile Include="Graphics\BeamRenderable.cs" />
|
<Compile Include="Graphics\BeamRenderable.cs" />
|
||||||
<Compile Include="Graphics\ContrailRenderable.cs" />
|
<Compile Include="Graphics\ContrailRenderable.cs" />
|
||||||
<Compile Include="Graphics\RangeCircleRenderable.cs" />
|
<Compile Include="Graphics\RangeCircleRenderable.cs" />
|
||||||
|
<Compile Include="Graphics\SelectionBoxRenderable.cs" />
|
||||||
<Compile Include="Graphics\SpriteActorPreview.cs" />
|
<Compile Include="Graphics\SpriteActorPreview.cs" />
|
||||||
<Compile Include="Graphics\TextRenderable.cs" />
|
<Compile Include="Graphics\TextRenderable.cs" />
|
||||||
<Compile Include="Graphics\VoxelActorPreview.cs" />
|
<Compile Include="Graphics\VoxelActorPreview.cs" />
|
||||||
@@ -438,6 +439,7 @@
|
|||||||
<Compile Include="Traits\RepairsBridges.cs" />
|
<Compile Include="Traits\RepairsBridges.cs" />
|
||||||
<Compile Include="Traits\SeedsResource.cs" />
|
<Compile Include="Traits\SeedsResource.cs" />
|
||||||
<Compile Include="Traits\StoresResources.cs" />
|
<Compile Include="Traits\StoresResources.cs" />
|
||||||
|
<Compile Include="Traits\SelectionDecorations.cs" />
|
||||||
<Compile Include="Traits\SelfHealing.cs" />
|
<Compile Include="Traits\SelfHealing.cs" />
|
||||||
<Compile Include="Traits\Sellable.cs" />
|
<Compile Include="Traits\Sellable.cs" />
|
||||||
<Compile Include="Traits\ShakeOnDeath.cs" />
|
<Compile Include="Traits\ShakeOnDeath.cs" />
|
||||||
|
|||||||
@@ -9,21 +9,30 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
public class SelectionDecorationsInfo : ITraitInfo
|
public class SelectionDecorationsInfo : ITraitInfo, ISelectionDecorationsInfo
|
||||||
{
|
{
|
||||||
public readonly string Palette = "chrome";
|
public readonly string Palette = "chrome";
|
||||||
[Desc("Visual bounds for the selection box. If null, it matches Bounds.")]
|
[Desc("Visual bounds for selection box. If null, it uses AutoSelectionSize.")]
|
||||||
public readonly int[] VisualBounds = null;
|
public readonly int[] VisualBounds = null;
|
||||||
|
[Desc("Health bar, production progress bar etc.")]
|
||||||
|
public readonly bool RenderSelectionBars = true;
|
||||||
|
public readonly bool RenderSelectionBox = true;
|
||||||
|
public readonly Color SelectionBoxColor = Color.White;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new SelectionDecorations(init.Self, this); }
|
public object Create(ActorInitializer init) { return new SelectionDecorations(init.Self, this); }
|
||||||
|
|
||||||
|
public int[] SelectionBoxBounds { get { return VisualBounds; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SelectionDecorations : IPostRenderSelection
|
public class SelectionDecorations : ISelectionDecorations, IPostRenderSelection
|
||||||
{
|
{
|
||||||
// depends on the order of pips in TraitsInterfaces.cs!
|
// depends on the order of pips in TraitsInterfaces.cs!
|
||||||
static readonly string[] PipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" };
|
static readonly string[] PipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" };
|
||||||
@@ -32,6 +41,8 @@ namespace OpenRA.Traits
|
|||||||
public SelectionDecorationsInfo Info;
|
public SelectionDecorationsInfo Info;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
|
public ISelectionDecorationsInfo SelectionDecorationsInfo { get { return Info; } }
|
||||||
|
|
||||||
public SelectionDecorations(Actor self, SelectionDecorationsInfo info)
|
public SelectionDecorations(Actor self, SelectionDecorationsInfo info)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
@@ -43,6 +54,12 @@ namespace OpenRA.Traits
|
|||||||
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer) || self.World.FogObscures(self))
|
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer) || self.World.FogObscures(self))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
|
if (Info.RenderSelectionBox)
|
||||||
|
yield return new SelectionBoxRenderable(self, Info.SelectionBoxColor);
|
||||||
|
|
||||||
|
if (Info.RenderSelectionBars)
|
||||||
|
yield return new SelectionBarsRenderable(self);
|
||||||
|
|
||||||
var b = self.VisualBounds;
|
var b = self.VisualBounds;
|
||||||
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
||||||
var tl = wr.Viewport.WorldToViewPx(pos + new int2(b.Left, b.Top));
|
var tl = wr.Viewport.WorldToViewPx(pos + new int2(b.Left, b.Top));
|
||||||
@@ -12,6 +12,7 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Graphics;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user