forked from Puppet/berry-dash-godot-remake
Finish making settings
This commit is contained in:
17 files changed
+117
-32
No files matched your search
@@ -1,10 +1,9 @@
|
|||||||
[gd_scene load_steps=12 format=3 uid="uid://bg4fa11htun38"]
|
[gd_scene load_steps=11 format=3 uid="uid://bg4fa11htun38"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://crsloi4abxhqh" path="res://Scripts/LoadSaveFIle.cs" id="1_df05h"]
|
[ext_resource type="Script" uid="uid://cyo278cd6hfm" path="res://Scripts/FirstLoad.cs" id="1_ghw46"]
|
||||||
[ext_resource type="FontFile" uid="uid://dq7nkk7n7wrq4" path="res://Fonts/Lexend.ttf" id="1_tt5f1"]
|
[ext_resource type="FontFile" uid="uid://dq7nkk7n7wrq4" path="res://Fonts/Lexend.ttf" id="1_tt5f1"]
|
||||||
[ext_resource type="Script" uid="uid://bc4miccifwrk0" path="res://Scripts/SceneSwitcher.cs" id="2_8saeu"]
|
[ext_resource type="Script" uid="uid://bc4miccifwrk0" path="res://Scripts/SceneSwitcher.cs" id="2_8saeu"]
|
||||||
[ext_resource type="AudioStream" uid="uid://6v4630hrkeg6" path="res://Audio/Music/Menu.mp3" id="2_853f1"]
|
[ext_resource type="AudioStream" uid="uid://6v4630hrkeg6" path="res://Audio/Music/Menu.mp3" id="2_853f1"]
|
||||||
[ext_resource type="Script" uid="uid://c61hc1raouekv" path="res://Scripts/VersionChecker.cs" id="3_ghw46"]
|
|
||||||
|
|
||||||
[sub_resource type="LabelSettings" id="LabelSettings_tt5f1"]
|
[sub_resource type="LabelSettings" id="LabelSettings_tt5f1"]
|
||||||
font = ExtResource("1_tt5f1")
|
font = ExtResource("1_tt5f1")
|
||||||
@@ -52,7 +51,7 @@ anchor_right = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_df05h")
|
script = ExtResource("1_ghw46")
|
||||||
|
|
||||||
[node name="Center" type="Control" parent="."]
|
[node name="Center" type="Control" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
@@ -195,7 +194,6 @@ anchor_right = 1.0
|
|||||||
offset_left = -40.0
|
offset_left = -40.0
|
||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
script = ExtResource("3_ghw46")
|
|
||||||
|
|
||||||
[node name="Version" type="Label" parent="VersionText"]
|
[node name="Version" type="Label" parent="VersionText"]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
|
|||||||
+10
-4
@@ -1,7 +1,8 @@
|
|||||||
[gd_scene load_steps=8 format=3 uid="uid://ctb5p8ymhcshq"]
|
[gd_scene load_steps=9 format=3 uid="uid://ctb5p8ymhcshq"]
|
||||||
|
|
||||||
[ext_resource type="FontFile" uid="uid://dq7nkk7n7wrq4" path="res://Fonts/Lexend.ttf" id="1_flfri"]
|
[ext_resource type="FontFile" uid="uid://dq7nkk7n7wrq4" path="res://Fonts/Lexend.ttf" id="1_flfri"]
|
||||||
[ext_resource type="Script" uid="uid://bc4miccifwrk0" path="res://Scripts/SceneSwitcher.cs" id="2_yrknh"]
|
[ext_resource type="Script" uid="uid://bc4miccifwrk0" path="res://Scripts/SceneSwitcher.cs" id="2_yrknh"]
|
||||||
|
[ext_resource type="Script" uid="uid://jpjswk46hc64" path="res://Scripts/SettingsContainer.cs" id="3_mjqtt"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c0gvup8f48soq" path="res://Textures/MenuIcons/square-check-solid-full-recolored.svg" id="3_w1nw0"]
|
[ext_resource type="Texture2D" uid="uid://c0gvup8f48soq" path="res://Textures/MenuIcons/square-check-solid-full-recolored.svg" id="3_w1nw0"]
|
||||||
[ext_resource type="Texture2D" uid="uid://uph0cthbcrxs" path="res://Textures/MenuIcons/square-solid-full.svg" id="4_mjqtt"]
|
[ext_resource type="Texture2D" uid="uid://uph0cthbcrxs" path="res://Textures/MenuIcons/square-solid-full.svg" id="4_mjqtt"]
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ grow_horizontal = 2
|
|||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme_override_constants/separation = 179
|
theme_override_constants/separation = 179
|
||||||
alignment = 1
|
alignment = 1
|
||||||
|
script = ExtResource("3_mjqtt")
|
||||||
|
|
||||||
[node name="Fullscreen" type="Control" parent="SettingsContainer"]
|
[node name="Fullscreen" type="Control" parent="SettingsContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
@@ -102,10 +104,10 @@ theme_override_font_sizes/font_size = 76
|
|||||||
text = "Fullscreen"
|
text = "Fullscreen"
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="Vsync" type="Control" parent="SettingsContainer"]
|
[node name="VSync" type="Control" parent="SettingsContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="CheckBox" type="CheckBox" parent="SettingsContainer/Vsync"]
|
[node name="CheckBox" type="CheckBox" parent="SettingsContainer/VSync"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 6
|
anchors_preset = 6
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
@@ -123,7 +125,7 @@ theme_override_icons/checked = ExtResource("3_w1nw0")
|
|||||||
theme_override_icons/unchecked = ExtResource("4_mjqtt")
|
theme_override_icons/unchecked = ExtResource("4_mjqtt")
|
||||||
icon_alignment = 1
|
icon_alignment = 1
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="SettingsContainer/Vsync"]
|
[node name="Label" type="Label" parent="SettingsContainer/VSync"]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 8
|
anchors_preset = 8
|
||||||
anchor_left = 0.5
|
anchor_left = 0.5
|
||||||
@@ -179,3 +181,7 @@ theme_override_fonts/font = ExtResource("1_flfri")
|
|||||||
theme_override_font_sizes/font_size = 76
|
theme_override_font_sizes/font_size = 76
|
||||||
text = "Show FPS"
|
text = "Show FPS"
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[connection signal="toggled" from="SettingsContainer/Fullscreen/CheckBox" to="SettingsContainer" method="Fullscreen_Toggled"]
|
||||||
|
[connection signal="toggled" from="SettingsContainer/VSync/CheckBox" to="SettingsContainer" method="VSync_Toggled"]
|
||||||
|
[connection signal="toggled" from="SettingsContainer/ShowFPS/CheckBox" to="SettingsContainer" method="ShowFPS_Toggled"]
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class BackToMenuLogic : Control {
|
public partial class BackToMenuLogic : Control {
|
||||||
public void _on_menu_button_up() {
|
public void _on_menu_button_up() {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Godot;
|
|||||||
|
|
||||||
public partial class BazookaManager : Node {
|
public partial class BazookaManager : Node {
|
||||||
public static string HighScore = "0";
|
public static string HighScore = "0";
|
||||||
|
public static string Settings = "1";
|
||||||
|
|
||||||
public static string Read(string saveKey, string defaultValue) {
|
public static string Read(string saveKey, string defaultValue) {
|
||||||
string path = "user://" + saveKey + ".txt";
|
string path = "user://" + saveKey + ".txt";
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class BerryLogic : Node2D {
|
public partial class BerryLogic : Node2D {
|
||||||
string BerryType = "";
|
string BerryType = "";
|
||||||
|
|||||||
@@ -1,21 +1,27 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
public partial class VersionChecker : Control {
|
public partial class FirstLoad : Control {
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
Label VersionLabel = GetNode<Label>("Version");
|
Label VersionLabel = GetNode<Label>("VersionText/Version");
|
||||||
string GameVersion = ProjectSettings.GetSetting("application/config/version").AsString();
|
string GameVersion = ProjectSettings.GetSetting("application/config/version").AsString();
|
||||||
|
|
||||||
VersionLabel.Text = "Version: " + GameVersion;
|
VersionLabel.Text = "Version: " + GameVersion;
|
||||||
|
|
||||||
if (Globals.VersionChecked) {
|
if (Globals.FirstLoadDone) {
|
||||||
Label LatestVersionLabel = GetNode<Label>("LatestVersion");
|
Label LatestVersionLabel = GetNode<Label>("VersionText/LatestVersion");
|
||||||
|
|
||||||
LatestVersionLabel.Text = "Latest Version: " + Globals.LatestVersion;
|
LatestVersionLabel.Text = "Latest Version: " + Globals.LatestVersion;
|
||||||
} else {
|
} else {
|
||||||
HttpRequest GetLatestVersionNode = GetNode<HttpRequest>("LatestVersion/HTTPRequest");
|
//Load settings
|
||||||
|
List<string> settings = Utils.LoadSettings();
|
||||||
|
string fullscreen = settings.ElementAtOrDefault(0) ?? "1";
|
||||||
|
Utils.ToggleFullscreen(fullscreen == "1", settings); //This will also load VSync
|
||||||
|
|
||||||
|
//Version checking
|
||||||
|
HttpRequest GetLatestVersionNode = GetNode<HttpRequest>("VersionText/LatestVersion/HTTPRequest");
|
||||||
|
|
||||||
GetLatestVersionNode.RequestCompleted += OnRequestCompleted;
|
GetLatestVersionNode.RequestCompleted += OnRequestCompleted;
|
||||||
|
|
||||||
@@ -36,11 +42,11 @@ public partial class VersionChecker : Control {
|
|||||||
Globals.AccessLevel = ResponseValues[0];
|
Globals.AccessLevel = ResponseValues[0];
|
||||||
Globals.LatestVersion = ResponseValues[1];
|
Globals.LatestVersion = ResponseValues[1];
|
||||||
|
|
||||||
Label LatestVersionLabel = GetNode<Label>("LatestVersion");
|
Label LatestVersionLabel = GetNode<Label>("VersionText/LatestVersion");
|
||||||
|
|
||||||
LatestVersionLabel.Text = "Latest Version: " + Globals.LatestVersion;
|
LatestVersionLabel.Text = "Latest Version: " + Globals.LatestVersion;
|
||||||
|
|
||||||
Globals.VersionChecked = true;
|
Globals.FirstLoadDone = true;
|
||||||
|
|
||||||
string GameVersion = ProjectSettings.GetSetting("application/config/version").AsString();
|
string GameVersion = ProjectSettings.GetSetting("application/config/version").AsString();
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://cyo278cd6hfm
|
||||||
+1
-2
@@ -1,10 +1,9 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class Globals : Node {
|
public partial class Globals : Node {
|
||||||
public static string LatestVersion = "";
|
public static string LatestVersion = "";
|
||||||
public static string AccessLevel = "";
|
public static string AccessLevel = "";
|
||||||
public static bool VersionChecked = false;
|
public static bool FirstLoadDone = false;
|
||||||
|
|
||||||
public static float MovementSpeed = 800f;
|
public static float MovementSpeed = 800f;
|
||||||
public static float DefaultMovementSpeed = MovementSpeed;
|
public static float DefaultMovementSpeed = MovementSpeed;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class LoadSaveFIle : Control {
|
public partial class LoadSaveFIle : Control {
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
Globals.HighScore = int.Parse(BazookaManager.Read(BazookaManager.HighScore, "0"));
|
Globals.HighScore = int.Parse(BazookaManager.Read(BazookaManager.HighScore, "0"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class OutdatedVersionLogic : Control {
|
public partial class OutdatedVersionLogic : Control {
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class PauseMenuContinueButton : Button {
|
public partial class PauseMenuContinueButton : Button {
|
||||||
public void _on_button_up() {
|
public void _on_button_up() {
|
||||||
|
|||||||
+3
-4
@@ -1,5 +1,4 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class Player : Node2D {
|
public partial class Player : Node2D {
|
||||||
private float ScreenBorders = 120f;
|
private float ScreenBorders = 120f;
|
||||||
@@ -21,18 +20,18 @@ public partial class Player : Node2D {
|
|||||||
Vector2 Pos = Position;
|
Vector2 Pos = Position;
|
||||||
|
|
||||||
if (!Globals.IsPaused) {
|
if (!Globals.IsPaused) {
|
||||||
if ((Input.IsKeyPressed((Key)Key.Left) || Input.IsKeyPressed((Key)Key.A)) && Pos.X > ScreenBorders) {
|
if ((Input.IsKeyPressed(Key.Left) || Input.IsKeyPressed(Key.A)) && Pos.X > ScreenBorders) {
|
||||||
GetNode<Sprite2D>("Texture").FlipH = false;
|
GetNode<Sprite2D>("Texture").FlipH = false;
|
||||||
Pos.X -= Globals.MovementSpeed * (float)delta;
|
Pos.X -= Globals.MovementSpeed * (float)delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ScreenWidth = (WindowSize.X / WindowScale.X) - ScreenBorders;
|
float ScreenWidth = (WindowSize.X / WindowScale.X) - ScreenBorders;
|
||||||
if ((Input.IsKeyPressed((Key)Key.Right) || Input.IsKeyPressed((Key)Key.D)) && Pos.X < ScreenWidth) {
|
if ((Input.IsKeyPressed(Key.Right) || Input.IsKeyPressed(Key.D)) && Pos.X < ScreenWidth) {
|
||||||
GetNode<Sprite2D>("Texture").FlipH = true;
|
GetNode<Sprite2D>("Texture").FlipH = true;
|
||||||
Pos.X += Globals.MovementSpeed * (float)delta;
|
Pos.X += Globals.MovementSpeed * (float)delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.IsKeyPressed((Key)Key.Space) && Pos.Y >= 976) {
|
if (Input.IsKeyPressed(Key.Space) && Pos.Y >= 976) {
|
||||||
VelocityY = Globals.JumpHeight;
|
VelocityY = Globals.JumpHeight;
|
||||||
GetNode<AudioStreamPlayer>("JumpSoundPlayer").Play();
|
GetNode<AudioStreamPlayer>("JumpSoundPlayer").Play();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using Godot;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
public partial class SettingsContainer : VBoxContainer
|
||||||
|
{
|
||||||
|
private static bool ignoreToggle = true;
|
||||||
|
|
||||||
|
public override void _Ready() {
|
||||||
|
List<string> settings = Utils.LoadSettings();
|
||||||
|
|
||||||
|
string fullscreen = settings.ElementAtOrDefault(0) ?? "1";
|
||||||
|
string vsync = settings.ElementAtOrDefault(1) ?? "1";
|
||||||
|
string showfps = settings.ElementAtOrDefault(2) ?? "0";
|
||||||
|
GetNode<CheckBox>("Fullscreen/CheckBox").ButtonPressed = fullscreen == "1";
|
||||||
|
GetNode<CheckBox>("VSync/CheckBox").ButtonPressed = vsync == "1";
|
||||||
|
GetNode<CheckBox>("ShowFPS/CheckBox").ButtonPressed = showfps == "1";
|
||||||
|
|
||||||
|
ignoreToggle = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Fullscreen_Toggled(bool on)
|
||||||
|
{
|
||||||
|
if (ignoreToggle) return;
|
||||||
|
Toggle(0, on);
|
||||||
|
Utils.ToggleFullscreen(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void VSync_Toggled(bool on)
|
||||||
|
{
|
||||||
|
if (ignoreToggle) return;
|
||||||
|
Toggle(1, on);
|
||||||
|
Utils.ToggleVSync(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ShowFPS_Toggled(bool on)
|
||||||
|
{
|
||||||
|
if (ignoreToggle) return;
|
||||||
|
Toggle(2, on);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Toggle(int id, bool on) {
|
||||||
|
List<string> values = Utils.LoadSettings();
|
||||||
|
while (values.Count <= id) values.Add("0");
|
||||||
|
values[id] = on ? "1" : "0";
|
||||||
|
string newValue = string.Join(":", values);
|
||||||
|
BazookaManager.Write(BazookaManager.Settings, newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://jpjswk46hc64
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public static void ToggleFullscreen(bool on, List<string> settings)
|
||||||
|
{
|
||||||
|
DisplayServer.WindowSetMode(on ? DisplayServer.WindowMode.Fullscreen : DisplayServer.WindowMode.Maximized);
|
||||||
|
|
||||||
|
string vsync = settings.ElementAtOrDefault(1) ?? "1";
|
||||||
|
ToggleVSync(vsync == "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ToggleFullscreen(bool on)
|
||||||
|
{
|
||||||
|
List<string> settings = LoadSettings();
|
||||||
|
ToggleFullscreen(on, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ToggleVSync(bool on)
|
||||||
|
{
|
||||||
|
DisplayServer.WindowSetVsyncMode(on ? DisplayServer.VSyncMode.Enabled : DisplayServer.VSyncMode.Disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> LoadSettings() {
|
||||||
|
string value = BazookaManager.Read(BazookaManager.Settings, "");
|
||||||
|
List<string> values = [.. value.Split(':')];
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bnh8syp13bsom
|
||||||
@@ -1 +0,0 @@
|
|||||||
uid://c61hc1raouekv
|
|
||||||
Reference in new issue
Block a user