make scaling.gd utilize Options.gd scaling_mode variable, fix the other scaling modes
This commit is contained in:
parent
8452ebce66
commit
ebac7e2da2
2 changed files with 30 additions and 19 deletions
|
@ -68,6 +68,7 @@ func _set_fullscreen(value):
|
||||||
|
|
||||||
func _set_scaling_mode(value):
|
func _set_scaling_mode(value):
|
||||||
scaling_mode = value
|
scaling_mode = value
|
||||||
|
get_tree().emit_signal("screen_resized") # force screen size update
|
||||||
|
|
||||||
func _set_transition_speed(value):
|
func _set_transition_speed(value):
|
||||||
transition_speed = value
|
transition_speed = value
|
||||||
|
|
|
@ -4,8 +4,7 @@ var multiple = 1
|
||||||
onready var viewport = $ViewportContainer
|
onready var viewport = $ViewportContainer
|
||||||
onready var border = $TextureRect
|
onready var border = $TextureRect
|
||||||
onready var cheat_label = $ViewportContainer/Viewport/
|
onready var cheat_label = $ViewportContainer/Viewport/
|
||||||
# SCALE MODE: INTEGER, FIT, FILL
|
|
||||||
export var scale_mode = 0
|
|
||||||
# INTEGER SCALE SETTINGS
|
# INTEGER SCALE SETTINGS
|
||||||
export var overscale = 0
|
export var overscale = 0
|
||||||
onready var root = get_tree().root
|
onready var root = get_tree().root
|
||||||
|
@ -24,23 +23,34 @@ func _ready():
|
||||||
func _on_screen_resized():
|
func _on_screen_resized():
|
||||||
# VARS
|
# VARS
|
||||||
var window_size = OS.get_window_size()
|
var window_size = OS.get_window_size()
|
||||||
# INTEGER SCALE
|
match Options.scaling_mode:
|
||||||
if scale_mode == 0:
|
Options.ScalingMode.INTEGER:
|
||||||
# CENTER THE VIEWPORT
|
# CENTER THE VIEWPORT
|
||||||
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
||||||
viewport.rect_position.y = (window_size.y / 2) - half_res.y
|
viewport.rect_position.y = (window_size.y / 2) - half_res.y
|
||||||
# DETERMINE WHAT THE HIGHEST INTEGER MULTIPLE IS
|
# DETERMINE WHAT THE HIGHEST INTEGER MULTIPLE IS
|
||||||
multiple = window_size / res
|
multiple = (window_size / res).floor()
|
||||||
multiple = Vector2(floor(multiple.x),floor(multiple.y))
|
# SET THE HIGHEST SCALE AXIS TO THE LOWEST TO STAY SQUARE
|
||||||
# SET THE HIGHEST SCALE AXIS TO THE LOWEST TO STAY SQUARE
|
if multiple.x < multiple.y: multiple.y = multiple.x
|
||||||
if multiple.x < multiple.y: multiple.y = multiple.x
|
if multiple.x > multiple.y: multiple.x = multiple.y
|
||||||
if multiple.x > multiple.y: multiple.x = multiple.y
|
# SCALE THE VIEWPORT (IF OVERSCALE IS ON, SCALE IT BY 1 EXTRA)
|
||||||
# SCALE THE VIEWPORT (IF OVERSCALE IS ON, SCALE IT BY 1 EXTRA)
|
viewport.rect_scale = multiple + Vector2(overscale,overscale)
|
||||||
viewport.rect_scale = multiple + Vector2(overscale,overscale)
|
#viewport.rect_scale = Vector2(2,2)
|
||||||
#viewport.rect_scale = Vector2(2,2)
|
Options.ScalingMode.ASPECT:
|
||||||
# SCALE TO FIT
|
# CENTER THE VIEWPORT
|
||||||
if scale_mode == 1:
|
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
||||||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_KEEP,res,1)
|
viewport.rect_position.y = (window_size.y / 2) - half_res.y
|
||||||
|
# DETERMINE WHAT THE HIGHEST INTEGER MULTIPLE IS
|
||||||
|
multiple = window_size / res
|
||||||
|
# SET THE HIGHEST SCALE AXIS TO THE LOWEST TO STAY SQUARE
|
||||||
|
if multiple.x < multiple.y: multiple.y = multiple.x
|
||||||
|
if multiple.x > multiple.y: multiple.x = multiple.y
|
||||||
|
# SCALE THE VIEWPORT
|
||||||
|
viewport.rect_scale = multiple
|
||||||
|
Options.ScalingMode.STRETCH:
|
||||||
|
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
||||||
|
viewport.rect_position.y = (window_size.y / 2) - half_res.y
|
||||||
|
viewport.rect_scale = window_size / res
|
||||||
# BORDER
|
# BORDER
|
||||||
border.rect_size = window_size
|
border.rect_size = window_size
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue