Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public sealed class ExampleOptionsObject
public bool ToggleExample { get; set; }
public string DynamicInfoExample { get; set; } = "Dynamic Info";
public string InfoExample => "Info";
public Color ColorExample { get; set; }
public string StringExample { get; set; }
public int IntExample { get; set; }
public float FloatExample { get; set; }
public ExampleEnum EnumExample { get; set; }
Expand Down Expand Up @@ -162,6 +164,16 @@ This is the most part of this assets, the debug options (or widgets). Once you h
bool someBool = false;
section.AddToggle("Toggle name", val => someBool = val, () => someBool);
```
- Color: a color selector with a name. Requests a setter and a getter for the value.
```csharp
string someColor = Colors.White;
section.AddColor("Color name", val => someColor = val, () => someColor);
```
- String: a string editor with a name. Requests a setter and a getter for the value.
```csharp
string someString = "String value";
section.AddString("String name", val => someString = val, () => someString);
```
- Int: an int selector with a name. Requests a setter and a getter for the value.
```csharp
int someInt = 0;
Expand Down
327 changes: 3 additions & 324 deletions Scenes/ButtonDebugActionWidget.tscn

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions Scenes/ColorDebugActionWidget.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[gd_scene load_steps=6 format=3 uid="uid://dlm7gnw8tlsll"]

[ext_resource type="Script" path="res://addons/GDebugPanelGodot/Scripts/DebugActions/Widgets/ColorDebugActionWidget.cs" id="1_sqqip"]
[ext_resource type="FontFile" uid="uid://s3os5vbnjky3" path="res://addons/GDebugPanelGodot/Fonts/SpaceMono-Bold.ttf" id="2_8cmgh"]
[ext_resource type="Script" path="res://addons/GDebugPanelGodot/Scripts/Nodes/LabelAutowrapSelectionByControlWidthController.cs" id="3_ss8i0"]
[ext_resource type="Theme" uid="uid://ct64ildgsjeq5" path="res://addons/GDebugPanelGodot/Themes/GDebugPanelGodotTheme.tres" id="4_6urji"]

[sub_resource type="LabelSettings" id="LabelSettings_8bbui"]
line_spacing = 0.0
font = ExtResource("2_8cmgh")
font_size = 20

[node name="ColorDebugActionWidget" type="PanelContainer" node_paths=PackedStringArray("LabelAutowrapController", "Label", "ColorPickerButton")]
custom_minimum_size = Vector2(70, 40)
offset_right = 86.0
offset_bottom = 40.0
script = ExtResource("1_sqqip")
LabelAutowrapController = NodePath("MarginContainer/HBoxContainer/Label")
Label = NodePath("MarginContainer/HBoxContainer/Label")
ColorPickerButton = NodePath("MarginContainer/HBoxContainer/ColorPickerButton")

