-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldForm.cs
More file actions
97 lines (76 loc) · 3.09 KB
/
WorldForm.cs
File metadata and controls
97 lines (76 loc) · 3.09 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Windows.Forms;
using R2ObjView.SPO;
using Ray2Mod.Components.Types;
using Ray2Mod.Game;
using Ray2Mod.Game.Structs.SPO;
namespace R2ObjView
{
public unsafe partial class WorldForm : ChildFrame
{
public override ToolStrip ChildToolStrip => toolStrip;
private TreeNode activeWorld;
private TreeNode inactiveWorld;
private TreeNode fatherSector;
private ObjectTreeManager treeManager;
private bool GroupSpo => fmiToolStripButton.Checked;
public WorldForm()
{
InitializeComponent();
Icon = Resources.IconWorld;
treeManager = new ObjectTreeManager();
treeManager.InitIcons(worldTree);
InitWorldTree();
}
protected override void RefreshData()
{
UpdateWorldTree();
}
private void InitWorldTree()
{
spoToolStripButton.Enabled = false;
treeManager.Clear();
worldTree.Nodes.Clear();
activeWorld = treeManager.NewTreeNode("Active Dynamic World", IconId.World);
inactiveWorld = treeManager.NewTreeNode("Inactive Dynamic World", IconId.World);
fatherSector = treeManager.NewTreeNode("Father Sector", IconId.World);
worldTree.Nodes.Add(activeWorld);
worldTree.Nodes.Add(inactiveWorld);
worldTree.Nodes.Add(fatherSector);
UpdateWorldTree();
}
private void UpdateWorldTree()
{
treeManager.InvalidateAll();
ObjectTreeManager.GetCallbackDelegate getCallbackMethod = treeManager.GetEnumCallback(GroupSpo);
int nActive = Acp.XHIE_fn_lEnumSpoChildren(*(SuperObject**)Offsets.ActiveDynamicWorld,
getCallbackMethod(activeWorld));
int nInactive = Acp.XHIE_fn_lEnumSpoChildren(*(SuperObject**)Offsets.InactiveDynamicWorld,
getCallbackMethod(inactiveWorld));
int nSectors = Acp.XHIE_fn_lEnumSpoChildren(*(SuperObject**)Offsets.FatherSector, treeManager.GetEnumNonGroupedSpoCallback(fatherSector));
treeManager.RemoveInvalidated(GroupSpo);
ChildStatusText = $"Active: {nActive} objects, Inactive: {nInactive} objects, Sectors: {nSectors} objects.";
MainFrame.Instance.SetStatus(this, ChildStatusText);
}
private void fmiToolStripButton_CheckedChanged(object sender, EventArgs e)
{
InitWorldTree();
}
private void worldTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
treeManager.ShowSpoDetails(e.Node);
}
}
private void spoToolStripButton_Click(object sender, EventArgs e)
{
TreeNode node = worldTree.SelectedNode;
treeManager.ShowSpoDetails(node);
}
private void worldTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
spoToolStripButton.Enabled = e.Node.Tag is Pointer<SuperObject>;
}
}
}