More graphics, live reloading of textures

This commit is contained in:
crumblingstatue 2023-04-15 20:37:01 +02:00
parent f31add5218
commit cee7652e09
7 changed files with 10 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

View file

@ -7,6 +7,7 @@ use crate::{
math::{px_per_frame_to_km_h, WorldPos},
res::Res,
stringfmt::LengthDisp,
texture_atlas::AtlasBundle,
tiles::tiledb_edit_ui::tiledb_edit_ui,
};
@ -87,6 +88,10 @@ fn debug_panel_ui(
debug.tiledb_edit
}
});
if ui.button("Reload graphics").clicked() {
res.atlas = AtlasBundle::new().unwrap();
game.tile_db.update_rects(&res.atlas.rects);
}
ui.separator();
egui::ScrollArea::vertical().show(ui, |ui| {
gamedebug_core::for_each_imm(|info| match info {

View file

@ -118,7 +118,11 @@ impl TileDb {
pub(crate) fn update_rects(&mut self, rects: &RectMap) {
for def in &mut self.db {
if !def.graphic_name.is_empty() {
def.tex_rect = rects[&def.graphic_name];
if let Some(rect) = rects.get(&def.graphic_name) {
def.tex_rect = *rect;
} else {
log::error!("Missing texture for {}", def.graphic_name);
}
}
}
}

BIN
tiles.dat

Binary file not shown.