1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
mod constants;
mod version;
mod profile;
mod strsub;
use std::collections::HashMap;
use std::error::Error;
use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use version::VersionList;
use crate::launcher::profile::{Instance, Profile};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Settings {
profiles: HashMap<String, Profile>,
instances: HashMap<String, Instance>
}
pub struct Launcher {
online: bool,
home: PathBuf,
versions: VersionList,
settings_path: PathBuf, // maybe redundant but idc >:3
settings: Settings,
}
impl Launcher {
// FIXME: more descriptive error type por favor
pub async fn new(home: &Path, online: bool) -> Result<Launcher, Box<dyn Error>> {
let home = home.to_owned();
let versions;
if online {
versions = VersionList::online(home.join("versions").as_ref()).await?;
} else {
versions = VersionList::offline(home.join("versions").as_ref()).await?;
}
let settings_path = home.join("ozone.json");
let settings = serde_json::from_str(tokio::fs::read_to_string(&settings_path).await?.as_str())?;
Ok(Launcher {
online,
home: home.to_owned(),
versions,
settings_path,
settings
})
}
pub async fn launch(profile: &Profile) -> Result<(), Box<dyn Error>> {
/* tasks 2 l;aunch the gayme!!!! :3
* - java runtime
* - normal process (good research, past figboot :3)
* - libraries
* - check which libraries we actually need (some have classifiers that don't apply to us)
* - of the libraries we need, check which have correct size and sha1
* - redownload necessary libraries
* - (if offline mode and there are libraries to download, then explode violently)
* - extract natives
* - logging
* - download the config if present and necessary
* - (explode if offline mode and we need to download stuff)
* - assets
* - get asset index (check if our local copy is good and redownload if not)
* - check what ones are good and what needs to be downloaded
* - download them
* - (if offline mode, explode)
* - if virtual or resource-mapped, copy (or perhaps hardlink? that would be cool)
* - the actual client jar
* - check integriddy and download if needed
* - (explode if offline mode)
* - launch the game
* - build argument list and whatnot also
*/
todo!()
}
}
|