Move subsampling to new Settings singleton

This commit is contained in:
Luke Hubmayer-Werner 2021-01-14 20:35:30 +10:30
parent 40a5a9ea20
commit c2ab9dd78e
5 changed files with 49 additions and 26 deletions

View File

@ -237,7 +237,6 @@ margin_right = 250.0
margin_bottom = 276.0 margin_bottom = 276.0
min_value = -70.0 min_value = -70.0
max_value = 0.0 max_value = 0.0
step = 1.0
tick_count = 8 tick_count = 8
ticks_on_borders = true ticks_on_borders = true
__meta__ = { __meta__ = {

View File

@ -30,6 +30,7 @@ FileLoader="*res://scripts/FileLoader.gd"
Library="*res://scripts/Library.gd" Library="*res://scripts/Library.gd"
GameTheme="*res://scripts/GameTheme.gd" GameTheme="*res://scripts/GameTheme.gd"
SFXPlayer="*res://scripts/SFXPlayer.gd" SFXPlayer="*res://scripts/SFXPlayer.gd"
Settings="*res://scripts/Settings.gd"
[debug] [debug]
@ -60,3 +61,5 @@ singletons_disabled=[ ]
vram_compression/import_etc=true vram_compression/import_etc=true
quality/filters/msaa=1 quality/filters/msaa=1
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"
quality/subsampling/x=1.0
quality/subsampling/y=1.0

View File

@ -3,8 +3,8 @@ extends Label
var touch_points = {} # dict containing all points touched on the screen var touch_points = {} # dict containing all points touched on the screen
var touch_positions = [] # array of above var touch_positions = [] # array of above
var fingers = 0 setget set_fingers # setter for show fingers number on screen 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 txt_ball = preload('res://assets/ball.png') # preload our ball texture
var default_font = preload("res://assets/NotoSans.tres") var default_font = preload('res://assets/NotoSans.tres')
var buttons_pressed := PoolByteArray() var buttons_pressed := PoolByteArray()
var touchbuttons_pressed := PoolByteArray() var touchbuttons_pressed := PoolByteArray()
@ -18,7 +18,7 @@ const BUTTON_MIN_DIST := 0.925
const BUTTON_MAX_DIST := 1.25 const BUTTON_MAX_DIST := 1.25
func resize(): 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_position = -screen_size*0.5
rect_size = screen_size rect_size = screen_size
@ -33,12 +33,14 @@ func _ready():
Input.set_use_accumulated_input(false) # Gotta go fast Input.set_use_accumulated_input(false) # Gotta go fast
set_process_unhandled_input(true) # process user input set_process_unhandled_input(true) # process user input
set_fingers(0) set_fingers(0)
# connect("button_pressed", self, "print_pressed") # connect('button_pressed', self, 'print_pressed')
$"/root".connect("size_changed", self, "resize") $'/root'.connect('size_changed', self, 'resize')
$VsyncButton.connect("toggled", self, "update_vsync") $VsyncButton.connect('toggled', self, 'update_vsync')
$WakelockButton.connect("toggled", self, "update_wakelock") $WakelockButton.connect('toggled', self, 'update_wakelock')
$FilterSlider.connect("value_changed", self, "update_filter") $FilterSlider.connect('value_changed', self, 'update_filter')
$VolumeSlider.connect("value_changed", self, "update_volume") $VolumeSlider.connect('value_changed', self, 'update_volume')
$SSXSlider.connect('value_changed', Settings, 'SSX_set')
$SSYSlider.connect('value_changed', Settings, 'SSY_set')
resize() resize()
func update_vsync(setting: bool): func update_vsync(setting: bool):
@ -54,7 +56,7 @@ func update_volume(volume: float):
AudioServer.set_bus_volume_db(0, volume) AudioServer.set_bus_volume_db(0, volume)
func print_pressed(col: int): 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 fps: float = 0.0
var audio_latency: float = 0.0 var audio_latency: float = 0.0
func _draw(): 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 # draw points
for i in touch_points: for i in touch_points:
@ -144,16 +146,16 @@ func set_button_state(index: int, state: bool):
var new_state = int(state) var new_state = int(state)
match new_state - buttons_pressed[index]: match new_state - buttons_pressed[index]:
1: 1:
emit_signal("button_pressed", index) emit_signal('button_pressed', index)
-1: -1:
emit_signal("button_released", index) emit_signal('button_released', index)
buttons_pressed[index] = new_state buttons_pressed[index] = new_state
func set_touchbutton_state(index: int, state: bool): func set_touchbutton_state(index: int, state: bool):
var new_state = int(state) var new_state = int(state)
match new_state - touchbuttons_pressed[index]: match new_state - touchbuttons_pressed[index]:
1: 1:
emit_signal("touchbutton_pressed", index) emit_signal('touchbutton_pressed', index)
-1: -1:
emit_signal("touchbutton_released", index) emit_signal('touchbutton_released', index)
touchbuttons_pressed[index] = new_state touchbuttons_pressed[index] = new_state

View File

@ -1,9 +1,5 @@
extends Viewport 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') onready var base_height = ProjectSettings.get_setting('display/window/size/height')
func set_render_scale(scale: Vector2): func set_render_scale(scale: Vector2):
@ -13,11 +9,7 @@ func set_render_scale(scale: Vector2):
$Center.position = size * 0.5 $Center.position = size * 0.5
$Center.scale = size/base_height $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. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
SSX.connect('value_changed', self, 'slider_slot') Settings.connect('subsampling_changed', self, 'set_render_scale')
SSY.connect('value_changed', self, 'slider_slot') set_render_scale(Settings.subsampling)
slider_slot(1)

27
scripts/Settings.gd Normal file
View File

@ -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)