mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 04:25:00 +01:00
Make use of egui_inspect
This commit is contained in:
parent
85ebea1fca
commit
a11d69eee2
11 changed files with 154 additions and 40 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
10
src/game.rs
10
src/game.rs
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use sfml::{
|
|||
SfBox,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Res {
|
||||
pub tile_atlas: SfBox<Texture>,
|
||||
pub surf_music: Music<'static>,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue