using strong typing for setting

This commit is contained in:
Perfare 2020-03-25 11:18:12 +08:00
parent 14f47c6d30
commit 5c193c761a
6 changed files with 78 additions and 84 deletions

View File

@ -183,21 +183,21 @@
<ItemGroup Condition="'$(Platform)' == 'x86'">
<ContentWithTargetPath Include="Libraries\x86\fmod.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>fmod.dll</TargetPath>
<TargetPath>fmod.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="Libraries\x86\libfbxsdk.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>libfbxsdk.dll</TargetPath>
<TargetPath>libfbxsdk.dll</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x64'">
<ContentWithTargetPath Include="Libraries\x64\fmod.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>fmod.dll</TargetPath>
<TargetPath>fmod.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="Libraries\x64\libfbxsdk.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>libfbxsdk.dll</TargetPath>
<TargetPath>libfbxsdk.dll</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -147,7 +147,7 @@ namespace AssetStudioGUI
var tempDic = new Dictionary<Object, AssetItem>();
if (!dontBuildAssetListMenuItem.Checked)
{
BuildAssetList(tempDic, displayAll.Checked, displayOriginalName.Checked, out productName);
BuildAssetList(tempDic, out productName);
}
List<TreeNode> treeNodeCollection = null;
@ -412,7 +412,7 @@ namespace AssetStudioGUI
PreviewAsset(lastLoadedAsset);
}
Properties.Settings.Default["enablePreview"] = enablePreview.Checked;
Properties.Settings.Default.enablePreview = enablePreview.Checked;
Properties.Settings.Default.Save();
}
@ -427,7 +427,7 @@ namespace AssetStudioGUI
assetInfoLabel.Visible = false;
}
Properties.Settings.Default["displayInfo"] = displayInfo.Checked;
Properties.Settings.Default.displayInfo = displayInfo.Checked;
Properties.Settings.Default.Save();
}
@ -439,7 +439,7 @@ namespace AssetStudioGUI
private void assetGroupOptions_SelectedIndexChanged(object sender, EventArgs e)
{
Properties.Settings.Default["assetGroupOption"] = ((ToolStripComboBox)sender).SelectedIndex;
Properties.Settings.Default.assetGroupOption = ((ToolStripComboBox)sender).SelectedIndex;
Properties.Settings.Default.Save();
}
@ -1489,12 +1489,12 @@ namespace AssetStudioGUI
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
InitializeComponent();
displayOriginalName.Checked = (bool)Properties.Settings.Default["displayOriginalName"];
displayAll.Checked = (bool)Properties.Settings.Default["displayAll"];
displayInfo.Checked = (bool)Properties.Settings.Default["displayInfo"];
enablePreview.Checked = (bool)Properties.Settings.Default["enablePreview"];
openAfterExport.Checked = (bool)Properties.Settings.Default["openAfterExport"];
assetGroupOptions.SelectedIndex = (int)Properties.Settings.Default["assetGroupOption"];
displayOriginalName.Checked = Properties.Settings.Default.displayOriginalName;
displayAll.Checked = Properties.Settings.Default.displayAll;
displayInfo.Checked = Properties.Settings.Default.displayInfo;
enablePreview.Checked = Properties.Settings.Default.enablePreview;
openAfterExport.Checked = Properties.Settings.Default.openAfterExport;
assetGroupOptions.SelectedIndex = Properties.Settings.Default.assetGroupOption;
FMODinit();
Logger.Default = new GUILogger(StatusStripUpdate);
@ -1832,7 +1832,7 @@ namespace AssetStudioGUI
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
var exportPath = saveFolderDialog1.Folder + "\\Animator\\";
ExportAnimatorWithAnimationClip(animator, animationList, exportPath, openAfterExport.Checked);
ExportAnimatorWithAnimationClip(animator, animationList, exportPath);
}
}
}
@ -1864,7 +1864,7 @@ namespace AssetStudioGUI
animationList = null;
}
}
ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes, openAfterExport.Checked, animationList);
ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes, animationList);
}
}
else
@ -1905,7 +1905,7 @@ namespace AssetStudioGUI
animationList = null;
}
}
ExportObjectsMergeWithAnimationClip(exportPath, openAfterExport.Checked, gameObjects, animationList);
ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList);
}
}
}
@ -1973,7 +1973,7 @@ namespace AssetStudioGUI
if (saveFolderDialog1.ShowDialog(this) == DialogResult.OK)
{
var savePath = saveFolderDialog1.Folder + "\\";
ExportSplitObjects(savePath, sceneTreeView.Nodes, openAfterExport.Checked);
ExportSplitObjects(savePath, sceneTreeView.Nodes);
}
}
else
@ -2044,7 +2044,7 @@ namespace AssetStudioGUI
toExportAssets = visibleAssets;
break;
}
Studio.ExportAssets(saveFolderDialog1.Folder, toExportAssets, assetGroupOptions.SelectedIndex, openAfterExport.Checked, exportType);
Studio.ExportAssets(saveFolderDialog1.Folder, toExportAssets, exportType);
}
}
else

