Skip to content

Commit

Permalink
Merge branch 'build-improvement'
Browse files Browse the repository at this point in the history
  • Loading branch information
Blu3wolf committed Dec 15, 2017
2 parents 487cfc4 + 2e911cf commit 8338a09
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 26 deletions.
4 changes: 3 additions & 1 deletion 3DDBBuilderGUI/3DDBBuilderGUI.csproj
Expand Up @@ -103,7 +103,9 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="bin\Debug\B.BMP" />
<Content Include="3ddb_builder.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Binary file added 3DDBBuilderGUI/3ddb_builder.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions 3DDBBuilderGUI/MainWindow.xaml
Expand Up @@ -77,8 +77,8 @@
<TextBox TextWrapping="Wrap" Text="{Binding Mode=TwoWay, Path=BuildOutput}" />
</DockPanel>
<DockPanel Margin="0,10,0,0">
<Button Content="Select KoreaObj folder" Style="{StaticResource WFButton}" Click="SelTextureFolderButton_Click"/>
<Button Content="Set Texture Number" DockPanel.Dock="Right" Style="{StaticResource WFButton}" Click="SetTextureNumberButton_Click"/>
<Button Content="Select Object Folder" Style="{StaticResource WFButton}" Click="SelTextureFolderButton_Click"/>
<Button Content="Create Texture File" DockPanel.Dock="Right" Style="{StaticResource WFButton}" Click="SetTextureNumberButton_Click"/>
<TextBox TextAlignment="Center" Text="{Binding Mode=TwoWay,Path=TextureNumber}"/>
</DockPanel>
<DockPanel LastChildFill="False" Margin="0,10,0,0">
Expand Down
97 changes: 74 additions & 23 deletions 3DDBBuilderGUI/MainWindow.xaml.cs
Expand Up @@ -115,6 +115,8 @@ public MainWindow()

private int texturenumber;

private string texturefolder;

public ObservableCollection<ObjDB> DBsList { get; set; }

public string CurExtractionPath
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
}

Expand All @@ -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
Expand All @@ -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()
Expand Down
10 changes: 10 additions & 0 deletions 3DDBBuilderGUI/Properties/Resources.Designer.cs

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

0 comments on commit 8338a09

Please sign in to comment.