mirror of
https://github.com/kwsch/NHSE.git
synced 2026-07-02 00:11:55 -05:00
Add exterior acre pixel dumper, show exterior acres on Field Item editor
980KB -> 12KB when compressed, seems legit just an array of tile definitions (32x32 style), sequential acres (undefined acres are all zeroed) tiles aren't displated as granular as possible, only sets as 16x16 tiles instead of larger 32x32, but it should be a good enough color hint to people for editing big thanks to ninji for the color mapping in his disassembly and the pbc->tile parse
This commit is contained in:
parent
fd81b2cb61
commit
801db3e130
22
NHSE.Core/Drawing/AcreTileColor.cs
Normal file
22
NHSE.Core/Drawing/AcreTileColor.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System.Drawing;
|
||||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
public static class AcreTileColor
|
||||
{
|
||||
public static readonly byte[] AcreTiles = ResourceUtil.GetBinaryResource("outside.bin");
|
||||
|
||||
public static int GetAcreTileColor(byte acre, int x, int y)
|
||||
{
|
||||
if (acre > (byte)OutsideAcre.FldOutSBridge01)
|
||||
return Color.Transparent.ToArgb();
|
||||
var baseOfs = acre * 32 * 32 * 4;
|
||||
|
||||
// 64x64
|
||||
var shift = (4 * ((y * 64) + x));
|
||||
var ofs = baseOfs + shift;
|
||||
var tile = AcreTiles[ofs];
|
||||
return CollisionUtil.Dict[tile].ToArgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ namespace NHSE.Core
|
|||
{
|
||||
public static class TerrainTileColor
|
||||
{
|
||||
private static readonly Color River = Color.FromArgb(128, 215, 195);
|
||||
|
||||
public static Color GetTileColor(TerrainTile tile)
|
||||
{
|
||||
if (tile.UnitModelRoad.IsRoad())
|
||||
|
|
@ -13,7 +15,7 @@ public static Color GetTileColor(TerrainTile tile)
|
|||
if (tile.Elevation == 0)
|
||||
return baseColor;
|
||||
|
||||
return ColorUtil.Blend(baseColor, Color.White, 1d / (tile.Elevation + 1));
|
||||
return ColorUtil.Blend(baseColor, Color.White, 1.4d / (tile.Elevation + 1));
|
||||
}
|
||||
|
||||
private static readonly Color CliffBase = ColorUtil.Blend(Color.ForestGreen, Color.Black, 0.6d);
|
||||
|
|
@ -21,9 +23,9 @@ public static Color GetTileColor(TerrainTile tile)
|
|||
private static Color GetTileDefaultColor(TerrainUnitModel mdl)
|
||||
{
|
||||
if (mdl.IsRiver())
|
||||
return Color.DeepSkyBlue;
|
||||
return River;
|
||||
if (mdl.IsFall())
|
||||
return Color.DarkBlue;
|
||||
return Color.DeepSkyBlue;
|
||||
if (mdl.IsCliff())
|
||||
return CliffBase;
|
||||
return Color.ForestGreen;
|
||||
|
|
@ -40,12 +42,4 @@ public static string GetTileName(TerrainTile tile)
|
|||
return name.Substring(0, num) + Environment.NewLine + name.Substring(num);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AcreTileColor
|
||||
{
|
||||
public static int GetAcreTileColor(byte acre, int x, int y)
|
||||
{
|
||||
return Color.ForestGreen.ToArgb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<ItemGroup>
|
||||
<None Remove="Resources\byte\item_kind.bin" />
|
||||
<None Remove="Resources\byte\item_size.bin" />
|
||||
<None Remove="Resources\byte\outside.bin" />
|
||||
<None Remove="Resources\text\de\internal_de.txt" />
|
||||
<None Remove="Resources\text\de\MessageStrings_de.txt" />
|
||||
<None Remove="Resources\text\de\text_item_de.txt" />
|
||||
|
|
@ -50,6 +51,7 @@
|
|||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\byte\item_kind.bin" />
|
||||
<EmbeddedResource Include="Resources\byte\item_size.bin" />
|
||||
<EmbeddedResource Include="Resources\byte\outside.bin" />
|
||||
<EmbeddedResource Include="Resources\text\de\internal_de.txt" />
|
||||
<EmbeddedResource Include="Resources\text\de\MessageStrings_de.txt" />
|
||||
<EmbeddedResource Include="Resources\text\de\text_item_de.txt" />
|
||||
|
|
|
|||
BIN
NHSE.Core/Resources/byte/outside.bin
Normal file
BIN
NHSE.Core/Resources/byte/outside.bin
Normal file
Binary file not shown.
|
|
@ -1,4 +1,7 @@
|
|||
namespace NHSE.Core
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
public enum OutsideAcre : ushort
|
||||
{
|
||||
|
|
@ -162,4 +165,35 @@ public enum OutsideAcre : ushort
|
|||
FldOutSBridge02 = 243,
|
||||
FldOutSBridge01 = 244
|
||||
}
|
||||
|
||||
public static class CollisionUtil
|
||||
{
|
||||
public static readonly Dictionary<byte, Color> Dict = new Dictionary<byte, Color>
|
||||
{
|
||||
{00, Color.FromArgb( 70, 120, 64)}, // Grass
|
||||
{01, Color.FromArgb(128, 215, 195)}, // River
|
||||
{03, Color.FromArgb(192, 192, 192)}, // Stone
|
||||
{04, Color.FromArgb(240, 230, 170)}, // Sand
|
||||
{05, Color.FromArgb(128, 215, 195)}, // Sea
|
||||
{06, Color.FromArgb(255, 128, 128)}, // Wood
|
||||
{07, Color.FromArgb(0 , 0, 0)}, // Null
|
||||
{08, Color.FromArgb(32 , 32, 32)}, // Building
|
||||
{09, Color.FromArgb(255, 0, 0)}, // ??
|
||||
{10, Color.FromArgb(48 , 48, 48)}, // Door
|
||||
{12, Color.FromArgb(128, 215, 195)}, // Water at mouths of river
|
||||
{15, Color.FromArgb(128, 215, 195)}, // Strip of water between river mouth and river
|
||||
{22, Color.FromArgb(190, 98, 98)}, // Wood (thin)
|
||||
{28, Color.FromArgb(255, 0, 0)}, // ?? this one isn't even in ColGroundAttributeParam...
|
||||
{29, Color.FromArgb(232, 222, 162)}, // Edge of beach, next to sea
|
||||
{41, Color.FromArgb(118, 122, 132)}, // Rocks at top of map
|
||||
{42, Color.FromArgb(128, 133, 147)}, // Taller regions, rocks at top of map
|
||||
{43, Color.Cyan},
|
||||
{44, Color.FromArgb( 62, 112, 56)}, // Edge connecting grass and beach
|
||||
{45, Color.FromArgb(118, 122, 132)}, // Some kind of rock
|
||||
{46, Color.FromArgb(120, 207, 187)}, // Edge of sea, next to beach
|
||||
{47, Color.FromArgb(128, 128, 0)}, // Sandstone
|
||||
{49, Color.FromArgb(190, 98, 98)}, // Pier
|
||||
{51, Color.FromArgb(32 , 152, 32)}, // "Grass-growing building"??
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,9 +114,13 @@ public bool IsWithinGrid(int acreScale, int relX, int relY)
|
|||
|
||||
public int GetTileColor(int x, in int y)
|
||||
{
|
||||
//var acre = GetTileAcre(x, y);
|
||||
//if (acre != 0)
|
||||
// return AcreTileColor.GetAcreTileColor(acre, x % 16, y % 16);
|
||||
var acre = GetTileAcre(x, y);
|
||||
if (acre != 0)
|
||||
{
|
||||
var c = AcreTileColor.GetAcreTileColor(acre, x % 16, y % 16);
|
||||
if (c != -0x1000000) // transparent
|
||||
return c;
|
||||
}
|
||||
|
||||
var tile = GetTile(x, y);
|
||||
return TerrainTileColor.GetTileColor(tile).ToArgb();
|
||||
|
|
@ -128,7 +132,8 @@ private byte GetTileAcre(int x, int y)
|
|||
var acreY = 1 + (y / 16);
|
||||
|
||||
var acreIndex = ((AcreWidth + 2) * acreY) + acreX;
|
||||
return BaseAcres[acreIndex * 2]; // u16 array, never > 255
|
||||
var ofs = acreIndex * 2;
|
||||
return BaseAcres[ofs]; // u16 array, never > 255
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public struct GSavePlayerHandleName
|
|||
{
|
||||
public const int SIZE = 0xA;
|
||||
|
||||
private ushort ModifierId { get; set; }
|
||||
public ushort ModifierId { get; set; }
|
||||
public byte ModifierLevel { get; set; }
|
||||
|
||||
public ushort NounId { get; set; }
|
||||
|
|
|
|||
36
NHSE.Parsing/GamePBCDumper.cs
Normal file
36
NHSE.Parsing/GamePBCDumper.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NHSE.Core;
|
||||
|
||||
namespace NHSE.Parsing
|
||||
{
|
||||
public static class GamePBCDumper
|
||||
{
|
||||
public static void DumpOutsideAcrePixels(string modelPath, string path)
|
||||
{
|
||||
var files = Directory.EnumerateFiles(modelPath, "*.pbc", SearchOption.AllDirectories);
|
||||
|
||||
const int acreSize = 32 * 32 * 4;
|
||||
var maxAcre = Enum.GetValues(typeof(OutsideAcre)).Cast<OutsideAcre>().Max();
|
||||
var result = new byte[acreSize * ((int)maxAcre + 1)];
|
||||
|
||||
foreach (var f in files)
|
||||
{
|
||||
var fn = Path.GetFileNameWithoutExtension(f);
|
||||
if (fn == null)
|
||||
continue;
|
||||
if (!Enum.TryParse<OutsideAcre>(fn, out var acre))
|
||||
continue;
|
||||
|
||||
var data = File.ReadAllBytes(f);
|
||||
var pbc = new PBC(data);
|
||||
|
||||
var index = (int)acre;
|
||||
var offset = acreSize * index;
|
||||
pbc.Tiles.CopyTo(result, offset);
|
||||
}
|
||||
File.WriteAllBytes(path, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using NHSE.Core;
|
||||
|
||||
namespace NHSE.Parsing
|
||||
{
|
||||
|
|
@ -45,37 +45,10 @@ private byte[] GetTiles()
|
|||
}
|
||||
|
||||
public byte GetTile(int x, int y) => Tiles[(y * Width) + x];
|
||||
public Color GetTileColor(int x, int y) => Dict[GetTile(x, y)];
|
||||
public Color GetTileColor(int x, int y) => CollisionUtil.Dict[GetTile(x, y)];
|
||||
|
||||
public uint Magic => BitConverter.ToUInt32(Data, 0x00);
|
||||
public uint Width => BitConverter.ToUInt32(Data, 0x04);
|
||||
public uint Height => BitConverter.ToUInt32(Data, 0x08);
|
||||
|
||||
public static readonly Dictionary<byte, Color> Dict = new Dictionary<byte, Color>
|
||||
{
|
||||
{00, Color.FromArgb( 70, 120, 64)}, // Grass
|
||||
{01, Color.FromArgb(128, 215, 195)}, // River
|
||||
{03, Color.FromArgb(192, 192, 192)}, // Stone
|
||||
{04, Color.FromArgb(240, 230, 170)}, // Sand
|
||||
{05, Color.FromArgb(128, 215, 195)}, // Sea
|
||||
{06, Color.FromArgb(255, 128, 128)}, // Wood
|
||||
{07, Color.FromArgb(0 , 0, 0)}, // Null
|
||||
{08, Color.FromArgb(32 , 32, 32)}, // Building
|
||||
{09, Color.FromArgb(255, 0, 0)}, // ??
|
||||
{10, Color.FromArgb(48 , 48, 48)}, // Door
|
||||
{12, Color.FromArgb(128, 215, 195)}, // Water at mouths of river
|
||||
{15, Color.FromArgb(128, 215, 195)}, // Strip of water between river mouth and river
|
||||
{22, Color.FromArgb(190, 98, 98)}, // Wood (thin)
|
||||
{28, Color.FromArgb(255, 0, 0)}, // ?? this one isn't even in ColGroundAttributeParam...
|
||||
{29, Color.FromArgb(232, 222, 162)}, // Edge of beach, next to sea
|
||||
{41, Color.FromArgb(118, 122, 132)}, // Rocks at top of map
|
||||
{42, Color.FromArgb(128, 133, 147)}, // Taller regions, rocks at top of map
|
||||
{44, Color.FromArgb( 62, 112, 56)}, // Edge connecting grass and beach
|
||||
{45, Color.FromArgb(118, 122, 132)}, // Some kind of rock
|
||||
{46, Color.FromArgb(120, 207, 187)}, // Edge of sea, next to beach
|
||||
{47, Color.FromArgb(128, 128, 0)}, // Sandstone
|
||||
{49, Color.FromArgb(190, 98, 98)}, // Pier
|
||||
{51, Color.FromArgb(32 , 152, 32)}, // "Grass-growing building"??
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ public static void CreateMap(TerrainManager mgr, int[] pixels)
|
|||
{
|
||||
for (int x = 0; x < mgr.MapWidth; x++, i++)
|
||||
{
|
||||
var tile = mgr.GetTile(x, y);
|
||||
var color = TerrainTileColor.GetTileColor(tile);
|
||||
pixels[i] = color.ToArgb();
|
||||
pixels[i] = mgr.GetTileColor(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user