Make use of egui_inspect

This commit is contained in:
crumblingstatue 2023-04-07 00:36:34 +02:00
parent 85ebea1fca
commit a11d69eee2
11 changed files with 154 additions and 40 deletions

153
Cargo.lock generated
View file

@ -155,6 +155,17 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "dispatch"
version = "0.2.0"
@ -178,6 +189,25 @@ dependencies = [
"nohash-hasher",
]
[[package]]
name = "egui-inspect"
version = "0.1.0"
source = "git+https://github.com/crumblingstatue/egui-inspect.git#135c81eb0264ddbec69f98b0a9d5c7ec22867736"
dependencies = [
"egui",
"egui-inspect-derive",
]
[[package]]
name = "egui-inspect-derive"
version = "0.1.0"
source = "git+https://github.com/crumblingstatue/egui-inspect.git#135c81eb0264ddbec69f98b0a9d5c7ec22867736"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "egui-sfml"
version = "0.4.0"
@ -218,7 +248,7 @@ checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0"
dependencies = [
"errno-dragonfly",
"libc",
"windows-sys",
"windows-sys 0.45.0",
]
[[package]]
@ -430,9 +460,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hecs"
version = "0.10.1"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6befb02da14cb43e4d0e2cd369d516ed3abc70ce380a5b141c8ab6ca120c0b70"
checksum = "94cd00eb6bc3e98b1aea624d00da6fa27d984f4494cf7b4ae8fdcd9b2d5c16a0"
dependencies = [
"hashbrown 0.13.2",
"spin",
@ -465,13 +495,13 @@ dependencies = [
[[package]]
name = "io-lifetimes"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb"
checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220"
dependencies = [
"hermit-abi",
"libc",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
@ -485,9 +515,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.140"
version = "0.2.141"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5"
[[package]]
name = "link-cplusplus"
@ -537,6 +567,9 @@ name = "mantle-diver"
version = "0.1.0"
dependencies = [
"anyhow",
"derivative",
"egui",
"egui-inspect",
"egui-sfml",
"fnv",
"gamedebug_core",
@ -653,7 +686,7 @@ dependencies = [
"libc",
"redox_syscall",
"smallvec",
"windows-sys",
"windows-sys 0.45.0",
]
[[package]]
@ -687,7 +720,7 @@ dependencies = [
"libc",
"log",
"pin-project-lite",
"windows-sys",
"windows-sys 0.45.0",
]
[[package]]
@ -698,9 +731,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro2"
version = "1.0.55"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d0dd4be24fcdcfeaa12a432d588dc59bbad6cad3510c67e74a2b6b2fc950564"
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
dependencies = [
"unicode-ident",
]
@ -786,22 +819,22 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.37.6"
version = "0.37.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d097081ed288dfe45699b72f5b5d648e5f15d64d900c7080273baa20c16a6849"
checksum = "1aef160324be24d31a62147fae491c14d2204a3865c7ca8c3b0d7f7bcb3ea635"
dependencies = [
"bitflags",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys",
"windows-sys 0.48.0",
]
[[package]]
name = "s2dc"
version = "0.1.0"
source = "git+https://github.com/crumblingstatue/s2dc.git#68cc3009cf86a65d7b17f93f44fa8b2cf812c11c"
source = "git+https://github.com/crumblingstatue/s2dc.git#468ab3ca6de2d05f1eb5cdd8d869055d9157fb76"
dependencies = [
"num-traits",
]
@ -876,9 +909,9 @@ dependencies = [
[[package]]
name = "spin"
version = "0.9.7"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0959fd6f767df20b231736396e4f602171e00d95205676286e79d4a4eb67bef"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "syn"
@ -1084,7 +1117,7 @@ version = "0.44.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b"
dependencies = [
"windows-targets",
"windows-targets 0.42.2",
]
[[package]]
@ -1093,7 +1126,16 @@ version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets",
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.0",
]
[[package]]
@ -1102,13 +1144,28 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-targets"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
dependencies = [
"windows_aarch64_gnullvm 0.48.0",
"windows_aarch64_msvc 0.48.0",
"windows_i686_gnu 0.48.0",
"windows_i686_msvc 0.48.0",
"windows_x86_64_gnu 0.48.0",
"windows_x86_64_gnullvm 0.48.0",
"windows_x86_64_msvc 0.48.0",
]
[[package]]
@ -1117,42 +1174,84 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_i686_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
[[package]]
name = "winnow"
version = "0.4.1"

View file

@ -7,7 +7,9 @@ edition = "2021"
[dependencies]
anyhow = "1.0.70"
derivative = "2.2.0"
egui-sfml = "0.4.0"
egui = "0.21.0"
fnv = "1.0.7"
hecs = "0.10.1"
num-traits = "0.2.15"
@ -24,3 +26,6 @@ git = "https://github.com/crumblingstatue/sfml-xt.git"
[dependencies.gamedebug_core]
git = "https://github.com/crumblingstatue/gamedebug_core.git"
[dependencies.egui-inspect]
git = "https://github.com/crumblingstatue/egui-inspect.git"

View file

@ -1,6 +1,7 @@
use std::fmt::{self};
use anyhow::Context;
use egui_inspect::UiExt;
use egui_sfml::{egui, SfEgui};
use gamedebug_core::{imm, imm_dbg};
use sfml::{
@ -330,20 +331,15 @@ fn debug_panel_ui(
game.player.vspeed,
px_per_frame_to_km_h(game.player.vspeed)
));
ui.label("Gravity");
ui.add(egui::DragValue::new(&mut game.gravity));
}
ui.label("Tile to place");
ui.add(egui::DragValue::new(&mut game.tile_to_place));
ui.label("Music volume");
let mut vol = res.surf_music.volume();
ui.add(egui::DragValue::new(&mut vol));
res.surf_music.set_volume(vol);
ui.separator();
ui.label("Ambient light");
ui.add(egui::DragValue::new(&mut game.ambient_light).speed(0.01));
ui.label("Scale");
ui.add(egui::DragValue::new(scale));
ui.inspect_mut(game, &mut 0);
egui::ScrollArea::vertical().show(ui, |ui| {
gamedebug_core::for_each_imm(|info| match info {
gamedebug_core::Info::Msg(msg) => {

View file

@ -2,7 +2,7 @@ use sfml::window::Key;
use crate::input::Input;
#[derive(Default)]
#[derive(Default, Debug)]
pub struct DebugState {
pub panel: bool,
pub freecam: bool,

View file

@ -1,5 +1,7 @@
mod player;
use derivative::Derivative;
use egui_inspect::derive::Inspect;
use sfml::{
graphics::{
glsl::{Vec2, Vec4},
@ -20,20 +22,26 @@ use crate::{
use self::player::Player;
#[derive(Derivative, Inspect)]
#[derivative(Debug)]
pub struct GameState {
pub camera_offset: WorldPos,
#[opaque]
pub world: World,
pub player: Player,
pub gravity: f32,
pub tile_to_place: TileId,
pub current_biome: Biome,
pub prev_biome: Biome,
#[derivative(Debug = "ignore")]
#[opaque]
pub worldgen: Worldgen,
pub ambient_light: f32,
#[opaque]
pub clock: SfBox<Clock>,
}
#[derive(PartialEq, Eq, Clone, Copy)]
#[derive(PartialEq, Eq, Clone, Copy, Debug, Inspect)]
pub enum Biome {
Surface,
Underground,

View file

@ -1,3 +1,4 @@
use egui_inspect::derive::Inspect;
use s2dc::{vec2, MobileEntity};
use crate::{
@ -5,7 +6,9 @@ use crate::{
world::{TilePos, TilePosScalar},
};
#[derive(Debug, Inspect)]
pub struct Player {
#[opaque]
pub col_en: MobileEntity,
pub vspeed: f32,
pub hspeed: f32,

View file

@ -23,7 +23,7 @@ impl ScreenRes {
}
// We assume this game won't be played above 32767*32767 resolution
#[derive(Default, Clone, Copy)]
#[derive(Default, Clone, Copy, Debug)]
pub struct ScreenPos {
pub x: ScreenPosScalar,
pub y: ScreenPosScalar,

View file

@ -3,7 +3,7 @@ use sfml::window::{mouse, Event, Key};
use crate::graphics::ScreenPos;
#[derive(Default)]
#[derive(Default, Debug)]
pub struct Input {
down: FnvHashSet<Key>,
pressed: FnvHashSet<Key>,

View file

@ -1,10 +1,11 @@
use egui_inspect::derive::Inspect;
use num_traits::Signed;
use crate::world::{TilePos, TilePosScalar};
pub type WorldPosScalar = u32;
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug, Inspect)]
pub struct WorldPos {
pub x: WorldPosScalar,
pub y: WorldPosScalar,

View file

@ -4,6 +4,7 @@ use sfml::{
SfBox,
};
#[derive(Debug)]
pub struct Res {
pub tile_atlas: SfBox<Texture>,
pub surf_music: Music<'static>,

View file

@ -10,7 +10,7 @@ pub struct ChunkPos {
pub y: ChunkPosScalar,
}
#[derive(Default)]
#[derive(Default, Debug)]
pub struct World {
/// The currently loaded chunks
chunks: FnvHashMap<ChunkPos, Chunk>,
@ -99,6 +99,7 @@ const CHUNK_N_TILES: usize = CHUNK_EXTENT as usize * CHUNK_EXTENT as usize;
type ChunkTiles = [Tile; CHUNK_N_TILES];
#[derive(Debug)]
pub struct Chunk {
tiles: ChunkTiles,
}
@ -135,7 +136,7 @@ impl Chunk {
pub type TileId = u16;
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub struct Tile {
/// Background wall behind entities
pub bg: TileId,