diff --git a/SilicaTilesEditor/MainForm.Designer.cs b/SilicaTilesEditor/MainForm.Designer.cs
index e73d6ef..04d7674 100644
--- a/SilicaTilesEditor/MainForm.Designer.cs
+++ b/SilicaTilesEditor/MainForm.Designer.cs
@@ -82,22 +82,23 @@ namespace SilicaTilesEditor
// newItem
//
this.newItem.Name = "newItem";
- this.newItem.Size = new System.Drawing.Size(121, 22);
+ this.newItem.Size = new System.Drawing.Size(180, 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(121, 22);
+ this.loadItem.Size = new System.Drawing.Size(180, 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(121, 22);
+ this.saveItem.Size = new System.Drawing.Size(180, 22);
this.saveItem.Text = "Save File";
+ this.saveItem.Click += new System.EventHandler(this.saveItem_Click);
//
// layerMenu
//
diff --git a/SilicaTilesEditor/MainForm.cs b/SilicaTilesEditor/MainForm.cs
index 7bf0f96..bbe8c20 100644
--- a/SilicaTilesEditor/MainForm.cs
+++ b/SilicaTilesEditor/MainForm.cs
@@ -1,11 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Forms;
namespace SilicaTilesEditor
@@ -19,7 +12,18 @@ namespace SilicaTilesEditor
private void newItem_Click(object sender, EventArgs e)
{
-
+ this.Enabled = false;
+ NewMapForm mapForm = new NewMapForm();
+ DialogResult res = mapForm.ShowDialog();
+ this.Enabled = true;
+ if (res == DialogResult.OK)
+ {
+ MessageBox.Show("Map Created", "Map Creation", MessageBoxButtons.OK, MessageBoxIcon.Information);
+
+ tileList.UpdateScroll();
+ tileSelector.CalculateScroll();
+ tileSelector.Invalidate();
+ }
}
private void loadItem_Click(object sender, EventArgs e)
@@ -32,7 +36,8 @@ namespace SilicaTilesEditor
Map.OpenMap(loadFileDg.FileName);
tileList.UpdateScroll();
tileList.Invalidate();
-
+ tileSelector.CalculateScroll();
+ tileSelector.Invalidate();
}
}
private void MainForm_Load(object sender, EventArgs e)
@@ -43,6 +48,7 @@ namespace SilicaTilesEditor
layout.ColumnStyles[0].Width = (32*7) + SystemInformation.VerticalScrollBarWidth;
tileset0.Checked = true;
tileList.ExtOverlay = 0;
+ tileList.UpdateScroll();
tileSelector.CalculateScroll();
tileSelector.Invalidate();
}
@@ -154,5 +160,17 @@ namespace SilicaTilesEditor
}
+ private void saveItem_Click(object sender, EventArgs e)
+ {
+ SaveFileDialog saveFileDg = new SaveFileDialog();
+ saveFileDg.Filter = "Map Data Files|*.MAP";
+ saveFileDg.Title = "Select Map File";
+ saveFileDg.FileName = Map.LoadedMap;
+ if (saveFileDg.ShowDialog() == DialogResult.OK)
+ {
+ Map.SaveMap(saveFileDg.FileName);
+ MessageBox.Show("File saved successfully.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
}
}
diff --git a/SilicaTilesEditor/Map.cs b/SilicaTilesEditor/Map.cs
index c8a8cd6..e279443 100644
--- a/SilicaTilesEditor/Map.cs
+++ b/SilicaTilesEditor/Map.cs
@@ -52,6 +52,43 @@ namespace SilicaTilesEditor
return 1;
}
+ public static void SaveMap(string MapFile)
+ {
+ byte[] worldMap = new byte[8 + (Width * Height) * 2];
+
+ byte[] WidthInt = BitConverter.GetBytes(Width);
+ byte[] HeightInt = BitConverter.GetBytes(Height);
+ Array.ConstrainedCopy(WidthInt, 0, worldMap, 0, 4);
+ Array.ConstrainedCopy(HeightInt, 0, worldMap, 4, 4);
+
+ int ii = 8;
+
+ for (int i = 0; i < MapData.Length; i++)
+ {
+ worldMap[ii] = oMapData[i];
+ worldMap[ii + 1] = MapData[i];
+ ii += 2;
+ }
+
+ LoadedMap = MapFile;
+ MapLoaded = true;
+ File.WriteAllBytes(MapFile, worldMap);
+ }
+ public static void CreateMap(int width, int height)
+ {
+ Width = width;
+ Height = height;
+ MapData = new byte[width * height];
+ oMapData = new byte[width * height];
+ for (int i = 0; i < MapData.Length; i++)
+ {
+ oMapData[i] = 1;
+ MapData[i] = 1;
+ }
+
+ LoadedMap = "NEW.MAP";
+ MapLoaded = true;
+ }
public static void OpenMap(string MapFile)
{
byte[] worldMap = File.ReadAllBytes(MapFile);
@@ -70,8 +107,6 @@ namespace SilicaTilesEditor
ii += 2;
}
- worldMap = null;
-
LoadedMap = MapFile;
MapLoaded = true;
}
diff --git a/SilicaTilesEditor/NewMapForm.Designer.cs b/SilicaTilesEditor/NewMapForm.Designer.cs
new file mode 100644
index 0000000..f0d6dad
--- /dev/null
+++ b/SilicaTilesEditor/NewMapForm.Designer.cs
@@ -0,0 +1,136 @@
+
+namespace SilicaTilesEditor
+{
+ partial class NewMapForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.heightUpDown = new System.Windows.Forms.NumericUpDown();
+ this.widthUpDown = new System.Windows.Forms.NumericUpDown();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.createMap = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.heightUpDown)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.widthUpDown)).BeginInit();
+ this.SuspendLayout();
+ //
+ // heightUpDown
+ //
+ this.heightUpDown.Location = new System.Drawing.Point(57, 68);
+ this.heightUpDown.Maximum = new decimal(new int[] {
+ 2147483647,
+ 0,
+ 0,
+ 0});
+ this.heightUpDown.Name = "heightUpDown";
+ this.heightUpDown.Size = new System.Drawing.Size(140, 20);
+ this.heightUpDown.TabIndex = 0;
+ //
+ // widthUpDown
+ //
+ this.widthUpDown.Location = new System.Drawing.Point(57, 44);
+ this.widthUpDown.Maximum = new decimal(new int[] {
+ 2147483647,
+ 0,
+ 0,
+ 0});
+ this.widthUpDown.Name = "widthUpDown";
+ this.widthUpDown.Size = new System.Drawing.Size(140, 20);
+ this.widthUpDown.TabIndex = 1;
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(13, 46);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(38, 13);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Width:";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(10, 70);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(41, 13);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "Height:";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(10, 19);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(85, 13);
+ this.label3.TabIndex = 4;
+ this.label3.Text = "Create new Map";
+ //
+ // createMap
+ //
+ this.createMap.Location = new System.Drawing.Point(16, 101);
+ this.createMap.Name = "createMap";
+ this.createMap.Size = new System.Drawing.Size(181, 23);
+ this.createMap.TabIndex = 5;
+ this.createMap.Text = "Create Map";
+ this.createMap.UseVisualStyleBackColor = true;
+ this.createMap.Click += new System.EventHandler(this.createMap_Click);
+ //
+ // NewMapForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(212, 136);
+ this.Controls.Add(this.createMap);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.widthUpDown);
+ this.Controls.Add(this.heightUpDown);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "NewMapForm";
+ this.ShowInTaskbar = false;
+ this.Text = "New Map";
+ ((System.ComponentModel.ISupportInitialize)(this.heightUpDown)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.widthUpDown)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.NumericUpDown heightUpDown;
+ private System.Windows.Forms.NumericUpDown widthUpDown;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Button createMap;
+ }
+}
\ No newline at end of file
diff --git a/SilicaTilesEditor/NewMapForm.cs b/SilicaTilesEditor/NewMapForm.cs
new file mode 100644
index 0000000..cd72a82
--- /dev/null
+++ b/SilicaTilesEditor/NewMapForm.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Windows.Forms;
+
+namespace SilicaTilesEditor
+{
+ public partial class NewMapForm : Form
+ {
+ public NewMapForm()
+ {
+ InitializeComponent();
+ this.DialogResult = DialogResult.Cancel;
+ }
+
+ private void createMap_Click(object sender, EventArgs e)
+ {
+ Map.CreateMap(Convert.ToInt32(widthUpDown.Value), Convert.ToInt32(heightUpDown.Value));
+ this.DialogResult = DialogResult.OK;
+ this.Close();
+ }
+
+
+ }
+}
diff --git a/SilicaTilesEditor/NewMapForm.resx b/SilicaTilesEditor/NewMapForm.resx
new file mode 100644
index 0000000..29dcb1b
--- /dev/null
+++ b/SilicaTilesEditor/NewMapForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SilicaTilesEditor/SilicaTilesEditor.csproj b/SilicaTilesEditor/SilicaTilesEditor.csproj
index 26f101b..7b0662d 100644
--- a/SilicaTilesEditor/SilicaTilesEditor.csproj
+++ b/SilicaTilesEditor/SilicaTilesEditor.csproj
@@ -5,7 +5,7 @@
Debug
AnyCPU
{286BE9D8-B723-43A5-A9BA-6769D4FD36DB}
- Exe
+ WinExe
SilicaTilesEditor
SilicaTilesEditor
v4.7.2
@@ -57,6 +57,12 @@
MainForm.cs
+
+ Form
+
+
+ NewMapForm.cs
+
@@ -69,6 +75,9 @@
MainForm.cs
+
+ NewMapForm.cs
+
ResXFileCodeGenerator
Resources.Designer.cs
diff --git a/SilicaTilesEditor/TileMapEditorControl.cs b/SilicaTilesEditor/TileMapEditorControl.cs
index 1809e13..4acd599 100644
--- a/SilicaTilesEditor/TileMapEditorControl.cs
+++ b/SilicaTilesEditor/TileMapEditorControl.cs
@@ -32,6 +32,12 @@ namespace SilicaTilesEditor
selectedTileX = Convert.ToInt32(Math.Floor((float)HorizontalScroll.Value / 32.0)) + SelTileX;
selectedTileY = Convert.ToInt32(Math.Floor((float)VerticalScroll.Value / 32.0)) + SelTileY;
+
+ if (selectedTileX > Map.Width)
+ selectedTileX = Map.Width;
+ if (selectedTileY > Map.Height)
+ selectedTileX = Map.Height;
+
if (!(oldSelTileX == SelTileX && oldSelTileY == SelTileY))
{
diff --git a/SilicaTilesEditor/TileSelectorControl.cs b/SilicaTilesEditor/TileSelectorControl.cs
index e2d99bd..24ab0d2 100644
--- a/SilicaTilesEditor/TileSelectorControl.cs
+++ b/SilicaTilesEditor/TileSelectorControl.cs
@@ -35,13 +35,35 @@ namespace SilicaTilesEditor
SelectedTileid = ((SelTileY * maxX) + SelTileX) + 1;
+ bool change = false;
if(SelectedTileid > 0xFF)
{
SelectedTileid = 0xFF;
- SelTileX = (SelectedTileid % maxX) -1;
- SelTileY = SelectedTileid / maxX;
+ change = true;
}
+ if(!Program.form.tileList.DisplayOverlay)
+ {
+ if(SelectedTileid > Tileset.TerrainList.Length)
+ {
+ SelectedTileid = Tileset.TerrainList.Length;
+ change = true;
+ }
+ }
+ else
+ {
+ if (SelectedTileid > Tileset.JoinedTileset.Length)
+ {
+ SelectedTileid = Tileset.JoinedTileset.Length;
+ change = true;
+ }
+ }
+
+ if (change)
+ {
+ SelTileX = (SelectedTileid % maxX) - 1;
+ SelTileY = SelectedTileid / maxX;
+ }
if (!(oldSelTileX == SelTileX && oldSelTileY == SelTileY))
{
Program.form.selTileId.Text = "Seleted Tile ID: " + SelectedTileid;