remove the performance flag toggle

This commit is contained in:
Julian Chang 2026-07-31 04:50:49 +07:00
parent 0735b21060
commit 3e864c1d0f
No known key found for this signature in database
12 changed files with 25 additions and 139 deletions

View file

@ -79,21 +79,11 @@ impl Component for ClusterSettings {
}
.into_element(),
)
.child(
ToggleRow {
cluster_id,
field: BoolField::PerfFlags,
value: profile.perf_flags,
global: global.perf_flags.unwrap_or(true),
}
.into_element(),
)
.child(text_row(cluster_id, TextField::JvmArgs, &profile, &global))
.child(section_header("GAME"))
.child(
ToggleRow {
cluster_id,
field: BoolField::ForceFullscreen,
value: profile.force_fullscreen,
global: global.force_fullscreen.unwrap_or(false),
}
@ -135,7 +125,6 @@ impl Component for ClusterSettings {
#[derive(Clone, Copy, PartialEq)]
enum Field {
ForceFullscreen,
PerfFlags,
Resolution,
MemMax,
JavaPath,
@ -145,7 +134,6 @@ fn clear_update(field: Field) -> ProfileUpdate {
let mut u = ProfileUpdate::default();
match field {
Field::ForceFullscreen => u.force_fullscreen = Patch::Clear,
Field::PerfFlags => u.perf_flags = Patch::Clear,
Field::Resolution => u.resolution = Patch::Clear,
Field::MemMax => u.mem_max = Patch::Clear,
Field::JavaPath => u.java_path = Patch::Clear,
@ -153,45 +141,6 @@ fn clear_update(field: Field) -> ProfileUpdate {
u
}
#[derive(Clone, Copy, PartialEq)]
enum BoolField {
ForceFullscreen,
PerfFlags,
}
impl BoolField {
fn meta(self) -> (IconType, &'static str, &'static str) {
match self {
Self::ForceFullscreen => (
IconType::Maximize01,
"Force Fullscreen",
"Force Minecraft to start in fullscreen mode.",
),
Self::PerfFlags => (
IconType::Rocket02,
"Performance JVM Flags",
"Tune the garbage collector, heap and string deduplication to suit this cluster's Java runtime.",
),
}
}
fn patch(self, value: Patch<bool>) -> ProfileUpdate {
let mut u = ProfileUpdate::default();
match self {
Self::ForceFullscreen => u.force_fullscreen = value,
Self::PerfFlags => u.perf_flags = value,
}
u
}
fn field(self) -> Field {
match self {
Self::ForceFullscreen => Field::ForceFullscreen,
Self::PerfFlags => Field::PerfFlags,
}
}
}
fn runtime_label(runtime: &JavaRuntime) -> String {
format!("{} {} ({})", runtime.vendor, runtime.major, runtime.version)
}
@ -231,7 +180,6 @@ fn override_cell(
#[derive(PartialEq)]
struct ToggleRow {
cluster_id: i64,
field: BoolField,
value: Option<bool>,
global: bool,
}
@ -239,7 +187,6 @@ struct ToggleRow {
impl Component for ToggleRow {
fn render(&self) -> impl IntoElement {
let cluster_id = self.cluster_id;
let field = self.field;
let overridden = self.value.is_some();
let global = self.global;
let dispatch = use_dispatch();
@ -255,22 +202,27 @@ impl Component for ToggleRow {
return;
}
last.set(v);
dispatch.update_cluster_profile(cluster_id, field.patch(Patch::Set(v)));
dispatch.update_cluster_profile(
cluster_id,
ProfileUpdate {
force_fullscreen: Patch::Set(v),
..Default::default()
},
);
});
}
let on_reset: EventHandler<()> = (move |()| {
last.set(global);
state.set(global);
dispatch.update_cluster_profile(cluster_id, clear_update(field.field()));
dispatch.update_cluster_profile(cluster_id, clear_update(Field::ForceFullscreen));
})
.into();
let (icon, title, description) = field.meta();
settings_row(
icon,
title,
description,
IconType::Maximize01,
"Force Fullscreen",
"Force Minecraft to start in fullscreen mode.",
override_cell(toggle(state), overridden, on_reset),
)
}

View file

@ -38,10 +38,6 @@ impl Component for SettingsMinecraft {
let v = profile.mem_max.map(|m| m.to_string()).unwrap_or_default();
move || v
});
let perf_flags = use_state({
let v = profile.perf_flags.unwrap_or(true);
move || v
});
let jvm_args = use_state({
let v = profile.launch_args.clone().unwrap_or_default();
move || v
@ -66,7 +62,6 @@ impl Component for SettingsMinecraft {
&width.read(),
&height.read(),
&memory.read(),
*perf_flags.read(),
&jvm_args.read(),
&pre_launch_command.read(),
&wrapper_command.read(),
@ -99,12 +94,6 @@ impl Component for SettingsMinecraft {
"The amount of memory in megabytes allocated for the game.",
memory_field(memory),
))
.child(settings_row(
IconType::Rocket02,
"Performance JVM Flags",
"Tune the garbage collector, heap and string deduplication to suit whichever Java runtime a cluster launches with.",
toggle(perf_flags),
))
.child(settings_row(
IconType::Terminal,
"JVM Arguments",
@ -148,7 +137,6 @@ fn build_update(
width: &str,
height: &str,
memory: &str,
perf_flags: bool,
jvm_args: &str,
pre: &str,
wrapper: &str,
@ -171,7 +159,6 @@ fn build_update(
force_fullscreen: Patch::Set(fullscreen),
resolution,
mem_max,
perf_flags: Patch::Set(perf_flags),
launch_args: command_patch(jvm_args),
hook_pre: command_patch(pre),
hook_wrapper: command_patch(wrapper),

View file

@ -17,7 +17,6 @@ pub struct GameSettingsProfile {
pub hook_wrapper: Option<String>,
pub hook_post: Option<String>,
pub os_extra: Option<SettingsOsExtra>,
pub perf_flags: Option<bool>,
}
// `Resolution` moved to oneclient_common: the launch-argument builder needs it
@ -63,7 +62,6 @@ impl GameSettingsProfile {
hook_wrapper: None,
hook_post: None,
os_extra: Some(SettingsOsExtra::default()),
perf_flags: Some(true),
}
}
@ -102,9 +100,6 @@ impl GameSettingsProfile {
if self.os_extra.is_none() {
self.os_extra = global.os_extra.clone();
}
if self.perf_flags.is_none() {
self.perf_flags = global.perf_flags;
}
}
pub fn from_row(row: SettingProfileRow) -> crate::ClusterResult<Self> {
@ -126,7 +121,6 @@ impl GameSettingsProfile {
.os_extra
.map(|json| serde_json::from_str(&json))
.transpose()?,
perf_flags: row.perf_flags.map(|v| v != 0),
})
}
@ -150,7 +144,6 @@ impl GameSettingsProfile {
.as_ref()
.map(serde_json::to_string)
.transpose()?,
perf_flags: self.perf_flags.map(i64::from),
})
}
}

View file

@ -132,7 +132,6 @@ pub struct ProfileUpdate {
pub hook_wrapper: Patch<String>,
pub hook_post: Patch<String>,
pub os_extra: Patch<SettingsOsExtra>,
pub perf_flags: Patch<bool>,
}
impl ProfileUpdate {
@ -152,7 +151,6 @@ impl ProfileUpdate {
self.hook_post
.apply_to_command_option(&mut profile.hook_post);
self.os_extra.apply_to_option(&mut profile.os_extra);
self.perf_flags.apply_to_option(&mut profile.perf_flags);
}
}

View file

@ -265,7 +265,6 @@ pub async fn launch_cluster(
profile.launch_args.clone().unwrap_or_default(),
&java.os_arch,
java.major,
profile.perf_flags.unwrap_or(true),
)?;
let mut mc_args = arguments::minecraft_arguments(

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n\t\tSELECT name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n\t\t hook_pre, hook_wrapper, hook_post, os_extra, perf_flags\n\t\tFROM setting_profiles\n\t\tORDER BY name ASC\n\t\t",
"query": "\n\t\tSELECT name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n\t\t hook_pre, hook_wrapper, hook_post, os_extra\n\t\tFROM setting_profiles\n\t\tORDER BY name ASC\n\t\t",
"describe": {
"columns": [
{
@ -123,17 +123,6 @@
"name": "os_extra"
}
}
},
{
"name": "perf_flags",
"ordinal": 11,
"type_info": "Integer",
"origin": {
"Table": {
"table": "setting_profiles",
"name": "perf_flags"
}
}
}
],
"parameters": {
@ -150,9 +139,8 @@
true,
true,
true,
true,
true
]
},
"hash": "1408ae02e47afa471a08ae0279997066a17d6048d02e26eeb5ff88ad5275c6b5"
"hash": "4ab22fa481720e3bae5befee821fe1c0689d666f8bbcde98890e2d4715e9bc80"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n\t\tINSERT INTO setting_profiles (\n\t\t\tname, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n\t\t\thook_pre, hook_wrapper, hook_post, os_extra, perf_flags\n\t\t)\n\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n\t\tON CONFLICT(name) DO UPDATE SET\n\t\t\tjava_path = excluded.java_path,\n\t\t\tresolution = excluded.resolution,\n\t\t\tforce_fullscreen = excluded.force_fullscreen,\n\t\t\tmem_max = excluded.mem_max,\n\t\t\tlaunch_args = excluded.launch_args,\n\t\t\tlaunch_env = excluded.launch_env,\n\t\t\thook_pre = excluded.hook_pre,\n\t\t\thook_wrapper = excluded.hook_wrapper,\n\t\t\thook_post = excluded.hook_post,\n\t\t\tos_extra = excluded.os_extra,\n\t\t\tperf_flags = excluded.perf_flags\n\t\tRETURNING name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n hook_pre, hook_wrapper, hook_post, os_extra, perf_flags\n\t\t",
"query": "\n\t\tINSERT INTO setting_profiles (\n\t\t\tname, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n\t\t\thook_pre, hook_wrapper, hook_post, os_extra\n\t\t)\n\t\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n\t\tON CONFLICT(name) DO UPDATE SET\n\t\t\tjava_path = excluded.java_path,\n\t\t\tresolution = excluded.resolution,\n\t\t\tforce_fullscreen = excluded.force_fullscreen,\n\t\t\tmem_max = excluded.mem_max,\n\t\t\tlaunch_args = excluded.launch_args,\n\t\t\tlaunch_env = excluded.launch_env,\n\t\t\thook_pre = excluded.hook_pre,\n\t\t\thook_wrapper = excluded.hook_wrapper,\n\t\t\thook_post = excluded.hook_post,\n\t\t\tos_extra = excluded.os_extra\n\t\tRETURNING name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n hook_pre, hook_wrapper, hook_post, os_extra\n\t\t",
"describe": {
"columns": [
{
@ -123,21 +123,10 @@
"name": "os_extra"
}
}
},
{
"name": "perf_flags",
"ordinal": 11,
"type_info": "Integer",
"origin": {
"Table": {
"table": "setting_profiles",
"name": "perf_flags"
}
}
}
],
"parameters": {
"Right": 12
"Right": 11
},
"nullable": [
false,
@ -150,9 +139,8 @@
true,
true,
true,
true,
true
]
},
"hash": "93745def11c9e2ced3c14a4537caa9910b7f5c3167bafebf80aa7e731c1a2dcf"
"hash": "b41126ba17cbc3005b446b23cebc29ffe6fc366294191e546808e9f591b723a9"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n\t\tSELECT name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n\t\t hook_pre, hook_wrapper, hook_post, os_extra, perf_flags\n\t\tFROM setting_profiles\n\t\tWHERE name = ?\n\t\t",
"query": "\n\t\tSELECT name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,\n\t\t hook_pre, hook_wrapper, hook_post, os_extra\n\t\tFROM setting_profiles\n\t\tWHERE name = ?\n\t\t",
"describe": {
"columns": [
{
@ -123,17 +123,6 @@
"name": "os_extra"
}
}
},
{
"name": "perf_flags",
"ordinal": 11,
"type_info": "Integer",
"origin": {
"Table": {
"table": "setting_profiles",
"name": "perf_flags"
}
}
}
],
"parameters": {
@ -150,9 +139,8 @@
true,
true,
true,
true,
true
]
},
"hash": "eea8944fa38835f879435dfa511737722f7a32511b386d34d7e1ead8f2cbc9a4"
"hash": "de1b40c927c9819f675b8e3e8e1f583c41450ae9deda20739d82d95e8ca70b27"
}

