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::{ use crate::{
command::CmdVec, debug::{self, DebugState}, command::CmdVec,
game::GameState, input::Input, res::Res, CliArgs, debug::{self, DebugState},
game::GameState,
res::Res,
CliArgs,
}; };
use egui_sfml::SfEgui; use egui_sfml::SfEgui;
use sfml::graphics::{RenderTexture, RenderWindow};
/// Application level state (includes game and ui state, etc.) /// Application level state (includes game and ui state, etc.)
pub(crate) struct App { pub(crate) struct App {
pub(crate) game: GameState, pub(crate) game: GameState,

View file

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

View file

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

View file

@ -1,21 +1,7 @@
use std::path::PathBuf; use crate::{math::WorldPos, tiles::TileDb};
use derivative::Derivative; use derivative::Derivative;
use egui_inspect::derive::Inspect; 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)] #[derive(Derivative, Inspect)]
#[derivative(Debug)] #[derivative(Debug)]
pub(crate) struct GameState { pub(crate) struct GameState {

View file

@ -1,10 +1,6 @@
use egui_inspect::derive::Inspect; use egui_inspect::derive::Inspect;
use serde::{Deserialize, Serialize}; 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)] #[derive(Default, Clone, Copy, Debug, Inspect, Serialize, Deserialize)]
pub(crate) struct ScreenVec {} pub(crate) struct ScreenVec {}
/// Screen position/offset scalar /// 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)] #[derive(Default, Debug)]
pub(crate) struct Input {} pub(crate) struct Input {}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,14 +1,8 @@
mod reg_chunk_existence; mod reg_chunk_existence;
mod serialization; mod serialization;
use std::{fmt::Debug, fs::File, io::Seek, path::{Path, PathBuf}};
use egui_inspect::derive::Inspect; use egui_inspect::derive::Inspect;
use fnv::FnvHashMap; use std::fmt::Debug;
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;
#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy, Inspect)] #[derive(Hash, PartialEq, Eq, Debug, Clone, Copy, Inspect)]
pub(crate) struct ChunkPos {} pub(crate) struct ChunkPos {}
#[derive(Debug, Inspect)] #[derive(Debug, Inspect)]

View file

@ -1,3 +1,2 @@
use std::{fs::File, io::Read, path::Path};
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub(crate) struct ExistenceBitset(); 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 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) { pub(super) fn save_chunk(pos: &ChunkPos, chk: &Chunk, world_dir: &Path) {
loop {} 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 {} pub(crate) struct Worldgen {}