From 6da2387c8c64ad154da405edd89450e345eec6e0 Mon Sep 17 00:00:00 2001
From: Razmoth <32140579+Razmoth@users.noreply.github.com>
Date: Sun, 13 Aug 2023 19:20:54 +0400
Subject: [PATCH] - [GUI] Remember last selected CABMap if exists. - [GUI] Only
apply UnityCN key changes if game is selected.
---
AssetStudio/AssetsHelper.cs | 7 +++--
AssetStudioGUI/App.config | 3 ++
AssetStudioGUI/AssetStudioGUIForm.cs | 28 +++++++++++++++++--
.../Properties/Settings.Designer.cs | 12 ++++++++
AssetStudioGUI/Properties/Settings.settings | 3 ++
AssetStudioGUI/UnityCNForm.cs | 6 +++-
6 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/AssetStudio/AssetsHelper.cs b/AssetStudio/AssetsHelper.cs
index 060a9aa..d5cfbcd 100644
--- a/AssetStudio/AssetsHelper.cs
+++ b/AssetStudio/AssetsHelper.cs
@@ -189,7 +189,7 @@ private static void DumpCABMap(string mapName)
}
}
- public static void LoadCABMap(string mapName)
+ public static bool LoadCABMap(string mapName)
{
Logger.Info($"Loading {mapName}");
try
@@ -224,8 +224,11 @@ public static void LoadCABMap(string mapName)
}
catch (Exception e)
{
- Logger.Warning($"{mapName} was not loaded, {e}");
+ Logger.Warning($"{mapName} was not loaded, {e}");
+ return false;
}
+
+ return true;
}
public static void BuildAssetMap(string[] files, string mapName, Game game, string savePath, ExportListType exportListType, ManualResetEvent resetEvent = null, ClassIDType[] typeFilters = null, Regex[] nameFilters = null, Regex[] containerFilters = null)
diff --git a/AssetStudioGUI/App.config b/AssetStudioGUI/App.config
index b123ea2..a6385df 100644
--- a/AssetStudioGUI/App.config
+++ b/AssetStudioGUI/App.config
@@ -112,6 +112,9 @@
0
+
+
+
\ No newline at end of file
diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs
index b95ebdd..6d7096f 100644
--- a/AssetStudioGUI/AssetStudioGUIForm.cs
+++ b/AssetStudioGUI/AssetStudioGUIForm.cs
@@ -156,9 +156,21 @@ private void InitalizeOptions()
Studio.Game = GameManager.GetGame(Properties.Settings.Default.selectedGame);
Logger.Info($"Target Game type is {Studio.Game.Type}");
- MapNameComboBox.SelectedIndexChanged += new EventHandler(specifyNameComboBox_SelectedIndexChanged);
+ if (Studio.Game.Type.IsUnityCN())
+ {
UnityCNManager.SetKey(Properties.Settings.Default.selectedUnityCNKey);
}
+
+ MapNameComboBox.SelectedIndexChanged += new EventHandler(specifyNameComboBox_SelectedIndexChanged);
+ if (!string.IsNullOrEmpty(Properties.Settings.Default.selectedCABMapName))
+ {
+ if (!AssetsHelper.LoadCABMap(Properties.Settings.Default.selectedCABMapName))
+ {
+ Properties.Settings.Default.selectedCABMapName = "";
+ Properties.Settings.Default.Save();
+ }
+ }
+ }
private void AssetStudioGUIForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
@@ -2017,6 +2029,11 @@ private void specifyGame_SelectedIndexChanged(object sender, EventArgs e)
Studio.Game = GameManager.GetGame(Properties.Settings.Default.selectedGame);
Logger.Info($"Target Game is {Studio.Game.Name}");
+ if (Studio.Game.Type.IsUnityCN())
+ {
+ UnityCNManager.SetKey(Properties.Settings.Default.selectedUnityCNKey);
+ }
+
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
assetsManager.Game = Studio.Game;
}
@@ -2029,7 +2046,14 @@ private async void specifyNameComboBox_SelectedIndexChanged(object sender, Event
ResetForm();
var name = MapNameComboBox.SelectedItem.ToString();
- await Task.Run(() => AssetsHelper.LoadCABMap(name));
+ await Task.Run(() =>
+ {
+ if (AssetsHelper.LoadCABMap(name))
+ {
+ Properties.Settings.Default.selectedCABMapName = name;
+ Properties.Settings.Default.Save();
+ }
+ });
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
assetsManager.Game = Studio.Game;
diff --git a/AssetStudioGUI/Properties/Settings.Designer.cs b/AssetStudioGUI/Properties/Settings.Designer.cs
index cec55b5..f0f1c59 100644
--- a/AssetStudioGUI/Properties/Settings.Designer.cs
+++ b/AssetStudioGUI/Properties/Settings.Designer.cs
@@ -453,5 +453,17 @@ public int selectedUnityCNKey {
this["selectedUnityCNKey"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string selectedCABMapName {
+ get {
+ return ((string)(this["selectedCABMapName"]));
+ }
+ set {
+ this["selectedCABMapName"] = value;
+ }
+ }
}
}
diff --git a/AssetStudioGUI/Properties/Settings.settings b/AssetStudioGUI/Properties/Settings.settings
index e473a34..40ac230 100644
--- a/AssetStudioGUI/Properties/Settings.settings
+++ b/AssetStudioGUI/Properties/Settings.settings
@@ -110,5 +110,8 @@
0
+
+
+
\ No newline at end of file
diff --git a/AssetStudioGUI/UnityCNForm.cs b/AssetStudioGUI/UnityCNForm.cs
index d8956fa..50cc888 100644
--- a/AssetStudioGUI/UnityCNForm.cs
+++ b/AssetStudioGUI/UnityCNForm.cs
@@ -65,7 +65,11 @@ private void specifyUnityCNList_RowHeaderMouseDoubleClick(object sender, DataGri
}
}
UnityCNManager.SaveEntries(keys.Reverse().ToList());
- UnityCNManager.SetKey(specifyUnityCNList.CurrentRow.Index);
+
+ if (Studio.Game.Type.IsUnityCN())
+ {
+ UnityCNManager.SetKey(specifyUnityCNList.CurrentRow.Index);
+ }
Properties.Settings.Default.selectedUnityCNKey = specifyUnityCNList.CurrentRow.Index;
Properties.Settings.Default.Save();