Fancy global inspector
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
# A simple main menu
|
||||
extends Control
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("debug_loadgame"):
|
||||
_on_load_game_pressed()
|
||||
if event.is_action_pressed("debug_no_intro"):
|
||||
_on_new_without_intro_pressed()
|
||||
|
||||
# Start the game
|
||||
func _on_new_game_pressed():
|
||||
escoria.new_game()
|
||||
@@ -45,10 +39,3 @@ func reset():
|
||||
$load_game.hide()
|
||||
$options.hide()
|
||||
$main.show()
|
||||
|
||||
func _on_new_without_intro_pressed():
|
||||
escoria.new_game()
|
||||
escoria.globals_manager.set_global("skip_intro",true)
|
||||
escoria.globals_manager.set_global("cocina_delante_intro_played",true)
|
||||
escoria.globals_manager.set_global("cocina_intro_played",true)
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
# A menu shown in game
|
||||
extends Control
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("debug_loadgame"):
|
||||
_on_load_game_pressed()
|
||||
if event.is_action_pressed("debug_no_intro"):
|
||||
_on_new_without_intro_pressed()
|
||||
|
||||
# Make the pause menu process in pause mode and hide it just to be sure
|
||||
func _ready():
|
||||
self.process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
@@ -79,10 +73,3 @@ func _on_new_game_pressed():
|
||||
#yield(escoria.new_game(), "completed")
|
||||
escoria.new_game()
|
||||
escoria.main.current_scene.game.unpause_game()
|
||||
|
||||
func _on_new_without_intro_pressed():
|
||||
escoria.new_game()
|
||||
escoria.globals_manager.set_global("skip_intro",true)
|
||||
escoria.globals_manager.set_global("cocina_delante_intro_played",true)
|
||||
escoria.globals_manager.set_global("cocina_intro_played",true)
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends Control
|
||||
|
||||
@export var labelContainer: Container
|
||||
@export var labelContainer: VBoxContainer
|
||||
|
||||
var ui_global_variable = preload("res://addons/escoria-ui-return-monkey-island/tools/dev/ui/ui_global_variable.tscn")
|
||||
|
||||
func _ready() -> void:
|
||||
escoria.globals_manager.global_changed.connect(_on_escoria_global_changed)
|
||||
@@ -9,15 +11,37 @@ func _ready() -> void:
|
||||
# React to changes to inventory globals
|
||||
func _on_escoria_global_changed(global: String, old_value, new_value) -> void:
|
||||
clear()
|
||||
for variable_name in escoria.globals_manager._globals:
|
||||
labelContainer.add_child(createLabel(variable_name,escoria.globals_manager._globals[variable_name] ))
|
||||
var global_variables = escoria.globals_manager._globals
|
||||
global_variables.sort()
|
||||
for variable_name in global_variables:
|
||||
var label = createLabel(variable_name,escoria.globals_manager._globals[variable_name] )
|
||||
labelContainer.add_child(label)
|
||||
#_sort()
|
||||
|
||||
# Sort the hover stack by items' z-index
|
||||
#func _sort():
|
||||
# labelContainer.custo
|
||||
# if labelContainer != null:
|
||||
# labelContainer.queue_sort().sort_custom(Callable(VariableSorter, "sort_ascending_alphabetical"))
|
||||
|
||||
func clear():
|
||||
for child in labelContainer.get_children():
|
||||
labelContainer.remove_child(child)
|
||||
child.queue_free()
|
||||
|
||||
func setCopied(name):
|
||||
for child in labelContainer.get_children():
|
||||
if child.var_name == name:
|
||||
child.copied = true
|
||||
else:
|
||||
child.copied = false
|
||||
|
||||
func createLabel(name: String, value) -> Label:
|
||||
var label = Label.new()
|
||||
label.text = "%s | %s" % [name,value]
|
||||
return label
|
||||
|
||||
func createLabel(name: String, value):
|
||||
var uiLabel:UIGlobalVariable = ui_global_variable.instantiate()
|
||||
uiLabel.set_value(name, value)
|
||||
uiLabel.connect("just_copied",_on_just_copied)
|
||||
return uiLabel
|
||||
|
||||
func _on_just_copied(name):
|
||||
setCopied(name)
|
||||
|
||||
@@ -10,14 +10,20 @@ labelContainer = NodePath("PanelContainer/MarginContainer/ScrollContainer/VBoxCo
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
layout_mode = 0
|
||||
offset_right = 500.0
|
||||
offset_bottom = 400.0
|
||||
offset_right = 4.0
|
||||
offset_bottom = 4.0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
|
||||
custom_minimum_size = Vector2(500, 500)
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 2
|
||||
theme_override_constants/margin_top = 2
|
||||
theme_override_constants/margin_right = 2
|
||||
theme_override_constants/margin_bottom = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_42y5j")
|
||||
labelContainer = NodePath("PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/LabelContainer")
|
||||
labelContainer = NodePath("PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/MarginContainer/VariableContainer")
|
||||
|
||||
[node name="ClearButton" type="Button" parent="."]
|
||||
layout_mode = 1
|
||||
@@ -25,17 +25,26 @@ offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
|
||||
custom_minimum_size = Vector2(400, 0)
|
||||
custom_minimum_size = Vector2(400, 400)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer/VBoxContainer"]
|
||||
custom_minimum_size = Vector2(0, 300)
|
||||
custom_minimum_size = Vector2(0, 400)
|
||||
layout_mode = 2
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="LabelContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 5
|
||||
theme_override_constants/margin_top = 5
|
||||
theme_override_constants/margin_right = 5
|
||||
theme_override_constants/margin_bottom = 5
|
||||
|
||||
[node name="VariableContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer/VBoxContainer/ScrollContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[connection signal="pressed" from="ClearButton" to="." method="_on_clear_button_pressed"]
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
extends Control
|
||||
class_name UIGlobalVariable
|
||||
|
||||
var var_name: String
|
||||
var var_value
|
||||
|
||||
var copied: bool = false
|
||||
signal just_copied
|
||||
|
||||
func set_value(name: String, value):
|
||||
var_name = name
|
||||
var_value = value
|
||||
$Name.set_text(var_name)
|
||||
$Name.tooltip_text = var_name
|
||||
$Value.text = "%s" % value
|
||||
$Value.tooltip_text = "%s" % value
|
||||
copied = false
|
||||
set_value_color()
|
||||
|
||||
func set_value_color():
|
||||
if var_value is bool:
|
||||
var boolean_color = Color.GREEN if var_value else Color.RED
|
||||
$Value.add_theme_color_override("font_color", boolean_color)
|
||||
if var_value == null:
|
||||
$Value.add_theme_color_override("font_color", Color.CORAL)
|
||||
|
||||
|
||||
|
||||
func _on_name_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton && event.double_click:
|
||||
just_copied.emit(var_name)
|
||||
DisplayServer.clipboard_set(var_name)
|
||||
escoria.logger.info(self, "%s copied." % var_name)
|
||||
pass # Replace with function body.
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if copied:
|
||||
$Name.add_theme_color_override("font_color", Color.AQUA)
|
||||
else:
|
||||
$Name.add_theme_color_override("font_color", Color.WHITE)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bqvsgtqhafuci
|
||||
@@ -0,0 +1,30 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://mt5e6xw32u1b"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bqvsgtqhafuci" path="res://addons/escoria-ui-return-monkey-island/tools/dev/ui/ui_global_variable.gd" id="1_fdv5b"]
|
||||
|
||||
[node name="Variable" type="HBoxContainer"]
|
||||
offset_right = 419.0
|
||||
offset_bottom = 23.0
|
||||
script = ExtResource("1_fdv5b")
|
||||
|
||||
[node name="Name" type="Label" parent="."]
|
||||
custom_minimum_size = Vector2(350, 0)
|
||||
layout_mode = 2
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "VERY_VERY_VERY_LONG_TEXT_VARIABLE_NAME"
|
||||
vertical_alignment = 1
|
||||
clip_text = true
|
||||
text_overrun_behavior = 3
|
||||
|
||||
[node name="Value" type="Label" parent="."]
|
||||
clip_contents = true
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
mouse_filter = 1
|
||||
text = "VERY_LONG_TEXT_VARIABLE_NAME"
|
||||
clip_text = true
|
||||
text_overrun_behavior = 1
|
||||
|
||||
[connection signal="gui_input" from="Name" to="." method="_on_name_gui_input"]
|
||||
Reference in New Issue
Block a user