View File

@ -15,9 +15,9 @@ namespace AssetStudioGUI
public ExportOptions()
{
InitializeComponent();
converttexture.Checked = (bool)Properties.Settings.Default["convertTexture"];
convertAudio.Checked = (bool)Properties.Settings.Default["convertAudio"];
var str = (string)Properties.Settings.Default["convertType"];
converttexture.Checked = Properties.Settings.Default.convertTexture;
convertAudio.Checked = Properties.Settings.Default.convertAudio;
var str = Properties.Settings.Default.convertType;
foreach (Control c in panel1.Controls)
{
if (c.Text == str)
@ -26,42 +26,42 @@ namespace AssetStudioGUI
break;
}
}
eulerFilter.Checked = (bool)Properties.Settings.Default["eulerFilter"];
filterPrecision.Value = (decimal)Properties.Settings.Default["filterPrecision"];
exportAllNodes.Checked = (bool)Properties.Settings.Default["exportAllNodes"];
exportSkins.Checked = (bool)Properties.Settings.Default["exportSkins"];
exportAnimations.Checked = (bool)Properties.Settings.Default["exportAnimations"];
exportBlendShape.Checked = (bool)Properties.Settings.Default["exportBlendShape"];
castToBone.Checked = (bool)Properties.Settings.Default["castToBone"];
boneSize.Value = (decimal)Properties.Settings.Default["boneSize"];
scaleFactor.Value = (decimal)Properties.Settings.Default["scaleFactor"];
fbxVersion.SelectedIndex = (int)Properties.Settings.Default["fbxVersion"];
fbxFormat.SelectedIndex = (int)Properties.Settings.Default["fbxFormat"];
eulerFilter.Checked = Properties.Settings.Default.eulerFilter;
filterPrecision.Value = Properties.Settings.Default.filterPrecision;
exportAllNodes.Checked = Properties.Settings.Default.exportAllNodes;
exportSkins.Checked = Properties.Settings.Default.exportSkins;
exportAnimations.Checked = Properties.Settings.Default.exportAnimations;
exportBlendShape.Checked = Properties.Settings.Default.exportBlendShape;
castToBone.Checked = Properties.Settings.Default.castToBone;
boneSize.Value = Properties.Settings.Default.boneSize;
scaleFactor.Value = Properties.Settings.Default.scaleFactor;
fbxVersion.SelectedIndex = Properties.Settings.Default.fbxVersion;
fbxFormat.SelectedIndex = Properties.Settings.Default.fbxFormat;
}
private void OKbutton_Click(object sender, EventArgs e)
{
Properties.Settings.Default["convertTexture"] = converttexture.Checked;
Properties.Settings.Default["convertAudio"] = convertAudio.Checked;
Properties.Settings.Default.convertTexture = converttexture.Checked;
Properties.Settings.Default.convertAudio = convertAudio.Checked;
foreach (Control c in panel1.Controls)
{
if (((RadioButton)c).Checked)
{
Properties.Settings.Default["convertType"] = c.Text;
Properties.Settings.Default.convertType = c.Text;
break;
}
}
Properties.Settings.Default["eulerFilter"] = eulerFilter.Checked;
Properties.Settings.Default["filterPrecision"] = filterPrecision.Value;
Properties.Settings.Default["exportAllNodes"] = exportAllNodes.Checked;
Properties.Settings.Default["exportSkins"] = exportSkins.Checked;
Properties.Settings.Default["exportAnimations"] = exportAnimations.Checked;
Properties.Settings.Default["exportBlendShape"] = exportBlendShape.Checked;
Properties.Settings.Default["castToBone"] = castToBone.Checked;
Properties.Settings.Default["boneSize"] = boneSize.Value;
Properties.Settings.Default["scaleFactor"] = scaleFactor.Value;
Properties.Settings.Default["fbxVersion"] = fbxVersion.SelectedIndex;
Properties.Settings.Default["fbxFormat"] = fbxFormat.SelectedIndex;
Properties.Settings.Default.eulerFilter = eulerFilter.Checked;
Properties.Settings.Default.filterPrecision = filterPrecision.Value;
Properties.Settings.Default.exportAllNodes = exportAllNodes.Checked;
Properties.Settings.Default.exportSkins = exportSkins.Checked;
Properties.Settings.Default.exportAnimations = exportAnimations.Checked;
Properties.Settings.Default.exportBlendShape = exportBlendShape.Checked;
Properties.Settings.Default.castToBone = castToBone.Checked;
Properties.Settings.Default.boneSize = boneSize.Value;
Properties.Settings.Default.scaleFactor = scaleFactor.Value;
Properties.Settings.Default.fbxVersion = fbxVersion.SelectedIndex;
Properties.Settings.Default.fbxFormat = fbxFormat.SelectedIndex;
Properties.Settings.Default.Save();
DialogResult = DialogResult.OK;
Close();

View File

@ -13,14 +13,13 @@ namespace AssetStudioGUI
public static bool ExportTexture2D(AssetItem item, string exportPathName)
{
var m_Texture2D = (Texture2D)item.Asset;
var convertTexture = (bool)Properties.Settings.Default["convertTexture"];
if (convertTexture)
if (Properties.Settings.Default.convertTexture)
{
var bitmap = m_Texture2D.ConvertToBitmap(true);
if (bitmap == null)
return false;
ImageFormat format = null;
var ext = (string)Properties.Settings.Default["convertType"];
var ext = Properties.Settings.Default.convertType;
bool tga = false;
switch (ext)
{
@ -66,9 +65,8 @@ namespace AssetStudioGUI
var m_AudioData = m_AudioClip.m_AudioData.Value;
if (m_AudioData == null || m_AudioData.Length == 0)
return false;
var convertAudio = (bool)Properties.Settings.Default["convertAudio"];
var converter = new AudioClipConverter(m_AudioClip);
if (convertAudio && converter.IsFMODSupport)
if (Properties.Settings.Default.convertAudio && converter.IsFMODSupport)
{
var exportFullName = exportPath + item.Text + ".wav";
if (ExportFileExists(exportFullName))
@ -261,7 +259,7 @@ namespace AssetStudioGUI
public static bool ExportSprite(AssetItem item, string exportPath)
{
ImageFormat format = null;
var type = (string)Properties.Settings.Default["convertType"];
var type = Properties.Settings.Default.convertType;
bool tga = false;
switch (type)
{
@ -341,17 +339,17 @@ namespace AssetStudioGUI
private static void ExportFbx(IImported convert, string exportPath)
{
var eulerFilter = (bool)Properties.Settings.Default["eulerFilter"];
var filterPrecision = (float)(decimal)Properties.Settings.Default["filterPrecision"];
var exportAllNodes = (bool)Properties.Settings.Default["exportAllNodes"];
var exportSkins = (bool)Properties.Settings.Default["exportSkins"];
var exportAnimations = (bool)Properties.Settings.Default["exportAnimations"];
var exportBlendShape = (bool)Properties.Settings.Default["exportBlendShape"];
var castToBone = (bool)Properties.Settings.Default["castToBone"];
var boneSize = (int)(decimal)Properties.Settings.Default["boneSize"];
var scaleFactor = (float)(decimal)Properties.Settings.Default["scaleFactor"];
var fbxVersion = (int)Properties.Settings.Default["fbxVersion"];
var fbxFormat = (int)Properties.Settings.Default["fbxFormat"];
var eulerFilter = Properties.Settings.Default.eulerFilter;
var filterPrecision = (float)Properties.Settings.Default.filterPrecision;
var exportAllNodes = Properties.Settings.Default.exportAllNodes;
var exportSkins = Properties.Settings.Default.exportSkins;
var exportAnimations = Properties.Settings.Default.exportAnimations;
var exportBlendShape = Properties.Settings.Default.exportBlendShape;
var castToBone = Properties.Settings.Default.castToBone;
var boneSize = (int)Properties.Settings.Default.boneSize;
var scaleFactor = (float)Properties.Settings.Default.scaleFactor;
var fbxVersion = Properties.Settings.Default.fbxVersion;
var fbxFormat = Properties.Settings.Default.fbxFormat;
ModelExporter.ExportFbx(exportPath, convert, eulerFilter, filterPrecision,
exportAllNodes, exportSkins, exportAnimations, exportBlendShape, castToBone, boneSize, scaleFactor, fbxVersion, fbxFormat == 1);
}

View File

@ -12,7 +12,7 @@ namespace AssetStudioGUI.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@ -96,7 +96,7 @@ namespace AssetStudioGUI
return extractedCount;
}
public static void BuildAssetList(Dictionary<Object, AssetItem> tempDic, bool displayAll, bool displayOriginalName, out string productName)
public static void BuildAssetList(Dictionary<Object, AssetItem> tempDic, out string productName)
{
StatusStripUpdate("Building asset list...");
@ -192,18 +192,14 @@ namespace AssetStudioGUI
}
//处理非法文件名
assetItem.Text = FixFileName(assetItem.Text);
if (displayAll)
{
exportable = true;
}
if (exportable)
if (Properties.Settings.Default.displayAll || exportable)
{
tempExportableAssets.Add(assetItem);
}
Progress.Report(++j, progressCount);
}
if (displayOriginalName && ab != null)
if (Properties.Settings.Default.displayOriginalName && ab != null)
{
foreach (var item in tempExportableAssets)
{
@ -351,7 +347,7 @@ namespace AssetStudioGUI
return Path.GetInvalidFileNameChars().Aggregate(str, (current, c) => current.Replace(c, '_'));
}
public static void ExportAssets(string savePath, List<AssetItem> toExportAssets, int assetGroupSelectedIndex, bool openAfterExport, ExportType exportType)
public static void ExportAssets(string savePath, List<AssetItem> toExportAssets, ExportType exportType)
{
ThreadPool.QueueUserWorkItem(state =>
{
@ -364,11 +360,11 @@ namespace AssetStudioGUI
foreach (var asset in toExportAssets)
{
var exportpath = savePath + "\\";
if (assetGroupSelectedIndex == 1)
if (Properties.Settings.Default.assetGroupOption == 1)
{
exportpath += Path.GetFileNameWithoutExtension(asset.SourceFile.fullName) + "_export\\";
}
else if (assetGroupSelectedIndex == 0)
else if (Properties.Settings.Default.assetGroupOption == 0)
{
exportpath = savePath + "\\" + asset.TypeString + "\\";
}
@ -487,14 +483,14 @@ namespace AssetStudioGUI
StatusStripUpdate(statusText);
if (openAfterExport && exportedCount > 0)
if (Properties.Settings.Default.openAfterExport && exportedCount > 0)
{
Process.Start(savePath);
}
});
}
public static void ExportSplitObjects(string savePath, TreeNodeCollection nodes, bool openAfterExport)
public static void ExportSplitObjects(string savePath, TreeNodeCollection nodes)
{
ThreadPool.QueueUserWorkItem(state =>
{
@ -547,7 +543,7 @@ namespace AssetStudioGUI
StatusStripUpdate($"Finished exporting {filename}.fbx");
}
}
if (openAfterExport)
if (Properties.Settings.Default.openAfterExport)
{
Process.Start(savePath);
}
@ -564,7 +560,7 @@ namespace AssetStudioGUI
}
}
public static void ExportAnimatorWithAnimationClip(AssetItem animator, List<AssetItem> animationList, string exportPath, bool openAfterExport)
public static void ExportAnimatorWithAnimationClip(AssetItem animator, List<AssetItem> animationList, string exportPath)
{
ThreadPool.QueueUserWorkItem(state =>
{
@ -573,7 +569,7 @@ namespace AssetStudioGUI
try
{
ExportAnimator(animator, exportPath, animationList);
if (openAfterExport)
if (Properties.Settings.Default.openAfterExport)
{
Process.Start(exportPath);
}
@ -588,7 +584,7 @@ namespace AssetStudioGUI
});
}
public static void ExportObjectsWithAnimationClip(string exportPath, TreeNodeCollection nodes, bool openAfterExport, List<AssetItem> animationList = null)
public static void ExportObjectsWithAnimationClip(string exportPath, TreeNodeCollection nodes, List<AssetItem> animationList = null)
{
ThreadPool.QueueUserWorkItem(state =>
{
@ -615,7 +611,7 @@ namespace AssetStudioGUI
Progress.Report(++i, count);
}
if (openAfterExport)
if (Properties.Settings.Default.openAfterExport)
{
Process.Start(exportPath);
}
@ -627,7 +623,7 @@ namespace AssetStudioGUI
});
}
public static void ExportObjectsMergeWithAnimationClip(string exportPath, bool openAfterExport, List<GameObject> gameObjects, List<AssetItem> animationList = null)
public static void ExportObjectsMergeWithAnimationClip(string exportPath, List<GameObject> gameObjects, List<AssetItem> animationList = null)
{
ThreadPool.QueueUserWorkItem(state =>
{
@ -645,7 +641,7 @@ namespace AssetStudioGUI
MessageBox.Show($"Export Model:{name} error\r\n{ex.Message}\r\n{ex.StackTrace}");
StatusStripUpdate("Error in export");
}
if (openAfterExport)
if (Properties.Settings.Default.openAfterExport)
{
Process.Start(Path.GetDirectoryName(exportPath));
}