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

Commit

Permalink
WMSET4: Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
MaKiPL committed Oct 23, 2016
1 parent 3ce088c commit fe1ab6c
Show file tree
Hide file tree
Showing 7 changed files with 316 additions and 2 deletions.
88 changes: 88 additions & 0 deletions SerahToolkit_SharpGL/Forms/wm4.Designer.cs

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

46 changes: 46 additions & 0 deletions SerahToolkit_SharpGL/Forms/wm4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Windows.Forms;

namespace SerahToolkit_SharpGL.Forms
{
//just because I'm too lazy to make it via dynamic generated form... >_>
public partial class wm4 : Form
{
private WM_Section4 wm4s;
public wm4(object obj)
{
wm4s = obj as WM_Section4;
InitializeComponent();
}

public void InitialUpdate(ushort[] enc)
{
dataGridView1.MultiSelect = false;
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
DataGridViewTextBoxColumn idColumn = new DataGridViewTextBoxColumn {HeaderText = "ID", ReadOnly = true, AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells};
DataGridViewTextBoxColumn regionColumn = new DataGridViewTextBoxColumn { HeaderText = "Region", ReadOnly = true, AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells };
DataGridViewTextBoxColumn encColumn = new DataGridViewTextBoxColumn { HeaderText = "Encounter", ReadOnly = false, AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells };
dataGridView1.Columns.Add(idColumn);
dataGridView1.Columns.Add(regionColumn);
dataGridView1.Columns.Add(encColumn);

for (int i = 0; i < 672; i++)
dataGridView1.Rows.Add(i, returnRegion(i), wm4s.GetEncounters[i]);
dataGridView1.CellValueChanged += DataGridView1_CellValueChanged;
}

private void DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) => wm4s.GetEncounters[e.RowIndex] = ushort.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value as string);

private int returnRegion(int i) => (int) Math.Round((decimal) (i/48), 0);

private void compileSaveToolStripMenuItem_Click(object sender, EventArgs e)
{
ushort[] collection = wm4s.GetEncounters;
byte[] buffer = new byte[collection.Length*2+4];
Buffer.BlockCopy(collection,0,buffer,0,buffer.Length-4);
System.IO.File.WriteAllBytes(wm4s.path, buffer);
this.Close();
}
}
}
123 changes: 123 additions & 0 deletions SerahToolkit_SharpGL/Forms/wm4.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?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>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
9 changes: 9 additions & 0 deletions SerahToolkit_SharpGL/SerahToolkit_SharpGL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
<Compile Include="FF8_Core\TIM.cs" />
<Compile Include="FileScanner\FileScannerCore.cs" />
<Compile Include="FileScanner\FileScannerHeaders.cs" />
<Compile Include="Forms\wm4.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\wm4.Designer.cs">
<DependentUpon>wm4.cs</DependentUpon>
</Compile>
<Compile Include="GfEnviro.cs" />
<Compile Include="ManualGeometryRipper.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -155,6 +161,9 @@
<EmbeddedResource Include="BS_Vertices.resx">
<DependentUpon>BS_Vertices.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\wm4.resx">
<DependentUpon>wm4.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ManualGeometryRipper.resx">
<DependentUpon>ManualGeometryRipper.cs</DependentUpon>
</EmbeddedResource>
Expand Down
5 changes: 3 additions & 2 deletions SerahToolkit_SharpGL/SharpGLForm.Designer.cs

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

13 changes: 13 additions & 0 deletions SerahToolkit_SharpGL/SharpGLForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using SerahToolkit_SharpGL.FF8_Core;
using SerahToolkit_SharpGL.Forms;
using SharpGL;
using SharpGL.SceneGraph;
using SharpGL.SceneGraph.Primitives;
Expand Down Expand Up @@ -46,6 +47,7 @@ internal static class NativeMethods

private GfEnviro _gf;
private WM_Section2 wm2;
private WM_Section4 wm4;
private Form dynamicForm;

private const int StateBattleStageUv = 0;
Expand Down Expand Up @@ -1051,6 +1053,17 @@ private void CompileWMSETfile(FileInfo[] sections, string countyLiteral)
Console.WriteLine($"WMSET: Succesfully saved {sfd.FileName} file");
}

private void worldMapEncountersToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog { Filter = "WMset section 4|wm*.section4" };
if (ofd.ShowDialog() != DialogResult.OK) return;
wm4 = new WM_Section4(ofd.FileName);
Forms.wm4 wm4editor = new wm4(wm4);
wm4.ProduceData();
wm4editor.InitialUpdate(wm4.GetEncounters);
wm4editor.Show();
}

private void openGLControl_MouseDown(object sender, MouseEventArgs e)
{
mouseLeftDown = e.Button == MouseButtons.Left;
Expand Down
34 changes: 34 additions & 0 deletions SerahToolkit_SharpGL/wmset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,38 @@ public unsafe void ResetBlockColor(int blockID)
ColorizeBlock(blockID,regions[selectedRegion]);
}
}

internal class WM_Section4
{
public const byte BYTESPERREGION = 48;
public const byte REGIONSCOUNT = 14;
public string path;
private FileStream fs;
private BinaryReader br;

private ushort[] encounters;

public WM_Section4(string path)
{
this.path = path;
fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
br = new BinaryReader(fs);
encounters = new ushort[BYTESPERREGION*REGIONSCOUNT];
}

public void EndJob()
{
br.Dispose();
fs.Dispose();
}

public void ProduceData()
{
for (int i = 0x0; i < encounters.Length; i++)
encounters[i] = br.ReadUInt16();
EndJob();
}

public ushort[] GetEncounters => encounters;
}
}

0 comments on commit fe1ab6c

Please sign in to comment.