diff --git a/src/autoload/Shared.gd b/src/autoload/Shared.gd index 9dc9260..5834e81 100644 --- a/src/autoload/Shared.gd +++ b/src/autoload/Shared.gd @@ -30,6 +30,7 @@ var save_maps := {} var save_path := "user://save/" var save_filename := "box.save" var keys_path := "keys.tres" +var options_path := "options.tres" var scene_dict := {} export var is_scene_dict_refresh := false setget set_is_scene_dict_refresh var replays := [{}, {}, {}] @@ -98,6 +99,7 @@ func _ready(): if !dir.open(s) == OK: dir.make_dir(s) + load_options() load_slots() KeyMenu.default_keys() load_keys() @@ -265,6 +267,11 @@ func save(): save_file(save_path + str(save_slot) + "/" + save_filename, JSON.print(data, "\t")) +func load_slots(): + for i in 3: + load_save(i) + load_replays(i) + func save_keys(path := keys_path): var s_keys = SaveDict.new() for a in InputMap.get_actions(): @@ -284,10 +291,26 @@ func load_keys(path := keys_path): for e in r.dict[a]: InputMap.action_add_event(a, e) -func load_slots(): - for i in 3: - load_save(i) - load_replays(i) +func save_options(path := options_path): + var data = {} + data["sfx"] = bus_volume[1] + data["music"] = bus_volume[2] + data["fullscreen"] = int(OS.window_fullscreen) + + save_file(save_path + options_path, JSON.print(data, "\t")) + +func load_options(path := options_path): + var dict = {} + var l = load_file(save_path + path) + if l: dict = JSON.parse(l).result + + if !dict.empty(): + if dict.has("sfx"): + bus_volume[1] = int(dict["sfx"]) + if dict.has("music"): + bus_volume[2] = int(dict["music"]) + if dict.has("fullscreen"): + OS.window_fullscreen = bool(dict["fullscreen"]) func delete_slot(_slot := save_slot): var dir = Directory.new() @@ -303,7 +326,6 @@ func delete_slot(_slot := save_slot): func save_replays(arg := replay_map, _slot := save_slot): save_file(save_path + str(_slot) + "/" + arg + ".save", JSON.print(replays[save_slot][arg], "\t")) - func load_save(_slot = save_slot, is_reload := false): save_slot = clamp(_slot, 0, 2) diff --git a/src/menu/StartMenu.tscn b/src/menu/StartMenu.tscn index 36d9fab..7ee9351 100644 --- a/src/menu/StartMenu.tscn +++ b/src/menu/StartMenu.tscn @@ -210,7 +210,7 @@ font_data = ExtResource( 23 ) 1/shapes = [ ] 1/z_index = 0 -[sub_resource type="TileSet" id=19] +[sub_resource type="TileSet" id=21] 4/name = "bricks.png 4" 4/texture = ExtResource( 18 ) 4/tex_offset = Vector2( 0, 0 ) @@ -882,7 +882,7 @@ tile_data = PoolIntArray( 393222, 0, 0, 393223, 0, 1, 393224, 0, 0, 393225, 0, 1 [node name="DetailTileMap" parent="Stage" instance=ExtResource( 8 )] z_index = -11 -tile_set = SubResource( 19 ) +tile_set = SubResource( 21 ) tile_data = PoolIntArray( 131093, 536870916, 3, 131094, 4, 1, 131095, 4, 0, 131096, 4, 3, 196624, 5, 2, 196625, 5, 0, 196626, -1610612731, 2, 196630, 536870916, 0, 196631, 4, 1, 196632, 4, 0, 262154, 536870916, 3, 262155, 536870916, 0, 262156, 4, 3, 262159, 5, 2, 262160, 5, 0, 262161, 5, 0, 262162, 5, 0, 262163, -1610612731, 2, 262166, 4, 1, 262167, 4, 0, 262168, 4, 1, 327685, 5, 2, 327686, 5, 0, 327687, 5, 0, 327688, 5, 0, 327689, 536870917, 2, 327690, 536870916, 0, 327691, 4, 1, 327692, 4, 0, 327695, -1610612731, 0, 327696, 5, 0, 327697, 5, 0, 327698, 5, 0, 327699, -1073741819, 0, 327701, 536870916, 3, 327702, 4, 0, 327703, 4, 1, 327704, 536870916, 2, 393221, -1073741819, 0, 393227, 4, 1, 393228, 4, 0, 393229, 4, 3, 393231, -1073741819, 2, 393232, 5, 0, 393233, 5, 0, 393234, 5, 0, 393235, -536870907, 2, 393237, 536870916, 0, 393238, 4, 1, 393239, 536870916, 0, 458757, -1073741819, 2, 458759, -1610612731, 2, 458762, 4, 1, 458763, 536870916, 0, 458764, 4, 1, 458765, 4, 0, 458768, -1073741819, 2, 458769, 5, 0, 458770, 1610612741, 2, 458773, 4, 2, 458774, 4, 0, 458775, 4, 1, 458776, 4, 3, 524295, -1610612731, 0, 524298, 4, 2, 524299, 4, 1, 524300, 536870916, 0, 524301, 4, 1, 524302, 4, 3, 524305, 6, 0, 524310, 4, 2, 524311, 536870916, 0, 524312, 536870916, 2, 589831, -1610612730, 0, 589832, -1610612731, 0, 589836, 4, 2, 589837, 4, 1, 589838, 4, 0, 589839, 4, 3, 589841, 6, 0, 589842, -536870907, 2, 655367, -1610612731, 0, 655373, 536870916, 3, 655374, 4, 1, 655375, 536870916, 0, 655377, 6, 0, 720901, -2147483643, 2, 720903, -536870907, 2, 720905, 5, 2, 720906, 5, 0, 720907, 5, 0, 720908, 536870917, 2, 720909, 536870916, 3, 720910, 536870916, 0, 720911, 536870916, 2, 720912, 5, 2, 720913, 6, 0, 720914, 5, 0, 720915, 536870917, 2, 720917, 5, 2, 720918, 5, 0, 720919, 536870917, 2, 786437, -2147483643, 0, 786441, -1073741819, 0, 786455, -1610612731, 0, 851973, -1073741819, 2, 851974, 1610612741, 2, 851977, 1073741829, 2, 851978, 5, 0, 851979, 1610612741, 2, 851982, 4, 1, 851983, 4, 0, 851987, 1073741829, 2, 851988, 5, 0, 851989, 6, 0, 851990, 5, 0, 851991, -536870907, 2, 917517, 536870916, 0, 917518, 4, 1, 917519, 536870916, 2, 917525, 1610612741, 2, 983053, 4, 2, 983054, 4, 0, 983055, 536870916, 2 ) [node name="GameCamera" parent="Stage" instance=ExtResource( 13 )] diff --git a/src/menu/options/OptionsMenu.gd b/src/menu/options/OptionsMenu.gd new file mode 100644 index 0000000..d72de1d --- /dev/null +++ b/src/menu/options/OptionsMenu.gd @@ -0,0 +1,5 @@ +extends Menu + +func on_open(): + if !is_open: + Shared.save_options() diff --git a/src/menu/options/OptionsMenu.tscn b/src/menu/options/OptionsMenu.tscn index 2d56099..48b621c 100644 --- a/src/menu/options/OptionsMenu.tscn +++ b/src/menu/options/OptionsMenu.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=13 format=2] -[ext_resource path="res://src/menu/Menu.gd" type="Script" id=1] +[ext_resource path="res://src/menu/options/OptionsMenu.gd" type="Script" id=1] [ext_resource path="res://src/menu/options/Volume.tscn" type="PackedScene" id=2] [ext_resource path="res://src/menu/options/OpenKeyMenu.gd" type="Script" id=3] [ext_resource path="res://src/menu/Blink.gd" type="Script" id=4] @@ -39,6 +39,9 @@ is_close_btn_no = true modulate = Color( 0, 0, 0, 0.5 ) anchor_right = 1.0 anchor_bottom = 1.0 +__meta__ = { +"_editor_description_": "" +} [node name="Center" type="CenterContainer" parent="."] margin_right = 40.0