Skip to content

Commit

Permalink
(¦2019-12-20 16:49:54
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremieCHN committed Dec 20, 2019
1 parent 5938e73 commit 33cc386
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 40 deletions.
67 changes: 42 additions & 25 deletions SceneViewer/MainForm.Designer.cs

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

41 changes: 26 additions & 15 deletions SceneViewer/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using AssetStudio;
Expand All @@ -19,22 +13,21 @@ public MainForm() {
Logger.Default = new GUILogger() {
LogEvent = new Action<string>(delegate (string msg) {
if (InvokeRequired)
BeginInvoke(new Action(delegate { toolStripStatusLabel1.Text = msg; }));
Invoke(new Action(delegate { toolStripStatusLabel1.Text = msg; }));
else
toolStripStatusLabel1.Text = msg;
})
};
Progress.Default = new GUIProgress() {
reportEvent = new Action<int>(delegate (int val) {
if (InvokeRequired)
BeginInvoke(new Action(delegate { toolStripProgressBar1.Value = val; }));
Invoke(new Action(delegate { toolStripProgressBar1.Value = val; }));
else
toolStripProgressBar1.Value = val;
})
};

manager = new AssetsManager();
scriptDumper = new ScriptDumper();
openFileDialog.Multiselect = false;
}

Expand All @@ -54,7 +47,7 @@ private void 加载文件ToolStripMenuItem_Click(object sender, EventArgs e) {
ClearForm();
ThreadPool.QueueUserWorkItem(delegate {
manager.LoadFiles(openFileDialog.FileName);
BeginInvoke(new Action(delegate { AfterLoad(); }));
Invoke(new Action(delegate { AfterLoad(); }));
});
}
}
Expand All @@ -67,7 +60,12 @@ private void 加载文件夹ToolStripMenuItem_Click(object sender, EventArgs e)
ClearForm();
ThreadPool.QueueUserWorkItem(delegate {
manager.LoadFolder(openFolderDialog.Folder);
BeginInvoke(new Action(delegate { AfterLoad(); }));
if (Directory.Exists(openFolderDialog.Folder + "\\Manager"))
scriptDumper = new ScriptDumper(openFolderDialog.Folder + "\\Manager");
else
scriptDumper = new ScriptDumper();

Invoke(new Action(delegate { AfterLoad(); }));
});
}
}
Expand Down Expand Up @@ -100,6 +98,8 @@ private void AfterLoad() {

// TODO 加载脚本视图
Logger.Info("加载脚本视图");
ScriptTree.Nodes.AddRange(ScriptViewBuilder.BuildScriptTree(manager));
Logger.Info("加载脚本视图完成");

Logger.Info("视图更新完成");
} else {
Expand All @@ -119,15 +119,17 @@ private void ClearForm() {
ExternalList.Items.Clear();
AssetObjList.Items.Clear();

// 脚本视图
ScriptTree.Nodes.Clear();

// 右侧视图
DumpText.Text = "";
FileInfoText.Text = "";

Text = "MainForm";

manager.Clear();
scriptDumper.Dispose();
scriptDumper = new ScriptDumper();
scriptDumper?.Dispose();
}

// 场景视图部分
Expand All @@ -145,7 +147,15 @@ private void ComponentTree_AfterSelect(object sender, TreeViewEventArgs e) {
var obj = ComponentTree.SelectedNode.Tag as AssetObject;
ShowInfoForObj(obj);
}


// 脚本视图部分
private void ScriptTree_AfterSelect(object sender, TreeViewEventArgs e) {
var tag = ScriptTree.SelectedNode.Tag;
if (tag is MonoScript script)
ShowInfoForObj(script);
}


// 文件视图部分
private void FileView_Selector_SelectedIndexChanged(object sender, EventArgs e) {
ExternalList.Items.Clear();
Expand Down Expand Up @@ -202,6 +212,7 @@ private void 关闭文件ToolStripMenuItem_Click(object sender, EventArgs e) {
ClearForm();
Logger.Info("文件已关闭");
}

}

public class GUILogger : ILogger {
Expand Down
1 change: 1 addition & 0 deletions SceneViewer/SceneViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<Compile Include="OpenFolderDialog.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScriptViewBuilder.cs" />
<Compile Include="UnityForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
Loading

0 comments on commit 33cc386

Please sign in to comment.