-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
TDB Maker | ||
========= | ||
|
||
This program can convert TDB files to XML, and then back to TDB, in order to facilitate | ||
editing of the game's text. | ||
|
||
Recommended text editor for XML editing: Notepad++ (https://notepad-plus-plus.org/) | ||
|
||
Do not use good old Windows Notepad... more on that below. | ||
|
||
========================================================================================= | ||
|
||
### TDB to XML ### | ||
------------------ | ||
|
||
- Drag and drop one or more TDB files into TDB Maker's window. | ||
Resulting XML files will be created in the folder where source TDB's are. | ||
|
||
OR | ||
|
||
- Click "Convert TDB to XML"; | ||
- Select TDB file to be converted; | ||
- Select XML file to be created. | ||
|
||
### XML to TDB ### | ||
------------------ | ||
|
||
- Drag and drop one or more XML files into TDB Maker's window. | ||
Resulting TDB files will be created in the folder where source XML's are. | ||
|
||
OR | ||
|
||
- Click "Convert XML to TDB"; | ||
- Select XML file to be converted; | ||
- Select TDB file to be created. | ||
|
||
========================================================================================= | ||
|
||
***************** | ||
*** IMPORTANT *** | ||
***************** | ||
|
||
1) Do not run TDB Maker with admin rights or you may be unable to drop files on it. | ||
This is also valid for running Visual Studio as admin and debugging TDB Maker through it. | ||
|
||
2) Mark for new line used in generated XML's is 0A ("\n", vbLf), not 0D0A ("\r\n", vbCrLf). | ||
Notepad can only recognize 0D0A as new line mark. Notepad++ is able to recognize both marks, | ||
and any "enter" added by the user is written as whatever mark being already used in the file. | ||
There are multiline strings in the game (example: Battle of Gold explanation). | ||
TDB Maker will create a TDB file with whatever new line mark is present in the string entries | ||
of the source XML. | ||
While the game engine can work with both 0A and 0D0A, it seems developers intended to use only | ||
the former. Some TDB files, which are leftovers from Brave Soldiers as far as I can tell, use | ||
0D0A as new line mark, and TDB Maker will "convert" them to 0A (though this is useless | ||
because, as I said, they are leftovers). BS leftovers are present in PS3 and PC versions of SS, | ||
but only in PC they use 0D0A. | ||
|
||
3) TDB's from BS (actual files from that game or leftovers in SS) don't have all languages | ||
filled with text. | ||
I originally intended to use language names in XML tags, but in order to maintain coherence | ||
with BS, language tags in XML are named simply "LanguageX". | ||
Language order in Brave Soldiers: | ||
Japanese, English, Italian, French, Spanish, two unused languages and Brazilian Portuguese. | ||
Language order in Soldiers' Soul: | ||
Japanese, English, French, Italian, Castilian Spanish, Brazilian Portuguese, Latin American | ||
Spanish and Chinese. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Express 2012 for Windows Desktop | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDBMaker", "TDBMaker\TDBMaker.csproj", "{F09BAF93-B17A-45DC-B9AC-3F443B0BB638}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F09BAF93-B17A-45DC-B9AC-3F443B0BB638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F09BAF93-B17A-45DC-B9AC-3F443B0BB638}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F09BAF93-B17A-45DC-B9AC-3F443B0BB638}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F09BAF93-B17A-45DC-B9AC-3F443B0BB638}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace TDBMaker | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
|
||
private static int ConversionDoneCount; | ||
private static int IgnoreCount; | ||
|
||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); | ||
} | ||
|
||
private void Form1_DragDrop(object sender, DragEventArgs e) | ||
{ | ||
string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop); | ||
bool suppress = false; | ||
if (droppedFiles.Length >= 10) | ||
{ | ||
DialogResult dr = MessageBox.Show("You dropped " + droppedFiles.Length + " items into TDB Maker. Individual messages about overwriting and conversion result for all items will be suppressed.", "TDB Maker", MessageBoxButtons.OKCancel); | ||
if (dr == System.Windows.Forms.DialogResult.Cancel) | ||
return; | ||
suppress = true; | ||
} | ||
ConvertItems(droppedFiles, suppress); | ||
} | ||
|
||
private void ConvertItems(string[] itemArray, bool suppress) | ||
{ | ||
ConversionDoneCount = 0; | ||
IgnoreCount = 0; | ||
Cursor.Current = Cursors.WaitCursor; | ||
foreach (string file in itemArray) | ||
{ | ||
if (File.GetAttributes(file).HasFlag(FileAttributes.Directory)) | ||
{ | ||
IgnoreCount++; | ||
if (!suppress) | ||
MessageBox.Show(file + "\n\nThis item cannot be processed because it is a directory."); | ||
continue; | ||
} | ||
string ext = Path.GetExtension(file).ToLower(); | ||
string dir = Path.GetDirectoryName(file); | ||
string nameonly = Path.GetFileNameWithoutExtension(file); | ||
if (ext == ".tdb") | ||
{ | ||
ConvertToXML(file, Path.Combine(dir, nameonly + ".xml"), !suppress, suppress); | ||
} | ||
else if (ext == ".xml") | ||
{ | ||
ConvertToTDB(file, Path.Combine(dir, nameonly + ".tdb"), !suppress, suppress); | ||
} | ||
else | ||
{ | ||
IgnoreCount++; | ||
if (!suppress) | ||
MessageBox.Show(file + "\n\nThis item cannot be processed because it has no .tdb or .xml extension!"); | ||
} | ||
} | ||
Cursor.Current = Cursors.Default; | ||
if (itemArray.Length <= 1) | ||
return; | ||
string strReport = "Item count: " + itemArray.Length + "\n"; | ||
strReport += "Conversions done: " + ConversionDoneCount + "\n"; | ||
strReport += "Conversions failed: " + (itemArray.Length - ConversionDoneCount - IgnoreCount) + "\n"; | ||
strReport += "Ignored: " + IgnoreCount; | ||
MessageBox.Show(strReport, "Report", MessageBoxButtons.OK, MessageBoxIcon.Information); | ||
} | ||
|
||
private void Form1_DragEnter(object sender, DragEventArgs e) | ||
{ | ||
if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) | ||
{ | ||
e.Effect = DragDropEffects.All; | ||
} | ||
} | ||
|
||
private void btnTdb2Xml_Click(object sender, EventArgs e) | ||
{ | ||
OpenFileDialog ofd = new OpenFileDialog(); | ||
ofd.Filter = "TDB|*.tdb"; | ||
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) | ||
return; | ||
SaveFileDialog sfd = new SaveFileDialog(); | ||
sfd.Filter = "XML|*.xml"; | ||
sfd.FileName = Path.GetFileNameWithoutExtension(ofd.FileName) + ".xml"; | ||
if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK) | ||
return; | ||
ConvertToXML(ofd.FileName, sfd.FileName); | ||
} | ||
|
||
private void btnXml2Tdb_Click(object sender, EventArgs e) | ||
{ | ||
OpenFileDialog ofd = new OpenFileDialog(); | ||
ofd.Filter = "XML|*.xml"; | ||
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) | ||
return; | ||
SaveFileDialog sfd = new SaveFileDialog(); | ||
sfd.Filter = "TDB|*.tdb"; | ||
sfd.FileName = Path.GetFileNameWithoutExtension(ofd.FileName) + ".tdb"; | ||
if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK) | ||
return; | ||
ConvertToTDB(ofd.FileName, sfd.FileName); | ||
} | ||
|
||
public static void ConvertToTDB(string source, string destination, bool overwritewarning = false, bool suppressendmessage = false) | ||
{ | ||
if (overwritewarning && File.Exists(destination)) | ||
{ | ||
DialogResult dr = MessageBox.Show(destination + "\n\nThis file is about to be overwritten. Proceed?", "Overwrite file", MessageBoxButtons.YesNo); | ||
if (dr == DialogResult.No) | ||
return; | ||
} | ||
if (TDBHandler.Xml2Tdb(source, destination)) | ||
{ | ||
if (!suppressendmessage) | ||
MessageBox.Show("Done: " + Path.GetFileName(source) + " => " + Path.GetFileName(destination), "Xml2Tdb"); | ||
ConversionDoneCount++; | ||
} | ||
else | ||
{ | ||
if (!suppressendmessage) | ||
MessageBox.Show("Failed: " + Path.GetFileName(source) + " => " + Path.GetFileName(destination), "Xml2Tdb"); | ||
} | ||
} | ||
|
||
public static void ConvertToXML(string source, string destination, bool overwritewarning = false, bool suppressendmessage = false) | ||
{ | ||
if (overwritewarning && File.Exists(destination)) | ||
{ | ||
DialogResult dr = MessageBox.Show(destination + "\n\nThis file is about to be overwritten. Proceed?", "Overwrite file", MessageBoxButtons.YesNo); | ||
if (dr == DialogResult.No) | ||
return; | ||
} | ||
if (TDBHandler.Tdb2Xml(source, destination)) | ||
{ | ||
if(!suppressendmessage) | ||
MessageBox.Show("Done: " + Path.GetFileName(source) + " => " + Path.GetFileName(destination), "Tdb2Xml"); | ||
ConversionDoneCount++; | ||
} | ||
else | ||
{ | ||
if(!suppressendmessage) | ||
MessageBox.Show("Failed: " + Path.GetFileName(source) + " => " + Path.GetFileName(destination), "Tdb2Xml"); | ||
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.