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
|
@ -4,8 +4,7 @@ var multiple = 1
|
|||
onready var viewport = $ViewportContainer
|
||||
onready var border = $TextureRect
|
||||
onready var cheat_label = $ViewportContainer/Viewport/
|
||||
# SCALE MODE: INTEGER, FIT, FILL
|
||||
export var scale_mode = 0
|
||||
|
||||
# INTEGER SCALE SETTINGS
|
||||
export var overscale = 0
|
||||
onready var root = get_tree().root
|
||||
|
@ -24,23 +23,34 @@ func _ready():
|
|||
func _on_screen_resized():
|
||||
# VARS
|
||||
var window_size = OS.get_window_size()
|
||||
# INTEGER SCALE
|
||||
if scale_mode == 0:
|
||||
# CENTER THE VIEWPORT
|
||||
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
||||
viewport.rect_position.y = (window_size.y / 2) - half_res.y
|
||||
# DETERMINE WHAT THE HIGHEST INTEGER MULTIPLE IS
|
||||
multiple = window_size / res
|
||||
multiple = Vector2(floor(multiple.x),floor(multiple.y))
|
||||
# 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 (IF OVERSCALE IS ON, SCALE IT BY 1 EXTRA)
|
||||
viewport.rect_scale = multiple + Vector2(overscale,overscale)
|
||||
#viewport.rect_scale = Vector2(2,2)
|
||||
# SCALE TO FIT
|
||||
if scale_mode == 1:
|
||||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_KEEP,res,1)
|
||||
match Options.scaling_mode:
|
||||
Options.ScalingMode.INTEGER:
|
||||
# CENTER THE VIEWPORT
|
||||
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
||||
viewport.rect_position.y = (window_size.y / 2) - half_res.y
|
||||
# DETERMINE WHAT THE HIGHEST INTEGER MULTIPLE IS
|
||||
multiple = (window_size / res).floor()
|
||||
# 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 (IF OVERSCALE IS ON, SCALE IT BY 1 EXTRA)
|
||||
viewport.rect_scale = multiple + Vector2(overscale,overscale)
|
||||
#viewport.rect_scale = Vector2(2,2)
|
||||
Options.ScalingMode.ASPECT:
|
||||
# CENTER THE VIEWPORT
|
||||
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
||||
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.rect_size = window_size
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue