Ui Rebuild and Full Controller Support #59
6 changed files with 16 additions and 53 deletions
|
@ -41,7 +41,7 @@
|
||||||
[ext_resource type="StyleBox" uid="uid://0jfr1uwuog0s" path="res://Assets/UI/Slider/v/background.tres" id="39_dl1e4"]
|
[ext_resource type="StyleBox" uid="uid://0jfr1uwuog0s" path="res://Assets/UI/Slider/v/background.tres" id="39_dl1e4"]
|
||||||
[ext_resource type="FontFile" uid="uid://dqdeftjkwxe64" path="res://Assets/Fonts/Dogica/dogicapixel.ttf" id="40_bmcvq"]
|
[ext_resource type="FontFile" uid="uid://dqdeftjkwxe64" path="res://Assets/Fonts/Dogica/dogicapixel.ttf" id="40_bmcvq"]
|
||||||
|
|
||||||
[sub_resource type="Image" id="Image_kwuuq"]
|
[sub_resource type="Image" id="Image_cw2pn"]
|
||||||
data = {
|
data = {
|
||||||
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0),
|
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0),
|
||||||
"format": "RGBA8",
|
"format": "RGBA8",
|
||||||
|
@ -51,7 +51,7 @@ data = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="ImageTexture" id="ImageTexture_g5bup"]
|
[sub_resource type="ImageTexture" id="ImageTexture_g5bup"]
|
||||||
image = SubResource("Image_kwuuq")
|
image = SubResource("Image_cw2pn")
|
||||||
|
|
||||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_sj7h5"]
|
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_sj7h5"]
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,6 @@ vertical_alignment = 1
|
||||||
|
|
||||||
[node name="MoveUpRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
|
[node name="MoveUpRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
toggle_mode = true
|
|
||||||
script = ExtResource("2_4asaa")
|
script = ExtResource("2_4asaa")
|
||||||
input_action_name = "move_up"
|
input_action_name = "move_up"
|
||||||
remap_controller = NodePath("../../../../../Remap Controller")
|
remap_controller = NodePath("../../../../../Remap Controller")
|
||||||
|
@ -209,7 +208,6 @@ vertical_alignment = 1
|
||||||
[node name="MoveLeftRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
|
[node name="MoveLeftRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
toggle_mode = true
|
|
||||||
script = ExtResource("2_4asaa")
|
script = ExtResource("2_4asaa")
|
||||||
input_action_name = "move_left"
|
input_action_name = "move_left"
|
||||||
remap_controller = NodePath("../../../../../Remap Controller")
|
remap_controller = NodePath("../../../../../Remap Controller")
|
||||||
|
@ -223,7 +221,6 @@ vertical_alignment = 1
|
||||||
[node name="MoveDownRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
|
[node name="MoveDownRemapButton" type="Button" parent="SettingsTabs/Controls/MarginContainer/GridContainer" node_paths=PackedStringArray("remap_controller")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
toggle_mode = true
|
|
||||||
script = ExtResource("2_4asaa")
|
script = ExtResource("2_4asaa")
|
||||||
input_action_name = "move_down"
|
input_action_name = "move_down"
|
||||||
remap_controller = NodePath("../../../../../Remap Controller")
|
remap_controller = NodePath("../../../../../Remap Controller")
|
||||||
|
@ -238,7 +235,6 @@ vertical_alignment = 1
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
focus_neighbor_bottom = NodePath("../../../../../Back Button")
|
focus_neighbor_bottom = NodePath("../../../../../Back Button")
|
||||||
toggle_mode = true
|
|
||||||
script = ExtResource("2_4asaa")
|
script = ExtResource("2_4asaa")
|
||||||
input_action_name = "move_right"
|
input_action_name = "move_right"
|
||||||
remap_controller = NodePath("../../../../../Remap Controller")
|
remap_controller = NodePath("../../../../../Remap Controller")
|
||||||
|
|
|
@ -72,3 +72,8 @@ func set_controls_from_save_file() -> void:
|
||||||
var control_key = InputEventKey.new()
|
var control_key = InputEventKey.new()
|
||||||
control_key.set_keycode(Save.game_data.values()[i])
|
control_key.set_keycode(Save.game_data.values()[i])
|
||||||
InputMap.action_add_event(remappable_input_action, control_key)
|
InputMap.action_add_event(remappable_input_action, control_key)
|
||||||
|
pass
|
||||||
|
|
||||||
|
func set_control_binding(action : String, keycode : int):
|
||||||
|
print(keycode)
|
||||||
|
pass
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
extends TextureButton
|
|
||||||
|
|
||||||
@export var text : String = "Sample Text"
|
|
||||||
@export var pointer_margin_from_center : int = 100
|
|
||||||
@export var leftPointer : Sprite2D
|
|
||||||
@export var rightPointer : Sprite2D
|
|
||||||
@export var textBox : RichTextLabel
|
|
||||||
|
|
||||||
# Engine Callbacks
|
|
||||||
func _ready():
|
|
||||||
textBox.parse_bbcode("[center] %s [/center]" % [text])
|
|
||||||
pass
|
|
||||||
|
|
||||||
func _process(_delta):
|
|
||||||
handle_hover_and_focus()
|
|
||||||
handle_x_position()
|
|
||||||
|
|
||||||
func handle_hover_and_focus() -> void:
|
|
||||||
if has_focus():
|
|
||||||
leftPointer.visible = true
|
|
||||||
rightPointer.visible = true
|
|
||||||
elif is_hovered():
|
|
||||||
leftPointer.visible = true
|
|
||||||
leftPointer.modulate.a = 0.5
|
|
||||||
rightPointer.visible = true
|
|
||||||
rightPointer.modulate.a = 0.5
|
|
||||||
else:
|
|
||||||
leftPointer.visible = false
|
|
||||||
leftPointer.modulate.a = 1
|
|
||||||
rightPointer.visible = false
|
|
||||||
rightPointer.modulate.a = 1
|
|
||||||
pass
|
|
||||||
|
|
||||||
func handle_x_position() -> void:
|
|
||||||
var center_x = get_parent().position.x + (get_parent().size.x / 2.0)
|
|
||||||
leftPointer.global_position.x = center_x - pointer_margin_from_center
|
|
||||||
rightPointer.global_position.x = center_x + pointer_margin_from_center
|
|
||||||
pass
|
|
|
@ -20,17 +20,16 @@ func start_remap(button : Button, action : String):
|
||||||
remap_action = action
|
remap_action = action
|
||||||
remap_button.text = "..."
|
remap_button.text = "..."
|
||||||
set_process_unhandled_key_input(true)
|
set_process_unhandled_key_input(true)
|
||||||
|
button.release_focus()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func remap_key(event):
|
func remap_key(event):
|
||||||
print(event)
|
set_process_unhandled_key_input(false)
|
||||||
# Do Actual Rebinding
|
|
||||||
for key in InputMap.action_get_events(remap_action):
|
for key in InputMap.action_get_events(remap_action):
|
||||||
InputMap.action_erase_event(remap_action, key)
|
InputMap.action_erase_event(remap_action, key)
|
||||||
InputMap.action_add_event(remap_action, event)
|
InputMap.action_add_event(remap_action, event)
|
||||||
print(event.as_text_keycode())
|
Save.game_data["%s" % [remap_action]] = event.keycode
|
||||||
#Save.game_data["%s" % [remap_action]] = event.get_text_keycode()
|
|
||||||
remap_button.display_key()
|
remap_button.display_key()
|
||||||
|
remap_button.grab_focus()
|
||||||
remap_button = null
|
remap_button = null
|
||||||
set_process_unhandled_key_input(false)
|
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -67,6 +67,7 @@ func add_resolution_items():
|
||||||
|
|
||||||
# Other Buttons
|
# Other Buttons
|
||||||
func _on_back_pressed():
|
func _on_back_pressed():
|
||||||
|
Save.save_data()
|
||||||
on_back.call()
|
on_back.call()
|
||||||
queue_free()
|
queue_free()
|
||||||
pass
|
pass
|
||||||
|
|
Reference in a new issue