mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-24 23:27:14 -05:00
Add some map item code
no functions, just exploration
This commit is contained in:
parent
9988e72182
commit
e70d2b71d8
15
NHSE.Core/Structures/Item/MapItem.cs
Normal file
15
NHSE.Core/Structures/Item/MapItem.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class MapItem : Item
|
||||
{
|
||||
public new const int SIZE = 0x10;
|
||||
|
||||
public ushort X1, X2, X3, X4;
|
||||
public new static MapItem[] GetArray(byte[] data) => data.GetArray<MapItem>(SIZE);
|
||||
public static byte[] SetArray(IReadOnlyList<MapItem> data) => data.SetArray(SIZE);
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ public Bitmap CreateFake(Item item, Font font, bool slash = false)
|
|||
return bmp;
|
||||
}
|
||||
|
||||
private static void DrawItemAt(Graphics gfx, Item item, Font font, int x1, int y1, int x2, int y2, bool slash = false)
|
||||
public static void DrawItemAt(Graphics gfx, Item item, Font font, int x1, int y1, int x2, int y2, bool slash = false)
|
||||
{
|
||||
var color = GetItemColor(item);
|
||||
using var brush = new SolidBrush(color);
|
||||
|
|
@ -89,5 +89,22 @@ public static Color Blend(Color color, Color backColor, double amount)
|
|||
}
|
||||
|
||||
private static readonly KnownColor[] Colors = (KnownColor[])Enum.GetValues(typeof(KnownColor));
|
||||
|
||||
public Bitmap GetItemArray(Item[] items, int height, Font f)
|
||||
{
|
||||
//var items = MapItem.GetArray(SAV.Main.Data.Slice(0x20191C, 0xA8000));
|
||||
var width = items.Length / height;
|
||||
|
||||
var png = new Bitmap(width * Width, height * Height);
|
||||
var gfx = Graphics.FromImage(png);
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
var x = Height * (i / height);
|
||||
var y = Width * (i % height);
|
||||
DrawItemAt(gfx, items[i], f, x, y, x + Width - 1, y + Height - 1);
|
||||
}
|
||||
|
||||
return png;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,5 +21,13 @@ public void VillagerItemMarshal()
|
|||
var bytes = item.ToBytesClass();
|
||||
bytes.Length.Should().Be(VillagerItem.SIZE);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MapItemMarshal()
|
||||
{
|
||||
var item = new MapItem();
|
||||
var bytes = item.ToBytesClass();
|
||||
bytes.Length.Should().Be(MapItem.SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user