mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
save and load window size ! win size shown in options
remove Back.gd and Unlock.gd unused option scripts remove Shared.set_window_scale() and window_scale
This commit is contained in:
parent
bddb9123e8
commit
0a63473f29
5 changed files with 24 additions and 34 deletions
|
|
@ -109,8 +109,8 @@ KeyMenu="*res://src/menu/options/KeyMenu.tscn"
|
|||
|
||||
window/size/width=228
|
||||
window/size/height=128
|
||||
window/size/test_width=1280
|
||||
window/size/test_height=720
|
||||
window/size/test_width=1140
|
||||
window/size/test_height=640
|
||||
window/dpi/allow_hidpi=true
|
||||
window/stretch/mode="viewport"
|
||||
window/stretch/aspect="keep_height"
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ var is_save := false
|
|||
var last_menu := "main"
|
||||
var last_cursor := 0
|
||||
|
||||
var window_scale := 1
|
||||
var view_size := Vector2(228, 128)
|
||||
var bus_volume = [10, 10, 10]
|
||||
|
||||
|
|
@ -92,11 +91,6 @@ func _ready():
|
|||
ghosts.append(g)
|
||||
node_ghost.visible = false
|
||||
|
||||
# scale window
|
||||
window_scale = floor(OS.get_screen_size().x / get_viewport().size.x)
|
||||
window_scale = max(1, floor(window_scale * 0.9))
|
||||
#set_window_scale()
|
||||
|
||||
# lower volume
|
||||
for i in [1, 2]:
|
||||
set_bus_volume(i, 7)
|
||||
|
|
@ -111,7 +105,6 @@ func _ready():
|
|||
if !dir.open(s) == OK:
|
||||
dir.make_dir(s)
|
||||
|
||||
|
||||
# get all maps
|
||||
for i in dir_list(map_dir):
|
||||
maps.append(i.split(".")[0])
|
||||
|
|
@ -335,6 +328,8 @@ func save_options(path := options_path):
|
|||
data["touch"] = int(TouchScreen.is_stay)
|
||||
data["full"] = int(OS.window_fullscreen)
|
||||
data["view"] = int(window_option)
|
||||
var ws = OS.window_size
|
||||
data["size"] = str(ws.x) + "," + str(ws.y)
|
||||
data["time"] = time_elapsed
|
||||
|
||||
print("save_options, path: ", path, " time: ", time_elapsed)
|
||||
|
|
@ -360,6 +355,11 @@ func load_options(path := options_path):
|
|||
TouchScreen.is_stay = bool(dict["touch"])
|
||||
if dict.has("view"):
|
||||
self.window_option = int(dict["view"])
|
||||
if dict.has("size"):
|
||||
var ws = str(dict["size"]).split_floats(",", false)
|
||||
if ws.size() == 2:
|
||||
OS.window_size = Vector2(float(ws[0]), float(ws[1]))
|
||||
set_window_option()
|
||||
if dict.has("time"):
|
||||
time_elapsed = abs(int(dict["time"]))
|
||||
|
||||
|
|
@ -552,14 +552,6 @@ func set_bus_volume(_bus := 1, _vol := 5):
|
|||
bus_volume[_bus] = clamp(_vol, 0, 10)
|
||||
AudioServer.set_bus_volume_db(_bus, linear2db(bus_volume[_bus] / 10.0))
|
||||
|
||||
func set_window_scale(arg := window_scale):
|
||||
window_scale = max(1, arg if arg else window_scale)
|
||||
if OS.get_name() != "HTML5":
|
||||
OS.window_size = Vector2(view_size.x * window_scale, view_size.y * window_scale)
|
||||
# center window
|
||||
OS.set_window_position(OS.get_screen_size() * 0.5 - OS.get_window_size() * 0.5)
|
||||
return "window_scale: " + str(window_scale) + " - resolution: " + str(OS.get_window_size())
|
||||
|
||||
func get_all_children(n, a := []):
|
||||
if is_instance_valid(n):
|
||||
a.append(n)
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
extends Node2D
|
||||
|
||||
func act():
|
||||
Shared.wipe_scene(Shared.main_menu_path)
|
||||
Audio.play("menu_back", 0.9, 1.1)
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
extends Node2D
|
||||
|
||||
func act():
|
||||
Audio.play("menu_pick", 0.9, 1.1)
|
||||
Shared.unlock()
|
||||
Shared.cam.shake(10)
|
||||
|
|
@ -3,14 +3,23 @@ extends CanvasItem
|
|||
onready var label_scale := $Scale
|
||||
onready var label_res := $Resolution
|
||||
|
||||
var cursor = 0
|
||||
|
||||
func _ready():
|
||||
set_text()
|
||||
get_tree().connect("screen_resized", self, "size_changed")
|
||||
yield(get_tree(),"idle_frame")
|
||||
|
||||
size_changed()
|
||||
|
||||
func scroll(arg = 1):
|
||||
Shared.set_window_scale(clamp(Shared.window_scale + arg, 1, 12))
|
||||
set_text()
|
||||
cursor = clamp(cursor + arg, 1, 32)
|
||||
OS.window_size = Shared.view_size * cursor
|
||||
Shared.set_window_option()
|
||||
Audio.play("menu_scroll2", 0.7, 1.4)
|
||||
|
||||
func set_text():
|
||||
label_scale.text = str(Shared.window_scale) + "x"
|
||||
label_res.text = str(Shared.view_size.x * Shared.window_scale) + " x " + str(Shared.view_size.y * Shared.window_scale)
|
||||
func size_changed():
|
||||
var view_size = OS.window_size
|
||||
label_res.text = str(view_size.x) + " x " + str(view_size.y)
|
||||
|
||||
cursor = floor(view_size.y / Shared.view_size. y)
|
||||
label_scale.text = str(cursor) + "x" if OS.window_size == Shared.view_size * cursor else ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue