From 21735a349e5a776626890a11cf4cfe4092e95917 Mon Sep 17 00:00:00 2001
From: Li
Date: Mon, 28 Nov 2022 11:30:44 +1300
Subject: [PATCH] Fix some bugz
---
.gitignore | 3 ++
SilicaTilesEditor/MainForm.Designer.cs | 28 ++++++-------
SilicaTilesEditor/TileMapEditorControl.cs | 9 +++--
SilicaTilesEditor/TileSelectorControl.cs | 2 +-
SilicaTilesEditor/Tileset.cs | 48 +++++++++++++----------
5 files changed, 51 insertions(+), 39 deletions(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4e52eb2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.vs/*
+SilicaTilesEditor/obj/*
+SilicaTilesEditor/bin/*
\ No newline at end of file
diff --git a/SilicaTilesEditor/MainForm.Designer.cs b/SilicaTilesEditor/MainForm.Designer.cs
index dff39e7..d2dce73 100644
--- a/SilicaTilesEditor/MainForm.Designer.cs
+++ b/SilicaTilesEditor/MainForm.Designer.cs
@@ -48,9 +48,9 @@ namespace SilicaTilesEditor
this.tileset7 = new System.Windows.Forms.ToolStripMenuItem();
this.lookingAt = new System.Windows.Forms.Label();
this.layout = new System.Windows.Forms.TableLayoutPanel();
+ this.selTileId = new System.Windows.Forms.Label();
this.tileSelector = new SilicaTilesEditor.TileSelectorControl();
this.tileList = new SilicaTilesEditor.TileMapEditorControl();
- this.selTileId = new System.Windows.Forms.Label();
this.toolMenu.SuspendLayout();
this.layout.SuspendLayout();
this.SuspendLayout();
@@ -82,21 +82,21 @@ namespace SilicaTilesEditor
// newItem
//
this.newItem.Name = "newItem";
- this.newItem.Size = new System.Drawing.Size(180, 22);
+ this.newItem.Size = new System.Drawing.Size(121, 22);
this.newItem.Text = "New File";
this.newItem.Click += new System.EventHandler(this.newItem_Click);
//
// loadItem
//
this.loadItem.Name = "loadItem";
- this.loadItem.Size = new System.Drawing.Size(180, 22);
+ this.loadItem.Size = new System.Drawing.Size(121, 22);
this.loadItem.Text = "Load File";
this.loadItem.Click += new System.EventHandler(this.loadItem_Click);
//
// saveItem
//
this.saveItem.Name = "saveItem";
- this.saveItem.Size = new System.Drawing.Size(180, 22);
+ this.saveItem.Size = new System.Drawing.Size(121, 22);
this.saveItem.Text = "Save File";
this.saveItem.Click += new System.EventHandler(this.saveItem_Click);
//
@@ -234,6 +234,16 @@ namespace SilicaTilesEditor
this.layout.Size = new System.Drawing.Size(1107, 487);
this.layout.TabIndex = 4;
//
+ // selTileId
+ //
+ this.selTileId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.selTileId.AutoSize = true;
+ this.selTileId.Location = new System.Drawing.Point(12, 515);
+ this.selTileId.Name = "selTileId";
+ this.selTileId.Size = new System.Drawing.Size(89, 13);
+ this.selTileId.TabIndex = 5;
+ this.selTileId.Text = "Seleted Tile ID: 0";
+ //
// tileSelector
//
this.tileSelector.AutoScroll = true;
@@ -253,16 +263,6 @@ namespace SilicaTilesEditor
this.tileList.Size = new System.Drawing.Size(852, 481);
this.tileList.TabIndex = 1;
//
- // selTileId
- //
- this.selTileId.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.selTileId.AutoSize = true;
- this.selTileId.Location = new System.Drawing.Point(12, 515);
- this.selTileId.Name = "selTileId";
- this.selTileId.Size = new System.Drawing.Size(89, 13);
- this.selTileId.TabIndex = 5;
- this.selTileId.Text = "Seleted Tile ID: 1";
- //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
diff --git a/SilicaTilesEditor/TileMapEditorControl.cs b/SilicaTilesEditor/TileMapEditorControl.cs
index 4acd599..d0e4fa8 100644
--- a/SilicaTilesEditor/TileMapEditorControl.cs
+++ b/SilicaTilesEditor/TileMapEditorControl.cs
@@ -46,7 +46,7 @@ namespace SilicaTilesEditor
this.Invalidate();
if(Map.MapLoaded)
- Program.form.lookingAt.Text = "Looking at: " + selectedTileX + "," + selectedTileY + "(" + Map.GetTileId(selectedTileX, selectedTileY, false) + ":" + Map.GetTileId(selectedTileX, selectedTileY, true) + ")";
+ Program.form.lookingAt.Text = "Looking at: " + selectedTileX + "," + selectedTileY + "(" + (Map.GetTileId(selectedTileX, selectedTileY, false) - 1) + ":" + (Map.GetTileId(selectedTileX, selectedTileY, true) - 1) + ")";
}
}
@@ -89,7 +89,7 @@ namespace SilicaTilesEditor
int relY = 0;
if (Map.MapLoaded)
{
-
+ /* Draw Terrain Tiles */
for (int y = offsetY; y < (tlistHeight + offsetY)+1; y++)
{
relX = -1;
@@ -105,7 +105,7 @@ namespace SilicaTilesEditor
}
relY++;
}
-
+ /* Draw Overlay Tiles */
if (DisplayOverlay)
{
@@ -118,10 +118,11 @@ namespace SilicaTilesEditor
for (int x = offsetX; x < (tlistWidth + offsetX) + 1; x++)
{
relX++;
- int tileId = Map.GetTileId(x, y, true) - 1;
+ int tileId = Map.GetTileId(x, y, true) -1;
Bitmap Tile = null;
if (tileId >= Tileset.OverlayList.Length)
{
+ /* Draw Extenal Overlay Tiles */
tileId -= Tileset.OverlayList.Length;
Tile = Tileset.GetTileset(ExtOverlay)[tileId];
}
diff --git a/SilicaTilesEditor/TileSelectorControl.cs b/SilicaTilesEditor/TileSelectorControl.cs
index 24ab0d2..4d21db9 100644
--- a/SilicaTilesEditor/TileSelectorControl.cs
+++ b/SilicaTilesEditor/TileSelectorControl.cs
@@ -33,7 +33,7 @@ namespace SilicaTilesEditor
else
SelTileY = Convert.ToInt32(Math.Floor((float)VerticalScroll.Value / 48.0)) + Convert.ToInt32(Math.Floor((float)(e.Y + tinyOffsetY) / 48.0));
- SelectedTileid = ((SelTileY * maxX) + SelTileX) + 1;
+ SelectedTileid = ((SelTileY * maxX) + SelTileX);
bool change = false;
if(SelectedTileid > 0xFF)
diff --git a/SilicaTilesEditor/Tileset.cs b/SilicaTilesEditor/Tileset.cs
index 5f382a7..1848a24 100644
--- a/SilicaTilesEditor/Tileset.cs
+++ b/SilicaTilesEditor/Tileset.cs
@@ -7,17 +7,17 @@ namespace SilicaTilesEditor
class Tileset
{
public static Bitmap[] TerrainList = new Bitmap[((Resources.TerrainTileset.Height / 32) * (Resources.TerrainTileset.Width / 32)) + 1];
- public static Bitmap[] OverlayList = new Bitmap[193];
+ public static Bitmap[] OverlayList = new Bitmap[192 + 1];
public static Bitmap[] ExtOverlays = new Bitmap[8] { Resources.Tileset0, Resources.Tileset1, Resources.Tileset2, Resources.Tileset3, Resources.Tileset4, Resources.Tileset5, Resources.Tileset6, Resources.Tileset7 };
- public static Bitmap[] ExtNorm = new Bitmap[((Resources.Tileset0.Height / 48) * (Resources.Tileset0.Width / 32)) + 1];
- public static Bitmap[] ExtSnow = new Bitmap[((Resources.Tileset1.Height / 48) * (Resources.Tileset1.Width / 32)) + 1];
- public static Bitmap[] ExtSand = new Bitmap[((Resources.Tileset2.Height / 48) * (Resources.Tileset2.Width / 32)) + 1];
- public static Bitmap[] ExtPirt = new Bitmap[((Resources.Tileset3.Height / 48) * (Resources.Tileset3.Width / 32)) + 1];
- public static Bitmap[] ExtFlwr = new Bitmap[((Resources.Tileset4.Height / 48) * (Resources.Tileset4.Width / 32)) + 1];
- public static Bitmap[] ExtJngl = new Bitmap[((Resources.Tileset5.Height / 48) * (Resources.Tileset5.Width / 32)) + 1];
- public static Bitmap[] ExtClwd = new Bitmap[((Resources.Tileset6.Height / 48) * (Resources.Tileset6.Width / 32)) + 1];
- public static Bitmap[] ExtVolc = new Bitmap[((Resources.Tileset7.Height / 48) * (Resources.Tileset7.Width / 32)) + 1];
+ public static Bitmap[] ExtNorm = new Bitmap[((Resources.Tileset0.Height / 48) * (Resources.Tileset0.Width / 32))];
+ public static Bitmap[] ExtSnow = new Bitmap[((Resources.Tileset1.Height / 48) * (Resources.Tileset1.Width / 32))];
+ public static Bitmap[] ExtSand = new Bitmap[((Resources.Tileset2.Height / 48) * (Resources.Tileset2.Width / 32))];
+ public static Bitmap[] ExtPirt = new Bitmap[((Resources.Tileset3.Height / 48) * (Resources.Tileset3.Width / 32))];
+ public static Bitmap[] ExtFlwr = new Bitmap[((Resources.Tileset4.Height / 48) * (Resources.Tileset4.Width / 32))];
+ public static Bitmap[] ExtJngl = new Bitmap[((Resources.Tileset5.Height / 48) * (Resources.Tileset5.Width / 32))];
+ public static Bitmap[] ExtClwd = new Bitmap[((Resources.Tileset6.Height / 48) * (Resources.Tileset6.Width / 32))];
+ public static Bitmap[] ExtVolc = new Bitmap[((Resources.Tileset7.Height / 48) * (Resources.Tileset7.Width / 32))];
public static Bitmap[] JoinedTileset
{
@@ -83,6 +83,8 @@ namespace SilicaTilesEditor
{
Console.WriteLine("Reading Terrain.png...");
int i = 0;
+ Rectangle dstRect = new Rectangle(0, 0, 32, 32);
+ Rectangle srcRect = new Rectangle(0, 0, 32, 32);
for (int y = 0; y < (Resources.TerrainTileset.Height/32); y++)
{
@@ -90,9 +92,9 @@ namespace SilicaTilesEditor
{
i++;
TerrainList[i] = new Bitmap(32, 32);
- int posx = x * 32;
- int posy = y * 32;
- CopyRegionIntoImage(Resources.TerrainTileset, new Rectangle(posx, posy, 32, 32), TerrainList[i], new Rectangle(0, 0, 32, 32));
+ srcRect.X = x * 32;
+ srcRect.Y = y * 32;
+ CopyRegionIntoImage(Resources.TerrainTileset, srcRect, TerrainList[i], dstRect);
}
}
ReadAllTerrain = true;
@@ -100,7 +102,9 @@ namespace SilicaTilesEditor
public static void ReadExtOverlay()
{
- for(int picid = 0; picid <= 7; picid++)
+ Rectangle dstRect = new Rectangle(0, 0, 32, 48);
+ Rectangle srcRect = new Rectangle(0, 0, 32, 48);
+ for (int picid = 0; picid <= 7; picid++)
{
Bitmap[] TilesetList = GetTileset(picid);
Bitmap Tileset = ExtOverlays[picid];
@@ -112,11 +116,11 @@ namespace SilicaTilesEditor
{
for (int x = 0; x < (Tileset.Width / 32); x++)
{
- i++;
TilesetList[i] = new Bitmap(32, 48);
- int posx = x * 32;
- int posy = y * 48;
- CopyRegionIntoImage(Tileset, new Rectangle(posx, posy, 32, 48), TilesetList[i], new Rectangle(0, 0, 32, 48));
+ srcRect.X = x * 32;
+ srcRect.Y = y * 48;
+ CopyRegionIntoImage(Tileset, srcRect, TilesetList[i], dstRect);
+ i++;
}
}
Console.WriteLine("Total Tiles Read: " + i.ToString());
@@ -128,15 +132,19 @@ namespace SilicaTilesEditor
int i = 0;
int OVERLAY_SIZE = 24;
+ Rectangle dstRect = new Rectangle(0, 0, 32, 48);
+ Rectangle srcRect = new Rectangle(0, 0, 32, 48);
+
for (int y = 0; y < OVERLAY_SIZE; y++)
{
for (int x = 0; x < (Resources.OverlayTileset.Width / 32); x++)
{
i++;
OverlayList[i] = new Bitmap(32, 48);
- int posx = x * 32;
- int posy = y * 48;
- CopyRegionIntoImage(Resources.OverlayTileset, new Rectangle(posx, posy, 32, 48), OverlayList[i], new Rectangle(0, 0, 32, 48));
+ srcRect.X = x * 32;
+ srcRect.Y = y * 48;
+
+ CopyRegionIntoImage(Resources.OverlayTileset, srcRect, OverlayList[i], dstRect);
}
}
}