Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
- [GUI] Remember last selected CABMap if exists.
Browse files Browse the repository at this point in the history
- [GUI] Only apply UnityCN key changes if game is selected.
  • Loading branch information
Razmoth committed Aug 13, 2023
1 parent 463f992 commit 6da2387
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
7 changes: 5 additions & 2 deletions AssetStudio/AssetsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions AssetStudioGUI/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
<setting name="selectedUnityCNKey" serializeAs="String">
<value>0</value>
</setting>
<setting name="selectedCABMapName" serializeAs="String">
<value />
</setting>
</AssetStudioGUI.Properties.Settings>
</userSettings>
</configuration>
28 changes: 26 additions & 2 deletions AssetStudioGUI/AssetStudioGUIForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions AssetStudioGUI/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions AssetStudioGUI/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,8 @@
<Setting Name="selectedUnityCNKey" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="selectedCABMapName" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
6 changes: 5 additions & 1 deletion AssetStudioGUI/UnityCNForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ private void specifyUnityCNList_RowHeaderMouseDoubleClick(object sender, DataGri
}
}
UnityCNManager.SaveEntries(keys.Reverse<UnityCN.Entry>().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();
Expand Down

0 comments on commit 6da2387

Please sign in to comment.