mirror of
https://github.com/tonytins/dressupzack
synced 2025-06-25 16:14:43 -04:00
Resize default window size times 3 on Retina displays
This commit is contained in:
parent
39bcdcb78c
commit
a4a7c62e79
3 changed files with 26 additions and 11 deletions
|
@ -19,10 +19,19 @@ func save_file(save_file = "user://save.cfg"):
|
|||
func save_config(config_file = "user://config.cfg"):
|
||||
# Create new ConfigFile object.
|
||||
var config = ConfigFile.new()
|
||||
|
||||
# Store some values.
|
||||
config.set_value("window", "height", 1024)
|
||||
config.set_value("window", "width", 768)
|
||||
|
||||
var window_size = "display/window/size/";
|
||||
var default_width = ProjectSettings.get_setting(window_size + "viewport_width")
|
||||
var default_height = ProjectSettings.get_setting(window_size + "viewport_height")
|
||||
|
||||
# If Retina display, set a higher resolution
|
||||
var screen_scale = DisplayServer.screen_get_scale();
|
||||
if screen_scale == 2:
|
||||
config.set_value("window", "width", default_width * 3)
|
||||
config.set_value("window", "height", default_height * 3)
|
||||
else:
|
||||
config.set_value("window", "width", default_width)
|
||||
config.set_value("window", "height", default_height)
|
||||
|
||||
# Save it to a file (overwrite if already exists)
|
||||
if !FileAccess.file_exists(config_file):
|
||||
|
|
|
@ -15,26 +15,32 @@ var config_file = Config.config_file()
|
|||
var save_file = Config.save_file()
|
||||
|
||||
func _ready():
|
||||
|
||||
|
||||
# If config files don't exist, create them
|
||||
if !FileAccess.file_exists(config_file):
|
||||
Config.save_config(config_file)
|
||||
|
||||
if !FileAccess.file_exists(save_file):
|
||||
Config.save_game(save_file)
|
||||
|
||||
|
||||
# Load last saved game
|
||||
if FileAccess.file_exists(save_file):
|
||||
var clothes_section = "clothes"
|
||||
tops.frame = Config.load_config(clothes_section, "tops", save_file)
|
||||
bottoms.frame = Config.load_config(clothes_section, "bottoms", save_file)
|
||||
full_body.frame = Config.load_config(clothes_section, "full_body", save_file)
|
||||
|
||||
# Load window size
|
||||
if FileAccess.file_exists(config_file):
|
||||
var window_section = "window"
|
||||
var window_height = Config.load_config(window_section, "height", config_file)
|
||||
var window_width = Config.load_config(window_section, "width", config_file)
|
||||
var viewport = get_viewport();
|
||||
|
||||
if window_height && window_width != null:
|
||||
DisplayServer.window_set_size(Vector2i(window_height, window_width))
|
||||
# Set window size
|
||||
DisplayServer.window_set_size(Vector2i(window_width, window_height))
|
||||
|
||||
|
||||
func game_save():
|
||||
Config.save_game(tops.frame, bottoms.frame, full_body.frame, save_file, true)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue