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 ActorInfo Info;
|
||||
public bool Centered;
|
||||
public EditorAppearanceInfo Appearance;
|
||||
}
|
||||
|
||||
class BrushTemplate
|
||||
|
||||
@@ -145,10 +145,6 @@
|
||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||
<Name>OpenRA.Game</Name>
|
||||
</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>
|
||||
<Content Include="OpenRA.Editor.Icon.ico" />
|
||||
|
||||
@@ -13,7 +13,6 @@ using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
|
||||
namespace OpenRA.Editor
|
||||
{
|
||||
@@ -122,7 +121,12 @@ namespace OpenRA.Editor
|
||||
}
|
||||
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)
|
||||
{
|
||||
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 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 width = t.Bitmap.Width * Zoom;
|
||||
@@ -447,10 +449,12 @@ namespace OpenRA.Editor
|
||||
|
||||
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 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;
|
||||
|
||||
g.DrawRectangle(CordonPen,
|
||||
|
||||
@@ -68,19 +68,19 @@ namespace OpenRA
|
||||
int index = 0;
|
||||
while (t.Count != 0)
|
||||
{
|
||||
if( index >= t.Count )
|
||||
throw new InvalidOperationException( "Trait prerequisites not satisfied (or prerequisite loop) Actor={0} Unresolved={1}".F(
|
||||
Name, string.Join( ",", t.Select( x => x.GetType().Name ).ToArray())));
|
||||
|
||||
var prereqs = PrerequisitesOf(t[index]);
|
||||
if( prereqs.Count == 0 || prereqs.All( n => ret.Any( x => x.GetType() == n || x.GetType().IsSubclassOf( n ) ) ) )
|
||||
var unsatisfied = prereqs.Where(n => !ret.Any(x => x.GetType() == n || x.GetType().IsSubclassOf(n)));
|
||||
if (!unsatisfied.Any())
|
||||
{
|
||||
ret.Add(t[index]);
|
||||
t.RemoveAt(index);
|
||||
index = 0;
|
||||
}
|
||||
else
|
||||
++index;
|
||||
else if (++index >= t.Count)
|
||||
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;
|
||||
|
||||
@@ -211,6 +211,7 @@
|
||||
<Compile Include="Server\IServerExtension.cs" />
|
||||
<Compile Include="Server\NullServerExtension.cs" />
|
||||
<Compile Include="Traits\BaseBuilding.cs" />
|
||||
<Compile Include="Traits\EditorAppearance.cs" />
|
||||
<Compile Include="Traits\ValidateOrder.cs" />
|
||||
<Compile Include="Traits\Scale.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
|
||||
ActorLostNotification:
|
||||
Notification: strclost.aud
|
||||
EditorAppearance:
|
||||
RelativeToTopLeft: yes
|
||||
|
||||
^CivBuilding:
|
||||
Inherits: ^Building
|
||||
@@ -254,6 +256,8 @@
|
||||
HasMakeAnimation: false
|
||||
Palette: terrain
|
||||
GivesExperience:
|
||||
EditorAppearance:
|
||||
RelativeToTopLeft: yes
|
||||
|
||||
^Tree:
|
||||
Tooltip:
|
||||
|
||||
@@ -139,6 +139,8 @@
|
||||
FrozenUnderFog:
|
||||
CaptureNotification:
|
||||
Notification: strucap1.aud
|
||||
EditorAppearance:
|
||||
RelativeToTopLeft: yes
|
||||
|
||||
^Wall:
|
||||
AppearsOnRadar:
|
||||
@@ -163,6 +165,8 @@
|
||||
HasMakeAnimation: false
|
||||
Palette: terrain
|
||||
GivesExperience:
|
||||
EditorAppearance:
|
||||
RelativeToTopLeft: yes
|
||||
|
||||
^CivBuilding:
|
||||
Inherits: ^Building
|
||||
|
||||
Reference in New Issue
Block a user