This commit is contained in:
nora 2023-04-17 21:51:49 +02:00
parent af3d9add2a
commit 31ab20d9f3
15 changed files with 41 additions and 109 deletions

View file

@ -1,9 +1,11 @@
use crate::{
command::CmdVec, debug::{self, DebugState},
game::GameState, input::Input, res::Res, CliArgs,
command::CmdVec,
debug::{self, DebugState},
game::GameState,
res::Res,
CliArgs,
};
use egui_sfml::SfEgui;
use sfml::graphics::{RenderTexture, RenderWindow};
/// Application level state (includes game and ui state, etc.)
pub(crate) struct App {
pub(crate) game: GameState,

View file

@ -1,4 +1,3 @@
use crate::math::WorldPos;
/// A command that can change application or game state
pub(crate) enum Cmd {
/// Quit the application

View file

@ -1,9 +1,5 @@
use crate::{
command::CmdVec, game::GameState, res::Res, texture_atlas::AtlasBundle,
tiles::tiledb_edit_ui::TileDbEdit,
};
use crate::{command::CmdVec, game::GameState, res::Res};
use egui_inspect::{derive::Inspect, inspect};
use sfml::audio::SoundSource;
#[derive(Default, Debug, Inspect)]
pub(crate) struct DebugState {}
fn debug_panel_ui(
@ -13,36 +9,25 @@ fn debug_panel_ui(
res: &mut Res,
mut scale: &mut u8,
) {
egui::Window::new("Debug (F12)")
.show(
ctx,
|ui| {
egui::ScrollArea::both()
.id_source("insp_scroll")
.max_height(240.)
.max_width(340.0)
.show(
ui,
|ui| {
inspect! {
ui, scale, game, debug
}
},
);
egui::ScrollArea::vertical()
.show(
ui,
|ui| {
gamedebug_core::for_each_imm(|info| match info {
gamedebug_core::Info::Msg(msg) => {
ui.label(msg);
}
gamedebug_core::Info::Rect(_, _, _, _, _) => todo!(),
});
},
);
},
);
egui::Window::new("Debug (F12)").show(ctx, |ui| {
egui::ScrollArea::both()
.id_source("insp_scroll")
.max_height(240.)
.max_width(340.0)
.show(ui, |ui| {
inspect! {
ui, scale, game, debug
}
});
egui::ScrollArea::vertical().show(ui, |ui| {
gamedebug_core::for_each_imm(|info| match info {
gamedebug_core::Info::Msg(msg) => {
ui.label(msg);
}
gamedebug_core::Info::Rect(_, _, _, _, _) => todo!(),
});
});
});
}
pub(crate) fn do_debug_ui(
ctx: &egui::Context,

View file

@ -1,21 +1,7 @@
use std::path::PathBuf;
use crate::{math::WorldPos, tiles::TileDb};
use derivative::Derivative;
use egui_inspect::derive::Inspect;
use sfml::{
graphics::{
Color, Rect, RectangleShape, RenderTarget, RenderTexture, Shape, Sprite,
Transformable,
},
system::{Vector2f, Vector2u},
window::Key,
};
use crate::{
graphics::{ScreenSc, ScreenVec},
input::Input, inventory::{Inventory, ItemDb},
math::{smoothwave, wp_to_tp, WorldPos},
res::Res, tiles::TileDb, world::{TilePos, World},
worldgen::Worldgen,
};
#[derive(Derivative, Inspect)]
#[derivative(Debug)]
pub(crate) struct GameState {

View file

@ -1,10 +1,6 @@
use egui_inspect::derive::Inspect;
use serde::{Deserialize, Serialize};
use sfml::{
graphics::RenderWindow, system::Vector2f, window::{ContextSettings, Style, VideoMode},
};
use sfml_xt::graphics::RenderWindowExt;
use crate::math::FPS_TARGET;
#[derive(Default, Clone, Copy, Debug, Inspect, Serialize, Deserialize)]
pub(crate) struct ScreenVec {}
/// Screen position/offset scalar

View file

@ -1,5 +1,2 @@
use fnv::FnvHashSet;
use sfml::window::{mouse, Event, Key};
use crate::graphics::ScreenVec;
#[derive(Default, Debug)]
pub(crate) struct Input {}

View file

@ -1,5 +1,5 @@
use egui_inspect::derive::Inspect;
use crate::{math::IntRect, tiles::{BgTileId, FgTileId, MidTileId}};
#[derive(Debug, Inspect)]
pub(crate) struct Inventory {}
#[derive(Debug, Inspect)]

View file

@ -1,8 +1,8 @@
use std::fmt::Debug;
use crate::world::TPosSc;
use egui_inspect::derive::Inspect;
use num_traits::{Num, Signed};
use num_traits::Num;
use serde::{Deserialize, Serialize};
use crate::world::{TPosSc, TilePos};
use std::fmt::Debug;
pub(crate) type WPosSc = u32;
#[derive(Clone, Copy, Debug, Inspect)]
pub(crate) struct WorldPos {}

View file

@ -1,10 +1,5 @@
use std::path::Path;
use egui_inspect::{derive::Inspect, inspect};
use s2dc::{vec2, MobileEntity};
use egui_inspect::derive::Inspect;
use serde::{Deserialize, Serialize};
use crate::{
math::{WorldPos, TILE_SIZE},
world::{TPosSc, TilePos},
};
#[derive(Debug, Inspect, Serialize, Deserialize)]
pub(crate) struct Player {}

View file

@ -1,4 +1,3 @@
use sfml::audio::Music;
use crate::texture_atlas::AtlasBundle;
#[derive(Debug)]
pub(crate) struct Res {}

View file

@ -1,7 +1,6 @@
use std::{collections::HashMap, path::Path};
use crate::math::IntRect;
use sfml::{graphics::Texture, SfBox};
use texture_packer::{texture::Texture as _, TexturePacker, TexturePackerConfig};
use std::collections::HashMap;
pub(crate) type RectMap = HashMap<String, IntRect>;
#[derive(Debug)]
pub(crate) struct AtlasBundle {}

View file

@ -1,14 +1,8 @@
mod reg_chunk_existence;
mod serialization;
use std::{fmt::Debug, fs::File, io::Seek, path::{Path, PathBuf}};
use egui_inspect::derive::Inspect;
use fnv::FnvHashMap;
use serde::{Deserialize, Serialize};
use crate::{
math::WorldPos, player::Player, tiles::{BgTileId, FgTileId, MidTileId, TileId},
world::reg_chunk_existence::ExistenceBitset, worldgen::Worldgen,
};
use self::serialization::save_chunk;
use std::fmt::Debug;
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy, Inspect)]
pub(crate) struct ChunkPos {}
#[derive(Debug, Inspect)]

View file

@ -1,3 +1,2 @@
use std::{fs::File, io::Read, path::Path};
#[derive(Clone, Copy)]
pub(crate) struct ExistenceBitset();

View file

@ -1,12 +1,6 @@
use std::{
fs::OpenOptions, io::{Seek, Write},
path::Path,
};
use crate::world::{
format_reg_file_name, loc_byte_idx, loc_idx, reg_chunk_existence::ExistenceBitset,
REGION_BYTES, TILE_BYTES,
};
use super::{default_chunk_tiles, loc_byte_idx_xy, Chunk, ChunkPos};
use std::path::Path;
pub(super) fn save_chunk(pos: &ChunkPos, chk: &Chunk, world_dir: &Path) {
loop {}
}

View file

@ -1,14 +1 @@
use crate::{
tiles::{BgTileId, FgTileId, MidTileId, TileId},
world::{ChunkPos, Tile as Tl, CHUNK_EXTENT},
};
use worldgen::{
constraint,
noise::perlin::PerlinNoise,
noisemap::{NoiseMap, NoiseMapGenerator, Seed, Step},
world::{
tile::{Constraint, ConstraintType},
Size, Tile, World,
},
};
pub(crate) struct Worldgen {}