Skip to content
This repository has been archived by the owner on Oct 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from davpsh/dev
Browse files Browse the repository at this point in the history
Dev version 1.4.1
  • Loading branch information
handsomematt authored Jul 20, 2016
2 parents 52d6911 + eb29a1b commit 74b7fd1
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/TEXTool/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion src/TEXTool/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ 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.ComponentModel;

using System.Drawing;
using System.Drawing.Drawing2D;

Expand All @@ -37,6 +39,8 @@ namespace TEXTool
public partial class MainForm : Form
{
public TEXTool Tool;
public ProgressForm ProgressForm;

GraphicsPath graphicsPath;
float offsetX = 0, offsetY = 0, scaleX = 1, scaleY = 1;

Expand All @@ -45,6 +49,7 @@ public MainForm()
Tool = new TEXTool();
Tool.FileOpened += new FileOpenedEventHandler(TEXTool_FileOpened);
Tool.FileRawImage += new FileRawImageEventHandler(tool_FileRawImage);
Tool.OnProgressUpdate += tool_OnProgressUpdate;

InitializeComponent();
FillZoomLevelComboBox();
Expand Down Expand Up @@ -110,7 +115,10 @@ private void OpenFileDialog()

if (dialog.ShowDialog(this) == DialogResult.OK)
{
Tool.OpenFile(dialog.FileName, dialog.OpenFile());
ProgressForm = new ProgressForm();
ProgressForm.StartPosition = FormStartPosition.CenterParent;
backgroundWorker.RunWorkerAsync(dialog);
ProgressForm.ShowDialog(this);
}
}
}
Expand Down Expand Up @@ -301,6 +309,30 @@ private void imageBox_Paint(object sender, PaintEventArgs e)
}
}

private void tool_OnProgressUpdate(int value)
{
base.Invoke((Action)delegate
{
ProgressForm.ReportProgress(value);
});
}

private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
var dialog = (OpenFileDialog)e.Argument;
Tool.OpenFile(dialog.FileName, dialog.OpenFile());
}

private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (ProgressForm != null)
{
ProgressForm.Close();
ProgressForm.Dispose();
}
}

#endregion

}
}
3 changes: 3 additions & 0 deletions src/TEXTool/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
<metadata name="atlasElementsToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>485, 17</value>
</metadata>
<metadata name="backgroundWorker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>650, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
65 changes: 65 additions & 0 deletions src/TEXTool/ProgressForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions src/TEXTool/ProgressForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TEXTool
{
public partial class ProgressForm : Form
{
public ProgressForm()
{
InitializeComponent();
}
public void ReportProgress(int i)
{
progressBar.Value = i;
}
}
}
120 changes: 120 additions & 0 deletions src/TEXTool/ProgressForm.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
2 changes: 1 addition & 1 deletion src/TEXTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.0.0")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
12 changes: 11 additions & 1 deletion src/TEXTool/TEXTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public FileRawImageEventArgs(Bitmap image, List<KleiTextureAtlasElement> element

public delegate void FileOpenedEventHandler(object sender, FileOpenedEventArgs e);
public delegate void FileRawImageEventHandler(object sender, FileRawImageEventArgs e);
public delegate void ProgressUpdate(int value);

public class TEXTool
{
Expand All @@ -94,6 +95,9 @@ public class TEXTool
public event FileOpenedEventHandler FileOpened;
public event FileRawImageEventHandler FileRawImage;

public event ProgressUpdate OnProgressUpdate;


#region Util

public static class EnumHelper<T>
Expand Down Expand Up @@ -191,6 +195,7 @@ public void OpenFile(string filename, Stream stream)
Bitmap pt = new Bitmap((int)mipmap.Width, (int)mipmap.Height);

for (int y = 0; y < mipmap.Height; y++)
{
for (int x = 0; x < mipmap.Width; x++)
{
byte r = imgReader.ReadByte();
Expand All @@ -199,7 +204,12 @@ public void OpenFile(string filename, Stream stream)
byte a = imgReader.ReadByte();
pt.SetPixel(x, y, Color.FromArgb(a, r, g, b));
}

if (OnProgressUpdate != null)
{
OnProgressUpdate(y * 100 / mipmap.Height);
}
}

pt.RotateFlip(RotateFlipType.RotateNoneFlipY);

CurrentFileRaw = pt;
Expand Down
9 changes: 9 additions & 0 deletions src/TEXTool/TEXTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="ProgressForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ProgressForm.Designer.cs">
<DependentUpon>ProgressForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TEXTool.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ProgressForm.resx">
<DependentUpon>ProgressForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down

0 comments on commit 74b7fd1

Please sign in to comment.