addon for remapping inputs
set rect size of label to the icon size
bendn 2022-08-20
parent 2c8de33 · commit 06989d6
-rw-r--r--Test.tscn6
-rw-r--r--addons/remap/ActionLabel.gd1
-rw-r--r--addons/remap/InteractiveActionLabel.gd6
-rw-r--r--addons/remap/package.json2
4 files changed, 11 insertions, 4 deletions
diff --git a/Test.tscn b/Test.tscn
index 459c852..bd93336 100644
--- a/Test.tscn
+++ b/Test.tscn
@@ -14,6 +14,10 @@ margin_top = 42.0
margin_right = 316.0
margin_bottom = 75.0
script = ExtResource( 4 )
-_name = "lef"
+_name = " lef"
action = "ui_left"
icon_size = Vector2( 10, 10 )
+
+[node name="Label" type="Label" parent="."]
+margin_right = 40.0
+margin_bottom = 14.0
diff --git a/addons/remap/ActionLabel.gd b/addons/remap/ActionLabel.gd
index 087d1b2..2066174 100644
--- a/addons/remap/ActionLabel.gd
+++ b/addons/remap/ActionLabel.gd
@@ -18,6 +18,7 @@ func _ready() -> void:
add_child(name_label_bg)
name_label_bg.add_child(name_label)
name_label.text = _name
+ name_label.rect_min_size = icon_size
name_label.valign = Label.VALIGN_CENTER
name_label.align = Label.ALIGN_CENTER
var spacer := Control.new()
diff --git a/addons/remap/InteractiveActionLabel.gd b/addons/remap/InteractiveActionLabel.gd
index d337b59..febdb57 100644
--- a/addons/remap/InteractiveActionLabel.gd
+++ b/addons/remap/InteractiveActionLabel.gd
@@ -7,14 +7,16 @@ class_name InteractiveActionLabel
# - free itself when one of them is emitted
export(PackedScene) var popup = preload("./KeySelector.tscn")
-var clear := Button.new()
+var clear: Button
export(bool) var clear_button := true
+export(String) var clear_text := "✗"
func _ready():
if clear_button:
- clear.text = "✗"
+ clear = Button.new()
+ clear.text = clear_text
clear.connect("pressed", self, "clear")
clear.size_flags_vertical = SIZE_EXPAND_FILL
clear.rect_min_size = icon_size
diff --git a/addons/remap/package.json b/addons/remap/package.json
index e1334e5..b0d136d 100644
--- a/addons/remap/package.json
+++ b/addons/remap/package.json
@@ -1,6 +1,6 @@
{
"name": "@bendn/remap",
- "version": "1.1.5",
+ "version": "1.2.0",
"description": "godot input remapping",
"main": "InteractiveActionLabel.gd",
"scripts": {