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

Commit

Permalink
Fixed encoding when converting between xml and byml
Browse files Browse the repository at this point in the history
Also fixed save as xml and save as byml
  • Loading branch information
exelix11 committed May 22, 2017
1 parent 969da8f commit db9b36f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions The4Dimension/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class Form1 : Form
string LoadedFile = "";
bool AutoMoveCam = true;
bool AddObjectOrigin = false;
public static int ReleaseId = 10;
public static int ReleaseId = 11;

public Form1(string FileLoad = "")
{
Expand Down Expand Up @@ -2372,10 +2372,10 @@ void SzsSave(string filename)
MessageBox.Show("Done !");
}

void XmlSave(string filename, bool XML)
void XmlSave(string filename, bool BYML)
{
if (XML) File.WriteAllBytes(filename, BymlConverter.GetByml(MakeXML()));
else File.WriteAllText(filename, MakeXML());
if (BYML) File.WriteAllBytes(filename, BymlConverter.GetByml(MakeXML()));
else File.WriteAllText(filename, MakeXML(), DefEnc);
MessageBox.Show("Done !");
}

Expand All @@ -2400,7 +2400,7 @@ private void saveAsXmlToolStripMenuItem_Click(object sender, EventArgs e)
sav.Filter = "Xml file|*.xml";
if (sav.ShowDialog() == DialogResult.OK)
{
XmlSave(sav.FileName, true);
XmlSave(sav.FileName, false);
LoadedFile = sav.FileName;
this.Text = LoadedFile == "" ? "The Fourth Dimension - by Exelix11" : "The Fourth Dimension - " + LoadedFile;
saveToolStripMenuItem.Enabled = true;
Expand All @@ -2414,7 +2414,7 @@ private void saveAsBymlToolStripMenuItem1_Click(object sender, EventArgs e)
sav.Filter = "Byml file|*.byml";
if (sav.ShowDialog() == DialogResult.OK)
{
XmlSave(sav.FileName, false);
XmlSave(sav.FileName, true);
LoadedFile = sav.FileName;
this.Text = LoadedFile == "" ? "The Fourth Dimension - by Exelix11" : "The Fourth Dimension - " + LoadedFile;
saveToolStripMenuItem.Enabled = true;
Expand Down
9 changes: 5 additions & 4 deletions The4Dimension/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static void Main(string[] Args)
System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1.DefEnc = Encoding.GetEncoding("Shift-JIS");
if (Args.Length != 0)
{
if (Args[0].ToLower() == "batch")
Expand All @@ -37,9 +38,9 @@ static void Main(string[] Args)
{
try
{
string Cont = System.IO.File.ReadAllText(a);
string Cont = System.IO.File.ReadAllText(a, Form1.DefEnc);
if (Cont.StartsWith("<?xml")) File.WriteAllBytes(a + ".byml", BymlConverter.GetByml(Cont));
else if (Cont.StartsWith("YB") || Cont.StartsWith("BY")) File.WriteAllText(a + ".xml", BymlConverter.GetXml(a));
else if (Cont.StartsWith("YB") || Cont.StartsWith("BY")) File.WriteAllText(a + ".xml", BymlConverter.GetXml(a), Form1.DefEnc);
else { Console.WriteLine(a + " : filetype not supported"); continue; }
Console.WriteLine(a + " : Done");
}
Expand All @@ -63,10 +64,10 @@ static void Main(string[] Args)
}
else
{
string Cont = System.IO.File.ReadAllText(Args[0]);
string Cont = System.IO.File.ReadAllText(Args[0],Form1.DefEnc);
if (Cont.StartsWith("<?xml") || Cont.StartsWith("YB") || Cont.StartsWith("BY"))
{
if (Cont.StartsWith("<?xml")) new FormEditors.FrmXmlEditor(File.ReadAllText(Args[0]), Args[0], true).ShowDialog();
if (Cont.StartsWith("<?xml")) new FormEditors.FrmXmlEditor(File.ReadAllText(Args[0], Form1.DefEnc), Args[0], true).ShowDialog();
else new FormEditors.FrmXmlEditor(BymlConverter.GetXml(Args[0]), Args[0], true).ShowDialog();
}
else RunApp(Args[0].Trim());
Expand Down
4 changes: 2 additions & 2 deletions The4Dimension/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.9.1.0")]
[assembly: AssemblyFileVersion("0.9.1.0")]
[assembly: AssemblyVersion("0.9.2.0")]
[assembly: AssemblyFileVersion("0.9.2.0")]

0 comments on commit db9b36f

Please sign in to comment.