summaryrefslogtreecommitdiffstats
path: root/src/launcher/settings.rs
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-01-20 04:33:28 -0600
committerLibravatar bigfoot547 <[email protected]>2025-01-20 04:33:28 -0600
commitb317a8a652d2e3a48c8b9f4940c7933d3802cfc3 (patch)
treeec06208dd483d17eb7c764587c7629e4e4f0d100 /src/launcher/settings.rs
parentget rid of wacky closure business (diff)
it runs the game
Diffstat (limited to 'src/launcher/settings.rs')
-rw-r--r--src/launcher/settings.rs42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/launcher/settings.rs b/src/launcher/settings.rs
index 5a96589..29d9220 100644
--- a/src/launcher/settings.rs
+++ b/src/launcher/settings.rs
@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::error::Error;
+use std::ffi::{OsStr, OsString};
use std::fmt::{Display, Formatter};
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
@@ -140,11 +141,28 @@ pub enum ProfileVersion {
Specific(String)
}
+#[derive(Deserialize, Serialize, Debug, Clone, Copy)]
+pub struct Resolution {
+ width: u32,
+ height: u32
+}
+
+impl Default for Resolution {
+ fn default() -> Self {
+ Resolution { width: 864, height: 480 }
+ }
+}
+
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Profile {
game_version: ProfileVersion,
java_runtime: Option<String>,
- instance: String // ugly that this is a string instead of reference to an Instance but whatever I'm lazy
+ instance: String, // ugly that this is a string instead of reference to an Instance but whatever I'm lazy
+
+ #[serde(default)]
+ jvm_arguments: Vec<OsString>,
+
+ resolution: Option<Resolution>
}
impl<P: AsRef<Path>> From<P> for Instance {
@@ -165,12 +183,24 @@ impl Instance {
}
}
+const DEF_JVM_ARGUMENTS: [&'static str; 7] = [
+ "-Xmx2G",
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:+UseG1GC",
+ "-XX:G1NewSizePercent=20",
+ "-XX:G1ReservePercent=20",
+ "-XX:MaxGCPauseMillis=50",
+ "-XX:G1HeapRegionSize=32M"
+];
+
impl Profile {
fn new(instance_name: &str) -> Self {
Self {
game_version: ProfileVersion::LatestRelease,
java_runtime: None,
- instance: instance_name.into()
+ instance: instance_name.into(),
+ jvm_arguments: DEF_JVM_ARGUMENTS.iter().map(OsString::from).collect(),
+ resolution: None
}
}
@@ -181,4 +211,12 @@ impl Profile {
pub fn get_instance_name(&self) -> &str {
&self.instance
}
+
+ pub fn iter_arguments(&self) -> impl Iterator<Item = &OsString> {
+ self.jvm_arguments.iter()
+ }
+
+ pub fn get_resolution(&self) -> Option<Resolution> {
+ self.resolution
+ }
}