Skip to content

Commit

Permalink
Fixed Texture2D Bugs, context menu bugs, added a distinct working dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry committed Jun 4, 2018
1 parent 921ac89 commit 04b7375
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 111 deletions.
100 changes: 59 additions & 41 deletions GPK_RePack/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,8 @@
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup>
<userSettings>
<GPK_RePack.Properties.Settings>
<setting name="CopyMode" serializeAs="String">
<value>dataprops</value>
</setting>
<setting name="LogLevel" serializeAs="String">
<value>info</value>
</setting>
<setting name="Debug" serializeAs="String">
<value>False</value>
</setting>
<setting name="ViewMode" serializeAs="String">
<value>class</value>
</setting>
<setting name="SaveDir" serializeAs="String">
<value/>
</setting>
<setting name="OpenDir" serializeAs="String">
<value/>
</setting>
<setting name="ShowImports" serializeAs="String">
<value>False</value>
</setting>
<setting name="PatchMode" serializeAs="String">
<value>False</value>
</setting>
<setting name="UseUID" serializeAs="String">
<value>False</value>
</setting>
<setting name="JitData" serializeAs="String">
<value>False</value>
</setting>
<setting name="GenerateMipMaps" serializeAs="String">
<value>True</value>
</setting>
<setting name="ScaleFactorHack" serializeAs="String">
<value>1</value>
</setting>
</GPK_RePack.Properties.Settings>
</userSettings>
<runtime>
<loadFromRemoteSources enabled="true"/>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand All @@ -57,4 +17,62 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<GPK_RePack.Properties.Settings>
<setting name="CopyMode" serializeAs="String">
<value>dataprops</value>
</setting>
<setting name="LogLevel" serializeAs="String">
<value>info</value>
</setting>
<setting name="Debug" serializeAs="String">
<value>False</value>
</setting>
<setting name="ViewMode" serializeAs="String">
<value>class</value>
</setting>
<setting name="SaveDir" serializeAs="String">
<value />
</setting>
<setting name="OpenDir" serializeAs="String">
<value />
</setting>
<setting name="ShowImports" serializeAs="String">
<value>False</value>
</setting>
<setting name="PatchMode" serializeAs="String">
<value>False</value>
</setting>
<setting name="UseUID" serializeAs="String">
<value>False</value>
</setting>
<setting name="JitData" serializeAs="String">
<value>False</value>
</setting>
<setting name="GenerateMipMaps" serializeAs="String">
<value>True</value>
</setting>
<setting name="ScaleFactorHack" serializeAs="String">
<value>1</value>
</setting>
<setting name="EnableTexture2D" serializeAs="String">
<value>True</value>
</setting>
<setting name="WorkingDir" serializeAs="String">
<value />
</setting>
</GPK_RePack.Properties.Settings>
</userSettings>

<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>

<compatibility xmlns="urn:schemas-microsoft.com:compatibility.v1">
<application>
<!-- Windows 10 compatibility -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</configuration>

5 changes: 5 additions & 0 deletions GPK_RePack/Editors/TextureTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Windows.Media.Imaging;
using GPK_RePack.Model;
using GPK_RePack.Model.Payload;
using GPK_RePack.Model.Prop;
using GPK_RePack.Properties;
using NLog;
using UpkManager.Dds;
Expand Down Expand Up @@ -48,6 +49,7 @@ public static void importTexture(GpkExport export, string file)

var textureMipMap = new MipMap();
textureMipMap.compFlag = (int)CompressionTypes.LZO;
//textureMipMap.compFlag = 0;
textureMipMap.uncompressedData = outputData;
textureMipMap.uncompressedSize = outputData.Length;
textureMipMap.uncompressedSize_chunkheader = outputData.Length;
Expand All @@ -58,7 +60,10 @@ public static void importTexture(GpkExport export, string file)
texture2d.maps.Add(textureMipMap);
}

int mipTailBaseIdx = (int)Math.Log(image.Width > image.Height ? image.Width : image.Height, 2);
((GpkIntProperty) export.GetProperty("MipTailBaseIdx")).SetValue(mipTailBaseIdx.ToString());

logger.Info("Imported image from {0}, size {1}x{2}, target format {3}, mipTailBaseIdx {4}", file, image.Width, image.Height, config.FileFormat, mipTailBaseIdx);
}
catch (Exception ex)
{
Expand Down
117 changes: 64 additions & 53 deletions GPK_RePack/Forms/GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private void GUI_Load(object sender, EventArgs e)
MessageBox.Show("Setting file was missing. Please restart the application.");
Environment.Exit(0);
}
Debug.Print("LOL" + Settings.Default.EnableTexture2D);

//nlog init
NLogConfig.SetDefaultConfig();
Expand All @@ -114,6 +115,8 @@ private void GUI_Load(object sender, EventArgs e)
if (Settings.Default.OpenDir == "")
Settings.Default.OpenDir = Directory.GetCurrentDirectory();

if (Settings.Default.WorkingDir == "")
Settings.Default.WorkingDir = Directory.GetCurrentDirectory();

texturePage = tabTexturePreview;
hidePreviewTab();
Expand Down Expand Up @@ -195,7 +198,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
}
else
{
files = MiscFuncs.GenerateOpenDialog(true);
files = MiscFuncs.GenerateOpenDialog(true, this, false);
}

