Compare commits

...

2 Commits

Author SHA1 Message Date
VIA256 e09e9d56a5 added PlayerPrefs helper for loading settings 2025-12-22 22:10:47 -08:00
VIA256 95539b024a add beginnings of LobbyDecor.gd 2025-12-22 19:32:07 -08:00
5 changed files with 101 additions and 6 deletions
@@ -0,0 +1,75 @@
## PlayerPrefs.json example
"""
{
"i":{
"useMusic":1,
"hyperCam":0
},
"f":{
"camDist":3.422428
},
"s":{
"playerName":"MarsRacer"
}
}
"""
class_name PlayerPrefs;
extends Object;
const _prefs_path : String = "user://PlayerPrefs.json";
static var _prefs_synced : bool = false;
static var _int_prefs : Dictionary = {};
static var _float_prefs : Dictionary = {};
static var _string_prefs : Dictionary = {};
static func _sync_prefs():
_prefs_synced = true;
var jsonfile : FileAccess = FileAccess.open(_prefs_path, FileAccess.READ);
if jsonfile == null: return;
var jsontxt : String = jsonfile.get_as_text(true);
var json : Variant = JSON.parse_string(jsontxt);
if json == null || \
typeof(json) != TYPE_DICTIONARY:
return;
var jdict : Dictionary = json;
if jdict.has("i") && typeof(jdict["i"]) == TYPE_DICTIONARY:
_int_prefs = jdict["i"];
if jdict.has("f") && typeof(jdict["f"]) == TYPE_DICTIONARY:
_float_prefs = jdict["f"];
if jdict.has("s") && typeof(jdict["s"]) == TYPE_DICTIONARY:
_string_prefs = jdict["s"];
static func GetInt(key : String, default_value : int) -> int:
if !_prefs_synced:
_sync_prefs();
if _int_prefs.has(key) && (_int_prefs[key] as int) != null:
return _int_prefs[key];
else:
return default_value;
static func GetFloat(key : String, default_value : float) -> float:
if !_prefs_synced:
_sync_prefs();
if _float_prefs.has(key) && (_float_prefs[key] as float) != null:
return _float_prefs[key];
else:
return default_value;
static func GetString(key : String, default_value : String) -> String:
if !_prefs_synced:
_sync_prefs();
if _string_prefs.has(key) && (_string_prefs[key] as String) != null:
return _string_prefs[key];
else:
return default_value;
@@ -0,0 +1 @@
uid://iu33nnlpjkcj
+19 -2
View File
@@ -6,5 +6,22 @@ extends Node
@export var logoOffset : int;
func _ready() -> void:
pass;
@export var mainCamera : Node3D;
@onready var guiTexture : TextureRect = get_node("c_GUITexture");
func _ready():
if Time.get_ticks_msec() > 6000: guiTexture.modulate.a = 0;
elif bg:
bg.position = Vector2.ZERO;
bg.size = get_viewport().get_visible_rect().size;
func _process(_delta : float):
var screen_size = get_viewport().get_visible_rect().size
var width = screen_size.y * .84;
if width > 600: width -= (width - 600) * .5;
if width > screen_size.x - 30: width = screen_size.x - 30;
if Time.get_ticks_msec() > 1500 && \
!mainCamera.get_node("c_Audio Source").playing && \
PlayerPrefs.GetInt("useMusic", 1) != 0:
mainCamera.get_node("c_Audio Source").playing = true;
+2 -4
View File
@@ -36,19 +36,17 @@ fov = 60.0
near = 0.3
far = 1000.0
[node name="c_Audio Listener" type="AudioListener3D" parent="Decor/Camera"]
[node name="c_Audio Source" type="AudioStreamPlayer3D" parent="Decor/Camera"]
stream = ExtResource("4_3i53s")
volume_db = 1.0
autoplay = true
parameters/looping = true
[node name="Logo" type="Node3D" parent="Decor" node_paths=PackedStringArray("refLobby", "bg")]
[node name="Logo" type="Node3D" parent="Decor" node_paths=PackedStringArray("refLobby", "bg", "mainCamera")]
transform = Transform3D(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)
script = ExtResource("3_2ycrl")
refLobby = NodePath("../../Lobby")
bg = NodePath("../BlackMask/c_GUITexture")
mainCamera = NodePath("../Camera")
[node name="c_GUITexture" type="TextureRect" parent="Decor/Logo"]
texture = ExtResource("6_hlym1")
+4
View File
@@ -14,6 +14,10 @@ config/name="godot-marsxplr"
run/main_scene="uid://bjnttl8ui408c"
config/features=PackedStringArray("4.5", "Mobile")
[audio]
buses/default_bus_layout=""
[display]
window/stretch/mode="canvas_items"