Files
STARTLINER/rust/src/model/misc.rs
2025-04-16 13:20:43 +00:00

119 lines
3.2 KiB
Rust

use enumflags2::make_bitflags;
use serde::{Deserialize, Serialize};
use crate::pkg::PkgKey;
use super::profile::ProfileModule;
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Copy)]
#[serde(rename_all = "snake_case")]
pub enum Game {
Ongeki,
Chunithm,
}
impl Game {
pub fn from_str(s: &str) -> Option<Game> {
match s {
"ongeki" => Some(Game::Ongeki),
"chunithm" => Some(Game::Chunithm),
_ => None
}
}
pub fn print(&self) -> &'static str {
match self {
Game::Ongeki => "O.N.G.E.K.I.",
Game::Chunithm => "CHUNITHM"
}
}
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"]
}
}
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 | Display | Network | Keyboard | Mempatcher}),
}.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),
}
#[derive(Default, Serialize, Deserialize, Clone)]
pub struct ConfigHook {
#[serde(skip_serializing_if = "Option::is_none")]
pub allnet_auth: Option<ConfigHookAuth>,
#[serde(skip_serializing_if = "Option::is_none")]
pub aime: Option<ConfigHookAime>,
}
#[derive(Default, Serialize, Deserialize, Clone)]
pub struct ConfigHookAuth {
pub r#type: String
}
#[derive(Default, Serialize, Deserialize, Clone)]
pub struct ConfigHookAime {
pub unit: Vec<ConfigHookAimeUnit>
}
#[derive(Default, Serialize, Deserialize, Clone)]
pub struct ConfigHookAimeUnit {
pub port: i32,
pub id: i32
}