Skip to content

Commit

Permalink
fix: input mapping in settings wrong applied
Browse files Browse the repository at this point in the history
  • Loading branch information
myin142 committed May 21, 2023
1 parent 5a2383d commit 3ca2d89
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
14 changes: 9 additions & 5 deletions addons/input-system/InputType.gd
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ static func to_text(type: int) -> String:

var ev = to_event(type) as InputEventKey
if ev:
if ev.unicode:
var char = String.chr(ev.unicode)
if char == " ":
return "Space"
return char
# if ev.unicode:
# var char = String.chr(ev.unicode)
# if char == " ":
# return "Space"
# return char
return ev.as_text()
return ""

Expand All @@ -100,7 +100,11 @@ static func to_event(type: int) -> InputEvent:
if code >= KEY_SPECIAL:
key.keycode = code
else:
if code >= 97 and code <= 122: # lower case a-z
code -= 32 # make it upper case to match keycode
key.unicode = code
key.keycode = code
key.pressed = true
return key

if type >= Key.JOYSTICK_L_UP and type <= Key.JOYSTICK_R_LEFT:
Expand Down
11 changes: 10 additions & 1 deletion addons/menu-system/AudioSlider.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ extends HSlider
@export var vol_range = 40
@export var vol_offset = 5

@export var hover_sound: AudioStreamPlayer

var master_id

func _ready():
await owner.ready
master_id = AudioServer.get_bus_index(bus_name)
connect("value_changed", self._volume_changed)
value_changed.connect(self._volume_changed)
value = get_volume_percentage()

mouse_entered.connect(_on_hover)
focus_entered.connect(_on_hover)

func _on_hover():
hover_sound.play()

func _volume_changed(v: float):
if v == 0:
Expand Down
5 changes: 0 additions & 5 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ move_right={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
]
}
dev={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194343,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
move_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
Expand Down
4 changes: 3 additions & 1 deletion src/menu/InputSetting.gd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ func load_settings(config: ConfigFile):
for action in config.get_section_keys(section):
var type = config.get_value(section, action)
var button = _action_button_map[action]
button.remap_input(InputType.to_event(type))
var ev = InputType.to_event(type)
_logger.debug("Remapping %s to %s from type %s" % [action, ev, type])
button.remap_input(ev)


func save_settings(config: ConfigFile):
Expand Down
5 changes: 4 additions & 1 deletion src/menu/Options.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ vertical_alignment = 1
script = ExtResource("5_htjkt")
control = NodePath("../AudioSlider")

[node name="AudioSlider" type="HSlider" parent="CenterContainer/VBoxContainer/Options"]
[node name="AudioSlider" type="HSlider" parent="CenterContainer/VBoxContainer/Options" node_paths=PackedStringArray("hover_sound")]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
script = ExtResource("1")
vol_offset = 0
hover_sound = NodePath("../../TitleBack/Hover")

[node name="Control" type="Control" parent="CenterContainer/VBoxContainer/Options"]
custom_minimum_size = Vector2(0, 10)
Expand Down Expand Up @@ -93,3 +94,5 @@ layout_mode = 2
text = "Press any key..."

[connection signal="pressed" from="CenterContainer/VBoxContainer/TitleBack" to="." method="_on_title_back_pressed"]

[editable path="CenterContainer/VBoxContainer/TitleBack"]
2 changes: 1 addition & 1 deletion src/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var state = SPAWN
var portal

func _ready():
# in the final build, the texture does not exit for some reason
# in the final build, the texture does not exist for some reason
var mat = sprite.material as ShaderMaterial
mat.set_shader_parameter("dissolve_texture", dissolve_texture)

Expand Down

0 comments on commit 3ca2d89

Please sign in to comment.