diff --git a/src/overlay_resources/keyboard/KeyRow.tscn b/src/overlay_resources/keyboard/KeyRow.tscn index 48e2e2b..e482f22 100644 --- a/src/overlay_resources/keyboard/KeyRow.tscn +++ b/src/overlay_resources/keyboard/KeyRow.tscn @@ -3,6 +3,7 @@ [node name="KeyRow" type="HBoxContainer"] margin_right = 230.0 margin_bottom = 128.0 +alignment = 1 __meta__ = { "_edit_use_anchors_": false } diff --git a/src/overlay_resources/keyboard/key_normal.stylebox b/src/overlay_resources/keyboard/key_normal.stylebox new file mode 100644 index 0000000..c49a556 Binary files /dev/null and b/src/overlay_resources/keyboard/key_normal.stylebox differ diff --git a/src/overlay_resources/keyboard/key_pressed.stylebox b/src/overlay_resources/keyboard/key_pressed.stylebox new file mode 100644 index 0000000..572678f Binary files /dev/null and b/src/overlay_resources/keyboard/key_pressed.stylebox differ diff --git a/src/overlay_resources/keyboard/keyboard.theme b/src/overlay_resources/keyboard/keyboard.theme index a24fd02..4e441b3 100644 Binary files a/src/overlay_resources/keyboard/keyboard.theme and b/src/overlay_resources/keyboard/keyboard.theme differ diff --git a/src/overlay_resources/keyboard/keyboard_overlay.gd b/src/overlay_resources/keyboard/keyboard_overlay.gd index c944a3f..8457898 100644 --- a/src/overlay_resources/keyboard/keyboard_overlay.gd +++ b/src/overlay_resources/keyboard/keyboard_overlay.gd @@ -7,11 +7,15 @@ const OVERLAY_PROPERTIES = { export var key_size := 120 export var key_row : PackedScene export var key_button : PackedScene +export var row_container_path : NodePath + +var row_container var keymap := {} var toggle_keys := [] func _ready(): + row_container = get_node(row_container_path) load_keys("res://overlay_resources/keyboard/layouts/layout_se.json") @@ -27,7 +31,7 @@ func load_keys(fp: String): func apply_keys(): for row in keymap.rows: var row_box = key_row.instance() - $PanelContainer/CenterContainer/VBoxContainer.add_child(row_box) + row_container.add_child(row_box) for key in row.keys: var btn = key_button.instance() @@ -59,11 +63,11 @@ func apply_keys(): row_box.add_child(gapbox) # vertical gaps - if row.has("gap"): + if row.has("gap") and row.gap > 0: var gapbox = Control.new() gapbox.rect_min_size.y = row.gap * key_size gapbox.name = "Gap" - $PanelContainer/CenterContainer/VBoxContainer.add_child(gapbox) + row_container.add_child(gapbox) func key_toggled(state, code): diff --git a/src/overlay_resources/keyboard/layouts/layout_se.json b/src/overlay_resources/keyboard/layouts/layout_se.json index 88f5a43..efaf650 100644 --- a/src/overlay_resources/keyboard/layouts/layout_se.json +++ b/src/overlay_resources/keyboard/layouts/layout_se.json @@ -56,8 +56,7 @@ }, { "keycode": "F12", - "display": "F12", - "gap": 0.5 + "display": "F12" } ] }, @@ -231,7 +230,7 @@ }, { "keycode": "LESS", - "display": "> \n<|" + "display": "> \n< |" }, { "keycode": "Z" diff --git a/src/overlays/KeyboardOverlay.tscn b/src/overlays/KeyboardOverlay.tscn index ce3e950..e0201ef 100644 --- a/src/overlays/KeyboardOverlay.tscn +++ b/src/overlays/KeyboardOverlay.tscn @@ -15,25 +15,40 @@ __meta__ = { } key_row = ExtResource( 3 ) key_button = ExtResource( 4 ) +row_container_path = NodePath("CenterContainer/PanelContainer/RowContainer") -[node name="PanelContainer" type="PanelContainer" parent="."] -margin_right = 1024.0 -margin_bottom = 16.0 +[node name="CenterContainer" type="CenterContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 8.0 +margin_top = 8.0 +margin_right = 8.0 +margin_bottom = 8.0 size_flags_horizontal = 0 size_flags_vertical = 0 __meta__ = { "_edit_use_anchors_": false } -[node name="CenterContainer" type="CenterContainer" parent="PanelContainer"] +[node name="PanelContainer" type="PanelContainer" parent="CenterContainer"] +margin_left = 1016.0 +margin_top = 1016.0 +margin_right = 1032.0 +margin_bottom = 1032.0 +size_flags_horizontal = 0 +size_flags_vertical = 0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RowContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"] margin_left = 8.0 margin_top = 8.0 -margin_right = 1016.0 +margin_right = 8.0 margin_bottom = 8.0 - -[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/CenterContainer"] -margin_left = 504.0 -margin_right = 504.0 size_flags_horizontal = 0 size_flags_vertical = 0 alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +}