mirror of
https://github.com/Cuteminded/jellyframe.git
synced 2026-10-25 21:00:33 +01:00
Adds a new Passthrough viewing environment alongside Void and Theatre, including runtime support detection, environment blend switching, and safe fallback to Void when unsupported. Updates settings persistence/validation and the settings UI to expose Passthrough with proper disabled state and guidance. Also wires passthrough into world/main environment application flow, adds focused passthrough and settings tests, and introduces Android build setup to fetch/pin OpenXR vendor assets with checksum verification.
60 lines
2.4 KiB
GDScript
60 lines
2.4 KiB
GDScript
class_name JellyframeSettings
|
|
extends RefCounted
|
|
|
|
const PATH := "user://settings.cfg"
|
|
const SCREEN_KEYS := ["width", "distance", "height", "curvature"]
|
|
const LIBRARY_SORT_OPTIONS := [
|
|
["Name", "SortName"], ["Random", "Random"],
|
|
["Community rating", "CommunityRating"], ["Critics rating", "CriticRating"],
|
|
["Date added", "DateCreated"], ["Date played", "DatePlayed"],
|
|
["Parental rating", "OfficialRating"], ["Play count", "PlayCount"],
|
|
["Release date", "PremiereDate"], ["Runtime", "Runtime"]
|
|
]
|
|
var width := 3.6
|
|
var distance := 3.0
|
|
var height := 0.0
|
|
var curvature := 0.0
|
|
var environment := "Void"
|
|
var server := ""
|
|
var device_id := ""
|
|
var library_sort_by := "SortName"
|
|
var library_sort_order := "Ascending"
|
|
|
|
func load_settings(path: String = PATH) -> void:
|
|
var config := ConfigFile.new()
|
|
config.load(path)
|
|
width = clampf(config.get_value("screen", "width", width), 1.5, 7.0)
|
|
distance = clampf(config.get_value("screen", "distance", distance), 1.5, 8.0)
|
|
height = clampf(config.get_value("screen", "height", height), -2.0, 2.0)
|
|
curvature = clampf(config.get_value("screen", "curvature", curvature), 0.0, 1.2)
|
|
environment = config.get_value("screen", "environment", "Void")
|
|
if environment not in ["Void", "Theatre", "Passthrough"]: environment = "Void"
|
|
server = config.get_value("connection", "server", "")
|
|
device_id = config.get_value("connection", "device_id", "")
|
|
library_sort_by = str(config.get_value("library", "sort_by", "SortName"))
|
|
if not LIBRARY_SORT_OPTIONS.any(func(option: Array): return option[1] == library_sort_by):
|
|
library_sort_by = "SortName"
|
|
library_sort_order = str(config.get_value("library", "sort_order", "Ascending"))
|
|
if library_sort_order not in ["Ascending", "Descending"]:
|
|
library_sort_order = "Ascending"
|
|
if device_id.is_empty():
|
|
device_id = Crypto.new().generate_random_bytes(16).hex_encode()
|
|
save(path)
|
|
|
|
func reset_screen() -> void:
|
|
var defaults := JellyframeSettings.new()
|
|
for key in SCREEN_KEYS:
|
|
set(key, defaults.get(key))
|
|
|
|
func save(path: String = PATH) -> Error:
|
|
var config := ConfigFile.new()
|
|
for key in SCREEN_KEYS:
|
|
config.set_value("screen", key, get(key))
|
|
config.set_value("screen", "environment", environment)
|
|
config.set_value("connection", "server", server)
|
|
config.set_value("connection", "device_id", device_id)
|
|
config.set_value("library", "sort_by", library_sort_by)
|
|
config.set_value("library", "sort_order", library_sort_order)
|
|
return config.save(path)
|
|
|