基于GUI的外挂工具应用开发流程

基于GUI的外挂工具应用开发流程

2020-05-28 01:36:29 星期四

XScope支持以统一的方式管理各种处理工具,需遵循以下开发流程,即可在系统启动时自动加载到菜单列表中。

新建一个类,继承自mImGuiTooler

重载RenderUI,开发相关功能

写界面内容即可,工具默认都以model对话框显示,这里无须考虑关闭结束等操作。

注册该工具

有两种方式,一种在插件中完成,可以写在IPlugin类里面以插件的方式自动加载,也可以在系统启动时执行,建议用插件自动注册避免重复添加,如:

ImGuiToolBox.Insatance.RegeditRootTooler(new tGeoImagePyramidTileCreator());

4.系统菜单中添加拓展工具菜单,会自动在这里以菜单的方式显示各种工具。如

1
2
3
4
5
6
7
8
9
if (ImGui.BeginMenu("文件"))
{
ImGui.EndMenu();
}
ImGuiToolBox.Insatance.DrawRoolToolBoxMenuBar();
if (ImGui.BeginMenu("帮助"))
{
ImGui.EndMenu();
}

以下为批量将GIF转换VGI渲染对象的工具。

upload successful

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
public class tPathGIFToVGISheetItemMaker : mImGuiTooler
{
private string RootPath = System.Windows.Forms.Application.StartupPath;
private string mInfo = "";
public tPathGIFToVGISheetItemMaker()
{
this.m_Name = "批量生成GIF的VGI文件";
this.RootPath = Gaiaxis.Consoles.Root.Instance.WorldSettings.CachePath;
this.mInfo = "将文件夹的GIF图片批量生成VGI文件,默认位置居中,如需改变显示位置,请自行编辑";
}
public override void RenderUI()
{
ImGui.InputText("文件夹目录", ref this.RootPath, 256, ImGuiInputTextFlags.ReadOnly);
ImGui.SameLine();
if (ImGui.Button("设置路径"))
{
ImGuiPickFolderBrowser.Instance.ShowPopupModal(this.RootPath, (s) => { this.RootPath = s; });
}
ImGuiPickFolderBrowser.Instance.DrawPopup();

ImGui.Spacing();
ImGui.Text(this.mInfo);
ImGui.Spacing();
if (ImGui.Button("批量创建"))
{
this.Process();
}
ImGui.SameLine();
if (ImGui.Button("打开目录"))
{
this.OpenProcess();
}
}
private void OpenProcess()
{
if (string.IsNullOrEmpty(this.RootPath))
{
return;
}
if (!Directory.Exists(this.RootPath))
{
return;
}
System.Diagnostics.Process.Start(this.RootPath);
}
private void Process()
{
if (string.IsNullOrEmpty(this.RootPath))
{
return;
}
if (!Directory.Exists(this.RootPath))
{
return;
}
DirectoryInfo dd = new DirectoryInfo(this.RootPath);
var giffile = dd.GetFiles("*.gif", SearchOption.TopDirectoryOnly);

foreach (var item in giffile)
{
string name = System.IO.Path.GetFileNameWithoutExtension(item.FullName);
string xmlname = System.IO.Path.Combine(this.RootPath, name + ".vgi");
XScreenAnamationImageRenderDescription des = new XScreenAnamationImageRenderDescription();
des.Name = name;
des.GifImagename = item.FullName;
des.XYWH = new Defines.RegionSize(0.2f, 0.2f, 0.6f, 0.6f);
des.Save(xmlname);
}
}
}