DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 0d4a11794094ba20b6d6a637f748f3c819eab1f3 deck-builder/client/src/cfg/mod.rs -rw-r--r-- 2.1 KiB
0d4a1179Jonni Liljamo feat(api): init diesel and db 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * 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, Debug, Component, PartialEq, Clone)]
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, Debug, Component, PartialEq, Clone)]
pub struct CfgUser {
    /// User logged in status
    pub logged_in: bool,
    /// User Token
    pub user_token: String,
    /// User ID
    pub id: String,
    /// Username
    pub username: String,
    /// User email
    pub email: String,
}

impl Default for CfgUser {
    fn default() -> Self {
        CfgUser {
            logged_in: false,
            user_token: "".to_string(),
            id: "".to_string(),
            username: "".to_string(),
            email: "".to_string(),
        }
    }
}

/// Settings that the user has no access to, or can only access through developer settings
#[derive(Serialize, Deserialize, Resource, Debug, Component, PartialEq, Clone)]
pub struct CfgDev {
    /// API Server
    pub api_server: String,
}

impl Default for CfgDev {
    fn default() -> Self {
        CfgDev {
            api_server: "http://localhost:8080/api".to_string(),
        }
    }
}