Code now compiles, but will need to test and bugfix extensively.
Need to pre-fill the pixel buffers with sea first unless the acre fill actually works (maybe?)
Items need to be relative'd to apply 1 row lower, and skip the bottom row.
Need to check that terrain is the same as well.

Note to self:
For Map - probably better to get a starting x,y,width and iterate off that, fetching tile from relative, converting to absolute... idk.
For View - need to check if tile is in layer.
This commit is contained in:
Kurt
2026-01-19 23:12:59 -06:00
parent 50ce05af6f
commit 0ce31ca895
21 changed files with 1738 additions and 1617 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@ public sealed partial class FieldItemEditor : Form, IItemLayerEditor
{
private readonly MainSave SAV;
private readonly MapEditor Editor;
private readonly MapRenderer Renderer;
private MapViewState View => Editor.Mutator.View;
private MapTileManager Map => Editor.Mutator.Manager;
@@ -52,7 +53,7 @@ public FieldItemEditor(MainSave sav)
IsExtendedMap30 = sav.FieldItemAcreWidth != 7;
Editor = MapEditor.FromSaveFile(sav);
Editor.MapScale = scale;
Editor.AcreScale = scale;
Editor.ViewScale = scale;
Renderer = new MapRenderer(Editor);
Loading = true;
@@ -129,24 +130,22 @@ private void LoadItemGridAcre()
private void ReloadMapBackground()
{
var img = View.GetBackgroundTerrain(SelectedBuildingIndex);
var img = Renderer.GetBackgroundTerrain(SelectedBuildingIndex);
SetMapBackgroundImage(img);
}
private void ReloadMapItemGrid() => SetMapForegroundImage(View.GetMapWithReticle(GetItemTransparency()));
private void ReloadMapItemGrid() => SetMapForegroundImage(Renderer.GetMapWithReticle(GetItemTransparency()));
private void SetMapBackgroundImage(Bitmap img)
{
if (IsExtendedMap30)
img = View.GetInflatedImage(img);
img = Renderer.GetInflatedImage(img);
PB_Map.BackgroundImage = img;
PB_Map.Invalidate(); // background image reassigning to same img doesn't redraw; force it
}
private void SetMapForegroundImage(Bitmap img)
{
if (IsExtendedMap30)
img = View.GetInflatedImage(img);
PB_Map.Image = img;
}
@@ -154,12 +153,12 @@ private void ReloadAcreBackground()
{
var tbuild = (byte)TR_BuildingTransparency.Value;
var tterrain = (byte)TR_Terrain.Value;
var img = View.GetBackgroundAcre(L_Coordinates.Font, tbuild, tterrain, SelectedBuildingIndex);
var img = Renderer.GetBackgroundAcre(L_Coordinates.Font, tbuild, tterrain, SelectedBuildingIndex);
PB_Acre.BackgroundImage = img;
PB_Acre.Invalidate(); // background image reassigning to same img doesn't redraw; force it
}
private void ReloadAcreItemGrid() => PB_Acre.Image = View.GetLayerAcre(GetItemTransparency());
private void ReloadAcreItemGrid() => PB_Acre.Image = Renderer.GetLayerAcre(GetItemTransparency());
public void ReloadItems()
{
@@ -303,8 +302,8 @@ private void SetHoveredItem(MouseEventArgs e)
private void GetAcreCoordinates(MouseEventArgs e, out int x, out int y)
{
x = e.X / Editor.AcreScale;
y = e.Y / Editor.AcreScale;
x = e.X / Editor.ViewScale;
y = e.Y / Editor.ViewScale;
}
private void PB_Acre_MouseDown(object sender, MouseEventArgs e) => ResetDrag();
@@ -772,58 +771,30 @@ private void PB_Map_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
ClickMapAt(e, true);
ClickMapAt(e);
}
private void ClickMapAt(MouseEventArgs e, bool skipLagCheck)
private void ClickMapAt(MouseEventArgs e)
{
var layer = Editor.Items.Layer0;
int mX = e.X;
int mY = e.Y;
bool centerReticle = CHK_SnapToAcre.Checked;
View.GetViewAnchorCoordinates(mX, mY, out var x, out var y, centerReticle);
var (x, y) = Editor.GetMapCoordinates(e.X, e.Y, CHK_SnapToAcre.Checked ? MapViewCoordinateRequest.SnapAcre : MapViewCoordinateRequest.Centered);
// Truncate to root-node coordinates. The map is only 1px per tile, and nobody is wanting to click on extension-tiles.
x &= 0xFFFE;
y &= 0xFFFE;
var acre = layer.GetAcre(x, y);
bool sameAcre = AcreIndex == acre;
if (!skipLagCheck)
{
if (CHK_SnapToAcre.Checked)
{
if (sameAcre)
return;
}
else
{
const int delta = 0; // disabled = 0
var dx = Math.Abs(View.X - x);
var dy = Math.Abs(View.Y - y);
if (dx <= delta && dy <= delta && !sameAcre)
return;
}
}
if (!CHK_SnapToAcre.Checked)
{
if (View.SetViewTo(x, y))
LoadItemGridAcre();
return;
}
if (!sameAcre)
CB_Acre.SelectedIndex = acre;
if (View.SetViewTo(x, y))
LoadItemGridAcre();
}
private void PB_Map_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ClickMapAt(e, false);
ClickMapAt(e);
}
else if (e.Button == MouseButtons.None)
{
View.GetCursorCoordinates(e.X, e.Y, out var x, out var y);
Editor.GetCursorCoordinates(e.X, e.Y, out var x, out var y);
SetCoordinateText(x, y);
}
}

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@@ -167,9 +167,10 @@ private void DrawRoom(LayerItem layer)
var w = layer.TileInfo.TotalWidth;
var h = layer.TileInfo.TotalHeight;
Span<int> scale1 = stackalloc int[w * h];
int[] scaleX = new int[scale * scale * scale1.Length];
var scaleX = new int[scale * scale * scale1.Length];
var bmp = new Bitmap(scale * w, scale * h);
PB_Room.Image = ItemLayerSprite.GetBitmapItemLayerViewGrid(layer, 0, 0, scale, scale1, scaleX, bmp, gridlineColor: 0x7F000000);
ItemLayerSprite.LoadItemLayerViewGrid(bmp, layer, 0, 0, scale1, scaleX, scale, gridlineColor: 0x7F000000);
PB_Room.Image = bmp;
}
private void NUD_Room_ValueChanged(object sender, EventArgs e)