improved types
- moved types to types.rs - added custom serialization logic
This commit is contained in:
parent
bbe2bdf72d
commit
a0795c8041
2 changed files with 77 additions and 37 deletions
|
@ -1,50 +1,16 @@
|
||||||
// [Sync]: must be synced with `src/pages/Install/types.ts`
|
|
||||||
use tauri::Window;
|
use tauri::Window;
|
||||||
|
|
||||||
use crate::constants;
|
use crate::constants;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
||||||
|
mod types;
|
||||||
|
|
||||||
mod install_bepinex;
|
mod install_bepinex;
|
||||||
mod install_mod;
|
mod install_mod;
|
||||||
mod launch_game;
|
mod launch_game;
|
||||||
mod launch_options;
|
mod launch_options;
|
||||||
|
|
||||||
// [Sync]
|
use types::{InstallErr, InstallResult, InstallSteps};
|
||||||
#[derive(Clone, serde::Serialize)]
|
|
||||||
pub enum InstallSteps {
|
|
||||||
DownloadBepInEx,
|
|
||||||
InstallBepInEx,
|
|
||||||
LaunchOption,
|
|
||||||
LaunchGame,
|
|
||||||
DownloadWbmZip,
|
|
||||||
InstallWbm,
|
|
||||||
Done,
|
|
||||||
}
|
|
||||||
|
|
||||||
// [Sync]
|
|
||||||
#[derive(serde::Serialize, PartialEq)]
|
|
||||||
pub enum InstallResult {
|
|
||||||
NoErr,
|
|
||||||
SetLaunchOption,
|
|
||||||
LaunchGame,
|
|
||||||
Skip, // only used for subcommands
|
|
||||||
}
|
|
||||||
|
|
||||||
// [Sync]
|
|
||||||
#[derive(serde::Serialize)]
|
|
||||||
pub enum InstallErr {
|
|
||||||
FailedToGetGamePath,
|
|
||||||
UnsupportedOS,
|
|
||||||
BepInExDownloadFailed,
|
|
||||||
BepInExUnzipFailed,
|
|
||||||
WBMDownloadFailed,
|
|
||||||
WBMRemoveFailed,
|
|
||||||
WBMDirectoryCreationFailed,
|
|
||||||
WBMUnzipFailed,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize)]
|
|
||||||
struct InstallPayload(i64);
|
|
||||||
|
|
||||||
// todo: show current step in the frontend
|
// todo: show current step in the frontend
|
||||||
|
|
||||||
|
|
74
src-tauri/src/commands/install/types.rs
Normal file
74
src-tauri/src/commands/install/types.rs
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/// must be synced with `src/pages/Install/types.ts`
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum InstallSteps {
|
||||||
|
DownloadBepInEx,
|
||||||
|
InstallBepInEx,
|
||||||
|
LaunchOption,
|
||||||
|
LaunchGame,
|
||||||
|
DownloadWbmZip,
|
||||||
|
InstallWbm,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl serde::Serialize for InstallSteps {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
serializer.serialize_i64(*self as i64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
pub enum InstallResult {
|
||||||
|
NoErr,
|
||||||
|
SetLaunchOption,
|
||||||
|
LaunchGame,
|
||||||
|
Skip, // only used for subcommands
|
||||||
|
}
|
||||||
|
|
||||||
|
impl serde::Serialize for InstallResult {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
serializer.serialize_i64(*self as i64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum InstallErr {
|
||||||
|
FailedToGetGamePath,
|
||||||
|
UnsupportedOS,
|
||||||
|
BepInExDownloadFailed,
|
||||||
|
BepInExUnzipFailed,
|
||||||
|
WBMDownloadFailed,
|
||||||
|
WBMRemoveFailed,
|
||||||
|
WBMDirectoryCreationFailed,
|
||||||
|
WBMUnzipFailed,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl serde::Serialize for InstallErr {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: serde::Serializer,
|
||||||
|
{
|
||||||
|
serializer.serialize_i64(*self as i64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// #[derive(Clone, serde::Serialize)]
|
||||||
|
// struct InstallPayload(i64);
|
Loading…
Add table
Add a link
Reference in a new issue