Skip to content

Commit 9d0695a

Browse files
committed
Update Debug Info generation for MonkeyLoader standard
1 parent 02812ab commit 9d0695a

5 files changed

Lines changed: 52 additions & 21 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using MonkeyLoader.Configuration;
2+
using System;
3+
4+
namespace DynamicVariablePowerTools
5+
{
6+
internal sealed class DebugInfoConfig : ConfigSection
7+
{
8+
private static readonly DefiningConfigKey<bool> _enableLinkedComponentHierarchy = new("EnableLinkedComponentHierarchy", "Allow generating a hierarchical list of all dynamic variable components linked to a space.", () => true);
9+
private static readonly DefiningConfigKey<bool> _enableLinkedVariablesList = new("EnableLinkedVariablesList", "Allow generating a list of all dynamic variable definitions linked to a space.", () => true);
10+
public override string Description => "Contains the options for the available debug info buttons on DynamicVariableSpace Components.";
11+
12+
public bool EnableLinkedComponentHierarchy => _enableLinkedComponentHierarchy;
13+
public bool EnableLinkedVariablesList => _enableLinkedVariablesList;
14+
public override string Id => "DebugInfo";
15+
public override Version Version { get; } = new Version(1, 0, 0);
16+
}
17+
}

DynamicVariablePowerTools/DynVarSpaceTree.cs renamed to DynamicVariablePowerTools/DebugInfoGenerator.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using System.Reflection;
65
using System.Text;
76
using FrooxEngine;
8-
using FrooxEngine.UIX;
7+
using MonkeyLoader.Resonite;
98
using MonkeyLoader.Resonite.UI;
109

