removed editor -> ra dep; added EditorAppearance for inconvenient bits that the editor must have _some_ understanding of, but can't see
This commit is contained in:
@@ -18,7 +18,7 @@ namespace OpenRA.Editor
|
|||||||
{
|
{
|
||||||
public Bitmap Bitmap;
|
public Bitmap Bitmap;
|
||||||
public ActorInfo Info;
|
public ActorInfo Info;
|
||||||
public bool Centered;
|
public EditorAppearanceInfo Appearance;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BrushTemplate
|
class BrushTemplate
|
||||||
|
|||||||
@@ -145,10 +145,6 @@
|
|||||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||||
<Name>OpenRA.Game</Name>
|
<Name>OpenRA.Game</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\OpenRA.Mods.RA\OpenRA.Mods.RA.csproj">
|
|
||||||
<Project>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</Project>
|
|
||||||
<Name>OpenRA.Mods.RA</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="OpenRA.Editor.Icon.ico" />
|
<Content Include="OpenRA.Editor.Icon.ico" />
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using System.Drawing;
|
|||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
|
||||||
|
|
||||||
namespace OpenRA.Editor
|
namespace OpenRA.Editor
|
||||||
{
|
{
|
||||||
@@ -122,7 +121,12 @@ namespace OpenRA.Editor
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
return new ActorTemplate { Bitmap = bitmap, Info = info, Centered = !info.Traits.Contains<BuildingInfo>() };
|
return new ActorTemplate
|
||||||
|
{
|
||||||
|
Bitmap = bitmap,
|
||||||
|
Info = info,
|
||||||
|
Appearance = info.Traits.GetOrDefault<EditorAppearanceInfo>()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -413,10 +413,12 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
void DrawActor(System.Drawing.Graphics g, int2 p, ActorTemplate t, ColorPalette cp)
|
void DrawActor(System.Drawing.Graphics g, int2 p, ActorTemplate t, ColorPalette cp)
|
||||||
{
|
{
|
||||||
float OffsetX = t.Centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
|
var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft;
|
||||||
|
|
||||||
|
float OffsetX = centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
|
||||||
float DrawX = TileSet.TileSize * p.X * Zoom + Offset.X - OffsetX;
|
float DrawX = TileSet.TileSize * p.X * Zoom + Offset.X - OffsetX;
|
||||||
|
|
||||||
float OffsetY = t.Centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
|
float OffsetY = centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
|
||||||
float DrawY = TileSet.TileSize * p.Y * Zoom + Offset.Y - OffsetY;
|
float DrawY = TileSet.TileSize * p.Y * Zoom + Offset.Y - OffsetY;
|
||||||
|
|
||||||
float width = t.Bitmap.Width * Zoom;
|
float width = t.Bitmap.Width * Zoom;
|
||||||
@@ -447,10 +449,12 @@ namespace OpenRA.Editor
|
|||||||
|
|
||||||
void DrawActorBorder(System.Drawing.Graphics g, int2 p, ActorTemplate t)
|
void DrawActorBorder(System.Drawing.Graphics g, int2 p, ActorTemplate t)
|
||||||
{
|
{
|
||||||
float OffsetX = t.Centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
|
var centered = t.Appearance == null || !t.Appearance.RelativeToTopLeft;
|
||||||
|
|
||||||
|
float OffsetX = centered ? t.Bitmap.Width / 2 - TileSet.TileSize / 2 : 0;
|
||||||
float DrawX = TileSet.TileSize * p.X * Zoom + Offset.X - OffsetX;
|
float DrawX = TileSet.TileSize * p.X * Zoom + Offset.X - OffsetX;
|
||||||
|
|
||||||
float OffsetY = t.Centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
|
float OffsetY = centered ? t.Bitmap.Height / 2 - TileSet.TileSize / 2 : 0;
|
||||||
float DrawY = TileSet.TileSize * p.Y * Zoom + Offset.Y - OffsetY;
|
float DrawY = TileSet.TileSize * p.Y * Zoom + Offset.Y - OffsetY;
|
||||||
|
|
||||||
g.DrawRectangle(CordonPen,
|
g.DrawRectangle(CordonPen,
|
||||||
|
|||||||
@@ -66,21 +66,21 @@ namespace OpenRA
|
|||||||
var ret = new List<ITraitInfo>();
|
var ret = new List<ITraitInfo>();
|
||||||
var t = Traits.WithInterface<ITraitInfo>().ToList();
|
var t = Traits.WithInterface<ITraitInfo>().ToList();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while( t.Count != 0 )
|
while (t.Count != 0)
|
||||||
{
|
{
|
||||||
if( index >= t.Count )
|
var prereqs = PrerequisitesOf(t[index]);
|
||||||
throw new InvalidOperationException( "Trait prerequisites not satisfied (or prerequisite loop) Actor={0} Unresolved={1}".F(
|
var unsatisfied = prereqs.Where(n => !ret.Any(x => x.GetType() == n || x.GetType().IsSubclassOf(n)));
|
||||||
Name, string.Join( ",", t.Select( x => x.GetType().Name ).ToArray())));
|
if (!unsatisfied.Any())
|
||||||
|
|
||||||
var prereqs = PrerequisitesOf( t[ index ] );
|
|
||||||
if( prereqs.Count == 0 || prereqs.All( n => ret.Any( x => x.GetType() == n || x.GetType().IsSubclassOf( n ) ) ) )
|
|
||||||
{
|
{
|
||||||
ret.Add( t[ index ] );
|
ret.Add(t[index]);
|
||||||
t.RemoveAt( index );
|
t.RemoveAt(index);
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
else
|
else if (++index >= t.Count)
|
||||||
++index;
|
throw new InvalidOperationException("Trait prerequisites not satisfied (or prerequisite loop) Actor={0} Unresolved={1} Missing={2}".F(
|
||||||
|
Name,
|
||||||
|
string.Join(",", t.Select(x => x.GetType().Name).ToArray()),
|
||||||
|
string.Join(",", unsatisfied.Select(x => x.Name).ToArray())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -211,6 +211,7 @@
|
|||||||
<Compile Include="Server\IServerExtension.cs" />
|
<Compile Include="Server\IServerExtension.cs" />
|
||||||
<Compile Include="Server\NullServerExtension.cs" />
|
<Compile Include="Server\NullServerExtension.cs" />
|
||||||
<Compile Include="Traits\BaseBuilding.cs" />
|
<Compile Include="Traits\BaseBuilding.cs" />
|
||||||
|
<Compile Include="Traits\EditorAppearance.cs" />
|
||||||
<Compile Include="Traits\ValidateOrder.cs" />
|
<Compile Include="Traits\ValidateOrder.cs" />
|
||||||
<Compile Include="Traits\Scale.cs" />
|
<Compile Include="Traits\Scale.cs" />
|
||||||
<Compile Include="TraitDictionary.cs" />
|
<Compile Include="TraitDictionary.cs" />
|
||||||
|
|||||||
19
OpenRA.Game/Traits/EditorAppearance.cs
Normal file
19
OpenRA.Game/Traits/EditorAppearance.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2010 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 LICENSE.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace OpenRA.Traits
|
||||||
|
{
|
||||||
|
public class EditorAppearanceInfo : TraitInfo<EditorAppearance>
|
||||||
|
{
|
||||||
|
public readonly bool RelativeToTopLeft = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EditorAppearance { }
|
||||||
|
}
|
||||||
@@ -205,6 +205,8 @@
|
|||||||
Notification: nodcapt1.aud
|
Notification: nodcapt1.aud
|
||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
Notification: strclost.aud
|
Notification: strclost.aud
|
||||||
|
EditorAppearance:
|
||||||
|
RelativeToTopLeft: yes
|
||||||
|
|
||||||
^CivBuilding:
|
^CivBuilding:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -254,6 +256,8 @@
|
|||||||
HasMakeAnimation: false
|
HasMakeAnimation: false
|
||||||
Palette: terrain
|
Palette: terrain
|
||||||
GivesExperience:
|
GivesExperience:
|
||||||
|
EditorAppearance:
|
||||||
|
RelativeToTopLeft: yes
|
||||||
|
|
||||||
^Tree:
|
^Tree:
|
||||||
Tooltip:
|
Tooltip:
|
||||||
|
|||||||
@@ -139,6 +139,8 @@
|
|||||||
FrozenUnderFog:
|
FrozenUnderFog:
|
||||||
CaptureNotification:
|
CaptureNotification:
|
||||||
Notification: strucap1.aud
|
Notification: strucap1.aud
|
||||||
|
EditorAppearance:
|
||||||
|
RelativeToTopLeft: yes
|
||||||
|
|
||||||
^Wall:
|
^Wall:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -163,6 +165,8 @@
|
|||||||
HasMakeAnimation: false
|
HasMakeAnimation: false
|
||||||
Palette: terrain
|
Palette: terrain
|
||||||
GivesExperience:
|
GivesExperience:
|
||||||
|
EditorAppearance:
|
||||||
|
RelativeToTopLeft: yes
|
||||||
|
|
||||||
^CivBuilding:
|
^CivBuilding:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
Reference in New Issue
Block a user