forked from didirus/AstralRinth
added settings API + fixed bug (#62)
* added settings API + fixed bug * removed redundant API funcs * comment clarifications --------- Co-authored-by: Wyatt <wyatt@modrinth.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
pub mod auth;
|
||||
pub mod profile;
|
||||
pub mod profile_create;
|
||||
pub mod settings;
|
||||
|
||||
pub mod data {
|
||||
pub use crate::state::{
|
||||
@@ -15,6 +16,6 @@ pub mod prelude {
|
||||
auth::{self, Credentials},
|
||||
data::*,
|
||||
profile::{self, Profile},
|
||||
profile_create, State,
|
||||
profile_create, settings, State,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -204,12 +204,15 @@ pub async fn run(
|
||||
let memory = profile.memory.unwrap_or(settings.memory);
|
||||
let resolution = profile.resolution.unwrap_or(settings.game_resolution);
|
||||
|
||||
let env_args = &settings.custom_env_args;
|
||||
|
||||
let mc_process = crate::launcher::launch_minecraft(
|
||||
&profile.metadata.game_version,
|
||||
&profile.metadata.loader_version,
|
||||
&profile.path,
|
||||
java_install,
|
||||
java_args,
|
||||
env_args,
|
||||
wrapper,
|
||||
&memory,
|
||||
&resolution,
|
||||
|
||||
24
theseus/src/api/settings.rs
Normal file
24
theseus/src/api/settings.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
//! Theseus profile management interface
|
||||
pub use crate::{
|
||||
state::{
|
||||
Hooks, JavaSettings, MemorySettings, Profile, Settings, WindowSize,
|
||||
},
|
||||
State,
|
||||
};
|
||||
|
||||
/// Gets entire settings
|
||||
#[tracing::instrument]
|
||||
pub async fn get() -> crate::Result<Settings> {
|
||||
let state = State::get().await?;
|
||||
let settings = state.settings.read().await;
|
||||
Ok(settings.clone())
|
||||
}
|
||||
|
||||
/// Sets entire settings
|
||||
#[tracing::instrument]
|
||||
pub async fn set(settings: Settings) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
// Replaces the settings struct in the RwLock with the passed argument
|
||||
*state.settings.write().await = settings;
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user