- [GUI] Remember last selected CABMap if exists.

- [GUI] Only apply UnityCN key changes if game is selected.
This commit is contained in:
Razmoth
2023-08-13 19:20:54 +04:00
parent 463f992450
commit 6da2387c8c
6 changed files with 54 additions and 5 deletions

View File

@@ -189,7 +189,7 @@ namespace AssetStudio
} }
} }
public static void LoadCABMap(string mapName) public static bool LoadCABMap(string mapName)
{ {
Logger.Info($"Loading {mapName}"); Logger.Info($"Loading {mapName}");
try try
@@ -225,7 +225,10 @@ namespace AssetStudio
catch (Exception e) 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) 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)

View File

@@ -112,6 +112,9 @@
<setting name="selectedUnityCNKey" serializeAs="String"> <setting name="selectedUnityCNKey" serializeAs="String">
<value>0</value> <value>0</value>
</setting> </setting>
<setting name="selectedCABMapName" serializeAs="String">
<value />
</setting>
</AssetStudioGUI.Properties.Settings> </AssetStudioGUI.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@@ -156,9 +156,21 @@ namespace AssetStudioGUI
Studio.Game = GameManager.GetGame(Properties.Settings.Default.selectedGame); Studio.Game = GameManager.GetGame(Properties.Settings.Default.selectedGame);
Logger.Info($"Target Game type is {Studio.Game.Type}"); 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); 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) private void AssetStudioGUIForm_DragEnter(object sender, DragEventArgs e)
{ {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) if (e.Data.GetDataPresent(DataFormats.FileDrop))
@@ -2017,6 +2029,11 @@ namespace AssetStudioGUI
Studio.Game = GameManager.GetGame(Properties.Settings.Default.selectedGame); Studio.Game = GameManager.GetGame(Properties.Settings.Default.selectedGame);
Logger.Info($"Target Game is {Studio.Game.Name}"); Logger.Info($"Target Game is {Studio.Game.Name}");
if (Studio.Game.Type.IsUnityCN())
{
UnityCNManager.SetKey(Properties.Settings.Default.selectedUnityCNKey);
}
assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text; assetsManager.SpecifyUnityVersion = specifyUnityVersion.Text;
assetsManager.Game = Studio.Game; assetsManager.Game = Studio.Game;
} }
@@ -2029,7 +2046,14 @@ namespace AssetStudioGUI
ResetForm(); ResetForm();
var name = MapNameComboBox.SelectedItem.ToString(); 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.SpecifyUnityVersion = specifyUnityVersion.Text;
assetsManager.Game = Studio.Game; assetsManager.Game = Studio.Game;

View File

@@ -453,5 +453,17 @@ namespace AssetStudioGUI.Properties {
this["selectedUnityCNKey"] = value; 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;
}
}
} }
} }

View File

@@ -110,5 +110,8 @@
<Setting Name="selectedUnityCNKey" Type="System.Int32" Scope="User"> <Setting Name="selectedUnityCNKey" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value> <Value Profile="(Default)">0</Value>
</Setting> </Setting>
<Setting Name="selectedCABMapName" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@@ -65,7 +65,11 @@ namespace AssetStudioGUI
} }
} }
UnityCNManager.SaveEntries(keys.Reverse<UnityCN.Entry>().ToList()); UnityCNManager.SaveEntries(keys.Reverse<UnityCN.Entry>().ToList());
if (Studio.Game.Type.IsUnityCN())
{
UnityCNManager.SetKey(specifyUnityCNList.CurrentRow.Index); UnityCNManager.SetKey(specifyUnityCNList.CurrentRow.Index);
}
Properties.Settings.Default.selectedUnityCNKey = specifyUnityCNList.CurrentRow.Index; Properties.Settings.Default.selectedUnityCNKey = specifyUnityCNList.CurrentRow.Index;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();