diff --git a/GPK_RePack/App.config b/GPK_RePack/App.config
index b9d58ee..ca0ba5c 100644
--- a/GPK_RePack/App.config
+++ b/GPK_RePack/App.config
@@ -6,48 +6,8 @@
-
+
-
-
-
- dataprops
-
-
- info
-
-
- False
-
-
- class
-
-
-
-
-
-
-
-
- False
-
-
- False
-
-
- False
-
-
- False
-
-
- True
-
-
- 1
-
-
-
@@ -57,4 +17,62 @@
+
+
+
+ dataprops
+
+
+ info
+
+
+ False
+
+
+ class
+
+
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ True
+
+
+ 1
+
+
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GPK_RePack/Editors/TextureTools.cs b/GPK_RePack/Editors/TextureTools.cs
index 5004320..4f8a2b9 100644
--- a/GPK_RePack/Editors/TextureTools.cs
+++ b/GPK_RePack/Editors/TextureTools.cs
@@ -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;
@@ -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;
@@ -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)
{
diff --git a/GPK_RePack/Forms/GUI.cs b/GPK_RePack/Forms/GUI.cs
index afbb032..7f63e8a 100644
--- a/GPK_RePack/Forms/GUI.cs
+++ b/GPK_RePack/Forms/GUI.cs
@@ -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();
@@ -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();
@@ -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;
@@ -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);
@@ -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)
@@ -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];
@@ -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]))
@@ -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]))
@@ -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;
@@ -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);
+ }
+ }));
+ }
diff --git a/GPK_RePack/Forms/Options.Designer.cs b/GPK_RePack/Forms/Options.Designer.cs
index 78355e4..aa700e0 100644
--- a/GPK_RePack/Forms/Options.Designer.cs
+++ b/GPK_RePack/Forms/Options.Designer.cs
@@ -49,6 +49,8 @@ private void InitializeComponent()
this.boxGenerateMipmaps = new System.Windows.Forms.CheckBox();
this.label2 = new System.Windows.Forms.Label();
this.boxScaleFactor = new System.Windows.Forms.TextBox();
+ this.btnOpenSettingsFolder = new System.Windows.Forms.Button();
+ this.boxEnableTexture2D = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@@ -149,7 +151,7 @@ private void InitializeComponent()
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(12, 217);
+ this.label1.Location = new System.Drawing.Point(9, 243);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(182, 13);
this.label1.TabIndex = 2;
@@ -284,11 +286,34 @@ private void InitializeComponent()
this.boxScaleFactor.Text = "1,0";
this.boxScaleFactor.TextChanged += new System.EventHandler(this.boxScaleFactor_TextChanged);
//
+ // btnOpenSettingsFolder
+ //
+ this.btnOpenSettingsFolder.Location = new System.Drawing.Point(18, 220);
+ this.btnOpenSettingsFolder.Name = "btnOpenSettingsFolder";
+ this.btnOpenSettingsFolder.Size = new System.Drawing.Size(147, 20);
+ this.btnOpenSettingsFolder.TabIndex = 15;
+ this.btnOpenSettingsFolder.Text = "Open Setting Folder";
+ this.btnOpenSettingsFolder.UseVisualStyleBackColor = true;
+ this.btnOpenSettingsFolder.Click += new System.EventHandler(this.btnOpenSettingsFolder_Click);
+ //
+ // boxEnableTexture2D
+ //
+ this.boxEnableTexture2D.AutoSize = true;
+ this.boxEnableTexture2D.Location = new System.Drawing.Point(258, 147);
+ this.boxEnableTexture2D.Name = "boxEnableTexture2D";
+ this.boxEnableTexture2D.Size = new System.Drawing.Size(102, 17);
+ this.boxEnableTexture2D.TabIndex = 16;
+ this.boxEnableTexture2D.Text = "Texture Support";
+ this.boxEnableTexture2D.UseVisualStyleBackColor = true;
+ this.boxEnableTexture2D.CheckedChanged += new System.EventHandler(this.boxEnableTexture2D_CheckedChanged);
+ //
// Options
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(360, 249);
+ this.ClientSize = new System.Drawing.Size(356, 265);
+ this.Controls.Add(this.boxEnableTexture2D);
+ this.Controls.Add(this.btnOpenSettingsFolder);
this.Controls.Add(this.boxScaleFactor);
this.Controls.Add(this.label2);
this.Controls.Add(this.boxGenerateMipmaps);
@@ -340,5 +365,7 @@ private void InitializeComponent()
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox boxScaleFactor;
private System.Windows.Forms.RadioButton btnViewPack;
+ private System.Windows.Forms.Button btnOpenSettingsFolder;
+ private System.Windows.Forms.CheckBox boxEnableTexture2D;
}
}
\ No newline at end of file
diff --git a/GPK_RePack/Forms/Options.cs b/GPK_RePack/Forms/Options.cs
index fd06e51..6d74da3 100644
--- a/GPK_RePack/Forms/Options.cs
+++ b/GPK_RePack/Forms/Options.cs
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Configuration;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -68,6 +71,7 @@ private void Options_Load(object sender, EventArgs e)
boxJitData.Checked = Settings.Default.JitData;
boxGenerateMipmaps.Checked = Settings.Default.GenerateMipMaps;
boxScaleFactor.Text = Settings.Default.ScaleFactorHack.ToString();
+ boxEnableTexture2D.Checked = Settings.Default.EnableTexture2D;
}
private void Options_FormClosed(object sender, FormClosedEventArgs e)
@@ -163,6 +167,17 @@ private void boxScaleFactor_TextChanged(object sender, EventArgs e)
}
}
-
+ private void btnOpenSettingsFolder_Click(object sender, EventArgs e)
+ {
+ var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
+ var folder = Path.GetDirectoryName(config.FilePath);
+ Process.Start("explorer.exe", folder);
+
+ }
+
+ private void boxEnableTexture2D_CheckedChanged(object sender, EventArgs e)
+ {
+ Settings.Default.EnableTexture2D = boxEnableTexture2D.Checked;
+ }
}
}
diff --git a/GPK_RePack/GPK_RePack.csproj b/GPK_RePack/GPK_RePack.csproj
index 29dcab6..3f217ba 100644
--- a/GPK_RePack/GPK_RePack.csproj
+++ b/GPK_RePack/GPK_RePack.csproj
@@ -9,7 +9,7 @@
Properties
GPK_RePack
Terahelper
- v4.6.1
+ v4.7.1
512
false
@@ -104,6 +104,7 @@
+
diff --git a/GPK_RePack/IO/Reader.cs b/GPK_RePack/IO/Reader.cs
index aa8d762..b7e5161 100644
--- a/GPK_RePack/IO/Reader.cs
+++ b/GPK_RePack/IO/Reader.cs
@@ -382,7 +382,11 @@ public static void ParsePayload(GpkPackage package, GpkExport export)
export.Payload = new SoundCue();
break;
case "Core.Texture2D":
- //export.Payload = new Texture2D();
+ if (Settings.Default.EnableTexture2D)
+ {
+ export.Payload = new Texture2D();
+ }
+
break;
}
diff --git a/GPK_RePack/IO/Writer.cs b/GPK_RePack/IO/Writer.cs
index 6595706..042b23e 100644
--- a/GPK_RePack/IO/Writer.cs
+++ b/GPK_RePack/IO/Writer.cs
@@ -73,7 +73,8 @@ public void SaveGpkPackage(GpkPackage package, string savepath)
WriteImports(writer, package);
WriteExports(writer, package);
WriteExportsData(writer, package);
- WriteFilePadding(writer, package, compuSize);
+ //WriteFilePadding(writer, package, compuSize);
+ WriteFileEnding(writer, package, compuSize);
}
watch.Stop();
@@ -347,6 +348,19 @@ private void WriteFilePadding(BinaryWriter writer, GpkPackage package, int compu
logger.Info("New size {0} bytes, Old size {1} bytes. +{2} bytes", final_size, package.OrginalSize, final_size - package.OrginalSize);
}
+ }
+
+ private void WriteFileEnding(BinaryWriter writer, GpkPackage package, int compuSize)
+ {
+ long final_size = writer.BaseStream.Position + 4;
+ writer.Write((int)final_size);
+
+ logger.Debug("New size: {0}, Old size: {1}", final_size, package.OrginalSize);
+ logger.Debug("Compu Size: {0}, Diff: {1} -", compuSize, final_size - compuSize);
+
+
+
+
}
public static int GetStringBytes(string text, bool isUnicode)
@@ -377,7 +391,7 @@ public static void WriteUnicodeString(BinaryWriter writer, string text, bool inc
{
if (includeHeader)
{
- writer.Write(text.Length + 1 * -1);
+ writer.Write((text.Length + 1) * -1);
}
writer.Write(Encoding.Unicode.GetBytes(text));
writer.Write(new short());
diff --git a/GPK_RePack/MiscFuncs.cs b/GPK_RePack/MiscFuncs.cs
index 9eb2b84..ec1a45d 100644
--- a/GPK_RePack/MiscFuncs.cs
+++ b/GPK_RePack/MiscFuncs.cs
@@ -151,15 +151,27 @@ public static string GenerateSaveDialog(string filename, string ext)
return "";
}
- public static String[] GenerateOpenDialog(bool multiselect)
+ [STAThread]
+ public static String[] GenerateOpenDialog(bool multiselect, Control cnt, bool useWorkingDir = true)
{
OpenFileDialog open = new OpenFileDialog();
open.Multiselect = multiselect;
open.ValidateNames = true;
- open.InitialDirectory = Settings.Default.OpenDir;
+ open.InitialDirectory = useWorkingDir ? Settings.Default.WorkingDir : Settings.Default.OpenDir;
open.ShowDialog();
- if (File.Exists(open.FileName)) Settings.Default.OpenDir = Path.GetDirectoryName(open.FileName);
+ if (File.Exists(open.FileName))
+ {
+ if (useWorkingDir)
+ {
+ Settings.Default.WorkingDir = Path.GetDirectoryName(open.FileName);
+ } else
+ {
+ Settings.Default.OpenDir = Path.GetDirectoryName(open.FileName);
+ }
+
+ }
+
return open.FileNames;
}
diff --git a/GPK_RePack/Model/Payload/ChunkBlock.cs b/GPK_RePack/Model/Payload/ChunkBlock.cs
index 82dc9e2..53a82f7 100644
--- a/GPK_RePack/Model/Payload/ChunkBlock.cs
+++ b/GPK_RePack/Model/Payload/ChunkBlock.cs
@@ -64,7 +64,7 @@ public void decompress(int compFlag)
if (uncompressedData != null)
{
uncompressedDataSize = uncompressedData.Length;
- compressedData = null; //save memory
+ //compressedData = null; //save memory
}
}
@@ -102,10 +102,7 @@ public void compress(int compFlag)
}
}
- if (compressedData != null)
- {
- compressedSize = compressedData.Length;
- }
+ compressedSize = compressedData.Length;
}
}
}
diff --git a/GPK_RePack/Model/Payload/Texture2D.cs b/GPK_RePack/Model/Payload/Texture2D.cs
index 3b6233d..5cb110a 100644
--- a/GPK_RePack/Model/Payload/Texture2D.cs
+++ b/GPK_RePack/Model/Payload/Texture2D.cs
@@ -53,7 +53,7 @@ public void WriteData(BinaryWriter writer, GpkPackage package, GpkExport export)
foreach (var map in maps)
{
//refressh block info, compress blocks
- map.generateBlocks();
+ //map.generateBlocks();
//chunk
//info
diff --git a/GPK_RePack/Properties/Settings.Designer.cs b/GPK_RePack/Properties/Settings.Designer.cs
index c9d328d..7617fcd 100644
--- a/GPK_RePack/Properties/Settings.Designer.cs
+++ b/GPK_RePack/Properties/Settings.Designer.cs
@@ -169,7 +169,7 @@ public float ScaleFactorHack {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool EnableTexture2D {
get {
return ((bool)(this["EnableTexture2D"]));
@@ -178,5 +178,17 @@ public bool EnableTexture2D {
this["EnableTexture2D"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string WorkingDir {
+ get {
+ return ((string)(this["WorkingDir"]));
+ }
+ set {
+ this["WorkingDir"] = value;
+ }
+ }
}
}
diff --git a/GPK_RePack/Properties/Settings.settings b/GPK_RePack/Properties/Settings.settings
index 961712d..5052fae 100644
--- a/GPK_RePack/Properties/Settings.settings
+++ b/GPK_RePack/Properties/Settings.settings
@@ -38,5 +38,11 @@
1
+
+ True
+
+
+
+
\ No newline at end of file