gd: added input addon
This commit is contained in:
39
addons/guide/editor/input_display/input_display.gd
Normal file
39
addons/guide/editor/input_display/input_display.gd
Normal file
@ -0,0 +1,39 @@
|
||||
@tool
|
||||
extends RichTextLabel
|
||||
signal clicked()
|
||||
|
||||
var _formatter:GUIDEInputFormatter = GUIDEInputFormatter.new(64)
|
||||
|
||||
var input:GUIDEInput:
|
||||
set(value):
|
||||
if value == input:
|
||||
return
|
||||
|
||||
if is_instance_valid(input):
|
||||
input.changed.disconnect(_refresh)
|
||||
|
||||
input = value
|
||||
|
||||
if is_instance_valid(input):
|
||||
input.changed.connect(_refresh)
|
||||
|
||||
_refresh()
|
||||
|
||||
func _refresh():
|
||||
if not is_instance_valid(input):
|
||||
parse_bbcode("[center][i]<not bound>[/i][/center]")
|
||||
tooltip_text = ""
|
||||
return
|
||||
|
||||
var text := await _formatter.input_as_richtext_async(input, false)
|
||||
parse_bbcode("[center]" + text + "[/center]")
|
||||
tooltip_text = _formatter.input_as_text(input)
|
||||
|
||||
|
||||
func _gui_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
clicked.emit()
|
||||
|
||||
|
||||
|
1
addons/guide/editor/input_display/input_display.gd.uid
Normal file
1
addons/guide/editor/input_display/input_display.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cgf2qrodwja32
|
18
addons/guide/editor/input_display/input_display.tscn
Normal file
18
addons/guide/editor/input_display/input_display.tscn
Normal file
@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dsv7s6tfmnsrs"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/editor/input_display/input_display.gd" id="1_ne6sd"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0bp65"]
|
||||
|
||||
[node name="InputDisplay" type="RichTextLabel"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_0bp65")
|
||||
bbcode_enabled = true
|
||||
fit_content = true
|
||||
script = ExtResource("1_ne6sd")
|
Reference in New Issue
Block a user