diff --git a/3DDBBuilderGUI/3DDBBuilderGUI.csproj b/3DDBBuilderGUI/3DDBBuilderGUI.csproj
index 2aa49da..4735bfd 100644
--- a/3DDBBuilderGUI/3DDBBuilderGUI.csproj
+++ b/3DDBBuilderGUI/3DDBBuilderGUI.csproj
@@ -103,7 +103,9 @@
-
+
+ PreserveNewest
+
\ No newline at end of file
diff --git a/3DDBBuilderGUI/3ddb_builder.exe b/3DDBBuilderGUI/3ddb_builder.exe
new file mode 100644
index 0000000..1a1214f
Binary files /dev/null and b/3DDBBuilderGUI/3ddb_builder.exe differ
diff --git a/3DDBBuilderGUI/MainWindow.xaml b/3DDBBuilderGUI/MainWindow.xaml
index 36c83c5..254719b 100644
--- a/3DDBBuilderGUI/MainWindow.xaml
+++ b/3DDBBuilderGUI/MainWindow.xaml
@@ -77,8 +77,8 @@
-
-
+
+
diff --git a/3DDBBuilderGUI/MainWindow.xaml.cs b/3DDBBuilderGUI/MainWindow.xaml.cs
index 05f5fcf..689c725 100644
--- a/3DDBBuilderGUI/MainWindow.xaml.cs
+++ b/3DDBBuilderGUI/MainWindow.xaml.cs
@@ -115,6 +115,8 @@ public MainWindow()
private int texturenumber;
+ private string texturefolder;
+
public ObservableCollection DBsList { get; set; }
public string CurExtractionPath
@@ -196,10 +198,26 @@ public int TextureNumber
{
texturenumber = value;
NotifyPropertyChanged("TextureNumber");
+ // Need to update this whenever a new DB is selected to be built
}
}
}
+ public string TextureFolder
+ {
+ get => texturefolder;
+ set
+ {
+ if (value != texturefolder)
+ {
+ texturefolder = value;
+ // not sure anything relies on that property changing anyway? Oh well
+ NotifyPropertyChanged("TextureFolder");
+ }
+ TextureNumber = ObjDB.GetHighestTexture(value);
+ }
+ }
+
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyname)
@@ -526,14 +544,43 @@ private void ResetCurUpdatePathButton_Click(object sender, RoutedEventArgs e)
private void SelTextureFolderButton_Click(object sender, RoutedEventArgs e)
{
- string message = "Select the KoreaObj folder ";
+ string message = "Select the folder the database was originally extracted from: ";
MessageBox.Show(message, "Notification", MessageBoxButton.OK, MessageBoxImage.Information);
- GetFolder(false, true, "Select KoreaObj Folder...", "");
+ string KoreaObjDir = GetFolder(false, true, "Select Object Folder...", "");
+ if (KoreaObjDir != null)
+ {
+ TextureFolder = KoreaObjDir;
+ }
}
private void SetTextureNumberButton_Click(object sender, RoutedEventArgs e)
{
-
+ if (BuildSource == null)
+ {
+ string message = "Select a source folder to build, first.";
+ MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ if (TextureNumber == 0)
+ {
+ string message = "Specify an existing database, or a texture number, first.";
+ MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+ //first, check to see if a texture file exists already
+ string dir = BuildSource + @"\Textures";
+ string[] files = Directory.GetFiles(dir);
+ if (files.Length == 0)
+ {
+ string path = dir + @"\" + TextureNumber.ToString() + ".BMP";
+ WriteTexture(path);
+ }
+ else // a texture file already exists - likely case is that a single texture file already exists
+ {
+ // rename it to a new name I guess
+ string message = "A texture file already exists in the source /Textures folder. Please delete it and try again.";
+ MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
}
}
@@ -542,20 +589,37 @@ public class ObjDB
public ObjDB(string dir)
{
DirPath = dir;
- // given the obj dir, find the highest number texture ID
- string texpath = DirPath + "/KoreaObj";
- string[] filepaths = Directory.GetFiles(texpath, "*.dds");
- TextureNo = 0;
+ TextureNo = GetHighestTexture(dir);
+ }
+
+ public static bool Exists(String FolderName)
+ {
+ if (Directory.Exists(FolderName) && File.Exists(FolderName + @"\KoreaOBJ.LOD"))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public static int GetHighestTexture(string dir)
+ {
+ // dir is the object directory, so get the texture directory
+ string texpath = dir + @"\KoreaObj";
+ string[] filepaths = Directory.GetFiles(texpath, "*.dds");
+ int texno = 0;
foreach (string path in filepaths)
{
int number;
bool result = Int32.TryParse(System.IO.Path.GetFileNameWithoutExtension(path), out number);
if (result)
{
- if (number > TextureNo)
+ if (number > texno)
{
- TextureNo = number;
+ texno = number;
}
}
else
@@ -564,21 +628,8 @@ public ObjDB(string dir)
}
}
- // TextureNo should now be equal to the highest numbered texture in the folder
- MessageBox.Show(TextureNo.ToString());
-
- }
+ return texno;
- public static bool Exists(String FolderName)
- {
- if (Directory.Exists(FolderName) && File.Exists(FolderName + @"\KoreaOBJ.LOD"))
- {
- return true;
- }
- else
- {
- return false;
- }
}
public bool IsValid()
diff --git a/3DDBBuilderGUI/Properties/Resources.Designer.cs b/3DDBBuilderGUI/Properties/Resources.Designer.cs
index 7124b22..95b7460 100644
--- a/3DDBBuilderGUI/Properties/Resources.Designer.cs
+++ b/3DDBBuilderGUI/Properties/Resources.Designer.cs
@@ -60,6 +60,16 @@ internal class Resources {
}
}
+ ///
+ /// Looks up a localized resource of type System.Byte[].
+ ///
+ internal static byte[] _3ddb_builder {
+ get {
+ object obj = ResourceManager.GetObject("_3ddb_builder", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///