Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into MapMacros
  • Loading branch information
Clownacy committed Jun 3, 2015
2 parents afa3d88 + 4480024 commit 8b508bd
Show file tree
Hide file tree
Showing 21 changed files with 1,376 additions and 850 deletions.
102 changes: 51 additions & 51 deletions SonLVL INI Files/Common/InvisibleBlock.cs
Expand Up @@ -5,64 +5,64 @@

namespace S1ObjectDefinitions.Common
{
class InvisibleBlock : ObjectDefinition
{
private Sprite img;
class InvisibleBlock : ObjectDefinition
{
private Sprite img;

public override void Init(ObjectData data)
{
byte[] artfile = ObjectHelper.OpenArtFile("../artnem/Monitors.bin", CompressionType.Nemesis);
img = ObjectHelper.MapASMToBmp(artfile, "../_maps/Invisible Barriers.asm", 0, 0);
}
public override void Init(ObjectData data)
{
byte[] artfile = ObjectHelper.OpenArtFile("../artnem/Monitors.bin", CompressionType.Nemesis);
img = ObjectHelper.MapASMToBmp(artfile, "../_maps/Invisible Barriers.asm", 0, 0);
}

public override ReadOnlyCollection<byte> Subtypes
{
get { return new ReadOnlyCollection<byte>(new byte[] { 0 }); }
}
public override ReadOnlyCollection<byte> Subtypes
{
get { return new ReadOnlyCollection<byte>(new byte[] { 0 }); }
}

public override string Name
{
get { return "Invisible solid block"; }
}
public override string Name
{
get { return "Invisible solid block"; }
}

public override bool RememberState
{
get { return true; }
}
public override bool RememberState
{
get { return true; }
}

public override string SubtypeName(byte subtype)
{
return ((subtype >> 4) + 1) + "x" + ((subtype & 0xF) + 1) + " blocks";
}
public override string SubtypeName(byte subtype)
{
return ((subtype >> 4) + 1) + "x" + ((subtype & 0xF) + 1) + " blocks";
}

public override Sprite Image
{
get { return img; }
}
public override Sprite Image
{
get { return img; }
}

public override Sprite SubtypeImage(byte subtype)
{
return img;
}
public override Sprite SubtypeImage(byte subtype)
{
return img;
}

public override Sprite GetSprite(ObjectEntry obj)
{
int w = ((obj.SubType >> 4) + 1) * 16;
int h = ((obj.SubType & 0xF) + 1) * 16;
BitmapBits bmp = new BitmapBits(w, h);
bmp.DrawRectangle(0x1C, 0, 0, w - 1, h - 1);
Sprite spr = new Sprite(new Sprite(bmp, new Point(-(w / 2), -(h / 2))), img);
spr.Offset = new Point(spr.X + obj.X, spr.Y + obj.Y);
return spr;
}
public override Sprite GetSprite(ObjectEntry obj)
{
int w = ((obj.SubType >> 4) + 1) * 16;
int h = ((obj.SubType & 0xF) + 1) * 16;
BitmapBits bmp = new BitmapBits(w, h);
bmp.DrawRectangle(0x1C, 0, 0, w - 1, h - 1);
Sprite spr = new Sprite(new Sprite(bmp, new Point(-(w / 2), -(h / 2))), img);
spr.Offset = new Point(spr.X + obj.X, spr.Y + obj.Y);
return spr;
}

public override Rectangle GetBounds(ObjectEntry obj, Point camera)
{
int w = ((obj.SubType >> 4) + 1) * 16;
int h = ((obj.SubType & 0xF) + 1) * 16;
return new Rectangle(obj.X - (w / 2) - camera.X, obj.Y - (h / 2) - camera.Y, w, h);
}
public override Rectangle GetBounds(ObjectEntry obj, Point camera)
{
int w = ((obj.SubType >> 4) + 1) * 16;
int h = ((obj.SubType & 0xF) + 1) * 16;
return new Rectangle(obj.X - (w / 2) - camera.X, obj.Y - (h / 2) - camera.Y, w, h);
}

public override bool Debug { get { return true; } }
}
}
public override bool Debug { get { return true; } }
}
}
17 changes: 17 additions & 0 deletions SonLVL INI Files/Common/Lamppost.xml
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ObjDef xmlns="http://www.sonicretro.org" Name="Lamppost" Image="img" RememberState="true">
<Images>
<ImageFromMappings id="img">
<ArtFile filename="../artnem/Lamppost.bin"/>
<MapFile type="ASM" filename="../_maps/Lamppost.asm" frame="0" startpal="0"/>
</ImageFromMappings>
</Images>
<Properties>
<BitsProperty name="LamppostOrder" displayname="Lamppost Order" type="int" startbit="0" length="7" />
</Properties>
<Display>
<DisplayOption>
<ImageRef image="img" />
</DisplayOption>
</Display>
</ObjDef>
232 changes: 116 additions & 116 deletions SonLVL INI Files/Common/Ring.cs
Expand Up @@ -6,119 +6,119 @@

