-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
157 additions
and
10 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
@tool | ||
extends Node | ||
|
||
class AddonsPanelManager: | ||
const ADDONS_DOCK_NAME = "addons_dock_2c39d5937171140c1faaadb702029b32" | ||
static var _addons_dock: Control | ||
var _editor_plugin: EditorPlugin | ||
var _main_panel: Control | ||
var _tree: SceneTree | ||
|
||
func _init(p_editor_plugin) -> void: | ||
_editor_plugin = p_editor_plugin | ||
_tree = EditorInterface.get_editor_main_screen().get_tree() | ||
|
||
func _find_addons_dock() -> Control: | ||
var group = _tree.get_nodes_in_group(ADDONS_DOCK_NAME) | ||
if group.size() > 0: | ||
return group[0] | ||
return null | ||
|
||
func add_main_panel(p_panel) -> void: | ||
if not _addons_dock: | ||
_addons_dock = _find_addons_dock() | ||
if not _addons_dock: | ||
_addons_dock = preload("addons_panel_manager/scenes/ui_addons_dock.tscn").instantiate() | ||
_addons_dock.add_to_group(ADDONS_DOCK_NAME) | ||
_editor_plugin.add_control_to_dock(EditorPlugin.DOCK_SLOT_RIGHT_UL, _addons_dock) | ||
|
||
_main_panel = p_panel | ||
_addons_dock.child_container.add_child(p_panel) | ||
_sort_children_alphabetically(_addons_dock.child_container) | ||
|
||
func _sort_children_alphabetically(p_container) -> void: | ||
const LABEL_NAME = "AddonTitle" | ||
var children: Array[Dictionary] = [] | ||
for child in p_container.get_children(): | ||
var label = child.find_child(LABEL_NAME) | ||
children.append({"label": label, "node": child}) | ||
|
||
var sorter := func (p_a: Dictionary, p_b: Dictionary): | ||
var a_label: Label = p_a["label"] | ||
var b_label: Label = p_b["label"] | ||
|
||
# sort null labels to the end | ||
if a_label == null or b_label == null: | ||
return false | ||
|
||
return a_label.get_text().to_lower() < b_label.get_text().to_lower() | ||
|
||
children.sort_custom(sorter) | ||
for child in children: | ||
p_container.move_child(child["node"], p_container.get_child_count() - 1) | ||
|
||
func remove_main_panel() -> void: | ||
if not _addons_dock: | ||
return | ||
_addons_dock.child_container.remove_child(_main_panel) | ||
if _addons_dock.child_container.get_child_count() == 0: | ||
_editor_plugin.remove_control_from_docks(_addons_dock) | ||
_addons_dock.free() | ||
_addons_dock = null |
5 changes: 5 additions & 0 deletions
5
addons_shared_gen/addons_panel_manager/scenes/ui_addons_dock.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@tool | ||
extends Control | ||
|
||
@onready | ||
var child_container: Control = $ScrollContainer/VBoxContainer |
20 changes: 20 additions & 0 deletions
20
addons_shared_gen/addons_panel_manager/scenes/ui_addons_dock.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://lgxr7t7u3bh3"] | ||
|
||
[ext_resource type="Script" path="ui_addons_dock.gd" id="1_cqnue"] | ||
|
||
[node name="Addons" type="HBoxContainer"] | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
script = ExtResource("1_cqnue") | ||
|
||
[node name="ScrollContainer" type="ScrollContainer" parent="."] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] | ||
layout_mode = 2 | ||
size_flags_horizontal = 3 | ||
size_flags_vertical = 3 |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
@tool | ||
extends EditorPlugin | ||
|
||
var main_panel: Control | ||
var addons_panel_manager: Variant | ||
|
||
func _enter_tree() -> void: | ||
add_autoload_singleton("Log", "logger.gd") | ||
add_autoload_singleton("Log", "res://addons/gdlogging/funcs/logger.gd") | ||
addons_panel_manager = load("res://addons/gdlogging/addons_shared_gen/addons_panel_manager.gd").AddonsPanelManager.new(self) | ||
main_panel = preload("res://addons/gdlogging/scenes_editor/ui_addon_panel.tscn").instantiate() | ||
addons_panel_manager.add_main_panel(main_panel) | ||
|
||
func _exit_tree() -> void: | ||
remove_autoload_singleton("Log") | ||
addons_panel_manager.remove_main_panel() | ||
|
||
func _get_plugin_icon(): | ||
return preload("assets/icons/plugin_icon_white.svg") | ||
return preload("res://addons/gdlogging/assets/icons_editor/plugin_icon_white.svg") | ||
|
||
func _get_plugin_name(): | ||
return "gdlogging" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@tool | ||
extends Control | ||
|
||
@onready | ||
var option_button_log_level: OptionButton = $%OptionButtonLogLevel | ||
|
||
func _ready() -> void: | ||
option_button_log_level.connect("item_selected", _on_option_button_log_level_item_selected) | ||
|
||
func _on_option_button_log_level_item_selected(p_index: int) -> void: | ||
var log_level: Log.LogLevel = p_index | ||
Log.set_level(log_level) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://b02ua2myb78yb"] | ||
|
||
[ext_resource type="Script" path="res://addons/gdlogging/scenes_editor/ui_addon_panel.gd" id="1_ykg10"] | ||
|
||
[node name="AddonPanel" type="VBoxContainer"] | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
script = ExtResource("1_ykg10") | ||
|
||
[node name="AddonTitle" type="Label" parent="."] | ||
layout_mode = 2 | ||
theme_type_variation = &"HeaderLarge" | ||
text = "gdlogging" | ||
|
||
[node name="HBoxContainer" type="HBoxContainer" parent="."] | ||
layout_mode = 2 | ||
|
||
[node name="Label" type="Label" parent="HBoxContainer"] | ||
layout_mode = 2 | ||
text = "Editor log level" | ||
|
||
[node name="OptionButtonLogLevel" type="OptionButton" parent="HBoxContainer"] | ||
unique_name_in_owner = true | ||
layout_mode = 2 | ||
item_count = 4 | ||
selected = 1 | ||
popup/item_0/text = "TRACE" | ||
popup/item_0/id = 0 | ||
popup/item_1/text = "DEBUG" | ||
popup/item_1/id = 1 | ||
popup/item_2/text = "WARNING" | ||
popup/item_2/id = 2 | ||
popup/item_3/text = "ERROR" | ||
popup/item_3/id = 3 | ||
|
||
[node name="HSeparator" type="HSeparator" parent="."] | ||
layout_mode = 2 |