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

79 lines
2.1 KiB
Rust

use serde::{Deserialize, Serialize};
use crate::pkg::PkgKey;
#[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<Game> {
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"]
}
}
}
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),
}