namespace S1ObjectDefinitions.Common
{
public class Ring : ObjectDefinition
{
private Size[] Spacing = {
new Size(0x10, 0), // horizontal tight
new Size(0x18, 0), // horizontal normal
new Size(0x20, 0), // horizontal wide
new Size(0, 0x10), // vertical tight
new Size(0, 0x18), // vertical normal
new Size(0, 0x20), // vertical wide
new Size(0x10, 0x10), // diagonal
new Size(0x18, 0x18),
new Size(0x20, 0x20),
new Size(-0x10, 0x10),
new Size(-0x18, 0x18),
new Size(-0x20, 0x20),
new Size(0x10, 8),
new Size(0x18, 0x10),
new Size(-0x10, 8),
new Size(-0x18, 0x10)
};

private Sprite img;

public override void Init(ObjectData data)
{
byte[] artfile = ObjectHelper.OpenArtFile("../artnem/Rings.bin", CompressionType.Nemesis);
img = ObjectHelper.MapASMToBmp(artfile, data.CustomProperties.GetValueOrDefault("revision", "0") == "1" ? "../_maps/Rings (JP1).asm" : "../_maps/Rings.asm", 0, 1);
}

public override ReadOnlyCollection<byte> Subtypes
{
get { return new ReadOnlyCollection<byte>(new List<byte>()); }
}

public override string Name
{
get { return "Ring"; }
}

public override bool RememberState
{
get { return true; }
}

public override string SubtypeName(byte subtype)
{
return string.Empty;
}

public override Sprite Image
{
get { return img; }
}

public override Sprite SubtypeImage(byte subtype)
{
return img;
}

public override Rectangle GetBounds(ObjectEntry obj, Point camera)
{
int count = Math.Min(6, obj.SubType & 7);
Size space = Spacing[obj.SubType >> 4];
return new Rectangle(obj.X + img.X - camera.X, obj.Y + img.Y - camera.Y, (space.Width * count) + img.Width, (space.Height * count) + img.Height);
}

public override Sprite GetSprite(ObjectEntry obj)
{
int count = Math.Min(6, obj.SubType & 7) + 1;
Size space = Spacing[obj.SubType >> 4];
Point loc = new Point(img.X, img.Y);
List<Sprite> sprs = new List<Sprite>();
for (int i = 0; i < count; i++)
{
sprs.Add(new Sprite(img.Image, loc));
loc += space;
}
Sprite spr = new Sprite(sprs.ToArray());
spr.Offset = new Point(spr.X + obj.X, spr.Y + obj.Y);
return spr;
}

private PropertySpec[] customProperties = new PropertySpec[] {
new PropertySpec("Count", typeof(int), "Extended", null, null, GetCount, SetCount),
new PropertySpec("Direction", typeof(int), "Extended", null, null, GetDirection, SetDirection)
};

public override PropertySpec[] CustomProperties
{
get
{
return customProperties;
}
}

private static object GetCount(ObjectEntry obj)
{
return Math.Min(6, obj.SubType & 7) + 1;
}

private static void SetCount(ObjectEntry obj, object value)
{
obj.SubType = (byte)((obj.SubType & ~7) | (Math.Min((int)value, 7) - 1));
}

private static object GetDirection(ObjectEntry obj)
{
return obj.SubType >> 4;
}

private static void SetDirection(ObjectEntry obj, object value)
{
obj.SubType = (byte)((obj.SubType & ~0xF0) | (((int)value & 0xF) << 4));
}
}
}
public class Ring : ObjectDefinition
{
private Size[] Spacing = {
new Size(0x10, 0), // horizontal tight
new Size(0x18, 0), // horizontal normal
new Size(0x20, 0), // horizontal wide
new Size(0, 0x10), // vertical tight
new Size(0, 0x18), // vertical normal
new Size(0, 0x20), // vertical wide
new Size(0x10, 0x10), // diagonal
new Size(0x18, 0x18),
new Size(0x20, 0x20),
new Size(-0x10, 0x10),
new Size(-0x18, 0x18),
new Size(-0x20, 0x20),
new Size(0x10, 8),
new Size(0x18, 0x10),
new Size(-0x10, 8),
new Size(-0x18, 0x10)
};

private Sprite img;

public override void Init(ObjectData data)
{
byte[] artfile = ObjectHelper.OpenArtFile("../artnem/Rings.bin", CompressionType.Nemesis);
img = ObjectHelper.MapASMToBmp(artfile, data.CustomProperties.GetValueOrDefault("revision", "0") == "1" ? "../_maps/Rings (JP1).asm" : "../_maps/Rings.asm", 0, 1);
}

public override ReadOnlyCollection<byte> Subtypes
{
get { return new ReadOnlyCollection<byte>(new List<byte>()); }
}

public override string Name
{
get { return "Ring"; }
}

public override bool RememberState
{
get { return true; }
}

public override string SubtypeName(byte subtype)
{
return string.Empty;
}

public override Sprite Image
{
get { return img; }
}

public override Sprite SubtypeImage(byte subtype)
{
return img;
}

public override Rectangle GetBounds(ObjectEntry obj, Point camera)
{
int count = Math.Min(6, obj.SubType & 7);
Size space = Spacing[obj.SubType >> 4];
return new Rectangle(obj.X + img.X - camera.X, obj.Y + img.Y - camera.Y, (space.Width * count) + img.Width, (space.Height * count) + img.Height);
}

public override Sprite GetSprite(ObjectEntry obj)
{
int count = Math.Min(6, obj.SubType & 7) + 1;
Size space = Spacing[obj.SubType >> 4];
Point loc = new Point(img.X, img.Y);
List<Sprite> sprs = new List<Sprite>();
for (int i = 0; i < count; i++)
{
sprs.Add(new Sprite(img.Image, loc));
loc += space;
}
Sprite spr = new Sprite(sprs.ToArray());
spr.Offset = new Point(spr.X + obj.X, spr.Y + obj.Y);
return spr;
}

private PropertySpec[] customProperties = new PropertySpec[] {
new PropertySpec("Count", typeof(int), "Extended", null, null, GetCount, SetCount),
new PropertySpec("Direction", typeof(int), "Extended", null, null, GetDirection, SetDirection)
};

public override PropertySpec[] CustomProperties
{
get
{
return customProperties;
}
}

private static object GetCount(ObjectEntry obj)
{
return Math.Min(6, obj.SubType & 7) + 1;
}

private static void SetCount(ObjectEntry obj, object value)
{
obj.SubType = (byte)((obj.SubType & ~7) | (Math.Min((int)value, 7) - 1));
}

private static object GetDirection(ObjectEntry obj)
{
return obj.SubType >> 4;
}

private static void SetDirection(ObjectEntry obj, object value)
{
obj.SubType = (byte)((obj.SubType & ~0xF0) | (((int)value & 0xF) << 4));
}
}
}

0 comments on commit 8b508bd

Please sign in to comment.