/*
* This file is part of laurelin/client
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* Licensed under GPL-3.0-only.
* See LICENSE for licensing information.
*/
use bevy::prelude::*;
use serde::{Deserialize, Serialize};
// Constants for file names
pub const FILE_CFG_SETTINGS: &str = "cfgsettings.json";
pub const FILE_CFG_USER: &str = "cfguser.json";
pub const FILE_CFG_DEV: &str = ".cfgdev.json";
/// Stores a directories::ProjectDirs for easy access
#[derive(Resource, Debug, Component, Clone)]
pub struct CfgDirs(pub directories::ProjectDirs);
/// Various settings that can be changed from the... Settings.
#[derive(Serialize, Deserialize, Resource, Reflect, Debug, Component, PartialEq, Clone)]
#[reflect(Resource)]
pub struct CfgSettings {
/// Master Volume
pub volume_master: u32,
/// Fullscreen
pub fullscreen: bool,
/// Resolution
pub resolution: (f32, f32),
}
impl Default for CfgSettings {
fn default() -> Self {
CfgSettings {
volume_master: 7,
fullscreen: false,
resolution: (1280., 720.),
}
}
}
/// User details and status
#[derive(Serialize, Deserialize, Resource, Reflect, Debug, Component, PartialEq, Clone)]
#[reflect(Resource)]
pub struct CfgUser {
/// User logged in status
pub logged_in: bool,
/// Username
pub username: String,
/// User Session Cookie
pub cookie: String,
}
impl Default for CfgUser {
fn default() -> Self {
CfgUser {
logged_in: false,
username: "".to_string(),
cookie: "".to_string(),
}
}
}
/// Settings that the user has no access to, or can only access through developer settings
#[derive(Serialize, Deserialize, Resource, Reflect, Debug, Component, PartialEq, Clone)]
#[reflect(Resource)]
pub struct CfgDev {
/// Server
pub server_address: String,
}
impl Default for CfgDev {
fn default() -> Self {
CfgDev {
server_address: "http://127.0.0.1:14191".to_string(),
}
}
}