Saving some parameters

This commit is contained in:
Rendo 2025-07-12 08:43:56 +05:00
commit 48a22dd956
13 changed files with 73 additions and 14 deletions

View file

@ -0,0 +1,43 @@
using Godot;
using Newlon;
using System;
public partial class SettingsSerializer : Node
{
const string CFG_PATH = "user://config.cfg";
public override void _EnterTree()
{
GetTree().AutoAcceptQuit = false;
if (FileAccess.FileExists(CFG_PATH) == false) return;
var access = FileAccess.Open(CFG_PATH, FileAccess.ModeFlags.Read);
Utility.SFX = float.Parse(access.GetLine().Split(" ")[1]);
Utility.Music = float.Parse(access.GetLine().Split(" ")[1]);
Utility.Splash = bool.Parse(access.GetLine().Split(" ")[1]);
AudioServer.SetBusVolumeDb(0, Mathf.LinearToDb((float)Utility.SFX));
AudioServer.SetBusVolumeDb(1, Mathf.LinearToDb((float)Utility.Music));
access.Close();
}
public override void _ExitTree()
{
var access = FileAccess.Open(CFG_PATH, FileAccess.ModeFlags.Write);
access.Resize(0);
access.StoreString(string.Format("SFX {0}\nMusic {1}\nSplash {2}\n", Utility.SFX,Utility.Music,Utility.Splash));
access.Close();
}
public override void _Notification(int what)
{
if (what == NotificationWMCloseRequest)
{
_ExitTree();
GetTree().Quit();
}
}
}

View file

@ -0,0 +1 @@
uid://bflvotmed7jfy

View file

@ -31,6 +31,7 @@ public class Utility
public static double SFX = 1.0f;
public static double Music = 1.0f;
public static bool Splash = false;
}

View file

@ -0,0 +1,12 @@
using Godot;
using Newlon;
public partial class PrototypeWindow : AcceptDialog
{
public override void _Ready()
{
if (Utility.Splash) return;
Utility.Splash = true;
PopupCentered();
}
}

View file

@ -0,0 +1 @@
uid://cghu4i3bnyavg

View file

@ -7,6 +7,7 @@ func _on_play_button_pressed() -> void:
func _on_exit_button_pressed() -> void:
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
get_tree().quit()
$ChannelPlayer.call("Play")
@ -15,7 +16,10 @@ func _on_button_pressed() -> void:
$"../AboutWindow".popup_centered()
$ChannelPlayer.call("Play")
func _on_almanach_button_pressed() -> void:
$"../Almanach".visible = true
$ChannelPlayer.call("Play")
func _on_splash_button_pressed() -> void:
$"../PrototypeWindow".popup_centered()

View file

@ -1,9 +0,0 @@
extends AcceptDialog
static var seen = false
func _ready() -> void:
if seen:
return
seen = true
popup_centered()

View file

@ -1 +0,0 @@
uid://dgevhrbucpwrs