View file

@ -1 +0,0 @@
ALTER TABLE setting_profiles ADD COLUMN perf_flags INTEGER;

View file

@ -15,7 +15,7 @@ pub async fn list_all(pool: &SqlitePool) -> DbResult<Vec<SettingProfileRow>> {
SettingProfileRow,
r#"
SELECT name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,
hook_pre, hook_wrapper, hook_post, os_extra, perf_flags
hook_pre, hook_wrapper, hook_post, os_extra
FROM setting_profiles
ORDER BY name ASC
"#,
@ -31,7 +31,7 @@ pub async fn get_by_name(pool: &SqlitePool, name: &str) -> DbResult<Option<Setti
SettingProfileRow,
r#"
SELECT name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,
hook_pre, hook_wrapper, hook_post, os_extra, perf_flags
hook_pre, hook_wrapper, hook_post, os_extra
FROM setting_profiles
WHERE name = ?
"#,
@ -59,9 +59,9 @@ pub async fn upsert(
r#"
INSERT INTO setting_profiles (
name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,
hook_pre, hook_wrapper, hook_post, os_extra, perf_flags
hook_pre, hook_wrapper, hook_post, os_extra
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(name) DO UPDATE SET
java_path = excluded.java_path,
resolution = excluded.resolution,
@ -72,10 +72,9 @@ pub async fn upsert(
hook_pre = excluded.hook_pre,
hook_wrapper = excluded.hook_wrapper,
hook_post = excluded.hook_post,
os_extra = excluded.os_extra,
perf_flags = excluded.perf_flags
os_extra = excluded.os_extra
RETURNING name, java_path, resolution, force_fullscreen, mem_max, launch_args, launch_env,
hook_pre, hook_wrapper, hook_post, os_extra, perf_flags
hook_pre, hook_wrapper, hook_post, os_extra
"#,
&row.name,
&row.java_path,
@ -88,7 +87,6 @@ pub async fn upsert(
&row.hook_wrapper,
&row.hook_post,
&row.os_extra,
row.perf_flags,
)
.fetch_one(pool)
.await

View file

@ -13,5 +13,4 @@ pub struct SettingProfileRow {
pub hook_wrapper: Option<String>,
pub hook_post: Option<String>,
pub os_extra: Option<String>,
pub perf_flags: Option<i64>,
}

View file

@ -23,7 +23,6 @@ pub fn java_arguments(
custom_args: String,
java_arch: &str,
java_major: u32,
perf_flags: bool,
) -> McResult<Vec<String>> {
let mut parsed = Vec::new();
if let Some(args) = arguments {
@ -53,9 +52,7 @@ pub fn java_arguments(
parsed.push(classpaths.to_string());
}
if perf_flags {
parsed.extend(performance_flags(java_major, java_arch, mem_max));
}
parsed.extend(performance_flags(java_major, java_arch, mem_max));
parsed.push(format!("-Xmx{mem_max}M"));
parsed.extend(split_custom_args(&custom_args));