luminol_config/
lib.rs

1// Copyright (C) 2024 Melody Madeline Lyons
2//
3// This file is part of Luminol.
4//
5// Luminol is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Luminol is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Luminol.  If not, see <http://www.gnu.org/licenses/>.
17
18pub mod command_db;
19pub mod global;
20pub mod project;
21#[cfg(not(target_arch = "wasm32"))]
22pub mod terminal;
23
24#[derive(Clone, Copy, Hash, PartialEq, Debug, Default)]
25#[derive(serde::Deserialize, serde::Serialize)]
26#[derive(strum::EnumIter, strum::Display)]
27pub enum DataFormat {
28    #[default]
29    #[strum(to_string = "Ruby Marshal")]
30    Marshal,
31    #[strum(to_string = "RON")]
32    Ron { pretty: bool },
33    #[strum(to_string = "JSON")]
34    Json { pretty: bool },
35}
36
37impl DataFormat {
38    pub fn extension(self) -> &'static str {
39        match self {
40            Self::Marshal => "rxdata",
41            Self::Ron { .. } => "ron",
42            Self::Json { .. } => "json",
43        }
44    }
45}
46
47#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Debug)]
48#[derive(serde::Serialize, serde::Deserialize)]
49#[derive(strum::EnumIter, strum::Display)]
50#[allow(missing_docs)]
51pub enum RGSSVer {
52    #[strum(to_string = "ModShot")]
53    ModShot,
54    #[strum(to_string = "mkxp-oneshot")]
55    MKXPOneShot,
56    #[strum(to_string = "rsgss")]
57    RSGSS,
58    #[strum(to_string = "mkxp")]
59    MKXP,
60    #[strum(to_string = "mkxp-freebird")]
61    MKXPFreebird,
62    #[strum(to_string = "mkxp-z")]
63    MKXPZ,
64    #[default]
65    #[strum(to_string = "Stock RGSS1")]
66    RGSS1,
67}
68
69#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Debug)]
70#[derive(serde::Serialize, serde::Deserialize)]
71#[derive(strum::EnumIter, strum::Display)]
72#[allow(missing_docs)]
73pub enum RMVer {
74    #[default]
75    #[strum(to_string = "RPG Maker XP")]
76    XP = 1,
77    #[strum(to_string = "RPG Maker VX")]
78    VX = 2,
79    #[strum(to_string = "RPG Maker VX Ace")]
80    Ace = 3,
81}
82
83#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Debug)]
84#[derive(serde::Serialize, serde::Deserialize)]
85#[derive(strum::EnumIter, strum::Display)]
86#[allow(missing_docs)]
87pub enum VolumeScale {
88    #[default]
89    #[strum(to_string = "-35 dB")]
90    Db35,
91    #[strum(to_string = "Linear")]
92    Linear,
93}
94
95#[derive(Clone, Copy, Hash, PartialEq, Debug)]
96#[derive(serde::Serialize, serde::Deserialize)]
97pub struct CodeTheme {
98    pub dark_mode: bool,
99
100    pub syntect_theme: SyntectTheme,
101}
102
103impl Default for CodeTheme {
104    fn default() -> Self {
105        Self::dark()
106    }
107}
108
109impl CodeTheme {
110    #[must_use]
111    pub const fn dark() -> Self {
112        Self {
113            dark_mode: true,
114            syntect_theme: SyntectTheme::Base16MochaDark,
115        }
116    }
117
118    #[must_use]
119    pub const fn light() -> Self {
120        Self {
121            dark_mode: false,
122            syntect_theme: SyntectTheme::SolarizedLight,
123        }
124    }
125}
126
127#[derive(Clone, Copy, Hash, PartialEq, Debug)]
128#[derive(serde::Deserialize, serde::Serialize)]
129#[derive(strum::EnumIter, strum::Display)]
130pub enum SyntectTheme {
131    #[strum(to_string = "Base16 Eighties (dark)")]
132    Base16EightiesDark,
133    #[strum(to_string = "Base16 Mocha (dark)")]
134    Base16MochaDark,
135    #[strum(to_string = "Base16 Ocean (dark)")]
136    Base16OceanDark,
137    #[strum(to_string = "Base16 Ocean (light)")]
138    Base16OceanLight,
139    #[strum(to_string = "InspiredGitHub (light)")]
140    InspiredGitHub,
141    #[strum(to_string = "Solarized (dark)")]
142    SolarizedDark,
143    #[strum(to_string = "Solarized (light)")]
144    SolarizedLight,
145}
146
147impl SyntectTheme {
148    pub fn syntect_key_name(self) -> &'static str {
149        match self {
150            Self::Base16EightiesDark => "base16-eighties.dark",
151            Self::Base16MochaDark => "base16-mocha.dark",
152            Self::Base16OceanDark => "base16-ocean.dark",
153            Self::Base16OceanLight => "base16-ocean.light",
154            Self::InspiredGitHub => "InspiredGitHub",
155            Self::SolarizedDark => "Solarized (dark)",
156            Self::SolarizedLight => "Solarized (light)",
157        }
158    }
159
160    pub fn is_dark(self) -> bool {
161        match self {
162            Self::Base16EightiesDark
163            | Self::Base16MochaDark
164            | Self::Base16OceanDark
165            | Self::SolarizedDark => true,
166
167            Self::Base16OceanLight | Self::InspiredGitHub | Self::SolarizedLight => false,
168        }
169    }
170}