[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
mouse_filter = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
layout_mode = 2
mouse_filter = 2
theme_override_constants/separation = 10
alignment = 1

[node name="Label" type="Label" parent="MarginContainer/HBoxContainer" node_paths=PackedStringArray("ControlsSizeToSubstract")]
layout_mode = 2
size_flags_vertical = 1
text = "Toggle"
label_settings = SubResource("LabelSettings_8bbui")
vertical_alignment = 1
script = ExtResource("3_ss8i0")
MaxSizeOffset = -177.0
ControlsSizeToSubstract = []

[node name="ColorPickerButton" type="ColorPickerButton" parent="MarginContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
theme = ExtResource("4_6urji")
327 changes: 3 additions & 324 deletions Scenes/DynamicInfoDebugActionWidget.tscn

Large diffs are not rendered by default.

327 changes: 3 additions & 324 deletions Scenes/EnumDebugActionWidget.tscn

Large diffs are not rendered by default.

327 changes: 3 additions & 324 deletions Scenes/FloatDebugActionWidget.tscn

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Scenes/GDebugPanel.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://os30dycrhvs0"]
[gd_scene load_steps=17 format=3 uid="uid://os30dycrhvs0"]

[ext_resource type="Script" path="res://addons/GDebugPanelGodot/Scripts/Views/DebugPanelView.cs" id="1_3o12x"]
[ext_resource type="FontFile" uid="uid://s3os5vbnjky3" path="res://addons/GDebugPanelGodot/Fonts/SpaceMono-Bold.ttf" id="1_3wdhi"]
Expand All @@ -7,6 +7,8 @@
[ext_resource type="PackedScene" uid="uid://dast33no0qax8" path="res://addons/GDebugPanelGodot/Scenes/ButtonDebugActionWidget.tscn" id="3_r5431"]
[ext_resource type="PackedScene" uid="uid://hy0wr7qtm7vx" path="res://addons/GDebugPanelGodot/Scenes/GDebugPanelSection.tscn" id="3_rmsxo"]
[ext_resource type="PackedScene" uid="uid://ct2p5jkatd6p4" path="res://addons/GDebugPanelGodot/Scenes/ToggleDebugActionWidget.tscn" id="4_lwilv"]
[ext_resource type="PackedScene" uid="uid://jjcvncm5s1yq" path="res://addons/GDebugPanelGodot/Scenes/StringDebugActionWidget.tscn" id="7_8lp1x"]
[ext_resource type="PackedScene" uid="uid://dlm7gnw8tlsll" path="res://addons/GDebugPanelGodot/Scenes/ColorDebugActionWidget.tscn" id="7_iov0m"]
[ext_resource type="PackedScene" uid="uid://b2wgwoerjooqf" path="res://addons/GDebugPanelGodot/Scenes/IntDebugActionWidget.tscn" id="7_vbj6r"]
[ext_resource type="PackedScene" uid="uid://chrq3yyve2gwu" path="res://addons/GDebugPanelGodot/Scenes/FloatDebugActionWidget.tscn" id="8_ubasg"]
[ext_resource type="PackedScene" uid="uid://bvqepn62gdah" path="res://addons/GDebugPanelGodot/Scenes/EnumDebugActionWidget.tscn" id="9_cehxr"]
Expand Down Expand Up @@ -41,6 +43,8 @@ InfoDebugActionWidget = ExtResource("3_es4am")
DynamicInfoDebugActionWidget = ExtResource("3_c1kvk")
ButtonDebugActionWidget = ExtResource("3_r5431")
ToggleDebugActionWidget = ExtResource("4_lwilv")
ColorDebugActionWidget = ExtResource("7_iov0m")
StringDebugActionWidget = ExtResource("7_8lp1x")
IntDebugActionWidget = ExtResource("7_vbj6r")
FloatDebugActionWidget = ExtResource("8_ubasg")
EnumDebugActionWidget = ExtResource("9_cehxr")
Expand Down
327 changes: 3 additions & 324 deletions Scenes/GDebugPanelSection.tscn

Large diffs are not rendered by default.

327 changes: 3 additions & 324 deletions Scenes/InfoDebugActionWidget.tscn

Large diffs are not rendered by default.

327 changes: 3 additions & 324 deletions Scenes/IntDebugActionWidget.tscn

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions Scenes/StringDebugActionWidget.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[gd_scene load_steps=6 format=3 uid="uid://jjcvncm5s1yq"]

[ext_resource type="Script" path="res://addons/GDebugPanelGodot/Scripts/DebugActions/Widgets/StringDebugActionWidget.cs" id="1_gj7se"]
[ext_resource type="FontFile" uid="uid://s3os5vbnjky3" path="res://addons/GDebugPanelGodot/Fonts/SpaceMono-Bold.ttf" id="2_ur8dr"]
[ext_resource type="Script" path="res://addons/GDebugPanelGodot/Scripts/Nodes/LabelAutowrapSelectionByControlWidthController.cs" id="3_70l8r"]
[ext_resource type="Theme" uid="uid://ct64ildgsjeq5" path="res://addons/GDebugPanelGodot/Themes/GDebugPanelGodotTheme.tres" id="4_xxi00"]

[sub_resource type="LabelSettings" id="LabelSettings_8bbui"]
line_spacing = 0.0
font = ExtResource("2_ur8dr")
font_size = 20

[node name="StringDebugActionWidget" type="PanelContainer" node_paths=PackedStringArray("Label", "LabelAutowrapController", "LineEdit")]
custom_minimum_size = Vector2(70, 40)
offset_right = 86.0
offset_bottom = 40.0
script = ExtResource("1_gj7se")
Label = NodePath("MarginContainer/HBoxContainer/Label")
LabelAutowrapController = NodePath("MarginContainer/HBoxContainer/Label")
LineEdit = NodePath("MarginContainer/HBoxContainer/LineEdit")

[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
mouse_filter = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10

[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
layout_mode = 2
mouse_filter = 2
theme_override_constants/separation = 10
alignment = 1

[node name="Label" type="Label" parent="MarginContainer/HBoxContainer" node_paths=PackedStringArray("ControlsSizeToSubstract")]
layout_mode = 2
size_flags_vertical = 1
text = "Toggle"
label_settings = SubResource("LabelSettings_8bbui")
vertical_alignment = 1
script = ExtResource("3_70l8r")
ControlsSizeToSubstract = []
MaxSizeOffset = -177.0

[node name="LineEdit" type="LineEdit" parent="MarginContainer/HBoxContainer"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
theme = ExtResource("4_xxi00")
expand_to_text_length = true
327 changes: 3 additions & 324 deletions Scenes/ToggleDebugActionWidget.tscn

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions Scripts/DebugActions/Actions/ColorDebugAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using GDebugPanelGodot.DebugActions.Widgets;
using GDebugPanelGodot.Views;
using Godot;

namespace GDebugPanelGodot.DebugActions.Actions;

public sealed class ColorDebugAction : IDebugAction
{
public string Name { get; }
public Action<Color> SetAction { get; }
public Func<Color> GetAction { get; }

public ColorDebugAction(string name, Action<Color> setAction, Func<Color> getAction)
{
Name = name;
SetAction = setAction;
GetAction = getAction;
}

public DebugActionWidget InstantiateWidget(DebugPanelView debugPanelView)
{
ColorDebugActionWidget widget = debugPanelView.ColorDebugActionWidget!.Instantiate<ColorDebugActionWidget>();
widget.Init(debugPanelView.ContentControl!, Name, SetAction, GetAction);
return widget;
}
}
27 changes: 27 additions & 0 deletions Scripts/DebugActions/Actions/StringDebugAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using GDebugPanelGodot.DebugActions.Widgets;
using GDebugPanelGodot.Views;
using Godot;

namespace GDebugPanelGodot.DebugActions.Actions;

public sealed class StringDebugAction : IDebugAction
{
public string Name { get; }
public Action<string> SetAction { get; }
public Func<string> GetAction { get; }

public StringDebugAction(string name, Action<string> setAction, Func<string> getAction)
{
Name = name;
SetAction = setAction;
GetAction = getAction;
}

public DebugActionWidget InstantiateWidget(DebugPanelView debugPanelView)
{
StringDebugActionWidget widget = debugPanelView.StringDebugActionWidget!.Instantiate<StringDebugActionWidget>();
widget.Init(debugPanelView.ContentControl!, Name, SetAction, GetAction);
return widget;
}
}
40 changes: 40 additions & 0 deletions Scripts/DebugActions/Widgets/ColorDebugActionWidget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using GDebugPanelGodot.Extensions;
using GDebugPanelGodot.Nodes;
using Godot;

namespace GDebugPanelGodot.DebugActions.Widgets;

public partial class ColorDebugActionWidget : DebugActionWidget
{
[Export] public LabelAutowrapSelectionByControlWidthController? LabelAutowrapController;
[Export] public Label? Label;
[Export] public ColorPickerButton? ColorPickerButton;

Action<Color>? _setAction;
Func<Color>? _getAction;

public void Init(Control sizeControl, string name, Action<Color> setAction, Func<Color> getAction)
{
LabelAutowrapController!.SizeControl = sizeControl;
_setAction = setAction;
_getAction = getAction;

Label!.Text = name;
ColorPickerButton!.Color = getAction.Invoke();
ColorPickerButton!.EmitSignal(ColorPickerButton.SignalName.ColorChanged);
ColorPickerButton!.ConnectColorPickerButtonColorChanged(Changed);
}

public override bool Focus()
{
ColorPickerButton!.GrabFocus();
return true;
}

void Changed(Color color)
{
_setAction!.Invoke(color);
ColorPickerButton!.Color = _getAction!.Invoke();
}
}
42 changes: 42 additions & 0 deletions Scripts/DebugActions/Widgets/StringDebugActionWidget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using GDebugPanelGodot.Extensions;
using GDebugPanelGodot.Nodes;
using Godot;

namespace GDebugPanelGodot.DebugActions.Widgets;

public partial class StringDebugActionWidget : DebugActionWidget
{
[Export] public LabelAutowrapSelectionByControlWidthController? LabelAutowrapController;
[Export] public Label? Label;
[Export] public LineEdit? LineEdit;

Action<string>? _setAction;
Func<string>? _getAction;

public void Init(Control sizeControl, string name, Action<string> setAction, Func<string> getAction)
{
LabelAutowrapController!.SizeControl = sizeControl;
_setAction = setAction;
_getAction = getAction;

Label!.Text = name;
LineEdit!.Text = getAction.Invoke();
LineEdit!.EmitSignal(LineEdit.SignalName.TextChanged);
LineEdit!.ConnectLineEditTextChanged(Changed);
}

public override bool Focus()
{
LineEdit!.GrabFocus();
return true;
}

void Changed(string text)
{
int caretColumn = LineEdit!.CaretColumn;
_setAction!.Invoke(text);
LineEdit!.Text = _getAction!.Invoke();
LineEdit!.CaretColumn = caretColumn;
}
}
12 changes: 12 additions & 0 deletions Scripts/Extensions/ColorPickerButtonExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using Godot;

namespace GDebugPanelGodot.Extensions;

public static class ColorPickerButtonExtensions
{
public static void ConnectColorPickerButtonColorChanged(this ColorPickerButton colorPickerButton, Action<Color> action)
{
colorPickerButton.Connect(ColorPickerButton.SignalName.ColorChanged, Callable.From(action));
}
}
33 changes: 33 additions & 0 deletions Scripts/Extensions/DebugActionsSectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using GDebugPanelGodot.DebugActions.Actions;
using GDebugPanelGodot.DebugActions.Containers;
using Godot;

namespace GDebugPanelGodot.Extensions;

Expand Down Expand Up @@ -65,6 +66,38 @@ public static IDebugAction AddToggle(this IDebugActionsSection section, string n
return debugAction;
}

/// <summary>
/// Adds a color debug action with the provided name, and actions
/// for setting and getting the color value.
/// </summary>
/// <param name="section">The debug actions section to add the color action to.</param>
/// <param name="name">The name of the color.</param>
/// <param name="setAction">The action to set the color value.</param>
/// <param name="getAction">The function to get the current color value.</param>
/// <returns>The added color debug action.</returns>
public static IDebugAction AddColor(this IDebugActionsSection section, string name, Action<Color> setAction, Func<Color> getAction)
{
IDebugAction debugAction = new ColorDebugAction(name, setAction, getAction);
section.Add(debugAction);
return debugAction;
}

/// <summary>
/// Adds a string debug action with the provided name, and actions
/// for setting and getting the string value.
/// </summary>
/// <param name="section">The debug actions section to add the string action to.</param>
/// <param name="name">The name of the string.</param>
/// <param name="setAction">The action to set the string value.</param>
/// <param name="getAction">The function to get the current string value.</param>
/// <returns>The added string debug action.</returns>
public static IDebugAction AddString(this IDebugActionsSection section, string name, Action<string> setAction, Func<string> getAction)
{
IDebugAction debugAction = new StringDebugAction(name, setAction, getAction);
section.Add(debugAction);
return debugAction;
}

/// <summary>
/// Adds an integer debug action with the provided name, step, and actions
/// for setting and getting the integer value.
Expand Down
Loading