From 87ad277965c3ec2300eee603af99e117e33e3bdb Mon Sep 17 00:00:00 2001 From: davpsh Date: Mon, 11 Jul 2016 22:32:53 +0600 Subject: [PATCH 01/25] Fixing System.BadImageFormatException --- src/KleiLib/KleiLib.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KleiLib/KleiLib.csproj b/src/KleiLib/KleiLib.csproj index 6496681..73ef857 100644 --- a/src/KleiLib/KleiLib.csproj +++ b/src/KleiLib/KleiLib.csproj @@ -21,7 +21,7 @@ DEBUG;TRACE prompt 4 - x86 + AnyCPU pdbonly From 00d3678e7ef9bddba15a28c48a7cab3b91fac601 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 00:32:37 +0600 Subject: [PATCH 02/25] ToolStripContainer control added. All strips moved inside ToolStripContainer --- src/TEXTool/MainForm.Designer.cs | 102 ++++++++++++++++++++----------- src/TEXTool/MainForm.resx | 8 +-- 2 files changed, 69 insertions(+), 41 deletions(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index e1c97ea..43c0daa 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -56,6 +56,8 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.imageBox = new Cyotek.Windows.Forms.ImageBox(); this.mainToolStrip = new System.Windows.Forms.ToolStrip(); this.openToolStripButton = new System.Windows.Forms.ToolStripButton(); this.saveToolStripButton = new System.Windows.Forms.ToolStripButton(); @@ -72,14 +74,48 @@ private void InitializeComponent() this.sizeToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.mipmapsToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.platformToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.imageBox = new Cyotek.Windows.Forms.ImageBox(); this.textureTypeToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripContainer1.BottomToolStripPanel.SuspendLayout(); + this.toolStripContainer1.ContentPanel.SuspendLayout(); + this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); + this.toolStripContainer1.SuspendLayout(); this.mainToolStrip.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // + // toolStripContainer1 + // + // + // toolStripContainer1.BottomToolStripPanel + // + this.toolStripContainer1.BottomToolStripPanel.Controls.Add(this.statusStrip1); + // + // toolStripContainer1.ContentPanel + // + this.toolStripContainer1.ContentPanel.Controls.Add(this.imageBox); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(694, 370); + this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); + this.toolStripContainer1.Name = "toolStripContainer1"; + this.toolStripContainer1.Size = new System.Drawing.Size(694, 417); + this.toolStripContainer1.TabIndex = 2; + this.toolStripContainer1.Text = "toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.mainToolStrip); + // + // imageBox + // + this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.imageBox.Location = new System.Drawing.Point(0, 0); + this.imageBox.Name = "imageBox"; + this.imageBox.Size = new System.Drawing.Size(694, 370); + this.imageBox.TabIndex = 3; + // // mainToolStrip // + this.mainToolStrip.Dock = System.Windows.Forms.DockStyle.None; this.mainToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.openToolStripButton, this.saveToolStripButton, @@ -94,7 +130,8 @@ private void InitializeComponent() this.mainToolStrip.Location = new System.Drawing.Point(0, 0); this.mainToolStrip.Name = "mainToolStrip"; this.mainToolStrip.Size = new System.Drawing.Size(694, 25); - this.mainToolStrip.TabIndex = 0; + this.mainToolStrip.Stretch = true; + this.mainToolStrip.TabIndex = 1; // // openToolStripButton // @@ -104,7 +141,6 @@ private void InitializeComponent() this.openToolStripButton.Name = "openToolStripButton"; this.openToolStripButton.Size = new System.Drawing.Size(23, 22); this.openToolStripButton.Text = "&Open"; - this.openToolStripButton.Click += new System.EventHandler(this.openToolStripButton_Click); // // saveToolStripButton // @@ -114,7 +150,6 @@ private void InitializeComponent() this.saveToolStripButton.Name = "saveToolStripButton"; this.saveToolStripButton.Size = new System.Drawing.Size(23, 22); this.saveToolStripButton.Text = "&Save"; - this.saveToolStripButton.Click += new System.EventHandler(this.saveToolStripButton_Click); // // toolStripSeparator // @@ -129,7 +164,6 @@ private void InitializeComponent() this.fitToolStripButton.Name = "fitToolStripButton"; this.fitToolStripButton.Size = new System.Drawing.Size(23, 22); this.fitToolStripButton.Text = "Zoom To Fit"; - this.fitToolStripButton.Click += new System.EventHandler(this.fitToolStripButton_Click); // // zoomInToolStripButton // @@ -139,7 +173,6 @@ private void InitializeComponent() this.zoomInToolStripButton.Name = "zoomInToolStripButton"; this.zoomInToolStripButton.Size = new System.Drawing.Size(23, 22); this.zoomInToolStripButton.Text = "Zoom In"; - this.zoomInToolStripButton.Click += new System.EventHandler(this.zoomInToolStripButton_Click); // // zoomOutToolStripButton // @@ -149,7 +182,6 @@ private void InitializeComponent() this.zoomOutToolStripButton.Name = "zoomOutToolStripButton"; this.zoomOutToolStripButton.Size = new System.Drawing.Size(23, 22); this.zoomOutToolStripButton.Text = "Zoom Out"; - this.zoomOutToolStripButton.Click += new System.EventHandler(this.zoomOutToolStripButton_Click); // // toolStripSeparator1 // @@ -170,67 +202,57 @@ private void InitializeComponent() this.infoToolStripButton.Name = "infoToolStripButton"; this.infoToolStripButton.Size = new System.Drawing.Size(23, 22); this.infoToolStripButton.Text = "Info"; - this.infoToolStripButton.Click += new System.EventHandler(this.infoToolStripButton_Click); // // versionToolStripLabel // this.versionToolStripLabel.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; this.versionToolStripLabel.Name = "versionToolStripLabel"; - this.versionToolStripLabel.Size = new System.Drawing.Size(46, 22); + this.versionToolStripLabel.Size = new System.Drawing.Size(42, 22); this.versionToolStripLabel.Text = "Version"; // // statusStrip1 // + this.statusStrip1.Dock = System.Windows.Forms.DockStyle.None; this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.formatToolStripStatusLabel, this.sizeToolStripStatusLabel, this.mipmapsToolStripStatusLabel, this.platformToolStripStatusLabel, this.textureTypeToolStripStatusLabel}); - this.statusStrip1.Location = new System.Drawing.Point(0, 395); + this.statusStrip1.Location = new System.Drawing.Point(0, 0); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(694, 22); - this.statusStrip1.TabIndex = 1; + this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // // formatToolStripStatusLabel // this.formatToolStripStatusLabel.Name = "formatToolStripStatusLabel"; - this.formatToolStripStatusLabel.Size = new System.Drawing.Size(45, 17); + this.formatToolStripStatusLabel.Size = new System.Drawing.Size(41, 17); this.formatToolStripStatusLabel.Text = "Format"; // // sizeToolStripStatusLabel // this.sizeToolStripStatusLabel.Name = "sizeToolStripStatusLabel"; - this.sizeToolStripStatusLabel.Size = new System.Drawing.Size(27, 17); + this.sizeToolStripStatusLabel.Size = new System.Drawing.Size(26, 17); this.sizeToolStripStatusLabel.Text = "Size"; // // mipmapsToolStripStatusLabel // this.mipmapsToolStripStatusLabel.Name = "mipmapsToolStripStatusLabel"; - this.mipmapsToolStripStatusLabel.Size = new System.Drawing.Size(57, 17); + this.mipmapsToolStripStatusLabel.Size = new System.Drawing.Size(48, 17); this.mipmapsToolStripStatusLabel.Text = "Mipmaps"; // // platformToolStripStatusLabel // this.platformToolStripStatusLabel.Name = "platformToolStripStatusLabel"; - this.platformToolStripStatusLabel.Size = new System.Drawing.Size(53, 17); + this.platformToolStripStatusLabel.Size = new System.Drawing.Size(47, 17); this.platformToolStripStatusLabel.Text = "Platform"; // - // imageBox - // - this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.imageBox.Location = new System.Drawing.Point(0, 25); - this.imageBox.Name = "imageBox"; - this.imageBox.Size = new System.Drawing.Size(694, 370); - this.imageBox.TabIndex = 2; - this.imageBox.ZoomChanged += new System.EventHandler(this.imageBox1_ZoomChanged); - this.imageBox.ZoomLevelsChanged += new System.EventHandler(this.imageBox1_ZoomLevelsChanged); - // // textureTypeToolStripStatusLabel // this.textureTypeToolStripStatusLabel.Name = "textureTypeToolStripStatusLabel"; - this.textureTypeToolStripStatusLabel.Size = new System.Drawing.Size(51, 17); + this.textureTypeToolStripStatusLabel.Size = new System.Drawing.Size(49, 17); this.textureTypeToolStripStatusLabel.Text = "TexType"; // // MainForm @@ -238,23 +260,35 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(694, 417); - this.Controls.Add(this.imageBox); - this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.mainToolStrip); + this.Controls.Add(this.toolStripContainer1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "MainForm"; this.Text = "KleiStudio - TEXTool"; + this.toolStripContainer1.BottomToolStripPanel.ResumeLayout(false); + this.toolStripContainer1.BottomToolStripPanel.PerformLayout(); + this.toolStripContainer1.ContentPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); + this.toolStripContainer1.TopToolStripPanel.PerformLayout(); + this.toolStripContainer1.ResumeLayout(false); + this.toolStripContainer1.PerformLayout(); this.mainToolStrip.ResumeLayout(false); this.mainToolStrip.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion + private System.Windows.Forms.ToolStripContainer toolStripContainer1; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel formatToolStripStatusLabel; + private System.Windows.Forms.ToolStripStatusLabel sizeToolStripStatusLabel; + private System.Windows.Forms.ToolStripStatusLabel mipmapsToolStripStatusLabel; + private System.Windows.Forms.ToolStripStatusLabel platformToolStripStatusLabel; + private System.Windows.Forms.ToolStripStatusLabel textureTypeToolStripStatusLabel; + private Cyotek.Windows.Forms.ImageBox imageBox; private System.Windows.Forms.ToolStrip mainToolStrip; private System.Windows.Forms.ToolStripButton openToolStripButton; private System.Windows.Forms.ToolStripButton saveToolStripButton; @@ -264,15 +298,9 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripButton zoomOutToolStripButton; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripComboBox zoomLevelToolStripComboBox; - private System.Windows.Forms.StatusStrip statusStrip1; - private Cyotek.Windows.Forms.ImageBox imageBox; private System.Windows.Forms.ToolStripButton infoToolStripButton; private System.Windows.Forms.ToolStripLabel versionToolStripLabel; - private System.Windows.Forms.ToolStripStatusLabel formatToolStripStatusLabel; - private System.Windows.Forms.ToolStripStatusLabel sizeToolStripStatusLabel; - private System.Windows.Forms.ToolStripStatusLabel mipmapsToolStripStatusLabel; - private System.Windows.Forms.ToolStripStatusLabel platformToolStripStatusLabel; - private System.Windows.Forms.ToolStripStatusLabel textureTypeToolStripStatusLabel; + } } \ No newline at end of file diff --git a/src/TEXTool/MainForm.resx b/src/TEXTool/MainForm.resx index d9af9fa..edd975f 100644 --- a/src/TEXTool/MainForm.resx +++ b/src/TEXTool/MainForm.resx @@ -117,11 +117,11 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - - 145, 17 + 375, 17 + + + 255, 17 From 5b04c632d942dadd5fb2e4258fa5049ada326931 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 00:57:51 +0600 Subject: [PATCH 03/25] mainToolStrip's buttons events fixed --- src/TEXTool/MainForm.Designer.cs | 116 +++++++++++++++++-------------- src/TEXTool/MainForm.cs | 4 +- 2 files changed, 64 insertions(+), 56 deletions(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index 43c0daa..8aaf072 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -57,6 +57,12 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.formatToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.sizeToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.mipmapsToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.platformToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.textureTypeToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.imageBox = new Cyotek.Windows.Forms.ImageBox(); this.mainToolStrip = new System.Windows.Forms.ToolStrip(); this.openToolStripButton = new System.Windows.Forms.ToolStripButton(); @@ -69,18 +75,12 @@ private void InitializeComponent() this.zoomLevelToolStripComboBox = new System.Windows.Forms.ToolStripComboBox(); this.infoToolStripButton = new System.Windows.Forms.ToolStripButton(); this.versionToolStripLabel = new System.Windows.Forms.ToolStripLabel(); - this.statusStrip1 = new System.Windows.Forms.StatusStrip(); - this.formatToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.sizeToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.mipmapsToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.platformToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.textureTypeToolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripContainer1.BottomToolStripPanel.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); - this.mainToolStrip.SuspendLayout(); this.statusStrip1.SuspendLayout(); + this.mainToolStrip.SuspendLayout(); this.SuspendLayout(); // // toolStripContainer1 @@ -105,6 +105,51 @@ private void InitializeComponent() // this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.mainToolStrip); // + // statusStrip1 + // + this.statusStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.formatToolStripStatusLabel, + this.sizeToolStripStatusLabel, + this.mipmapsToolStripStatusLabel, + this.platformToolStripStatusLabel, + this.textureTypeToolStripStatusLabel}); + this.statusStrip1.Location = new System.Drawing.Point(0, 0); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(694, 22); + this.statusStrip1.TabIndex = 2; + this.statusStrip1.Text = "statusStrip1"; + // + // formatToolStripStatusLabel + // + this.formatToolStripStatusLabel.Name = "formatToolStripStatusLabel"; + this.formatToolStripStatusLabel.Size = new System.Drawing.Size(41, 17); + this.formatToolStripStatusLabel.Text = "Format"; + // + // sizeToolStripStatusLabel + // + this.sizeToolStripStatusLabel.Name = "sizeToolStripStatusLabel"; + this.sizeToolStripStatusLabel.Size = new System.Drawing.Size(26, 17); + this.sizeToolStripStatusLabel.Text = "Size"; + // + // mipmapsToolStripStatusLabel + // + this.mipmapsToolStripStatusLabel.Name = "mipmapsToolStripStatusLabel"; + this.mipmapsToolStripStatusLabel.Size = new System.Drawing.Size(48, 17); + this.mipmapsToolStripStatusLabel.Text = "Mipmaps"; + // + // platformToolStripStatusLabel + // + this.platformToolStripStatusLabel.Name = "platformToolStripStatusLabel"; + this.platformToolStripStatusLabel.Size = new System.Drawing.Size(47, 17); + this.platformToolStripStatusLabel.Text = "Platform"; + // + // textureTypeToolStripStatusLabel + // + this.textureTypeToolStripStatusLabel.Name = "textureTypeToolStripStatusLabel"; + this.textureTypeToolStripStatusLabel.Size = new System.Drawing.Size(49, 17); + this.textureTypeToolStripStatusLabel.Text = "TexType"; + // // imageBox // this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill; @@ -112,6 +157,8 @@ private void InitializeComponent() this.imageBox.Name = "imageBox"; this.imageBox.Size = new System.Drawing.Size(694, 370); this.imageBox.TabIndex = 3; + this.imageBox.ZoomChanged += new System.EventHandler(this.imageBox_ZoomChanged); + this.imageBox.ZoomLevelsChanged += new System.EventHandler(this.imageBox_ZoomLevelsChanged); // // mainToolStrip // @@ -141,6 +188,7 @@ private void InitializeComponent() this.openToolStripButton.Name = "openToolStripButton"; this.openToolStripButton.Size = new System.Drawing.Size(23, 22); this.openToolStripButton.Text = "&Open"; + this.openToolStripButton.Click += new System.EventHandler(this.openToolStripButton_Click); // // saveToolStripButton // @@ -150,6 +198,7 @@ private void InitializeComponent() this.saveToolStripButton.Name = "saveToolStripButton"; this.saveToolStripButton.Size = new System.Drawing.Size(23, 22); this.saveToolStripButton.Text = "&Save"; + this.saveToolStripButton.Click += new System.EventHandler(this.saveToolStripButton_Click); // // toolStripSeparator // @@ -164,6 +213,7 @@ private void InitializeComponent() this.fitToolStripButton.Name = "fitToolStripButton"; this.fitToolStripButton.Size = new System.Drawing.Size(23, 22); this.fitToolStripButton.Text = "Zoom To Fit"; + this.fitToolStripButton.Click += new System.EventHandler(this.fitToolStripButton_Click); // // zoomInToolStripButton // @@ -173,6 +223,7 @@ private void InitializeComponent() this.zoomInToolStripButton.Name = "zoomInToolStripButton"; this.zoomInToolStripButton.Size = new System.Drawing.Size(23, 22); this.zoomInToolStripButton.Text = "Zoom In"; + this.zoomInToolStripButton.Click += new System.EventHandler(this.zoomInToolStripButton_Click); // // zoomOutToolStripButton // @@ -182,6 +233,7 @@ private void InitializeComponent() this.zoomOutToolStripButton.Name = "zoomOutToolStripButton"; this.zoomOutToolStripButton.Size = new System.Drawing.Size(23, 22); this.zoomOutToolStripButton.Text = "Zoom Out"; + this.zoomOutToolStripButton.Click += new System.EventHandler(this.zoomOutToolStripButton_Click); // // toolStripSeparator1 // @@ -202,6 +254,7 @@ private void InitializeComponent() this.infoToolStripButton.Name = "infoToolStripButton"; this.infoToolStripButton.Size = new System.Drawing.Size(23, 22); this.infoToolStripButton.Text = "Info"; + this.infoToolStripButton.Click += new System.EventHandler(this.infoToolStripButton_Click); // // versionToolStripLabel // @@ -210,51 +263,6 @@ private void InitializeComponent() this.versionToolStripLabel.Size = new System.Drawing.Size(42, 22); this.versionToolStripLabel.Text = "Version"; // - // statusStrip1 - // - this.statusStrip1.Dock = System.Windows.Forms.DockStyle.None; - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.formatToolStripStatusLabel, - this.sizeToolStripStatusLabel, - this.mipmapsToolStripStatusLabel, - this.platformToolStripStatusLabel, - this.textureTypeToolStripStatusLabel}); - this.statusStrip1.Location = new System.Drawing.Point(0, 0); - this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(694, 22); - this.statusStrip1.TabIndex = 2; - this.statusStrip1.Text = "statusStrip1"; - // - // formatToolStripStatusLabel - // - this.formatToolStripStatusLabel.Name = "formatToolStripStatusLabel"; - this.formatToolStripStatusLabel.Size = new System.Drawing.Size(41, 17); - this.formatToolStripStatusLabel.Text = "Format"; - // - // sizeToolStripStatusLabel - // - this.sizeToolStripStatusLabel.Name = "sizeToolStripStatusLabel"; - this.sizeToolStripStatusLabel.Size = new System.Drawing.Size(26, 17); - this.sizeToolStripStatusLabel.Text = "Size"; - // - // mipmapsToolStripStatusLabel - // - this.mipmapsToolStripStatusLabel.Name = "mipmapsToolStripStatusLabel"; - this.mipmapsToolStripStatusLabel.Size = new System.Drawing.Size(48, 17); - this.mipmapsToolStripStatusLabel.Text = "Mipmaps"; - // - // platformToolStripStatusLabel - // - this.platformToolStripStatusLabel.Name = "platformToolStripStatusLabel"; - this.platformToolStripStatusLabel.Size = new System.Drawing.Size(47, 17); - this.platformToolStripStatusLabel.Text = "Platform"; - // - // textureTypeToolStripStatusLabel - // - this.textureTypeToolStripStatusLabel.Name = "textureTypeToolStripStatusLabel"; - this.textureTypeToolStripStatusLabel.Size = new System.Drawing.Size(49, 17); - this.textureTypeToolStripStatusLabel.Text = "TexType"; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -271,10 +279,10 @@ private void InitializeComponent() this.toolStripContainer1.TopToolStripPanel.PerformLayout(); this.toolStripContainer1.ResumeLayout(false); this.toolStripContainer1.PerformLayout(); - this.mainToolStrip.ResumeLayout(false); - this.mainToolStrip.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + this.mainToolStrip.ResumeLayout(false); + this.mainToolStrip.PerformLayout(); this.ResumeLayout(false); } diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 8247692..35f3c24 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -144,12 +144,12 @@ private void infoToolStripButton_Click(object sender, EventArgs e) #region Misc Form Event Handlers - private void imageBox1_ZoomLevelsChanged(object sender, EventArgs e) + private void imageBox_ZoomLevelsChanged(object sender, EventArgs e) { FillZoomLevelComboBox(); } - private void imageBox1_ZoomChanged(object sender, EventArgs e) + private void imageBox_ZoomChanged(object sender, EventArgs e) { zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom); } From 62d7fbc4bd3a9b80525594ce60a670bbef41fb46 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 02:13:01 +0600 Subject: [PATCH 04/25] Added KleiTextureAtlasElement class --- src/TEXTool/TEXTool.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index c160553..8063997 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -35,6 +35,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE namespace TEXTool { + + class KleiTextureAtlasElement + { + public string name { get; set; } + public int ImgHmin { get; set; } + public int ImgHmax { get; set; } + public int ImgVmin { get; set; } + public int ImgVmax { get; set; } + + public KleiTextureAtlasElement(string name, int u1, int u2, int v1, int v2) + { + this.name = name; + this.ImgHmin = u1; + this.ImgHmax = u2; + this.ImgVmin = v1; + this.ImgVmax = v2; + } + } + public class FileOpenedEventArgs : EventArgs { public string FileName { get; set; } From 2113fa0193d99ba7c09a995258aa8677b58913dc Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 02:40:50 +0600 Subject: [PATCH 05/25] Checking AtlasData XML file, reading if exist. --- src/TEXTool/TEXTool.cs | 49 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index 8063997..1b9e5d2 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -33,9 +33,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using KleiLib; using SquishNET; +using System.Collections.Generic; +using System.Xml; + namespace TEXTool { - class KleiTextureAtlasElement { public string name { get; set; } @@ -84,6 +86,8 @@ public FileRawImageEventArgs(Bitmap image) public class TEXTool { + public List AtlasElements = new List(); + public TEXFile CurrentFile; public Bitmap CurrentFileRaw; @@ -170,6 +174,16 @@ public void OpenFile(string filename, Stream stream) throw new Exception("Unknown pixel format?"); } + string atlasExt = "xml"; + FileInfo fileInfo = new FileInfo(filename); + string fileDir = fileInfo.DirectoryName; + string fileNameWithoutExt = fileInfo.Name.Replace(fileInfo.Extension, ""); + string atlasDataPath = fileDir + fileNameWithoutExt + "." + atlasExt; + if (File.Exists(atlasDataPath)) + { + ReadAtlasData(atlasDataPath, mipmap.Width, mipmap.Height); + } + var imgReader = new BinaryReader(new MemoryStream(argbData)); Bitmap pt = new Bitmap((int)mipmap.Width, (int)mipmap.Height); @@ -191,6 +205,39 @@ public void OpenFile(string filename, Stream stream) OnRawImage(new FileRawImageEventArgs(pt)); } + private void ReadAtlasData(string path, int mipmapWidth, int mipmapHeight) + { + try + { + XmlDocument xDoc = new XmlDocument(); + xDoc.Load(path); + + XmlNode xNodeElements = xDoc.SelectSingleNode("Atlas/Elements"); + foreach (XmlNode xChild in xNodeElements.ChildNodes) + { + string name = xChild.Attributes.GetNamedItem("name").Value; + double u1 = Convert.ToDouble(xChild.Attributes.GetNamedItem("u1").Value.Replace(".", ",")); + double u2 = Convert.ToDouble(xChild.Attributes.GetNamedItem("u2").Value.Replace(".", ",")); + double v1 = Convert.ToDouble(xChild.Attributes.GetNamedItem("v1").Value.Replace(".", ",")); + double v2 = Convert.ToDouble(xChild.Attributes.GetNamedItem("v2").Value.Replace(".", ",")); + + int imgHmin, imgHmax, imgVmin, imgVmax; + double margin = 0.5; + imgHmin = Convert.ToInt16(u1 * mipmapWidth - margin); + imgHmax = Convert.ToInt16(u2 * mipmapWidth - margin); + imgVmin = Convert.ToInt16(v1 * mipmapHeight - margin); + imgVmax = Convert.ToInt16(v2 * mipmapHeight - margin); + + AtlasElements.Add(new KleiTextureAtlasElement(name, imgHmin, imgHmax, imgVmin, imgVmax)); + } + } + catch (Exception e) + { + AtlasElements.Clear(); + Console.WriteLine(e.Message); + } + } + public void SaveFile(string FilePath) { CurrentFileRaw.Save(FilePath); From b3b0f01ee68bd3938bfccf461e04ec3033677365 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 02:45:49 +0600 Subject: [PATCH 06/25] n to N --- src/TEXTool/TEXTool.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index 1b9e5d2..ae1b508 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -40,7 +40,7 @@ namespace TEXTool { class KleiTextureAtlasElement { - public string name { get; set; } + public string Name { get; set; } public int ImgHmin { get; set; } public int ImgHmax { get; set; } public int ImgVmin { get; set; } @@ -48,7 +48,7 @@ class KleiTextureAtlasElement public KleiTextureAtlasElement(string name, int u1, int u2, int v1, int v2) { - this.name = name; + this.Name = name; this.ImgHmin = u1; this.ImgHmax = u2; this.ImgVmin = v1; @@ -238,6 +238,8 @@ private void ReadAtlasData(string path, int mipmapWidth, int mipmapHeight) } } + + public void SaveFile(string FilePath) { CurrentFileRaw.Save(FilePath); From ffeeda450d5e86d69b6942cb6172123f8c3aeb8e Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 03:06:18 +0600 Subject: [PATCH 07/25] Check changes --- src/TEXTool/TEXTool.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index ae1b508..f84d3bc 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -38,7 +38,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE namespace TEXTool { - class KleiTextureAtlasElement + public class KleiTextureAtlasElement { public string Name { get; set; } public int ImgHmin { get; set; } @@ -74,10 +74,12 @@ public FileOpenedEventArgs(string filename) { public class FileRawImageEventArgs : EventArgs { public Bitmap Image { get; set; } + public List AtlasElements { get; set; } - public FileRawImageEventArgs(Bitmap image) + public FileRawImageEventArgs(Bitmap image, List elements) { this.Image = image; + this.AtlasElements = elements; } } @@ -86,8 +88,6 @@ public FileRawImageEventArgs(Bitmap image) public class TEXTool { - public List AtlasElements = new List(); - public TEXFile CurrentFile; public Bitmap CurrentFileRaw; @@ -179,9 +179,14 @@ public void OpenFile(string filename, Stream stream) string fileDir = fileInfo.DirectoryName; string fileNameWithoutExt = fileInfo.Name.Replace(fileInfo.Extension, ""); string atlasDataPath = fileDir + fileNameWithoutExt + "." + atlasExt; + List atlasElements = null; if (File.Exists(atlasDataPath)) { - ReadAtlasData(atlasDataPath, mipmap.Width, mipmap.Height); + atlasElements = ReadAtlasData(atlasDataPath, mipmap.Width, mipmap.Height); + } + else + { + atlasElements = new List(); } var imgReader = new BinaryReader(new MemoryStream(argbData)); @@ -202,11 +207,12 @@ public void OpenFile(string filename, Stream stream) CurrentFileRaw = pt; - OnRawImage(new FileRawImageEventArgs(pt)); + OnRawImage(new FileRawImageEventArgs(pt, atlasElements)); } - private void ReadAtlasData(string path, int mipmapWidth, int mipmapHeight) + private List ReadAtlasData(string path, int mipmapWidth, int mipmapHeight) { + var AtlasElements = new List(); try { XmlDocument xDoc = new XmlDocument(); @@ -236,6 +242,7 @@ private void ReadAtlasData(string path, int mipmapWidth, int mipmapHeight) AtlasElements.Clear(); Console.WriteLine(e.Message); } + return AtlasElements; } From 3f0a459ccaadbc14548b7b768ceee8b2221584af Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 03:06:57 +0600 Subject: [PATCH 08/25] Show atlaselements in combobox --- src/TEXTool/MainForm.Designer.cs | 10 +++++++++- src/TEXTool/MainForm.cs | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index 8aaf072..c3e1be4 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -75,6 +75,7 @@ private void InitializeComponent() this.zoomLevelToolStripComboBox = new System.Windows.Forms.ToolStripComboBox(); this.infoToolStripButton = new System.Windows.Forms.ToolStripButton(); this.versionToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox(); this.toolStripContainer1.BottomToolStripPanel.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -173,7 +174,8 @@ private void InitializeComponent() this.toolStripSeparator1, this.zoomLevelToolStripComboBox, this.infoToolStripButton, - this.versionToolStripLabel}); + this.versionToolStripLabel, + this.toolStripComboBox1}); this.mainToolStrip.Location = new System.Drawing.Point(0, 0); this.mainToolStrip.Name = "mainToolStrip"; this.mainToolStrip.Size = new System.Drawing.Size(694, 25); @@ -263,6 +265,11 @@ private void InitializeComponent() this.versionToolStripLabel.Size = new System.Drawing.Size(42, 22); this.versionToolStripLabel.Text = "Version"; // + // toolStripComboBox1 + // + this.toolStripComboBox1.Name = "toolStripComboBox1"; + this.toolStripComboBox1.Size = new System.Drawing.Size(121, 25); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -308,6 +315,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripComboBox zoomLevelToolStripComboBox; private System.Windows.Forms.ToolStripButton infoToolStripButton; private System.Windows.Forms.ToolStripLabel versionToolStripLabel; + private System.Windows.Forms.ToolStripComboBox toolStripComboBox1; } diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 35f3c24..2e84010 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -50,6 +50,13 @@ public MainForm() void tool_FileRawImage(object sender, FileRawImageEventArgs e) { + if (e.AtlasElements.Count > 0) + { + foreach (KleiTextureAtlasElement el in e.AtlasElements) + { + toolStripComboBox1.Items.Add(el.Name); + } + } imageBox.Image = e.Image; zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom); } From baa132ce0397cbc52450995594131da4e18de826 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 03:11:19 +0600 Subject: [PATCH 09/25] Fixed wrong directory path --- src/TEXTool/TEXTool.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index f84d3bc..6fb4e2f 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -178,8 +178,9 @@ public void OpenFile(string filename, Stream stream) FileInfo fileInfo = new FileInfo(filename); string fileDir = fileInfo.DirectoryName; string fileNameWithoutExt = fileInfo.Name.Replace(fileInfo.Extension, ""); - string atlasDataPath = fileDir + fileNameWithoutExt + "." + atlasExt; + string atlasDataPath = fileDir + @"\" + fileNameWithoutExt + "." + atlasExt; List atlasElements = null; + Console.WriteLine(atlasDataPath); if (File.Exists(atlasDataPath)) { atlasElements = ReadAtlasData(atlasDataPath, mipmap.Width, mipmap.Height); From 744b0969e301c8d5edc49ed1f9b313a7306e4b1f Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 12 Jul 2016 03:38:20 +0600 Subject: [PATCH 10/25] Draw GraphicPath if AtlasElements exist --- src/TEXTool/MainForm.Designer.cs | 1 + src/TEXTool/MainForm.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index c3e1be4..77e3ea9 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -160,6 +160,7 @@ private void InitializeComponent() this.imageBox.TabIndex = 3; this.imageBox.ZoomChanged += new System.EventHandler(this.imageBox_ZoomChanged); this.imageBox.ZoomLevelsChanged += new System.EventHandler(this.imageBox_ZoomLevelsChanged); + this.imageBox.Paint += new System.Windows.Forms.PaintEventHandler(this.imageBox_Paint); // // mainToolStrip // diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 2e84010..d822f53 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -29,11 +29,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using System.Reflection; using System.Windows.Forms; +using System.Drawing; +using System.Drawing.Drawing2D; + namespace TEXTool { public partial class MainForm : Form { public TEXTool Tool; + GraphicsPath gp; public MainForm() { @@ -52,15 +56,29 @@ void tool_FileRawImage(object sender, FileRawImageEventArgs e) { if (e.AtlasElements.Count > 0) { + gp = new GraphicsPath(); foreach (KleiTextureAtlasElement el in e.AtlasElements) { + gp.AddRectangle(new Rectangle(el.ImgHmin, el.ImgVmin, el.ImgHmin + el.ImgHmax, el.ImgVmin + el.ImgVmax)); toolStripComboBox1.Items.Add(el.Name); } } + else + { + gp = null; + } imageBox.Image = e.Image; zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom); } + private void imageBox_Paint(object sender, PaintEventArgs e) + { + if (imageBox.Image != null && gp != null) + { + e.Graphics.DrawPath(Pens.Black, gp); + } + } + private void TEXTool_FileOpened(object sender, FileOpenedEventArgs e) { this.Text = String.Format("Klei Studio - TEXTool - [{0}]", e.FileName); From 0678bc8286e47354db4f24ebff87f768b633416c Mon Sep 17 00:00:00 2001 From: davpsh Date: Wed, 13 Jul 2016 14:29:58 +0600 Subject: [PATCH 11/25] Added atlasElementsToolStrip --- src/TEXTool/MainForm.Designer.cs | 85 ++++++++++++++++++++++++++++---- src/TEXTool/MainForm.resx | 3 ++ 2 files changed, 79 insertions(+), 9 deletions(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index 77e3ea9..8c431cb 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -75,13 +75,21 @@ private void InitializeComponent() this.zoomLevelToolStripComboBox = new System.Windows.Forms.ToolStripComboBox(); this.infoToolStripButton = new System.Windows.Forms.ToolStripButton(); this.versionToolStripLabel = new System.Windows.Forms.ToolStripLabel(); - this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox(); + this.atlasElementsToolStrip = new System.Windows.Forms.ToolStrip(); + this.atlasElementsToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.atlasElementsCountToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementsCountIntToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.atlasElementsTitleToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementsListToolStripComboBox = new System.Windows.Forms.ToolStripComboBox(); this.toolStripContainer1.BottomToolStripPanel.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.mainToolStrip.SuspendLayout(); + this.atlasElementsToolStrip.SuspendLayout(); this.SuspendLayout(); // // toolStripContainer1 @@ -94,7 +102,7 @@ private void InitializeComponent() // toolStripContainer1.ContentPanel // this.toolStripContainer1.ContentPanel.Controls.Add(this.imageBox); - this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(694, 370); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(694, 345); this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); this.toolStripContainer1.Name = "toolStripContainer1"; @@ -104,6 +112,7 @@ private void InitializeComponent() // // toolStripContainer1.TopToolStripPanel // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.atlasElementsToolStrip); this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.mainToolStrip); // // statusStrip1 @@ -156,7 +165,7 @@ private void InitializeComponent() this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill; this.imageBox.Location = new System.Drawing.Point(0, 0); this.imageBox.Name = "imageBox"; - this.imageBox.Size = new System.Drawing.Size(694, 370); + this.imageBox.Size = new System.Drawing.Size(694, 345); this.imageBox.TabIndex = 3; this.imageBox.ZoomChanged += new System.EventHandler(this.imageBox_ZoomChanged); this.imageBox.ZoomLevelsChanged += new System.EventHandler(this.imageBox_ZoomLevelsChanged); @@ -175,8 +184,7 @@ private void InitializeComponent() this.toolStripSeparator1, this.zoomLevelToolStripComboBox, this.infoToolStripButton, - this.versionToolStripLabel, - this.toolStripComboBox1}); + this.versionToolStripLabel}); this.mainToolStrip.Location = new System.Drawing.Point(0, 0); this.mainToolStrip.Name = "mainToolStrip"; this.mainToolStrip.Size = new System.Drawing.Size(694, 25); @@ -266,10 +274,60 @@ private void InitializeComponent() this.versionToolStripLabel.Size = new System.Drawing.Size(42, 22); this.versionToolStripLabel.Text = "Version"; // - // toolStripComboBox1 + // atlasElementsToolStrip // - this.toolStripComboBox1.Name = "toolStripComboBox1"; - this.toolStripComboBox1.Size = new System.Drawing.Size(121, 25); + this.atlasElementsToolStrip.Dock = System.Windows.Forms.DockStyle.None; + this.atlasElementsToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.atlasElementsToolStripLabel, + this.toolStripSeparator2, + this.atlasElementsCountToolStripLabel, + this.atlasElementsCountIntToolStripLabel, + this.toolStripSeparator3, + this.atlasElementsTitleToolStripLabel, + this.atlasElementsListToolStripComboBox}); + this.atlasElementsToolStrip.Location = new System.Drawing.Point(3, 25); + this.atlasElementsToolStrip.Name = "atlasElementsToolStrip"; + this.atlasElementsToolStrip.Size = new System.Drawing.Size(366, 25); + this.atlasElementsToolStrip.TabIndex = 2; + // + // atlasElementsToolStripLabel + // + this.atlasElementsToolStripLabel.Name = "atlasElementsToolStripLabel"; + this.atlasElementsToolStripLabel.Size = new System.Drawing.Size(81, 22); + this.atlasElementsToolStripLabel.Text = "Atlas Elements:"; + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); + // + // atlasElementsCountToolStripLabel + // + this.atlasElementsCountToolStripLabel.Name = "atlasElementsCountToolStripLabel"; + this.atlasElementsCountToolStripLabel.Size = new System.Drawing.Size(40, 22); + this.atlasElementsCountToolStripLabel.Text = "Count:"; + // + // atlasElementsCountIntToolStripLabel + // + this.atlasElementsCountIntToolStripLabel.Name = "atlasElementsCountIntToolStripLabel"; + this.atlasElementsCountIntToolStripLabel.Size = new System.Drawing.Size(13, 22); + this.atlasElementsCountIntToolStripLabel.Text = "0"; + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25); + // + // atlasElementsTitleToolStripLabel + // + this.atlasElementsTitleToolStripLabel.Name = "atlasElementsTitleToolStripLabel"; + this.atlasElementsTitleToolStripLabel.Size = new System.Drawing.Size(54, 22); + this.atlasElementsTitleToolStripLabel.Text = "Elements:"; + // + // atlasElementsListToolStripComboBox + // + this.atlasElementsListToolStripComboBox.Name = "atlasElementsListToolStripComboBox"; + this.atlasElementsListToolStripComboBox.Size = new System.Drawing.Size(121, 25); // // MainForm // @@ -291,6 +349,8 @@ private void InitializeComponent() this.statusStrip1.PerformLayout(); this.mainToolStrip.ResumeLayout(false); this.mainToolStrip.PerformLayout(); + this.atlasElementsToolStrip.ResumeLayout(false); + this.atlasElementsToolStrip.PerformLayout(); this.ResumeLayout(false); } @@ -316,7 +376,14 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripComboBox zoomLevelToolStripComboBox; private System.Windows.Forms.ToolStripButton infoToolStripButton; private System.Windows.Forms.ToolStripLabel versionToolStripLabel; - private System.Windows.Forms.ToolStripComboBox toolStripComboBox1; + private System.Windows.Forms.ToolStrip atlasElementsToolStrip; + private System.Windows.Forms.ToolStripLabel atlasElementsToolStripLabel; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripLabel atlasElementsCountToolStripLabel; + private System.Windows.Forms.ToolStripLabel atlasElementsCountIntToolStripLabel; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripLabel atlasElementsTitleToolStripLabel; + private System.Windows.Forms.ToolStripComboBox atlasElementsListToolStripComboBox; } diff --git a/src/TEXTool/MainForm.resx b/src/TEXTool/MainForm.resx index edd975f..acaac65 100644 --- a/src/TEXTool/MainForm.resx +++ b/src/TEXTool/MainForm.resx @@ -120,6 +120,9 @@ 375, 17 + + 485, 17 + 255, 17 From ff27878e56ab99df2422d274816342c44e6a7add Mon Sep 17 00:00:00 2001 From: davpsh Date: Wed, 13 Jul 2016 14:36:53 +0600 Subject: [PATCH 12/25] Cleaning atlasElementsListToolStripComboBox on ImageRaw. Added DisplayMember for atlasElementsListToolStripComboBox. Show elments count. --- src/TEXTool/MainForm.cs | 8 +++++++- src/TEXTool/TEXTool.cs | 8 ++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index d822f53..47395aa 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -48,25 +48,31 @@ public MainForm() InitializeComponent(); FillZoomLevelComboBox(); versionToolStripLabel.Text = string.Format("Version: {0}", Assembly.GetEntryAssembly().GetName().Version); + + atlasElementsListToolStripComboBox.ComboBox.DisplayMember = "Name"; } #region void tool_FileRawImage(object sender, FileRawImageEventArgs e) { + atlasElementsCountIntToolStripLabel.Text = e.AtlasElements.Count.ToString(); + atlasElementsListToolStripComboBox.ComboBox.Items.Clear(); + if (e.AtlasElements.Count > 0) { gp = new GraphicsPath(); foreach (KleiTextureAtlasElement el in e.AtlasElements) { gp.AddRectangle(new Rectangle(el.ImgHmin, el.ImgVmin, el.ImgHmin + el.ImgHmax, el.ImgVmin + el.ImgVmax)); - toolStripComboBox1.Items.Add(el.Name); + atlasElementsListToolStripComboBox.Items.Add(el); } } else { gp = null; } + imageBox.Image = e.Image; zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom); } diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index 6fb4e2f..c778f7e 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -179,16 +179,12 @@ public void OpenFile(string filename, Stream stream) string fileDir = fileInfo.DirectoryName; string fileNameWithoutExt = fileInfo.Name.Replace(fileInfo.Extension, ""); string atlasDataPath = fileDir + @"\" + fileNameWithoutExt + "." + atlasExt; - List atlasElements = null; - Console.WriteLine(atlasDataPath); + List atlasElements = new List(); + if (File.Exists(atlasDataPath)) { atlasElements = ReadAtlasData(atlasDataPath, mipmap.Width, mipmap.Height); } - else - { - atlasElements = new List(); - } var imgReader = new BinaryReader(new MemoryStream(argbData)); From 0ea9ae0f9ebcf46ad075cb372acb503df81d3b79 Mon Sep 17 00:00:00 2001 From: davpsh Date: Mon, 18 Jul 2016 23:57:34 +0600 Subject: [PATCH 13/25] gp to graphicsPath --- src/TEXTool/MainForm.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 47395aa..6643f41 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -37,7 +37,7 @@ namespace TEXTool public partial class MainForm : Form { public TEXTool Tool; - GraphicsPath gp; + GraphicsPath graphicsPath; public MainForm() { @@ -59,19 +59,16 @@ void tool_FileRawImage(object sender, FileRawImageEventArgs e) atlasElementsCountIntToolStripLabel.Text = e.AtlasElements.Count.ToString(); atlasElementsListToolStripComboBox.ComboBox.Items.Clear(); + graphicsPath = null; + if (e.AtlasElements.Count > 0) { - gp = new GraphicsPath(); + graphicsPath = new GraphicsPath(); foreach (KleiTextureAtlasElement el in e.AtlasElements) { - gp.AddRectangle(new Rectangle(el.ImgHmin, el.ImgVmin, el.ImgHmin + el.ImgHmax, el.ImgVmin + el.ImgVmax)); atlasElementsListToolStripComboBox.Items.Add(el); } } - else - { - gp = null; - } imageBox.Image = e.Image; zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom); @@ -79,9 +76,9 @@ void tool_FileRawImage(object sender, FileRawImageEventArgs e) private void imageBox_Paint(object sender, PaintEventArgs e) { - if (imageBox.Image != null && gp != null) + if (graphicsPath != null) { - e.Graphics.DrawPath(Pens.Black, gp); + e.Graphics.DrawPath(Pens.Black, graphicsPath); } } From 7e738f103c4381ef4c7eaca0b8b846464d5ab96e Mon Sep 17 00:00:00 2001 From: davpsh Date: Mon, 18 Jul 2016 23:59:41 +0600 Subject: [PATCH 14/25] Added Dev regions --- src/TEXTool/MainForm.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 6643f41..5710de6 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -209,5 +209,13 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) } #endregion + + #region Dev Custom Functions + + #endregion + + #region Dev Event Handlers + + #endregion } } From fd608831878944b59a0d8c025f77727452461af5 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 00:07:01 +0600 Subject: [PATCH 15/25] Drawing region with DrawRectangle() function on atlasElementsListToolStripComboBox_SelectedIndexChanged(). --- src/TEXTool/MainForm.cs | 55 +++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 5710de6..1a0f042 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -38,6 +38,7 @@ public partial class MainForm : Form { public TEXTool Tool; GraphicsPath graphicsPath; + float offsetX = 0, offsetY = 0, scaleX = 1, scaleY = 1; public MainForm() { @@ -74,14 +75,6 @@ void tool_FileRawImage(object sender, FileRawImageEventArgs e) zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom); } - private void imageBox_Paint(object sender, PaintEventArgs e) - { - if (graphicsPath != null) - { - e.Graphics.DrawPath(Pens.Black, graphicsPath); - } - } - private void TEXTool_FileOpened(object sender, FileOpenedEventArgs e) { this.Text = String.Format("Klei Studio - TEXTool - [{0}]", e.FileName); @@ -212,9 +205,55 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) #region Dev Custom Functions + private void DrawRectangle(KleiTextureAtlasElement element) + { + int x, y, width, height; + x = element.ImgHmin; + y = element.ImgVmin; + + width = element.ImgHmin + element.ImgHmax; + height = element.ImgVmin + element.ImgVmax; + + graphicsPath = new GraphicsPath(); + graphicsPath.AddRectangle(new Rectangle(x, y, width, height)); + + imageBox.Invalidate(); + } + #endregion #region Dev Event Handlers + + private void atlasElementsListToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + var element = (KleiTextureAtlasElement)atlasElementsListToolStripComboBox.SelectedItem; + DrawRectangle(element); + } + + private void imageBox_Paint(object sender, PaintEventArgs e) + { + if (graphicsPath != null) + { + scaleX = imageBox.Zoom / 100f; + scaleY = imageBox.Zoom / 100f; + offsetX = ((imageBox.ClientSize.Width - imageBox.PreferredSize.Width) / 2f); + offsetY = ((imageBox.ClientSize.Height - imageBox.PreferredSize.Height) / 2f); + + if (offsetX < 0) + { + offsetX = -imageBox.HorizontalScroll.Value; + } + if (offsetY < 0) + { + offsetY = -imageBox.VerticalScroll.Value; + } + + e.Graphics.TranslateTransform(offsetX, offsetY); + e.Graphics.ScaleTransform(scaleX, scaleY); + + e.Graphics.DrawPath(Pens.Black, graphicsPath); + } + } #endregion } From df321f7a08c1daf5335f1587cdbc6cf970ba0353 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 00:10:20 +0600 Subject: [PATCH 16/25] Added rule for atlasElementsListToolStripComboBox and small changes on Designer.cs --- src/TEXTool/MainForm.Designer.cs | 6 ++++-- src/TEXTool/MainForm.cs | 2 ++ src/TEXTool/MainForm.resx | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index 8c431cb..5266c25 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -112,8 +112,8 @@ private void InitializeComponent() // // toolStripContainer1.TopToolStripPanel // - this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.atlasElementsToolStrip); this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.mainToolStrip); + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.atlasElementsToolStrip); // // statusStrip1 // @@ -287,7 +287,7 @@ private void InitializeComponent() this.atlasElementsListToolStripComboBox}); this.atlasElementsToolStrip.Location = new System.Drawing.Point(3, 25); this.atlasElementsToolStrip.Name = "atlasElementsToolStrip"; - this.atlasElementsToolStrip.Size = new System.Drawing.Size(366, 25); + this.atlasElementsToolStrip.Size = new System.Drawing.Size(333, 25); this.atlasElementsToolStrip.TabIndex = 2; // // atlasElementsToolStripLabel @@ -326,8 +326,10 @@ private void InitializeComponent() // // atlasElementsListToolStripComboBox // + this.atlasElementsListToolStripComboBox.Enabled = false; this.atlasElementsListToolStripComboBox.Name = "atlasElementsListToolStripComboBox"; this.atlasElementsListToolStripComboBox.Size = new System.Drawing.Size(121, 25); + this.atlasElementsListToolStripComboBox.SelectedIndexChanged += new System.EventHandler(this.atlasElementsListToolStripComboBox_SelectedIndexChanged); // // MainForm // diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 1a0f042..0364285 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -61,10 +61,12 @@ void tool_FileRawImage(object sender, FileRawImageEventArgs e) atlasElementsListToolStripComboBox.ComboBox.Items.Clear(); graphicsPath = null; + atlasElementsListToolStripComboBox.Enabled = false; if (e.AtlasElements.Count > 0) { graphicsPath = new GraphicsPath(); + atlasElementsListToolStripComboBox.Enabled = true; foreach (KleiTextureAtlasElement el in e.AtlasElements) { atlasElementsListToolStripComboBox.Items.Add(el); diff --git a/src/TEXTool/MainForm.resx b/src/TEXTool/MainForm.resx index acaac65..86d6964 100644 --- a/src/TEXTool/MainForm.resx +++ b/src/TEXTool/MainForm.resx @@ -120,12 +120,12 @@ 375, 17 - - 485, 17 - 255, 17 + + 485, 17 + From c730334d6909c0bfbe91955388782a1f6e8e2530 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 00:14:43 +0600 Subject: [PATCH 17/25] atlasElementsToolStrip.Stretch --- src/TEXTool/MainForm.Designer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index 5266c25..d126ef5 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -287,7 +287,8 @@ private void InitializeComponent() this.atlasElementsListToolStripComboBox}); this.atlasElementsToolStrip.Location = new System.Drawing.Point(3, 25); this.atlasElementsToolStrip.Name = "atlasElementsToolStrip"; - this.atlasElementsToolStrip.Size = new System.Drawing.Size(333, 25); + this.atlasElementsToolStrip.Size = new System.Drawing.Size(366, 25); + this.atlasElementsToolStrip.Stretch = true; this.atlasElementsToolStrip.TabIndex = 2; // // atlasElementsToolStripLabel From 955849dcf24e2dd2198fc5e0909f238822f224bc Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 01:07:47 +0600 Subject: [PATCH 18/25] Added atlas element's region border color property --- src/TEXTool/MainForm.Designer.cs | 133 ++++++++++++++++++++++++++++--- src/TEXTool/MainForm.cs | 34 +++++++- 2 files changed, 154 insertions(+), 13 deletions(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index d126ef5..b5064af 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -83,6 +83,19 @@ private void InitializeComponent() this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.atlasElementsTitleToolStripLabel = new System.Windows.Forms.ToolStripLabel(); this.atlasElementsListToolStripComboBox = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.atlasElementWidthToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementWidthToolStrip = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementHeightToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementHeightToolStrip = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementXToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementXToolStrip = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementYToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementYToolStrip = new System.Windows.Forms.ToolStripLabel(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.atlasElementBorderColorToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementBorderColors = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripContainer1.BottomToolStripPanel.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -102,11 +115,11 @@ private void InitializeComponent() // toolStripContainer1.ContentPanel // this.toolStripContainer1.ContentPanel.Controls.Add(this.imageBox); - this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(694, 345); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(748, 345); this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); this.toolStripContainer1.Name = "toolStripContainer1"; - this.toolStripContainer1.Size = new System.Drawing.Size(694, 417); + this.toolStripContainer1.Size = new System.Drawing.Size(748, 417); this.toolStripContainer1.TabIndex = 2; this.toolStripContainer1.Text = "toolStripContainer1"; // @@ -126,7 +139,7 @@ private void InitializeComponent() this.textureTypeToolStripStatusLabel}); this.statusStrip1.Location = new System.Drawing.Point(0, 0); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(694, 22); + this.statusStrip1.Size = new System.Drawing.Size(748, 22); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // @@ -165,7 +178,7 @@ private void InitializeComponent() this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill; this.imageBox.Location = new System.Drawing.Point(0, 0); this.imageBox.Name = "imageBox"; - this.imageBox.Size = new System.Drawing.Size(694, 345); + this.imageBox.Size = new System.Drawing.Size(748, 345); this.imageBox.TabIndex = 3; this.imageBox.ZoomChanged += new System.EventHandler(this.imageBox_ZoomChanged); this.imageBox.ZoomLevelsChanged += new System.EventHandler(this.imageBox_ZoomLevelsChanged); @@ -187,7 +200,7 @@ private void InitializeComponent() this.versionToolStripLabel}); this.mainToolStrip.Location = new System.Drawing.Point(0, 0); this.mainToolStrip.Name = "mainToolStrip"; - this.mainToolStrip.Size = new System.Drawing.Size(694, 25); + this.mainToolStrip.Size = new System.Drawing.Size(748, 25); this.mainToolStrip.Stretch = true; this.mainToolStrip.TabIndex = 1; // @@ -284,10 +297,23 @@ private void InitializeComponent() this.atlasElementsCountIntToolStripLabel, this.toolStripSeparator3, this.atlasElementsTitleToolStripLabel, - this.atlasElementsListToolStripComboBox}); - this.atlasElementsToolStrip.Location = new System.Drawing.Point(3, 25); + this.atlasElementsListToolStripComboBox, + this.toolStripSeparator4, + this.atlasElementBorderColorToolStripLabel, + this.atlasElementBorderColors, + this.toolStripSeparator7, + this.atlasElementWidthToolStripLabel, + this.atlasElementWidthToolStrip, + this.atlasElementHeightToolStripLabel, + this.atlasElementHeightToolStrip, + this.toolStripSeparator5, + this.atlasElementXToolStripLabel, + this.atlasElementXToolStrip, + this.atlasElementYToolStripLabel, + this.atlasElementYToolStrip}); + this.atlasElementsToolStrip.Location = new System.Drawing.Point(0, 25); this.atlasElementsToolStrip.Name = "atlasElementsToolStrip"; - this.atlasElementsToolStrip.Size = new System.Drawing.Size(366, 25); + this.atlasElementsToolStrip.Size = new System.Drawing.Size(748, 25); this.atlasElementsToolStrip.Stretch = true; this.atlasElementsToolStrip.TabIndex = 2; // @@ -332,11 +358,87 @@ private void InitializeComponent() this.atlasElementsListToolStripComboBox.Size = new System.Drawing.Size(121, 25); this.atlasElementsListToolStripComboBox.SelectedIndexChanged += new System.EventHandler(this.atlasElementsListToolStripComboBox_SelectedIndexChanged); // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(6, 25); + // + // atlasElementWidthToolStripLabel + // + this.atlasElementWidthToolStripLabel.Name = "atlasElementWidthToolStripLabel"; + this.atlasElementWidthToolStripLabel.Size = new System.Drawing.Size(39, 22); + this.atlasElementWidthToolStripLabel.Text = "Width:"; + // + // atlasElementWidthToolStrip + // + this.atlasElementWidthToolStrip.Name = "atlasElementWidthToolStrip"; + this.atlasElementWidthToolStrip.Size = new System.Drawing.Size(13, 22); + this.atlasElementWidthToolStrip.Text = "0"; + // + // atlasElementHeightToolStripLabel + // + this.atlasElementHeightToolStripLabel.Name = "atlasElementHeightToolStripLabel"; + this.atlasElementHeightToolStripLabel.Size = new System.Drawing.Size(42, 22); + this.atlasElementHeightToolStripLabel.Text = "Height:"; + // + // atlasElementHeightToolStrip + // + this.atlasElementHeightToolStrip.Name = "atlasElementHeightToolStrip"; + this.atlasElementHeightToolStrip.Size = new System.Drawing.Size(13, 22); + this.atlasElementHeightToolStrip.Text = "0"; + // + // atlasElementXToolStripLabel + // + this.atlasElementXToolStripLabel.Name = "atlasElementXToolStripLabel"; + this.atlasElementXToolStripLabel.Size = new System.Drawing.Size(17, 22); + this.atlasElementXToolStripLabel.Text = "X:"; + // + // atlasElementXToolStrip + // + this.atlasElementXToolStrip.Name = "atlasElementXToolStrip"; + this.atlasElementXToolStrip.Size = new System.Drawing.Size(13, 22); + this.atlasElementXToolStrip.Text = "0"; + // + // atlasElementYToolStripLabel + // + this.atlasElementYToolStripLabel.Name = "atlasElementYToolStripLabel"; + this.atlasElementYToolStripLabel.Size = new System.Drawing.Size(17, 22); + this.atlasElementYToolStripLabel.Text = "Y:"; + // + // atlasElementYToolStrip + // + this.atlasElementYToolStrip.Name = "atlasElementYToolStrip"; + this.atlasElementYToolStrip.Size = new System.Drawing.Size(13, 22); + this.atlasElementYToolStrip.Text = "0"; + // + // toolStripSeparator5 + // + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25); + // + // atlasElementBorderColorToolStripLabel + // + this.atlasElementBorderColorToolStripLabel.Name = "atlasElementBorderColorToolStripLabel"; + this.atlasElementBorderColorToolStripLabel.Size = new System.Drawing.Size(69, 22); + this.atlasElementBorderColorToolStripLabel.Text = "Border color:"; + // + // atlasElementBorderColors + // + this.atlasElementBorderColors.Enabled = false; + this.atlasElementBorderColors.Name = "atlasElementBorderColors"; + this.atlasElementBorderColors.Size = new System.Drawing.Size(121, 25); + this.atlasElementBorderColors.SelectedIndexChanged += new System.EventHandler(this.atlasElementBorderColors_SelectedIndexChanged); + // + // toolStripSeparator7 + // + this.toolStripSeparator7.Name = "toolStripSeparator7"; + this.toolStripSeparator7.Size = new System.Drawing.Size(6, 25); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(694, 417); + this.ClientSize = new System.Drawing.Size(748, 417); this.Controls.Add(this.toolStripContainer1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "MainForm"; @@ -387,6 +489,19 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripLabel atlasElementsTitleToolStripLabel; private System.Windows.Forms.ToolStripComboBox atlasElementsListToolStripComboBox; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private System.Windows.Forms.ToolStripLabel atlasElementWidthToolStripLabel; + private System.Windows.Forms.ToolStripLabel atlasElementWidthToolStrip; + private System.Windows.Forms.ToolStripLabel atlasElementHeightToolStripLabel; + private System.Windows.Forms.ToolStripLabel atlasElementHeightToolStrip; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; + private System.Windows.Forms.ToolStripLabel atlasElementXToolStripLabel; + private System.Windows.Forms.ToolStripLabel atlasElementXToolStrip; + private System.Windows.Forms.ToolStripLabel atlasElementYToolStripLabel; + private System.Windows.Forms.ToolStripLabel atlasElementYToolStrip; + private System.Windows.Forms.ToolStripLabel atlasElementBorderColorToolStripLabel; + private System.Windows.Forms.ToolStripComboBox atlasElementBorderColors; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; } diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 0364285..36d018e 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -50,6 +50,15 @@ public MainForm() FillZoomLevelComboBox(); versionToolStripLabel.Text = string.Format("Version: {0}", Assembly.GetEntryAssembly().GetName().Version); + foreach (PropertyInfo prop in typeof(Color).GetProperties()) + { + if (prop.PropertyType.FullName == "System.Drawing.Color") + { + atlasElementBorderColors.ComboBox.Items.Add(prop.Name); + } + } + atlasElementBorderColors.ComboBox.SelectedItem = "Black"; + atlasElementsListToolStripComboBox.ComboBox.DisplayMember = "Name"; } @@ -61,12 +70,13 @@ void tool_FileRawImage(object sender, FileRawImageEventArgs e) atlasElementsListToolStripComboBox.ComboBox.Items.Clear(); graphicsPath = null; - atlasElementsListToolStripComboBox.Enabled = false; + atlasElementsListToolStripComboBox.Enabled = atlasElementBorderColors.Enabled = false; + atlasElementWidthToolStrip.Text = atlasElementHeightToolStrip.Text = atlasElementXToolStrip.Text = atlasElementYToolStrip.Text = "0"; if (e.AtlasElements.Count > 0) { graphicsPath = new GraphicsPath(); - atlasElementsListToolStripComboBox.Enabled = true; + atlasElementsListToolStripComboBox.Enabled = atlasElementBorderColors.Enabled = true; foreach (KleiTextureAtlasElement el in e.AtlasElements) { atlasElementsListToolStripComboBox.Items.Add(el); @@ -219,6 +229,11 @@ private void DrawRectangle(KleiTextureAtlasElement element) graphicsPath = new GraphicsPath(); graphicsPath.AddRectangle(new Rectangle(x, y, width, height)); + atlasElementWidthToolStrip.Text = width.ToString(); + atlasElementHeightToolStrip.Text = height.ToString(); + atlasElementXToolStrip.Text = x.ToString(); + atlasElementYToolStrip.Text = y.ToString(); + imageBox.Invalidate(); } @@ -228,10 +243,19 @@ private void DrawRectangle(KleiTextureAtlasElement element) private void atlasElementsListToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { - var element = (KleiTextureAtlasElement)atlasElementsListToolStripComboBox.SelectedItem; + var element = (KleiTextureAtlasElement)atlasElementsListToolStripComboBox.ComboBox.SelectedItem; DrawRectangle(element); } + private void atlasElementBorderColors_SelectedIndexChanged(object sender, EventArgs e) + { + var element = (KleiTextureAtlasElement)atlasElementsListToolStripComboBox.ComboBox.SelectedItem; + if (element != null) + { + DrawRectangle(element); + } + } + private void imageBox_Paint(object sender, PaintEventArgs e) { if (graphicsPath != null) @@ -253,7 +277,9 @@ private void imageBox_Paint(object sender, PaintEventArgs e) e.Graphics.TranslateTransform(offsetX, offsetY); e.Graphics.ScaleTransform(scaleX, scaleY); - e.Graphics.DrawPath(Pens.Black, graphicsPath); + Color color = Color.FromName(atlasElementBorderColors.ComboBox.SelectedItem.ToString()); + Pen pen = new Pen(new SolidBrush(color), 5f); + e.Graphics.DrawPath(pen, graphicsPath); } } From a30a1b0a4e54a4678a9f2f96ece4400ab6421c14 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 01:30:38 +0600 Subject: [PATCH 19/25] Image zooming on zoomlevel changed zoomLevelToolStripComboBox_SelectedIndexChanged() --- src/TEXTool/MainForm.Designer.cs | 55 ++++++++++++++++---------------- src/TEXTool/MainForm.cs | 9 ++++++ 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index b5064af..2de572d 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -84,18 +84,18 @@ private void InitializeComponent() this.atlasElementsTitleToolStripLabel = new System.Windows.Forms.ToolStripLabel(); this.atlasElementsListToolStripComboBox = new System.Windows.Forms.ToolStripComboBox(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.atlasElementBorderColorToolStripLabel = new System.Windows.Forms.ToolStripLabel(); + this.atlasElementBorderColors = new System.Windows.Forms.ToolStripComboBox(); + this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.atlasElementWidthToolStripLabel = new System.Windows.Forms.ToolStripLabel(); this.atlasElementWidthToolStrip = new System.Windows.Forms.ToolStripLabel(); this.atlasElementHeightToolStripLabel = new System.Windows.Forms.ToolStripLabel(); this.atlasElementHeightToolStrip = new System.Windows.Forms.ToolStripLabel(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); this.atlasElementXToolStripLabel = new System.Windows.Forms.ToolStripLabel(); this.atlasElementXToolStrip = new System.Windows.Forms.ToolStripLabel(); this.atlasElementYToolStripLabel = new System.Windows.Forms.ToolStripLabel(); this.atlasElementYToolStrip = new System.Windows.Forms.ToolStripLabel(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.atlasElementBorderColorToolStripLabel = new System.Windows.Forms.ToolStripLabel(); - this.atlasElementBorderColors = new System.Windows.Forms.ToolStripComboBox(); - this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripContainer1.BottomToolStripPanel.SuspendLayout(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -268,6 +268,7 @@ private void InitializeComponent() // this.zoomLevelToolStripComboBox.Name = "zoomLevelToolStripComboBox"; this.zoomLevelToolStripComboBox.Size = new System.Drawing.Size(121, 25); + this.zoomLevelToolStripComboBox.SelectedIndexChanged += new System.EventHandler(this.zoomLevelToolStripComboBox_SelectedIndexChanged); // // infoToolStripButton // @@ -363,6 +364,24 @@ private void InitializeComponent() this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Size = new System.Drawing.Size(6, 25); // + // atlasElementBorderColorToolStripLabel + // + this.atlasElementBorderColorToolStripLabel.Name = "atlasElementBorderColorToolStripLabel"; + this.atlasElementBorderColorToolStripLabel.Size = new System.Drawing.Size(69, 22); + this.atlasElementBorderColorToolStripLabel.Text = "Border color:"; + // + // atlasElementBorderColors + // + this.atlasElementBorderColors.Enabled = false; + this.atlasElementBorderColors.Name = "atlasElementBorderColors"; + this.atlasElementBorderColors.Size = new System.Drawing.Size(121, 25); + this.atlasElementBorderColors.SelectedIndexChanged += new System.EventHandler(this.atlasElementBorderColors_SelectedIndexChanged); + // + // toolStripSeparator7 + // + this.toolStripSeparator7.Name = "toolStripSeparator7"; + this.toolStripSeparator7.Size = new System.Drawing.Size(6, 25); + // // atlasElementWidthToolStripLabel // this.atlasElementWidthToolStripLabel.Name = "atlasElementWidthToolStripLabel"; @@ -387,6 +406,11 @@ private void InitializeComponent() this.atlasElementHeightToolStrip.Size = new System.Drawing.Size(13, 22); this.atlasElementHeightToolStrip.Text = "0"; // + // toolStripSeparator5 + // + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25); + // // atlasElementXToolStripLabel // this.atlasElementXToolStripLabel.Name = "atlasElementXToolStripLabel"; @@ -411,29 +435,6 @@ private void InitializeComponent() this.atlasElementYToolStrip.Size = new System.Drawing.Size(13, 22); this.atlasElementYToolStrip.Text = "0"; // - // toolStripSeparator5 - // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25); - // - // atlasElementBorderColorToolStripLabel - // - this.atlasElementBorderColorToolStripLabel.Name = "atlasElementBorderColorToolStripLabel"; - this.atlasElementBorderColorToolStripLabel.Size = new System.Drawing.Size(69, 22); - this.atlasElementBorderColorToolStripLabel.Text = "Border color:"; - // - // atlasElementBorderColors - // - this.atlasElementBorderColors.Enabled = false; - this.atlasElementBorderColors.Name = "atlasElementBorderColors"; - this.atlasElementBorderColors.Size = new System.Drawing.Size(121, 25); - this.atlasElementBorderColors.SelectedIndexChanged += new System.EventHandler(this.atlasElementBorderColors_SelectedIndexChanged); - // - // toolStripSeparator7 - // - this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(6, 25); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 36d018e..ca418f0 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -240,6 +240,15 @@ private void DrawRectangle(KleiTextureAtlasElement element) #endregion #region Dev Event Handlers + + private void zoomLevelToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (imageBox.Image != null) + { + int z = int.Parse(zoomLevelToolStripComboBox.SelectedItem.ToString().Replace("%", "")); + imageBox.Zoom = z; + } + } private void atlasElementsListToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { From ad3326893d31110851b9e9136d9702a91a866d8d Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 01:32:51 +0600 Subject: [PATCH 20/25] Some fixes --- src/TEXTool/MainForm.Designer.cs | 14 +++++++------- src/TEXTool/MainForm.cs | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/TEXTool/MainForm.Designer.cs b/src/TEXTool/MainForm.Designer.cs index 2de572d..73e466a 100644 --- a/src/TEXTool/MainForm.Designer.cs +++ b/src/TEXTool/MainForm.Designer.cs @@ -115,11 +115,11 @@ private void InitializeComponent() // toolStripContainer1.ContentPanel // this.toolStripContainer1.ContentPanel.Controls.Add(this.imageBox); - this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(748, 345); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(781, 345); this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); this.toolStripContainer1.Name = "toolStripContainer1"; - this.toolStripContainer1.Size = new System.Drawing.Size(748, 417); + this.toolStripContainer1.Size = new System.Drawing.Size(781, 417); this.toolStripContainer1.TabIndex = 2; this.toolStripContainer1.Text = "toolStripContainer1"; // @@ -139,7 +139,7 @@ private void InitializeComponent() this.textureTypeToolStripStatusLabel}); this.statusStrip1.Location = new System.Drawing.Point(0, 0); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(748, 22); + this.statusStrip1.Size = new System.Drawing.Size(781, 22); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // @@ -178,7 +178,7 @@ private void InitializeComponent() this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill; this.imageBox.Location = new System.Drawing.Point(0, 0); this.imageBox.Name = "imageBox"; - this.imageBox.Size = new System.Drawing.Size(748, 345); + this.imageBox.Size = new System.Drawing.Size(781, 345); this.imageBox.TabIndex = 3; this.imageBox.ZoomChanged += new System.EventHandler(this.imageBox_ZoomChanged); this.imageBox.ZoomLevelsChanged += new System.EventHandler(this.imageBox_ZoomLevelsChanged); @@ -200,7 +200,7 @@ private void InitializeComponent() this.versionToolStripLabel}); this.mainToolStrip.Location = new System.Drawing.Point(0, 0); this.mainToolStrip.Name = "mainToolStrip"; - this.mainToolStrip.Size = new System.Drawing.Size(748, 25); + this.mainToolStrip.Size = new System.Drawing.Size(781, 25); this.mainToolStrip.Stretch = true; this.mainToolStrip.TabIndex = 1; // @@ -314,7 +314,7 @@ private void InitializeComponent() this.atlasElementYToolStrip}); this.atlasElementsToolStrip.Location = new System.Drawing.Point(0, 25); this.atlasElementsToolStrip.Name = "atlasElementsToolStrip"; - this.atlasElementsToolStrip.Size = new System.Drawing.Size(748, 25); + this.atlasElementsToolStrip.Size = new System.Drawing.Size(781, 25); this.atlasElementsToolStrip.Stretch = true; this.atlasElementsToolStrip.TabIndex = 2; // @@ -439,7 +439,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(748, 417); + this.ClientSize = new System.Drawing.Size(781, 417); this.Controls.Add(this.toolStripContainer1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "MainForm"; diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index ca418f0..93d40f6 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -258,10 +258,9 @@ private void atlasElementsListToolStripComboBox_SelectedIndexChanged(object send private void atlasElementBorderColors_SelectedIndexChanged(object sender, EventArgs e) { - var element = (KleiTextureAtlasElement)atlasElementsListToolStripComboBox.ComboBox.SelectedItem; - if (element != null) + if (graphicsPath != null) { - DrawRectangle(element); + imageBox.Refresh(); } } From 203c281bb2a4ff74d0479722ad91c46f295c8cf8 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 01:35:56 +0600 Subject: [PATCH 21/25] Version updated to 1.4(dev) --- src/TEXTool/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TEXTool/Properties/AssemblyInfo.cs b/src/TEXTool/Properties/AssemblyInfo.cs index 0e6d631..d2d9487 100644 --- a/src/TEXTool/Properties/AssemblyInfo.cs +++ b/src/TEXTool/Properties/AssemblyInfo.cs @@ -40,5 +40,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE [assembly: Guid("76bbf4d2-c278-4dae-a48c-18f660bc6e61")] -[assembly: AssemblyVersion("1.3.0.0")] +[assembly: AssemblyVersion("1.4.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] From 186350f1f00dcfd19b98174f100f98ac5649120d Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 04:24:39 +0600 Subject: [PATCH 22/25] Small mistake --- src/TEXTool/MainForm.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 93d40f6..a1903f3 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -223,8 +223,8 @@ private void DrawRectangle(KleiTextureAtlasElement element) x = element.ImgHmin; y = element.ImgVmin; - width = element.ImgHmin + element.ImgHmax; - height = element.ImgVmin + element.ImgVmax; + width = element.ImgHmax - element.ImgHmin; + height = element.ImgVmax - element.ImgVmin; graphicsPath = new GraphicsPath(); graphicsPath.AddRectangle(new Rectangle(x, y, width, height)); From 17d22a0c7c574491f84822f40e6cd950ddbc4d50 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 04:25:46 +0600 Subject: [PATCH 23/25] !!! IMPORTANT TIP !!! for Klei Atlas Elements and inverted the y-axis --- src/TEXTool/TEXTool.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index c778f7e..3567b2c 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -221,9 +221,28 @@ private List ReadAtlasData(string path, int mipmapWidth string name = xChild.Attributes.GetNamedItem("name").Value; double u1 = Convert.ToDouble(xChild.Attributes.GetNamedItem("u1").Value.Replace(".", ",")); double u2 = Convert.ToDouble(xChild.Attributes.GetNamedItem("u2").Value.Replace(".", ",")); + + /* !!! IMPORTANT TIP !!! + * You may need to invert the y-axis depending on the software you use to check your pixel coordinates. + * Some image softwares count from the bottom left corner and others from the top left corner. + * The former can be used as-is because the game uses the same format. + * But if your software counts pixels starting from the upper left corner, you should not use them directly. + * Instead, subtract your resulting coordinates them from 1. + * E.g. if your y-coordinate is 0.3, you would use 0.7 (1 – 0.3). + * ONLY for Y-coordinates. For best result Ymin = v1 and Ymax = v2 + */ + + /* NORMAL THE Y-AXIS */ double v1 = Convert.ToDouble(xChild.Attributes.GetNamedItem("v1").Value.Replace(".", ",")); double v2 = Convert.ToDouble(xChild.Attributes.GetNamedItem("v2").Value.Replace(".", ",")); + /* INVERT THE Y-AXIS + * If you don't swap the values of Ymin and Ymax, the height will be negative + * I don't want add Math.Abs() for height :) + */ + v1 = 1 - v2; + v2 = 1 - v1; + int imgHmin, imgHmax, imgVmin, imgVmax; double margin = 0.5; imgHmin = Convert.ToInt16(u1 * mipmapWidth - margin); From ab5cbac6029a2e9ebac5957abc91441b8bfc0aef Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 04:37:20 +0600 Subject: [PATCH 24/25] nvm :) --- src/TEXTool/MainForm.cs | 8 +++++++- src/TEXTool/TEXTool.cs | 11 ++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index a1903f3..2066646 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -223,8 +223,14 @@ private void DrawRectangle(KleiTextureAtlasElement element) x = element.ImgHmin; y = element.ImgVmin; + /* INVERT THE Y-AXIS */ + if (element.ImgVmin > element.ImgVmax) + { + y = element.ImgVmax; + } + width = element.ImgHmax - element.ImgHmin; - height = element.ImgVmax - element.ImgVmin; + height = Math.Abs(element.ImgVmax - element.ImgVmin); graphicsPath = new GraphicsPath(); graphicsPath.AddRectangle(new Rectangle(x, y, width, height)); diff --git a/src/TEXTool/TEXTool.cs b/src/TEXTool/TEXTool.cs index 3567b2c..5627497 100644 --- a/src/TEXTool/TEXTool.cs +++ b/src/TEXTool/TEXTool.cs @@ -229,19 +229,16 @@ private List ReadAtlasData(string path, int mipmapWidth * But if your software counts pixels starting from the upper left corner, you should not use them directly. * Instead, subtract your resulting coordinates them from 1. * E.g. if your y-coordinate is 0.3, you would use 0.7 (1 – 0.3). - * ONLY for Y-coordinates. For best result Ymin = v1 and Ymax = v2 + * ONLY for Y-coordinates. */ /* NORMAL THE Y-AXIS */ double v1 = Convert.ToDouble(xChild.Attributes.GetNamedItem("v1").Value.Replace(".", ",")); double v2 = Convert.ToDouble(xChild.Attributes.GetNamedItem("v2").Value.Replace(".", ",")); - /* INVERT THE Y-AXIS - * If you don't swap the values of Ymin and Ymax, the height will be negative - * I don't want add Math.Abs() for height :) - */ - v1 = 1 - v2; - v2 = 1 - v1; + /* INVERT THE Y-AXIS */ + v1 = 1 - v1; + v2 = 1 - v2; int imgHmin, imgHmax, imgVmin, imgVmax; double margin = 0.5; From 7a29831a13b15a5ae918952c11b7c377f9a7a871 Mon Sep 17 00:00:00 2001 From: davpsh Date: Tue, 19 Jul 2016 04:45:18 +0600 Subject: [PATCH 25/25] Reset SelectedIndex --- src/TEXTool/MainForm.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/TEXTool/MainForm.cs b/src/TEXTool/MainForm.cs index 2066646..829788b 100644 --- a/src/TEXTool/MainForm.cs +++ b/src/TEXTool/MainForm.cs @@ -67,6 +67,7 @@ public MainForm() void tool_FileRawImage(object sender, FileRawImageEventArgs e) { atlasElementsCountIntToolStripLabel.Text = e.AtlasElements.Count.ToString(); + atlasElementsListToolStripComboBox.ComboBox.SelectedIndex = -1; atlasElementsListToolStripComboBox.ComboBox.Items.Clear(); graphicsPath = null; @@ -259,7 +260,10 @@ private void zoomLevelToolStripComboBox_SelectedIndexChanged(object sender, Even private void atlasElementsListToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { var element = (KleiTextureAtlasElement)atlasElementsListToolStripComboBox.ComboBox.SelectedItem; - DrawRectangle(element); + if (element != null) + { + DrawRectangle(element); + } } private void atlasElementBorderColors_SelectedIndexChanged(object sender, EventArgs e)