luminol_config/
project.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//
18//     Additional permission under GNU GPL version 3 section 7
19//
20// If you modify this Program, or any covered work, by linking or combining
21// it with Steamworks API by Valve Corporation, containing parts covered by
22// terms of the Steamworks API by Valve Corporation, the licensors of this
23// Program grant you additional permission to convey the resulting work.
24use serde::{Deserialize, Serialize};
25
26use super::{command_db, DataFormat, RGSSVer, RMVer, VolumeScale};
27
28#[derive(Debug, Clone)]
29#[allow(clippy::large_enum_variant)]
30pub struct Config {
31    pub project: Project,
32    pub command_db: command_db::CommandDB,
33    pub game_ini: ini::Ini,
34}
35
36#[derive(Serialize, Deserialize, Debug, Clone)]
37#[serde(default)]
38/// Local luminol project config
39#[allow(missing_docs)]
40pub struct Project {
41    pub project_name: String,
42    pub scripts_path: String,
43    pub data_format: DataFormat,
44    pub rgss_ver: RGSSVer,
45    pub editor_ver: RMVer,
46    pub volume_scale: VolumeScale,
47    pub playtest_exe: String,
48    pub prefer_rgssad: bool,
49    pub persistence_id: u64,
50}
51
52impl Default for Project {
53    fn default() -> Self {
54        Self {
55            project_name: String::new(),
56            scripts_path: "Scripts".to_string(),
57            data_format: DataFormat::Marshal,
58            rgss_ver: RGSSVer::RGSS1,
59            editor_ver: RMVer::XP,
60            volume_scale: VolumeScale::Db35,
61            playtest_exe: "game".to_string(),
62            prefer_rgssad: false,
63            persistence_id: 0,
64        }
65    }
66}
67
68impl Config {
69    pub fn from_project(project: Project) -> Self {
70        let mut game_ini = ini::Ini::new();
71        game_ini
72            .with_section(Some("Game"))
73            .set("Library", "RGSS104E.dll")
74            .set("Scripts", format!("Data/{}", project.scripts_path))
75            .set("Title", &project.project_name)
76            .set("RTP1", "")
77            .set("RTP2", "")
78            .set("RTP3", "");
79
80        let command_db = command_db::CommandDB::new(project.editor_ver);
81
82        Self {
83            project,
84            command_db,
85            game_ini,
86        }
87    }
88}