if (files.Length == 0) return;
Expand Down Expand Up @@ -523,8 +526,8 @@ private void treeMain_AfterSelect(object sender, TreeViewEventArgs e)
}

//check if we have a leaf
else if (e.Node.Level == 2 && Settings.Default.ViewMode != "package" ||
Settings.Default.ViewMode == "package" && e.Node.Nodes.Count == 0)
else if (e.Node.Level == 2 && Settings.Default.ViewMode == "normal" ||
e.Node.Nodes.Count == 0)
{
GpkPackage package = loadedGpkPackages[Convert.ToInt32(getRootNode().Name)];
Object selected = package.GetObjectByUID(e.Node.Name);
Expand Down Expand Up @@ -581,6 +584,9 @@ private void refreshExportInfo()

private void tabControl_Selected(object sender, TabControlEventArgs e)
{
if (selectedExport == null)
return;

if (e.TabPage == tabTexturePreview)
{
if (selectedExport.Payload != null && selectedExport.Payload is Texture2D)
Expand Down Expand Up @@ -701,7 +707,7 @@ private void btnReplace_Click(object sender, EventArgs e)
return;
}

String[] files = MiscFuncs.GenerateOpenDialog(false);
String[] files = MiscFuncs.GenerateOpenDialog(false, this);
if (files.Length == 0) return;
string path = files[0];

Expand Down Expand Up @@ -911,7 +917,7 @@ private void btnImageImport_Click(object sender, EventArgs e)
return;
}

string[] files = MiscFuncs.GenerateOpenDialog(false);
string[] files = MiscFuncs.GenerateOpenDialog(false, this);
if (files.Length == 0) return;

if (files[0] != "" && File.Exists(files[0]))
Expand Down Expand Up @@ -955,7 +961,7 @@ private void btnImportOgg_Click(object sender, EventArgs e)
{
if (selectedExport != null)
{
String[] files = MiscFuncs.GenerateOpenDialog(false);
String[] files = MiscFuncs.GenerateOpenDialog(false, this);
if (files.Length == 0) return;

if (File.Exists(files[0]))
Expand Down Expand Up @@ -1614,7 +1620,7 @@ private void BigBytePropImport_Click(object sender, EventArgs e)
var arrayProp = checkArrayRow();
if (arrayProp == null) return;

String[] files = MiscFuncs.GenerateOpenDialog(false);
String[] files = MiscFuncs.GenerateOpenDialog(false, this);
if (files.Length == 0) return;
string path = files[0];
if (!File.Exists(path)) return;
Expand Down Expand Up @@ -1680,59 +1686,64 @@ private void treeContextMenu_ItemClicked(object sender, ToolStripItemClickedEven
}


[STAThread]
private void selectContextAction(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem == addToolStripMenuItem)
this.BeginInvoke(new MethodInvoker(delegate
{

}
else if (e.ClickedItem == removeToolStripMenuItem)
{
btnDelete_Click(null, null);
}
else if (e.ClickedItem == copyToolStripMenuItem)
{
btnCopy_Click(null, null);
}
else if (e.ClickedItem == pasteToolStripMenuItem)
{
btnPaste_Click(null, null);
}
if (e.ClickedItem == addToolStripMenuItem)
{

//import
else if (e.ClickedItem == importRawDataToolStripMenuItem)
{
btnReplace_Click(null, null);
}
else if (e.ClickedItem == importDDSToolStripMenuItem)
{
btnImageImport_Click(null, null);
}
else if (e.ClickedItem == importOGGToolStripMenuItem)
{
btnImportOgg_Click(null, null);
}
}
else if (e.ClickedItem == removeToolStripMenuItem)
{
btnDelete_Click(null, null);
}
else if (e.ClickedItem == copyToolStripMenuItem)
{
btnCopy_Click(null, null);
}
else if (e.ClickedItem == pasteToolStripMenuItem)
{
btnPaste_Click(null, null);
}

//export
else if (e.ClickedItem == exportRawDataToolStripMenuItem)
{
btnExport_Click(null, null);
}
else if (e.ClickedItem == exportDDSToolStripMenuItem)
{
btnImageExport_Click(null, null);
}
else if (e.ClickedItem == exportOGGToolStripMenuItem)
{
btnExtractOGG_Click(null, null);
}
//preview ogg
//import
else if (e.ClickedItem == importRawDataToolStripMenuItem)
{
btnReplace_Click(null, null);
}
else if (e.ClickedItem == importDDSToolStripMenuItem)
{
btnImageImport_Click(null, null);
}
else if (e.ClickedItem == importOGGToolStripMenuItem)
{
btnImportOgg_Click(null, null);
}

else if (e.ClickedItem == previewOGGToolStripMenuItem)
{
btnOggPreview_Click(null, null);
}
}
//export
else if (e.ClickedItem == exportRawDataToolStripMenuItem)
{
btnExport_Click(null, null);
}
else if (e.ClickedItem == exportDDSToolStripMenuItem)
{
btnImageExport_Click(null, null);
}
else if (e.ClickedItem == exportOGGToolStripMenuItem)
{
btnExtractOGG_Click(null, null);
}
//preview ogg

else if (e.ClickedItem == previewOGGToolStripMenuItem)
{
btnOggPreview_Click(null, null);
}
}));
}



Expand Down
31 changes: 29 additions & 2 deletions GPK_RePack/Forms/Options.Designer.cs

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

Loading

0 comments on commit 04b7375

Please sign in to comment.