Save debug menu settings to file

This commit is contained in:
2026-08-31 22:20:35 +02:00
parent c2a7b2f5d1
commit bf75b5a301
4 changed files with 72 additions and 11 deletions
Generated
+51
View File
@@ -565,6 +565,26 @@ dependencies = [
"syn 2.0.119", "syn 2.0.119",
] ]
[[package]]
name = "bevy-settings"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04372da0c37bab175e0bfbc4ad8f214ffcbea01850225573b6e49132db11e18b"
dependencies = [
"bevy_app",
"bevy_ecs",
"bevy_ecs_macros",
"bevy_log",
"bevy_platform",
"bevy_reflect",
"bevy_tasks",
"bevy_time",
"serde",
"thiserror 2.0.19",
"toml",
"web-sys",
]
[[package]] [[package]]
name = "bevy_a11y" name = "bevy_a11y"
version = "0.19.0" version = "0.19.0"
@@ -1319,6 +1339,7 @@ version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a85632a749f956f92b7b391c31ce1f229e57b06de879d1b60a3bb91e4e240" checksum = "d52a85632a749f956f92b7b391c31ce1f229e57b06de879d1b60a3bb91e4e240"
dependencies = [ dependencies = [
"bevy-settings",
"bevy_a11y", "bevy_a11y",
"bevy_android", "bevy_android",
"bevy_animation", "bevy_animation",
@@ -6392,6 +6413,15 @@ dependencies = [
"zmij", "zmij",
] ]
[[package]]
name = "serde_spanned"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
[[package]] [[package]]
name = "sha3" name = "sha3"
version = "0.10.9" version = "0.10.9"
@@ -6972,6 +7002,21 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "toml"
version = "1.1.4+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5"
dependencies = [
"indexmap",
"serde_core",
"serde_spanned",
"toml_datetime",
"toml_parser",
"toml_writer",
"winnow",
]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "1.1.1+spec-1.1.0" version = "1.1.1+spec-1.1.0"
@@ -7002,6 +7047,12 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "toml_writer"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2"
[[package]] [[package]]
name = "tracing" name = "tracing"
version = "0.1.44" version = "0.1.44"
+1 -1
View File
@@ -15,7 +15,7 @@ authors = [""]
[workspace] [workspace]
[dependencies] [dependencies]
bevy = { version = "0.19", features = ["asset_processor", "dynamic_linking", "free_camera", "file_watcher"] } bevy = { version = "0.19", features = ["asset_processor", "dynamic_linking", "free_camera", "file_watcher", "bevy_settings"] }
# Loads the scenes you author in the editor (assets/*.bsn) and builds # Loads the scenes you author in the editor (assets/*.bsn) and builds
# physics colliders from them. An ordinary dependency; remove it if you # physics colliders from them. An ordinary dependency; remove it if you
# stop using authored scenes. # stop using authored scenes.
+18 -7
View File
@@ -1,15 +1,15 @@
//! Local developer overlays and their controller-driven palette. //! Local developer overlays and their controller-driven palette.
use std::collections::HashMap; use std::{collections::HashMap, time::Duration};
use bevy::prelude::*; use bevy::{prelude::*, settings::{SaveSettingsDeferred, SettingsGroup, ReflectSettingsGroup}};
use bevy_egui::{EguiContexts, EguiPrimaryContextPass, egui}; use bevy_egui::{EguiContexts, EguiPrimaryContextPass, egui};
use crate::player::Player; use crate::player::Player;
pub const PLAYER_DEBUG_ROW_COUNT: usize = 6; pub const PLAYER_DEBUG_ROW_COUNT: usize = 6;
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Reflect)]
pub enum FighterDebugRowKind { pub enum FighterDebugRowKind {
None, None,
CurrentState, CurrentState,
@@ -19,7 +19,7 @@ pub enum FighterDebugRowKind {
Facing, Facing,
} }
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Reflect)]
pub enum PresentationMotionMode { pub enum PresentationMotionMode {
#[default] #[default]
Interpolation, Interpolation,
@@ -169,13 +169,18 @@ enum DebugMenuPage {
PlayerList, PlayerList,
PlayerRows(usize), PlayerRows(usize),
} }
#[derive(Resource, SettingsGroup, Reflect)]
#[derive(Resource)] #[reflect(Resource, SettingsGroup, Default)]
pub struct DebugSettings { pub struct DebugSettings {
#[reflect(ignore)]
pub menu_open: bool, pub menu_open: bool,
#[reflect(ignore)]
controller: Option<Entity>, controller: Option<Entity>,
#[reflect(ignore)]
pages: Vec<DebugMenuPage>, pages: Vec<DebugMenuPage>,
#[reflect(ignore)]
selections: Vec<usize>, selections: Vec<usize>,
#[reflect(ignore)]
pub player_rows: HashMap<usize, [FighterDebugRowKind; PLAYER_DEBUG_ROW_COUNT]>, pub player_rows: HashMap<usize, [FighterDebugRowKind; PLAYER_DEBUG_ROW_COUNT]>,
pub network: bool, pub network: bool,
pub ecb: bool, pub ecb: bool,
@@ -328,6 +333,7 @@ fn handle_palette_input(
gamepads: Query<(Entity, &Gamepad)>, gamepads: Query<(Entity, &Gamepad)>,
players: Query<&Player>, players: Query<&Player>,
mut settings: ResMut<DebugSettings>, mut settings: ResMut<DebugSettings>,
mut commands: Commands,
) { ) {
if keyboard.just_pressed(KeyCode::KeyT) { if keyboard.just_pressed(KeyCode::KeyT) {
settings.toggle_flag(DebugFlag::DrawThroughGeometry); settings.toggle_flag(DebugFlag::DrawThroughGeometry);
@@ -386,6 +392,8 @@ fn handle_palette_input(
let selected = settings.selected(); let selected = settings.selected();
let rows = settings.rows_mut(handle); let rows = settings.rows_mut(handle);
rows[selected] = rows[selected].cycle(direction); rows[selected] = rows[selected].cycle(direction);
commands.queue(SaveSettingsDeferred(Duration::from_secs_f32(0.1)));
} }
} }
if let DebugMenuPage::Static(entries) = page if let DebugMenuPage::Static(entries) = page
@@ -401,7 +409,10 @@ fn handle_palette_input(
if gamepad.just_pressed(GamepadButton::South) { if gamepad.just_pressed(GamepadButton::South) {
match page { match page {
DebugMenuPage::Static(entries) if page_len != 0 => match entries[settings.selected()] { DebugMenuPage::Static(entries) if page_len != 0 => match entries[settings.selected()] {
DebugMenuEntry::Toggle { flag, .. } => settings.toggle_flag(flag), DebugMenuEntry::Toggle { flag, .. } => {
settings.toggle_flag(flag);
commands.queue(SaveSettingsDeferred(Duration::from_secs_f32(0.1)));
},
DebugMenuEntry::Submenu { entries, .. } => { DebugMenuEntry::Submenu { entries, .. } => {
settings.push_page(DebugMenuPage::Static(entries)); settings.push_page(DebugMenuPage::Static(entries));
} }
+2 -3
View File
@@ -22,9 +22,7 @@
//! appears in `Add Component`. No registration code is needed. //! appears in `Add Component`. No registration code is needed.
use bevy::{ use bevy::{
asset::processor::{AssetProcessor, ProcessorState}, asset::processor::{AssetProcessor, ProcessorState}, prelude::*, settings::SettingsPlugin, tasks::block_on,
prelude::*,
tasks::block_on,
}; };
use bevy_asset_loader::prelude::*; use bevy_asset_loader::prelude::*;
use bevy_wind_waker_shader::prelude::*; use bevy_wind_waker_shader::prelude::*;
@@ -80,6 +78,7 @@ impl Plugin for GamePlugin {
// game-level content and configuration. // game-level content and configuration.
app.init_state::<AppState>() app.init_state::<AppState>()
.add_plugins(( .add_plugins((
SettingsPlugin::new("moe.eirteam.shinespark.debug_settings"),
WindWakerShaderPlugin::default(), WindWakerShaderPlugin::default(),
// Brings up GGRS (and with it `GgrsSchedule`), so it goes first. // Brings up GGRS (and with it `GgrsSchedule`), so it goes first.
netcode::FighterNetcodePlugin::default(), netcode::FighterNetcodePlugin::default(),