diff --git a/main.tscn b/main.tscn index 49b552d..ec2d32b 100644 --- a/main.tscn +++ b/main.tscn @@ -237,7 +237,6 @@ margin_right = 250.0 margin_bottom = 276.0 min_value = -70.0 max_value = 0.0 -step = 1.0 tick_count = 8 ticks_on_borders = true __meta__ = { diff --git a/project.godot b/project.godot index da5c629..a2c47ed 100644 --- a/project.godot +++ b/project.godot @@ -30,6 +30,7 @@ FileLoader="*res://scripts/FileLoader.gd" Library="*res://scripts/Library.gd" GameTheme="*res://scripts/GameTheme.gd" SFXPlayer="*res://scripts/SFXPlayer.gd" +Settings="*res://scripts/Settings.gd" [debug] @@ -60,3 +61,5 @@ singletons_disabled=[ ] vram_compression/import_etc=true quality/filters/msaa=1 environment/default_environment="res://default_env.tres" +quality/subsampling/x=1.0 +quality/subsampling/y=1.0 diff --git a/scripts/InputHandler.gd b/scripts/InputHandler.gd index 52c8bee..967f054 100644 --- a/scripts/InputHandler.gd +++ b/scripts/InputHandler.gd @@ -3,8 +3,8 @@ extends Label var touch_points = {} # dict containing all points touched on the screen var touch_positions = [] # array of above var fingers = 0 setget set_fingers # setter for show fingers number on screen -var txt_ball = preload("res://assets/ball.png") # preload our ball texture -var default_font = preload("res://assets/NotoSans.tres") +var txt_ball = preload('res://assets/ball.png') # preload our ball texture +var default_font = preload('res://assets/NotoSans.tres') var buttons_pressed := PoolByteArray() var touchbuttons_pressed := PoolByteArray() @@ -18,7 +18,7 @@ const BUTTON_MIN_DIST := 0.925 const BUTTON_MAX_DIST := 1.25 func resize(): - var screen_size = $"/root".get_visible_rect().size + var screen_size = $'/root'.get_visible_rect().size rect_position = -screen_size*0.5 rect_size = screen_size @@ -33,12 +33,14 @@ func _ready(): Input.set_use_accumulated_input(false) # Gotta go fast set_process_unhandled_input(true) # process user input set_fingers(0) -# connect("button_pressed", self, "print_pressed") - $"/root".connect("size_changed", self, "resize") - $VsyncButton.connect("toggled", self, "update_vsync") - $WakelockButton.connect("toggled", self, "update_wakelock") - $FilterSlider.connect("value_changed", self, "update_filter") - $VolumeSlider.connect("value_changed", self, "update_volume") +# connect('button_pressed', self, 'print_pressed') + $'/root'.connect('size_changed', self, 'resize') + $VsyncButton.connect('toggled', self, 'update_vsync') + $WakelockButton.connect('toggled', self, 'update_wakelock') + $FilterSlider.connect('value_changed', self, 'update_filter') + $VolumeSlider.connect('value_changed', self, 'update_volume') + $SSXSlider.connect('value_changed', Settings, 'SSX_set') + $SSYSlider.connect('value_changed', Settings, 'SSY_set') resize() func update_vsync(setting: bool): @@ -54,7 +56,7 @@ func update_volume(volume: float): AudioServer.set_bus_volume_db(0, volume) func print_pressed(col: int): - print("Pressed %d"%col) + print('Pressed %d'%col) ########################################################################## @@ -62,7 +64,7 @@ func print_pressed(col: int): var fps: float = 0.0 var audio_latency: float = 0.0 func _draw(): - set_text("FPS: %.0f\nAudio Latency: %.2fms"%[fps, audio_latency*1000]) + set_text('FPS: %.0f\nAudio Latency: %.2fms'%[fps, audio_latency*1000]) # draw points for i in touch_points: @@ -144,16 +146,16 @@ func set_button_state(index: int, state: bool): var new_state = int(state) match new_state - buttons_pressed[index]: 1: - emit_signal("button_pressed", index) + emit_signal('button_pressed', index) -1: - emit_signal("button_released", index) + emit_signal('button_released', index) buttons_pressed[index] = new_state func set_touchbutton_state(index: int, state: bool): var new_state = int(state) match new_state - touchbuttons_pressed[index]: 1: - emit_signal("touchbutton_pressed", index) + emit_signal('touchbutton_pressed', index) -1: - emit_signal("touchbutton_released", index) + emit_signal('touchbutton_released', index) touchbuttons_pressed[index] = new_state diff --git a/scripts/NoteViewport.gd b/scripts/NoteViewport.gd index f8895e8..3b0d6a2 100644 --- a/scripts/NoteViewport.gd +++ b/scripts/NoteViewport.gd @@ -1,9 +1,5 @@ extends Viewport -export var SubsampleXControl = @'/root/main/InputHandler/SSXSlider' -export var SubsampleYControl = @'/root/main/InputHandler/SSYSlider' -onready var SSX = get_node(SubsampleXControl) -onready var SSY = get_node(SubsampleYControl) onready var base_height = ProjectSettings.get_setting('display/window/size/height') func set_render_scale(scale: Vector2): @@ -13,11 +9,7 @@ func set_render_scale(scale: Vector2): $Center.position = size * 0.5 $Center.scale = size/base_height -func slider_slot(arg1): - set_render_scale(Vector2(SSX.value, SSY.value)) - # Called when the node enters the scene tree for the first time. func _ready(): - SSX.connect('value_changed', self, 'slider_slot') - SSY.connect('value_changed', self, 'slider_slot') - slider_slot(1) + Settings.connect('subsampling_changed', self, 'set_render_scale') + set_render_scale(Settings.subsampling) diff --git a/scripts/Settings.gd b/scripts/Settings.gd new file mode 100644 index 0000000..4e5899a --- /dev/null +++ b/scripts/Settings.gd @@ -0,0 +1,27 @@ +# A slightly redundant proxy to ProjectSettings +# This is mostly used so that signals can be used to respond to settings changes +extends Node + +signal subsampling_changed(xy) + +var subsampling: Vector2 setget SSXY_set, SSXY_get +var subsampling_x: float setget SSX_set, SSX_get +var subsampling_y: float setget SSY_set, SSY_get + +func SSX_set(x: float): + ProjectSettings.set_setting('rendering/quality/subsampling/x', x) + emit_signal('subsampling_changed', self.subsampling) +func SSY_set(y: float): + ProjectSettings.set_setting('rendering/quality/subsampling/y', y) + emit_signal('subsampling_changed', self.subsampling) +func SSXY_set(xy: Vector2): + ProjectSettings.set_setting('rendering/quality/subsampling/x', xy.x) + ProjectSettings.set_setting('rendering/quality/subsampling/y', xy.y) + emit_signal('subsampling_changed', self.subsampling) + +func SSX_get() -> float: + return ProjectSettings.get_setting('rendering/quality/subsampling/x') +func SSY_get() -> float: + return ProjectSettings.get_setting('rendering/quality/subsampling/y') +func SSXY_get() -> Vector2: + return Vector2(self.subsampling_x, self.subsampling_y)