diff --git a/assets/art/bars.png b/assets/art/bars/artwork.png similarity index 100% rename from assets/art/bars.png rename to assets/art/bars/artwork.png diff --git a/assets/art/bars.png.import b/assets/art/bars/artwork.png.import similarity index 72% rename from assets/art/bars.png.import rename to assets/art/bars/artwork.png.import index 1f29d66..25c174d 100644 --- a/assets/art/bars.png.import +++ b/assets/art/bars/artwork.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://cavipaqyic82h" -path="res://.godot/imported/bars.png-cf5fff97d300ec62385570bfe6d84fda.ctex" +path="res://.godot/imported/artwork.png-ae994aa3741bd5935bb8df0387bf6245.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://assets/art/bars.png" -dest_files=["res://.godot/imported/bars.png-cf5fff97d300ec62385570bfe6d84fda.ctex"] +source_file="res://assets/art/bars/artwork.png" +dest_files=["res://.godot/imported/artwork.png-ae994aa3741bd5935bb8df0387bf6245.ctex"] [params] diff --git a/assets/art/bars/crystal.png b/assets/art/bars/crystal.png new file mode 100644 index 0000000..0ce7eaa Binary files /dev/null and b/assets/art/bars/crystal.png differ diff --git a/assets/art/bars/crystal.png.import b/assets/art/bars/crystal.png.import new file mode 100644 index 0000000..0429a17 --- /dev/null +++ b/assets/art/bars/crystal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ba4kmbeffsaxr" +path="res://.godot/imported/crystal.png-9a078245697205aa94366b700fd03b34.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/art/bars/crystal.png" +dest_files=["res://.godot/imported/crystal.png-9a078245697205aa94366b700fd03b34.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/art/bars/stone.png b/assets/art/bars/stone.png new file mode 100644 index 0000000..ba799ed Binary files /dev/null and b/assets/art/bars/stone.png differ diff --git a/assets/art/bars/stone.png.import b/assets/art/bars/stone.png.import new file mode 100644 index 0000000..ae1d250 --- /dev/null +++ b/assets/art/bars/stone.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://wrw6050870ix" +path="res://.godot/imported/stone.png-d92ffe5bd2ff8dde6952d39b8785472e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/art/bars/stone.png" +dest_files=["res://.godot/imported/stone.png-d92ffe5bd2ff8dde6952d39b8785472e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/components/Bars.tscn b/components/Bars.tscn index a207554..3738f22 100644 --- a/components/Bars.tscn +++ b/components/Bars.tscn @@ -1,15 +1,10 @@ -[gd_scene load_steps=2 format=3 uid="uid://clptnshbcs6cn"] +[gd_scene load_steps=3 format=3 uid="uid://clptnshbcs6cn"] -[ext_resource type="Texture2D" uid="uid://cavipaqyic82h" path="res://assets/art/bars.png" id="1_xyrd0"] +[ext_resource type="Script" path="res://components/bars.gd" id="1_5icge"] +[ext_resource type="Texture2D" uid="uid://cavipaqyic82h" path="res://assets/art/bars/artwork.png" id="1_xyrd0"] -[node name="Bars" type="Control"] -layout_mode = 3 -anchors_preset = 0 -offset_right = 40.0 -offset_bottom = 40.0 - -[node name="TextureRect" type="TextureRect" parent="."] -layout_mode = 0 +[node name="Bars" type="TextureRect"] offset_right = 40.0 offset_bottom = 40.0 texture = ExtResource("1_xyrd0") +script = ExtResource("1_5icge") diff --git a/components/bars.gd b/components/bars.gd new file mode 100644 index 0000000..d062065 --- /dev/null +++ b/components/bars.gd @@ -0,0 +1,16 @@ +extends TextureRect + +var artwork = load("res://assets/art/bars/artwork.png") +var stone = load("res://assets/art/bars/stone.png") +var crystal = load("res://assets/art/bars/crystal.png") + +func _ready() -> void: + var bar_index = ConfigManager.get_setting("bars") + + match bar_index: + 0: + set_texture(artwork) + 1: + set_texture(stone) + 2: + set_texture(crystal) diff --git a/project.godot b/project.godot index 66fc298..7006732 100644 --- a/project.godot +++ b/project.godot @@ -24,7 +24,8 @@ animation/layers/only_include_visible_layers_by_default=true [autoload] -GlobalKeybinds="*res://scripts/global.gd" +Global="*res://scripts/global.gd" +ConfigManager="*res://scripts/config_manager.gd" [display] @@ -68,7 +69,7 @@ toggle_fullscreen={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194342,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } -quit={ +back={ "deadzone": 0.5, "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] diff --git a/scripts/config_manager.gd b/scripts/config_manager.gd new file mode 100644 index 0000000..50a247d --- /dev/null +++ b/scripts/config_manager.gd @@ -0,0 +1,36 @@ +extends Node + +const CONFIG_PATH = "user://claustrophemia.cfg" + +var settings = { + "bars": 0 +} + +func _ready() -> void: + load_settings() + +func load_settings() -> void: + var config = ConfigFile.new() + + if config.load(CONFIG_PATH) == OK: + for key in settings.keys(): + if config.has_section_key("Settings", key): + settings[key] = config.get_value("Settings", key, settings[key]) + +func save_settings(): + var config = ConfigFile.new() + + for key in settings.keys(): + config.set_value("Settings", key, settings[key]) + + config.save(CONFIG_PATH) + +func set_setting(key: String, value) -> void: + if settings.has(key): + settings[key] = value + save_settings() + +func get_setting(key: String): + if settings.has(key): + return settings[key] + return null diff --git a/scripts/global.gd b/scripts/global.gd index 1f9538c..11d6729 100644 --- a/scripts/global.gd +++ b/scripts/global.gd @@ -5,13 +5,20 @@ var previous_window_mode = -1 func _process(delta: float) -> void: # keybinds if Input.is_action_just_pressed("toggle_fullscreen"): - if get_window().mode == Window.MODE_FULLSCREEN: + var window = get_window() + if window.mode == Window.MODE_FULLSCREEN: if previous_window_mode != -1: - get_window().mode = previous_window_mode + window.mode = previous_window_mode else: - get_window().mode = Window.MODE_MAXIMIZED + window.mode = Window.MODE_MAXIMIZED else: - previous_window_mode = get_window().mode - get_window().mode = Window.MODE_FULLSCREEN - elif Input.is_action_just_pressed("quit") and not OS.has_feature("web"): - get_tree().quit() + previous_window_mode = window.mode + window.mode = Window.MODE_FULLSCREEN + elif Input.is_action_just_pressed("back") and not OS.has_feature("web"): + var tree = get_tree() + print(tree.current_scene.name) + + if tree.current_scene.name == "MainMenu": + tree.quit() + else: + tree.change_scene_to_file("res://ui/MainMenu.tscn") diff --git a/ui/Credits.tscn b/ui/Credits.tscn index 33d5ffa..004e524 100644 --- a/ui/Credits.tscn +++ b/ui/Credits.tscn @@ -12,6 +12,7 @@ offset_left = -2.0 offset_top = -2.0 grow_horizontal = 2 grow_vertical = 2 +theme = ExtResource("1_8e6h6") color = Color(0.301961, 0, 0.00392157, 1) [node name="RichTextLabel" type="RichTextLabel" parent="."] @@ -20,7 +21,6 @@ offset_left = 58.0 offset_top = 138.0 offset_right = 610.0 offset_bottom = 330.0 -theme = ExtResource("1_8e6h6") text = "Thank you for playing our GMTK Game Jam 2024 Game! We had to on-the-spot learn Godot to produce this, so I hope it is not too dreadful! Credits: diff --git a/ui/MainMenu.tscn b/ui/MainMenu.tscn index a7b0ca0..1a17ead 100644 --- a/ui/MainMenu.tscn +++ b/ui/MainMenu.tscn @@ -4,9 +4,11 @@ [ext_resource type="Texture2D" uid="uid://077ffi13hk2e" path="res://assets/art/export/claustrophemia-Layer 1.png" id="2_dgsrv"] [ext_resource type="Theme" uid="uid://r0t1dx6hpo2m" path="res://ui/menu.tres" id="3_5x31f"] -[node name="Main Menu" type="ColorRect"] +[node name="MainMenu" type="ColorRect"] offset_right = 640.0 -offset_bottom = 360.0 +offset_bottom = 363.0 +scale = Vector2(1, 0.991561) +theme = ExtResource("3_5x31f") color = Color(0.300955, 0, 0.00368265, 1) script = ExtResource("1_wuxjj") @@ -44,14 +46,20 @@ offset_left = 256.0 offset_top = 144.0 offset_right = 384.0 offset_bottom = 192.0 -theme = ExtResource("3_5x31f") text = "Start" -[node name="ExitButton" type="Button" parent="."] +[node name="SettingsButton" type="Button" parent="."] layout_mode = 0 offset_left = 256.0 offset_top = 216.0 offset_right = 384.0 offset_bottom = 264.0 -theme = ExtResource("3_5x31f") +text = "Settings" + +[node name="ExitButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 256.0 +offset_top = 288.0 +offset_right = 384.0 +offset_bottom = 336.0 text = "Exit" diff --git a/ui/Settings.tscn b/ui/Settings.tscn new file mode 100644 index 0000000..3f2801d --- /dev/null +++ b/ui/Settings.tscn @@ -0,0 +1,44 @@ +[gd_scene load_steps=3 format=3 uid="uid://ghsqwi0kr7vl"] + +[ext_resource type="Script" path="res://ui/settings.gd" id="2_w2fss"] +[ext_resource type="Theme" uid="uid://r0t1dx6hpo2m" path="res://ui/menu.tres" id="3_mitji"] + +[node name="Settings" type="ColorRect"] +offset_right = 640.0 +offset_bottom = 360.0 +theme = ExtResource("3_mitji") +color = Color(0.300955, 0, 0.00368265, 1) +script = ExtResource("2_w2fss") + +[node name="Title" type="RichTextLabel" parent="."] +layout_mode = 0 +offset_left = 176.0 +offset_top = 24.0 +offset_right = 448.0 +offset_bottom = 104.0 +theme_override_font_sizes/normal_font_size = 84 +text = "Settings" + +[node name="Bars" type="Control" parent="."] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="Label" type="RichTextLabel" parent="Bars"] +offset_left = 204.0 +offset_top = 133.0 +offset_right = 252.0 +offset_bottom = 157.0 +text = "Bars" + +[node name="Select" type="OptionButton" parent="Bars"] +offset_left = 272.0 +offset_top = 128.0 +offset_right = 375.0 +offset_bottom = 159.0 +item_count = 3 +popup/item_0/text = "Artwork" +popup/item_1/text = "Stone" +popup/item_1/id = 1 +popup/item_2/text = "Crystal" +popup/item_2/id = 2 diff --git a/ui/main_menu.gd b/ui/main_menu.gd index 8770f4b..f0c9b89 100644 --- a/ui/main_menu.gd +++ b/ui/main_menu.gd @@ -1,10 +1,12 @@ extends Control @onready var start_button = $StartButton +@onready var settings_button = $SettingsButton @onready var exit_button = $ExitButton func _ready() -> void: start_button.button_down.connect(start_game) + settings_button.button_down.connect(open_settings) if OS.has_feature("web"): exit_button.queue_free() @@ -13,6 +15,9 @@ func _ready() -> void: func start_game() -> void: get_tree().change_scene_to_file("res://levels/level1/stage1.tscn") + +func open_settings() -> void: + get_tree().change_scene_to_file("res://ui/Settings.tscn") func exit_game() -> void: get_tree().quit() diff --git a/ui/settings.gd b/ui/settings.gd new file mode 100644 index 0000000..3d2ffa8 --- /dev/null +++ b/ui/settings.gd @@ -0,0 +1,10 @@ +extends ColorRect + +@onready var bar_option = $Bars/Select + +func _ready() -> void: + bar_option.selected = ConfigManager.get_setting("bars") + bar_option.item_selected.connect(change_bar_selection) + +func change_bar_selection(index: int) -> void: + ConfigManager.set_setting("bars", index)