stepstead-client/autoload/config.gd
jts 6a1706051d İlk commit: Stepstead Godot istemci (4.6 Mobile)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-11 11:31:35 +03:00

63 lines
1.7 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends Node
## Global yapılandırma. API endpoint ve sabitler.
const API_BASE_URL := "https://api.stepstead.com"
const VERSION := "0.1.0"
const PLATFORM_ANDROID := "android"
const PLATFORM_IOS := "ios"
## Testler için runtime override (örn. headless E2E'de http://127.0.0.1:8002)
var override_base := ""
func get_api_base() -> String:
if override_base != "":
return override_base
return API_BASE_URL
func current_platform() -> String:
var name := OS.get_name().to_lower()
if name == "android":
return PLATFORM_ANDROID
if name == "ios":
return PLATFORM_IOS
return name
## --- Kullanıcı ayarları (Ayarlar paneli) ---
const _SETTINGS_PATH := "user://settings.cfg"
var sound_on := true
var music_on := true
var notif_on := true
func _ready() -> void:
load_settings()
func load_settings() -> void:
var cf := ConfigFile.new()
if cf.load(_SETTINGS_PATH) == OK:
sound_on = bool(cf.get_value("audio", "sound", true))
music_on = bool(cf.get_value("audio", "music", true))
notif_on = bool(cf.get_value("notify", "enabled", true))
_apply_audio()
func save_settings() -> void:
var cf := ConfigFile.new()
cf.set_value("audio", "sound", sound_on)
cf.set_value("audio", "music", music_on)
cf.set_value("notify", "enabled", notif_on)
cf.save(_SETTINGS_PATH)
_apply_audio()
func _apply_audio() -> void:
# "Sfx" / "Music" bus'ları varsa sustur; yoksa Master'ı ses ayarına bağla
var sfx := AudioServer.get_bus_index("Sfx")
if sfx != -1:
AudioServer.set_bus_mute(sfx, not sound_on)
var mus := AudioServer.get_bus_index("Music")
if mus != -1:
AudioServer.set_bus_mute(mus, not music_on)
if sfx == -1 and mus == -1:
var master := AudioServer.get_bus_index("Master")
if master != -1:
AudioServer.set_bus_mute(master, not (sound_on or music_on))