aboutsummaryrefslogtreecommitdiff
path: root/client/player
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-09-15 01:26:13 +0200
committermetamuffin <metamuffin@disroot.org>2025-09-15 01:38:34 +0200
commit676d4dcb6c439677b91b1b5cbc0bf08f98e2dd9d (patch)
tree5cd83591e230833735fbdacf41df5c1d69dd8c0e /client/player
parent4e196b83a42b9b217e3b7107b55a14cb1a005b84 (diff)
downloadhurrycurry-676d4dcb6c439677b91b1b5cbc0bf08f98e2dd9d.tar
hurrycurry-676d4dcb6c439677b91b1b5cbc0bf08f98e2dd9d.tar.bz2
hurrycurry-676d4dcb6c439677b91b1b5cbc0bf08f98e2dd9d.tar.zst
Refactor settings; store as JSON; input settings now broken
Diffstat (limited to 'client/player')
-rw-r--r--client/player/controllable_player.gd16
-rw-r--r--client/player/follow_camera.gd6
-rw-r--r--client/player/onscreen_controls/controls.gd2
3 files changed, 12 insertions, 12 deletions
diff --git a/client/player/controllable_player.gd b/client/player/controllable_player.gd
index 3bcfacff..1700d900 100644
--- a/client/player/controllable_player.gd
+++ b/client/player/controllable_player.gd
@@ -73,7 +73,7 @@ var moving_duration = 0
var fps_rotation_target = 0
func _process_movement(delta):
var input = Input.get_vector("left", "right", "forwards", "backwards") if is_input_enabled() else Vector2.ZERO
- if Global.get_setting("gameplay.first_person"):
+ if Settings.read("gameplay.first_person"):
fps_rotation_target += input.x * delta * 3.
if abs(input.x) > 0.1: input.y -= 0.5
input.x = 0.
@@ -82,14 +82,14 @@ func _process_movement(delta):
else:
input = input.rotated(input_rotation)
- var boost = Input.is_action_pressed("boost") or (Global.get_setting("gameplay.latch_boost") and boosting)
+ var boost = Input.is_action_pressed("boost") or (Settings.read("gameplay.latch_boost") and boosting)
if Input.is_action_pressed("interact_left") or Input.is_action_just_released("interact_left") or Input.is_action_pressed("interact_right") or Input.is_action_just_released("interact_right"):
input *= 0
else:
update_interact_target()
- if Global.get_setting("gameplay.accessible_movement"):
+ if Settings.read("gameplay.accessible_movement"):
if input.length() < 0.5: moving_duration -= delta * 2
else: moving_duration += delta
moving_duration = clamp(moving_duration, 0, 1)
@@ -99,7 +99,7 @@ func _process_movement(delta):
var was_boosting = boosting
direction = input
update(delta, boost)
- if boosting and not was_boosting and Global.get_setting("gameplay.vibration"):
+ if boosting and not was_boosting and Settings.read("gameplay.vibration"):
Input.start_joy_vibration(0, 0, input.length(), 0.15)
Input.vibrate_handheld(75, input.length() * 0.1)
walking = input.length_squared() > 0.1
@@ -171,7 +171,7 @@ func progress(position__: float, speed: float, warn: bool, h):
current_vibration_strength = position__
current_vibration_change = speed
var vibration_strength := pow(current_vibration_strength, 3)
- if Global.get_setting("gameplay.vibration"): # todo maybe include the lines above too
+ if Settings.read("gameplay.vibration"): # todo maybe include the lines above too
Input.start_joy_vibration(0, vibration_strength, 0, 0.1)
Input.vibrate_handheld(100, vibration_strength)
vibration_timer.start()
@@ -190,13 +190,13 @@ func _on_vibration_timeout():
func put_item(tile: Tile, h: int):
super(tile, h)
- if Global.get_setting("gameplay.vibration"):
+ if Settings.read("gameplay.vibration"):
Input.start_joy_vibration(0, 0.1, 0.0, 0.075)
Input.vibrate_handheld(75, 0.1)
func take_item(tile: Tile, h: int):
super(tile, h)
- if Global.get_setting("gameplay.vibration"):
+ if Settings.read("gameplay.vibration"):
Input.start_joy_vibration(0, 0.1, 0.0, 0.075)
Input.vibrate_handheld(75, 0.1)
@@ -229,7 +229,7 @@ func interact():
marker.visible = false
func update_interact_target():
- match Global.get_setting("gameplay.interact_target"):
+ match Settings.read("gameplay.interact_target"):
"dirsnap": return update_interact_target_dirsnap()
"dir": return update_interact_target_dir()
_: return update_interact_target_dir()
diff --git a/client/player/follow_camera.gd b/client/player/follow_camera.gd
index 7ca674e0..804a9ebe 100644
--- a/client/player/follow_camera.gd
+++ b/client/player/follow_camera.gd
@@ -75,14 +75,14 @@ func zoom(zoom_dist: float) -> void:
camera_distance_target = clamp(camera_distance_target, MIN_ZOOM, MAX_ZOOM)
func follow(delta):
- if Global.get_setting("gameplay.first_person"):
+ if Settings.read("gameplay.first_person"):
global_position = target.global_position + Vector3.UP * 1.33
rotation = target.rotation + Vector3(0,PI,0)
if target.get_parent() is ControllablePlayer:
target.get_parent().input_rotation = -rotation.y
return
- var invert_factor = -1 if Global.get_setting("gameplay.invert_camera") else 1;
+ var invert_factor = -1 if Settings.read("gameplay.invert_camera") else 1;
if not _disable_input:
angle_target += Input.get_axis("rotate_left", "rotate_right") * ROTATE_SPEED * delta * invert_factor
@@ -99,7 +99,7 @@ func follow(delta):
new_transform.origin = target.position + offset
new_transform = new_transform.looking_at(target.position)
- if Global.get_setting("gameplay.interpolate_camera_rotation"):
+ if Settings.read("gameplay.interpolate_camera_rotation"):
transform.basis = Basis.from_euler(Vector3(
G.interpolate_angle(transform.basis.get_euler().x, new_transform.basis.get_euler().x, delta * LOOK_WEIGHT),
G.interpolate_angle(transform.basis.get_euler().y, new_transform.basis.get_euler().y, delta * LOOK_WEIGHT),
diff --git a/client/player/onscreen_controls/controls.gd b/client/player/onscreen_controls/controls.gd
index 16c10beb..c7fa0e36 100644
--- a/client/player/onscreen_controls/controls.gd
+++ b/client/player/onscreen_controls/controls.gd
@@ -25,7 +25,7 @@ var touch_enabled := false
func _ready():
Settings.hook_changed_init("ui.touch_controls", false, apply_touch)
- Global.using_touch_change.connect(func f(_x): apply_touch(Global.get_setting("ui.touch_controls"))) # throw away useless argument
+ Global.using_touch_change.connect(func f(_x): apply_touch(Settings.read("ui.touch_controls"))) # throw away useless argument
Global.hand_count_change.connect(apply_hand_count)
apply_hand_count(Global.hand_count)