You've already forked AstralRinth
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:
53
theseus_gui/src/helpers/settings.js
Normal file
53
theseus_gui/src/helpers/settings.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* All theseus API calls return serialized values (both return values and errors);
|
||||
* So, for example, addDefaultInstance creates a blank Profile object, where the Rust struct is serialized,
|
||||
* and deserialized into a usable JS object.
|
||||
*/
|
||||
import { invoke } from '@tauri-apps/api/tauri'
|
||||
|
||||
// Settings object
|
||||
/*
|
||||
|
||||
Settings {
|
||||
"memory": MemorySettings,
|
||||
"game_resolution": [int int],
|
||||
"custom_java_args": [String ...],
|
||||
"custom_env_args" : [(string, string) ... ]>,
|
||||
"java_8_path": Path (can be null),
|
||||
"java_17_path": Path (can be null),
|
||||
"default_user": Uuid string (can be null),
|
||||
"hooks": Hooks,
|
||||
"max_concurrent_downloads": uint,
|
||||
"version": u32,
|
||||
}
|
||||
|
||||
Memorysettings {
|
||||
"min": u32, can be null,
|
||||
"max": u32,
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// An example test function for getting/setting settings
|
||||
export async function test() {
|
||||
// First, print settings and store them to an object
|
||||
let settings = await get()
|
||||
console.log(JSON.stringify(settings))
|
||||
|
||||
// Then set some random settings in that object
|
||||
settings.java_8_path = '/example/path'
|
||||
|
||||
// Set the new settings object
|
||||
await set(settings)
|
||||
console.log(JSON.stringify(await get()))
|
||||
}
|
||||
|
||||
// Get full settings object
|
||||
export async function get() {
|
||||
return await invoke('settings_get')
|
||||
}
|
||||
|
||||
// Set full settings object
|
||||
export async function set(settings) {
|
||||
return await invoke('settings_set', { settings })
|
||||
}
|
||||
Reference in New Issue
Block a user