From 31ab20d9f3b16c9fb252bd9c5c75c7312009e14f Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 17 Apr 2023 21:51:49 +0200 Subject: [PATCH] manual --- src/app.rs | 8 +++-- src/command.rs | 1 - src/debug.rs | 55 ++++++++++++-------------------- src/game.rs | 18 ++--------- src/graphics.rs | 6 +--- src/input.rs | 3 -- src/inventory.rs | 2 +- src/math.rs | 6 ++-- src/player.rs | 9 ++---- src/res.rs | 3 +- src/texture_atlas.rs | 5 ++- src/world.rs | 10 ++---- src/world/reg_chunk_existence.rs | 1 - src/world/serialization.rs | 10 ++---- src/worldgen.rs | 13 -------- 15 files changed, 41 insertions(+), 109 deletions(-) diff --git a/src/app.rs b/src/app.rs index 8c0a718..426080c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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, diff --git a/src/command.rs b/src/command.rs index 8c91a23..b7cbda5 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,4 +1,3 @@ -use crate::math::WorldPos; /// A command that can change application or game state pub(crate) enum Cmd { /// Quit the application diff --git a/src/debug.rs b/src/debug.rs index 0521081..a3b5bf4 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -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, diff --git a/src/game.rs b/src/game.rs index 45fb970..5be8e51 100644 --- a/src/game.rs +++ b/src/game.rs @@ -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 { diff --git a/src/graphics.rs b/src/graphics.rs index fdb31fd..39b3d04 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -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 diff --git a/src/input.rs b/src/input.rs index f3b3b22..10e7098 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,5 +1,2 @@ -use fnv::FnvHashSet; -use sfml::window::{mouse, Event, Key}; -use crate::graphics::ScreenVec; #[derive(Default, Debug)] pub(crate) struct Input {} diff --git a/src/inventory.rs b/src/inventory.rs index 254982d..57a3fa5 100644 --- a/src/inventory.rs +++ b/src/inventory.rs @@ -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)] diff --git a/src/math.rs b/src/math.rs index ded8fe5..a48e5e8 100644 --- a/src/math.rs +++ b/src/math.rs @@ -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 {} diff --git a/src/player.rs b/src/player.rs index 871b910..aa95925 100644 --- a/src/player.rs +++ b/src/player.rs @@ -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 {} diff --git a/src/res.rs b/src/res.rs index f142179..a8a1d18 100644 --- a/src/res.rs +++ b/src/res.rs @@ -1,4 +1,3 @@ -use sfml::audio::Music; -use crate::texture_atlas::AtlasBundle; + #[derive(Debug)] pub(crate) struct Res {} diff --git a/src/texture_atlas.rs b/src/texture_atlas.rs index a06b78b..4a7220c 100644 --- a/src/texture_atlas.rs +++ b/src/texture_atlas.rs @@ -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; #[derive(Debug)] pub(crate) struct AtlasBundle {} diff --git a/src/world.rs b/src/world.rs index 75f4245..12c975a 100644 --- a/src/world.rs +++ b/src/world.rs @@ -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)] diff --git a/src/world/reg_chunk_existence.rs b/src/world/reg_chunk_existence.rs index b39ddea..82b51d4 100644 --- a/src/world/reg_chunk_existence.rs +++ b/src/world/reg_chunk_existence.rs @@ -1,3 +1,2 @@ -use std::{fs::File, io::Read, path::Path}; #[derive(Clone, Copy)] pub(crate) struct ExistenceBitset(); diff --git a/src/world/serialization.rs b/src/world/serialization.rs index 2f6daf5..88fe9b2 100644 --- a/src/world/serialization.rs +++ b/src/world/serialization.rs @@ -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 {} } diff --git a/src/worldgen.rs b/src/worldgen.rs index 50a6cbb..b61e69b 100644 --- a/src/worldgen.rs +++ b/src/worldgen.rs @@ -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 {}