mirror of
https://github.com/aelurum/AssetStudio.git
synced 2026-11-14 11:18:47 -05:00
Improve support for legacy Unity versions (WIP). Close #103
This commit is contained in:
@@ -8,6 +8,7 @@ namespace AssetStudioGUI
|
||||
{
|
||||
public partial class ImportOptionsForm : Form
|
||||
{
|
||||
private static readonly string SampleVersion = "e.g. 2022.3.2f1";
|
||||
private readonly AssetsManager _assetsManager;
|
||||
private string _cachePath;
|
||||
|
||||
@@ -19,18 +20,22 @@ namespace AssetStudioGUI
|
||||
{
|
||||
customUnityVersionTextBox.Text = assetsManager.Options.CustomUnityVersion.FullVersion;
|
||||
}
|
||||
unityVerAutoRadioButton.Checked = true;
|
||||
else
|
||||
{
|
||||
ResetUnityVersionTextBox();
|
||||
}
|
||||
legacyUnityVersionComboBox.SelectedIndex = SetLegacyUnityVersionComboBoxIndex();
|
||||
cachePathLabel.AutoSize = IsWine; //to disable AutoEllipsis in Wine
|
||||
_cachePath = _assetsManager.Options.BundleOptions.CustomCachePath;
|
||||
DisplayCachePath();
|
||||
alwaysDecompressToDiskCheckBox.Checked = assetsManager.Options.BundleOptions.DecompressToDisk;
|
||||
customBlockInfoCompressionComboBox.SelectedIndex = SetComboBoxIndex(assetsManager.Options.BundleOptions.CustomBlockInfoCompression);
|
||||
customBlockCompressionComboBox.SelectedIndex = SetComboBoxIndex(assetsManager.Options.BundleOptions.CustomBlockCompression);
|
||||
customBlockInfoCompressionComboBox.SelectedIndex = SetCompressionComboBoxIndex(assetsManager.Options.BundleOptions.CustomBlockInfoCompression);
|
||||
customBlockCompressionComboBox.SelectedIndex = SetCompressionComboBoxIndex(assetsManager.Options.BundleOptions.CustomBlockCompression);
|
||||
}
|
||||
|
||||
private void ApplyOptions()
|
||||
{
|
||||
if (string.IsNullOrEmpty(customUnityVersionTextBox.Text))
|
||||
if (string.IsNullOrEmpty(customUnityVersionTextBox.Text) || customUnityVersionTextBox.Text == SampleVersion)
|
||||
{
|
||||
_assetsManager.Options.CustomUnityVersion = null;
|
||||
}
|
||||
@@ -39,6 +44,7 @@ namespace AssetStudioGUI
|
||||
try
|
||||
{
|
||||
_assetsManager.Options.CustomUnityVersion = new UnityVersion(customUnityVersionTextBox.Text);
|
||||
legacyUnityVersionComboBox.SelectedIndex = SetLegacyUnityVersionComboBoxIndex();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -61,6 +67,79 @@ namespace AssetStudioGUI
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
#region General
|
||||
private void customUnityVersionTextBox_Enter(object sender, EventArgs e)
|
||||
{
|
||||
if (customUnityVersionTextBox.Text == SampleVersion)
|
||||
{
|
||||
customUnityVersionTextBox.Text = "";
|
||||
customUnityVersionTextBox.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
}
|
||||
}
|
||||
|
||||
private void customUnityVersionTextBox_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(customUnityVersionTextBox.Text))
|
||||
{
|
||||
ResetUnityVersionTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetUnityVersionTextBox()
|
||||
{
|
||||
customUnityVersionTextBox.ForeColor = System.Drawing.SystemColors.GrayText;
|
||||
customUnityVersionTextBox.Text = SampleVersion;
|
||||
}
|
||||
|
||||
private void legacyUnityVersionComboBox_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
var version = GetLegacyUnityVersion(legacyUnityVersionComboBox.SelectedIndex);
|
||||
if (version != null)
|
||||
{
|
||||
customUnityVersionTextBox.ForeColor = System.Drawing.SystemColors.WindowText;
|
||||
customUnityVersionTextBox.Text = version.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetUnityVersionTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
private static UnityVersion GetLegacyUnityVersion(int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: return null;
|
||||
case 1: return new UnityVersion(1, 2);
|
||||
case 2: return new UnityVersion(1, 6);
|
||||
case 3: return new UnityVersion(2, 0);
|
||||
case 4: return new UnityVersion(2, 1);
|
||||
case 5: return new UnityVersion(2, 5);
|
||||
case 6: return new UnityVersion(2, 6);
|
||||
default: throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
private int SetLegacyUnityVersionComboBoxIndex()
|
||||
{
|
||||
var version = _assetsManager.Options.CustomUnityVersion;
|
||||
|
||||
switch (version?.Major)
|
||||
{
|
||||
case 2 when version.Minor >= 6: return 6;
|
||||
case 2 when version.Minor == 5: return 5;
|
||||
case 2 when version.Minor > 0: return 4;
|
||||
case 2: return 3;
|
||||
case 1 when version.Minor >= 7: return 4;
|
||||
case 1 when version.Minor >= 5: return 2;
|
||||
case 1: return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Asset Bundles
|
||||
private static CompressionType GetCustomCompressionTypes(int index)
|
||||
{
|
||||
switch (index)
|
||||
@@ -74,7 +153,7 @@ namespace AssetStudioGUI
|
||||
}
|
||||
}
|
||||
|
||||
private static int SetComboBoxIndex(CompressionType compressionType)
|
||||
private static int SetCompressionComboBoxIndex(CompressionType compressionType)
|
||||
{
|
||||
switch (compressionType)
|
||||
{
|
||||
@@ -126,6 +205,7 @@ namespace AssetStudioGUI
|
||||
_assetsManager.Options.SaveToFile(savePath);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void closeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user