use enumflags2::make_bitflags; use serde::{Deserialize, Serialize}; use crate::pkg::PkgKey; use super::profile::ProfileModule; #[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Copy)] pub enum Game { #[serde(rename = "ongeki")] Ongeki, #[serde(rename = "chunithm")] Chunithm, } impl Game { pub fn from_str(s: &str) -> Option { match s { "ongeki" => Some(Game::Ongeki), "chunithm" => Some(Game::Chunithm), _ => None } } pub fn hook_exe(&self) -> &'static str { match self { Game::Ongeki => "mu3hook.dll", Game::Chunithm => "chusanhook_x86.dll", } } pub fn hook_amd(&self) -> &'static str { match self { Game::Ongeki => "mu3hook.dll", Game::Chunithm => "chusanhook_x64.dll", } } pub fn inject_exe(&self) -> &'static str { match self { Game::Ongeki => "inject.exe", Game::Chunithm => "inject_x86.exe", } } pub fn inject_amd(&self) -> &'static str { match self { Game::Ongeki => "inject.exe", Game::Chunithm => "inject_x64.exe", } } pub fn exe(&self) -> &'static str { match self { Game::Ongeki => "mu3.exe", Game::Chunithm => "chusanApp.exe", } } pub fn amd_args(&self) -> Vec<&'static str> { match self { Game::Ongeki => vec!["-f", "-c", "config_common.json", "config_server.json", "config_client.json"], Game::Chunithm => vec!["-c", "config_common.json", "config_server.json", "config_client.json", "config_cvt.json", "config_sp.json", "config_hook.json"] } } pub fn has_module(&self, module: ProfileModule) -> bool { match self { Game::Ongeki => make_bitflags!(ProfileModule::{Segatools | Display | Network | BepInEx | Mu3Ini | Keyboard}), Game::Chunithm => make_bitflags!(ProfileModule::{Segatools | Network | Keyboard}), }.contains(module) } } impl std::fmt::Display for Game { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Game::Ongeki => write!(f, "ongeki"), Game::Chunithm => write!(f, "chunithm") } } } #[derive(Serialize, Deserialize)] pub enum StartCheckError { MissingRemotePackage(PkgKey), MissingLocalPackage(PkgKey), MissingDependency(PkgKey, PkgKey), MissingTool(PkgKey), }