From a386c7cc16f7c2f374908424f4703a66e339bee9 Mon Sep 17 00:00:00 2001 From: dam Date: Thu, 23 Jun 2022 11:03:00 +0000 Subject: Implemented day and night themes. --- main.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'main.gd') diff --git a/main.gd b/main.gd index 5d17d68..09e1963 100644 --- a/main.gd +++ b/main.gd @@ -6,6 +6,7 @@ var themes := [ preload("res://themes/day.tres") as Theme, preload("res://themes/night.tres") as Theme ] +var os_name := OS.get_name() onready var settings := Settings.new() onready var popup := get_node("/root/main/popup") as ModalPopup @@ -22,7 +23,7 @@ func _init(): Physics2DServer.set_active(false) PhysicsServer.set_active(false) - if OS.get_name() == "Android": + if os_name == "Android": var permissions := Array(OS.get_granted_permissions()) if permissions.has("android.permission.READ_EXTERNAL_STORAGE") == false \ or permissions.has("android.permission.WRITE_EXTERNAL_STORAGE") == false: @@ -30,6 +31,9 @@ func _init(): func _ready(): + if os_name != "Android" && os_name != "iOS": + get_tree().set_screen_stretch (SceneTree.STRETCH_MODE_DISABLED, SceneTree.STRETCH_ASPECT_IGNORE, Vector2.ONE, 0.75) + Input.set_use_accumulated_input(false) apply_theme(settings.get_value("theme_index", 0)) keyboard_height_offset = OS.get_virtual_keyboard_height() @@ -82,7 +86,7 @@ func toggle_theme(): func apply_theme(theme_idx: int) -> void: - self.theme = themes[theme_idx] + self.theme = themes[theme_idx%themes.size()] # Avoids out-of-array index. VisualServer.set_default_clear_color(get_color("background", "Misc")) -- cgit v1.2.3