Files
STARTLINER/rust/src/model/profile.rs

249 lines
5.5 KiB
Rust

use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use crate::pkg::PkgKey;
use enumflags2::bitflags;
use super::misc::Game;
#[derive(Deserialize, Serialize, Clone, Default, PartialEq, Debug)]
pub enum Aime {
Disabled,
#[default] BuiltIn,
AMNet(PkgKey),
Other(PkgKey),
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(default)]
pub struct AMNet {
pub name: String,
pub addr: String,
pub physical: bool,
}
impl Default for AMNet {
fn default() -> Self {
Self { name: Default::default(), addr: "http://+:6070".to_string(), physical: false }
}
}
#[derive(Deserialize, Serialize, Clone, Debug, Default )]
#[serde(default)]
pub struct Segatools {
pub target: PathBuf,
pub hook: Option<PkgKey>,
pub io: Option<PkgKey>,
pub aime: Aime,
pub amfs: PathBuf,
pub option: PathBuf,
pub appdata: PathBuf,
pub intel: bool,
pub amnet: AMNet,
pub aime_port: Option<i32>,
}
impl Segatools {
pub fn default_for(game: Game) -> Self {
Segatools {
target: PathBuf::default(),
hook: match game {
Game::Ongeki => Some(PkgKey("segatools-mu3hook".to_owned())),
Game::Chunithm => Some(PkgKey("segatools-chusanhook".to_owned()))
},
io: None,
amfs: PathBuf::default(),
option: PathBuf::default(),
appdata: PathBuf::from("appdata"),
aime: Aime::default(),
intel: false,
amnet: AMNet::default(),
aime_port: None
}
}
}
#[derive(Deserialize, Serialize, Clone, Default, PartialEq, Debug)]
pub enum DisplayMode {
Window,
#[default] Borderless,
Fullscreen
}
#[derive(Deserialize, Serialize, Clone, Debug, Default)]
#[serde(default)]
pub struct Display {
pub target: String,
pub rez: (i32, i32),
pub mode: DisplayMode,
pub rotation: Option<i32>,
pub frequency: i32,
pub borderless_fullscreen: bool,
pub dont_switch_primary: bool,
pub monitor_index_override: Option<i32>,
}
impl Display {
pub fn default_for(game: Game) -> Self {
Display {
target: "default".to_owned(),
rez: match game {
Game::Chunithm => (1920, 1080),
Game::Ongeki => (1080, 1920),
},
mode: DisplayMode::Borderless,
rotation: None,
frequency: match game {
Game::Chunithm => 120,
Game::Ongeki => 60,
},
borderless_fullscreen: true,
dont_switch_primary: false,
monitor_index_override: None,
}
}
}
#[derive(Deserialize, Serialize, Clone, Default, PartialEq, Debug)]
pub enum NetworkType {
#[default] Remote,
Artemis,
}
#[derive(Deserialize, Serialize, Clone, Default, Debug)]
#[serde(default)]
pub struct Network {
pub network_type: NetworkType,
pub local_path: PathBuf,
pub local_console: bool,
pub remote_address: String,
pub keychip: String,
pub subnet: String,
pub suffix: Option<i32>,
}
#[derive(Deserialize, Serialize, Clone, Default, Debug)]
#[serde(default)]
pub struct BepInEx {
pub console: bool,
}
#[derive(Deserialize, Serialize, Clone)]
#[serde(default)]
pub struct Wine {
pub runtime: PathBuf,
pub prefix: PathBuf,
}
impl Default for Wine {
fn default() -> Self {
Wine {
runtime: PathBuf::from("/usr/bin/wine"),
prefix: std::env::var("HOME")
.and_then(|home| Ok(PathBuf::from(home).join(".wine")))
.unwrap_or_default()
}
}
}
#[derive(Deserialize, Serialize, Clone, PartialEq, Debug, Copy)]
pub enum Mu3Audio {
Shared,
Excl6Ch,
Excl2Ch,
}
#[derive(Deserialize, Serialize, Clone, Debug, Default)]
#[serde(default)]
pub struct Mu3Ini {
pub audio: Option<Mu3Audio>,
pub blacklist: Option<(i32, i32)>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(default)]
pub struct OngekiKeyboard {
pub enabled: bool,
pub use_mouse: bool,
pub coin: i32,
pub svc: i32,
pub test: i32,
pub lmenu: i32,
pub rmenu: i32,
pub l1: i32,
pub l2: i32,
pub l3: i32,
pub r1: i32,
pub r2: i32,
pub r3: i32,
pub lwad: i32,
pub rwad: i32,
}
impl Default for OngekiKeyboard {
fn default() -> Self {
Self {
enabled: true,
use_mouse: true,
test: 0x70,
svc: 0x71,
coin: 0x72,
lmenu: 0x55,
rmenu: 0x4F,
lwad: 0x01,
rwad: 0x02,
l1: 0x41,
l2: 0x53,
l3: 0x44,
r1: 0x4A,
r2: 0x4B,
r3: 0x4C
}
}
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(default)]
pub struct ChunithmKeyboard {
pub enabled: bool,
pub coin: i32,
pub svc: i32,
pub test: i32,
pub cell: [i32; 32],
pub ir: [i32; 6],
}
impl Default for ChunithmKeyboard {
fn default() -> Self {
Self {
enabled: true,
test: 0x70,
svc: 0x71,
coin: 0x72,
cell: Default::default(),
ir: Default::default(),
}
}
}
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(tag = "game", content = "data")]
pub enum Keyboard {
Ongeki(OngekiKeyboard),
Chunithm(ChunithmKeyboard),
}
#[bitflags]
#[repr(u16)]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum ProfileModule {
Segatools,
Network,
Display,
BepInEx,
Mu3Ini,
Keyboard,
Mempatcher
}