Compare commits

...

2 Commits

4 changed files with 147 additions and 3 deletions

30
src/Save/save_settings.gd Normal file
View File

@ -0,0 +1,30 @@
extends Node
const SETTINGS_FILE = "GameSettings.save"
var game_data: = {}
func _ready() -> void:
load_data()
func load_data():
var file: = File.new()
if not file.file_exists(SETTINGS_FILE):
game_data = {
"fullscreen": false,
"vsync": false,
"particle_effects": true,
"master_vol": -10
}
save_data()
file.open(SETTINGS_FILE, File.READ)
game_data = file.get_var()
file.close()
func save_data():
var file: = File.new()
file.open(SETTINGS_FILE, File.WRITE)
file.store_var(game_data)
file.close()

View File

@ -66,6 +66,7 @@ margin_bottom = 84.0
focus_next = NodePath("../QuitButton") focus_next = NodePath("../QuitButton")
focus_previous = NodePath("../PlayButton") focus_previous = NodePath("../PlayButton")
text = "Settings" text = "Settings"
next_scene_path = "res://src/Screens/SettingsMenu.tscn"
[node name="QuitButton" parent="MenuButtons" instance=ExtResource( 4 )] [node name="QuitButton" parent="MenuButtons" instance=ExtResource( 4 )]
margin_top = 88.0 margin_top = 88.0

View File

@ -4,6 +4,11 @@ extends Control
# TODO: Add Audio settings (Master Volume, since only 2 SFX) # TODO: Add Audio settings (Master Volume, since only 2 SFX)
# TODO: Make them presist between launchs # TODO: Make them presist between launchs
onready var fullscreen: CheckButton = $MarginContainer/GameSettings/FullScreenToggle
onready var v_sync: CheckButton = $MarginContainer/GameSettings/VSyncCheckToggle
onready var paticle_effects: CheckButton = $MarginContainer/GameSettings/ParticleEffectsToggle
onready var game_volume_slider: HSlider = $MarginContainer/GameSettings/VolumeSlider/VolumeSliderBar
onready var game_volume_label: Label = $MarginContainer/GameSettings/VolumeSlider/VolumeSliderLabel
func _ready() -> void: func _ready() -> void:
pass fullscreen.grab_focus()

View File

@ -1,9 +1,11 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=10 format=2]
[ext_resource path="res://assets/Background.png" type="Texture" id=1] [ext_resource path="res://assets/Background.png" type="Texture" id=1]
[ext_resource path="res://assets-raw/BBB_Simulator_Black.otf" type="DynamicFontData" id=2] [ext_resource path="res://assets-raw/BBB_Simulator_Black.otf" type="DynamicFontData" id=2]
[ext_resource path="res://src/UI/Title.tscn" type="PackedScene" id=3] [ext_resource path="res://src/UI/Title.tscn" type="PackedScene" id=3]
[ext_resource path="res://src/Screens/SettingsMenu.gd" type="Script" id=4] [ext_resource path="res://src/Screens/SettingsMenu.gd" type="Script" id=4]
[ext_resource path="res://src/UI/ChangeScene.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/ui_theme.tres" type="Theme" id=6]
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
font_data = ExtResource( 2 ) font_data = ExtResource( 2 )
@ -11,10 +13,17 @@ font_data = ExtResource( 2 )
[sub_resource type="Theme" id=2] [sub_resource type="Theme" id=2]
default_font = SubResource( 1 ) default_font = SubResource( 1 )
[sub_resource type="DynamicFont" id=3]
size = 12
font_data = ExtResource( 2 )
[node name="SettingsMenu" type="Control"] [node name="SettingsMenu" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 4 ) script = ExtResource( 4 )
__meta__ = {
"_edit_vertical_guides_": [ 640.0 ]
}
[node name="Background" type="TextureRect" parent="."] [node name="Background" type="TextureRect" parent="."]
modulate = Color( 0, 0, 0, 1 ) modulate = Color( 0, 0, 0, 1 )
@ -27,6 +36,105 @@ texture = ExtResource( 1 )
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -150.5 margin_left = -150.5
margin_top = 112.0
margin_right = 150.5 margin_right = 150.5
margin_bottom = 67.0 margin_bottom = 179.0
text = "Settings" text = "Settings"
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -150.0
margin_top = -100.0
margin_right = 150.0
margin_bottom = 100.0
theme = ExtResource( 6 )
[node name="GameSettings" type="GridContainer" parent="MarginContainer"]
margin_right = 300.0
margin_bottom = 200.0
columns = 2
[node name="FullScreenLabel" type="Label" parent="MarginContainer/GameSettings"]
margin_top = 4.0
margin_right = 194.0
margin_bottom = 38.0
text = "Fullscreen:"
[node name="FullScreenToggle" type="CheckButton" parent="MarginContainer/GameSettings"]
margin_left = 198.0
margin_right = 274.0
margin_bottom = 42.0
focus_next = NodePath("../VSyncToggle")
focus_previous = NodePath("../../../BackButton")
[node name="VSyncLabel" type="Label" parent="MarginContainer/GameSettings"]
margin_top = 50.0
margin_right = 194.0
margin_bottom = 84.0
text = "V-Sync:"
[node name="VSyncToggle" type="CheckButton" parent="MarginContainer/GameSettings"]
margin_left = 198.0
margin_top = 46.0
margin_right = 274.0
margin_bottom = 88.0
focus_next = NodePath("../ParticleEffectsToggle")
focus_previous = NodePath("../FullScreenToggle")
[node name="ParticleEffectsLabel" type="Label" parent="MarginContainer/GameSettings"]
margin_top = 96.0
margin_right = 194.0
margin_bottom = 130.0
text = "Particle Effects:"
[node name="ParticleEffectsToggle" type="CheckButton" parent="MarginContainer/GameSettings"]
margin_left = 198.0
margin_top = 92.0
margin_right = 274.0
margin_bottom = 134.0
focus_next = NodePath("../VolumeSlider/VolumeSliderBar")
focus_previous = NodePath("../VSyncToggle")
[node name="VolumeLabel" type="Label" parent="MarginContainer/GameSettings"]
margin_top = 140.0
margin_right = 194.0
margin_bottom = 174.0
text = "Volume:"
[node name="VolumeSlider" type="VBoxContainer" parent="MarginContainer/GameSettings"]
margin_left = 198.0
margin_top = 138.0
margin_right = 274.0
margin_bottom = 176.0
[node name="VolumeSliderBar" type="HSlider" parent="MarginContainer/GameSettings/VolumeSlider"]
margin_right = 76.0
margin_bottom = 16.0
focus_next = NodePath("../../../../BackButton")
focus_previous = NodePath("../../ParticleEffectsToggle")
[node name="VolumeSliderText" type="Label" parent="MarginContainer/GameSettings/VolumeSlider"]
margin_top = 20.0
margin_right = 76.0
margin_bottom = 38.0
custom_fonts/font = SubResource( 3 )
text = "100%"
align = 1
valign = 2
[node name="BackButton" parent="." instance=ExtResource( 5 )]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -97.0
margin_top = 144.0
margin_right = 97.0
margin_bottom = 184.0
focus_next = NodePath("../MarginContainer/GameSettings/FullScreenToggle")
focus_previous = NodePath("../MarginContainer/GameSettings/VolumeSlider/VolumeSliderBar")
text = "Back"
next_scene_path = "res://src/Screens/MainMenu.tscn"