1110
namespace DynamicVariablePowerTools
1211
{
13-
internal sealed class DynVarSpaceTree : ResoniteInspectorMonkey<DynVarSpaceTree, BuildInspectorBodyEvent, DynamicVariableSpace>
12+
internal sealed class DebugInfoGenerator : ConfiguredResoniteInspectorMonkey<DebugInfoGenerator, DebugInfoConfig, BuildInspectorBodyEvent, DynamicVariableSpace>
1413
{
15-
//[AutoRegisterConfigKey]
16-
//private static readonly ModConfigurationKey<bool> EnableLinkedVariablesList = new("EnableLinkedVariablesList", "Allow generating a list of dynamic variable definitions for a space.", () => true);
17-
18-
//[AutoRegisterConfigKey]
19-
//private static readonly ModConfigurationKey<bool> EnableVariableHierarchy = new("EnableVariableHierarchy", "Allow generating a hierarchy of dynamic variable components for a space.", () => true);
14+
/// <inheritdoc/>
15+
public override bool CanBeDisabled => true;
2016

17+
/// <inheritdoc/>
2118
public override int Priority => -HarmonyLib.Priority.High;
2219

2320
/// <inheritdoc/>
@@ -28,16 +25,22 @@ protected override void Handle(BuildInspectorBodyEvent eventData)
2825

2926
var outputField = ui.Current.AttachComponent<ValueField<string>>();
3027

31-
//if (Config.GetValue(EnableLinkedVariablesList))
32-
ui.LocalActionButton("Output names of linked Variables", _ => OutputVariableNames(space, outputField.Value));
28+
if (ConfigSection.EnableLinkedVariablesList)
29+
{
30+
ui.LocalActionButton(Mod.GetLocaleString("EnableLinkedVariablesList.Button"), _ => OutputLinkedVariables(space, outputField.Value))
31+
.WithTooltip(Mod.GetLocaleString("EnableLinkedVariablesList.Tooltip"));
32+
}
3333

34-
//if (Config.GetValue(EnableVariableHierarchy))
35-
ui.LocalActionButton("Output tree of linked Variable Hierarchy", _ => OutputVariableHierarchy(space, outputField.Value));
34+
if (ConfigSection.EnableLinkedComponentHierarchy)
35+
{
36+
ui.LocalActionButton(Mod.GetLocaleString("EnableLinkedComponentHierarchy.Button"), _ => OutputComponentHierarchy(space, outputField.Value))
37+
.WithTooltip(Mod.GetLocaleString("EnableLinkedComponentHierarchy.Tooltip"));
38+
}
3639

3740
SyncMemberEditorBuilder.Build(outputField.Value, "Output", outputField.GetSyncMemberFieldInfo("Value"), ui);
3841
}
3942

40-
private static void OutputVariableHierarchy(DynamicVariableSpace space, Sync<string> target)
43+
private static void OutputComponentHierarchy(DynamicVariableSpace space, Sync<string> target)
4144
{
4245
space.StartTask(async () =>
4346
{
@@ -52,9 +55,9 @@ private static void OutputVariableHierarchy(DynamicVariableSpace space, Sync<str
5255
});
5356
}
5457

55-
private static void OutputVariableNames(DynamicVariableSpace space, Sync<string> target)
58+
private static void OutputLinkedVariables(DynamicVariableSpace space, Sync<string> target)
5659
{
57-
var names = new StringBuilder("Variables linked to Namespace ");
60+
var names = new StringBuilder($"Variables linked to Namespace [{space.SpaceName}] on {space.Slot.Name}");
5861
names.Append(space.SpaceName);
5962
names.AppendLine(":");
6063

DynamicVariablePowerTools/Locale/en.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
"localeCode": "en",
33
"authors": [ "Banane9" ],
44
"messages": {
5-
"FlexibleContactsSort.Pin": "Pin Contact",
6-
"FlexibleContactsSort.Unpin": "Unpin Contact"
5+
"DynamicVariablePowerTools.EnableLinkedVariablesList.Name": "Variable Definitions",
6+
"DynamicVariablePowerTools.EnableLinkedVariablesList.Description": "Allow generating a list of all dynamic variable definitions linked to a space.",
7+
"DynamicVariablePowerTools.EnableLinkedVariablesList.Button": "Output Variable Definitions",
8+
"DynamicVariablePowerTools.EnableLinkedVariablesList.Tooltip": "Generates a list of all dynamic variable definitions linked to this space in the <i>Output</i> field.",
9+
10+
"DynamicVariablePowerTools.EnableLinkedComponentHierarchy.Name": "Component Hierarchy",
11+
"DynamicVariablePowerTools.EnableLinkedComponentHierarchy.Description": "Allow generating a hierarchical list of all dynamic variable components linked to a space.",
12+
"DynamicVariablePowerTools.EnableLinkedComponentHierarchy.Button": "Output Component Hierarchy",
13+
"DynamicVariablePowerTools.EnableLinkedComponentHierarchy.Tooltip": "Generates a hierarchical list of all dynamic variable components linked to this space in the <i>Output</i> field.",
14+
15+
"DynamicVariablePowerTools.DebugInfo.Name": "Debug Info"
716
}
817
}

DynamicVariablePowerTools/RenameDirectlyLinkedDynVars.cs renamed to DynamicVariablePowerTools/RenameDirectlyLinkedVariables.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
namespace DynamicVariablePowerTools
1111
{
12-
[HarmonyPatchCategory(nameof(RenameDirectlyLinkedDynVars))]
12+
[HarmonyPatchCategory(nameof(RenameDirectlyLinkedVariables))]
1313
[HarmonyPatch(typeof(DynamicVariableSpace), nameof(DynamicVariableSpace.UpdateName))]
14-
internal sealed class RenameDirectlyLinkedDynVars : ResoniteMonkey<RenameDirectlyLinkedDynVars>
14+
internal sealed class RenameDirectlyLinkedVariables : ResoniteMonkey<RenameDirectlyLinkedVariables>
1515
{
1616
//[AutoRegisterConfigKey]
1717
//private static ModConfigurationKey<bool> ChangeDynVarNamespaces = new ModConfigurationKey<bool>("ChangeDynVarNamespaces", "Enable searching and renaming directly linked variables and drivers when namespace changes.", () => false);

DynamicVariablePowerTools/SpaceTree.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using FrooxEngine;
7-
using HarmonyLib;
87

98
namespace DynamicVariablePowerTools
109
{
@@ -32,7 +31,10 @@ public bool Process()
3231

3332
public override string ToString()
3433
{
35-
var builder = new StringBuilder(_space.Slot.Name).Append(": Namespace ").AppendLine(_space.SpaceName);
34+
var builder = new StringBuilder("Hierarchy of linked dynamic variable components of Namespace [")
35+
.Append(_space.SpaceName)
36+
.Append("] on ")
37+
.AppendLine(_space.Slot.Name);
3638

3739
BuildString(builder, "");
3840
builder.Remove(builder.Length - Environment.NewLine.Length, Environment.NewLine.Length);

0 commit comments

Comments
 (0)