Initial asset library impl + tile images
BIN
assets/thumbnails/corner-ne-1-wall.png
Normal file
|
After Width: | Height: | Size: 372 B |
BIN
assets/thumbnails/corner-ne-2-walls-south.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
assets/thumbnails/corner-ne-2-walls-west.png
Normal file
|
After Width: | Height: | Size: 380 B |
BIN
assets/thumbnails/corner-ne-3-walls.png
Normal file
|
After Width: | Height: | Size: 383 B |
BIN
assets/thumbnails/corner-nw-1-wall.png
Normal file
|
After Width: | Height: | Size: 375 B |
BIN
assets/thumbnails/corner-nw-2-walls-east.png
Normal file
|
After Width: | Height: | Size: 384 B |
BIN
assets/thumbnails/corner-nw-2-walls-south.png
Normal file
|
After Width: | Height: | Size: 377 B |
BIN
assets/thumbnails/corner-nw-3-walls.png
Normal file
|
After Width: | Height: | Size: 386 B |
BIN
assets/thumbnails/corner-se-1-wall.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
assets/thumbnails/corner-se-2-walls-north.png
Normal file
|
After Width: | Height: | Size: 377 B |
BIN
assets/thumbnails/corner-se-2-walls-west.png
Normal file
|
After Width: | Height: | Size: 391 B |
BIN
assets/thumbnails/corner-se-3-walls.png
Normal file
|
After Width: | Height: | Size: 392 B |
BIN
assets/thumbnails/corner-sw-1-wall.png
Normal file
|
After Width: | Height: | Size: 374 B |
BIN
assets/thumbnails/corner-sw-2-walls-east.png
Normal file
|
After Width: | Height: | Size: 378 B |
BIN
assets/thumbnails/corner-sw-2-walls-north.png
Normal file
|
After Width: | Height: | Size: 376 B |
BIN
assets/thumbnails/corner-sw-3-walls.png
Normal file
|
After Width: | Height: | Size: 380 B |
BIN
assets/thumbnails/full-0-walls.png
Normal file
|
After Width: | Height: | Size: 299 B |
BIN
assets/thumbnails/full-1-wall.png
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
assets/thumbnails/full-2-walls.png
Normal file
|
After Width: | Height: | Size: 317 B |
BIN
assets/thumbnails/full-3-walls.png
Normal file
|
After Width: | Height: | Size: 319 B |
BIN
assets/thumbnails/full-4-walls.png
Normal file
|
After Width: | Height: | Size: 319 B |
BIN
assets/tiles/corner-ne-1-wall.png
Normal file
|
After Width: | Height: | Size: 403 B |
BIN
assets/tiles/corner-ne-2-walls-south.png
Normal file
|
After Width: | Height: | Size: 405 B |
BIN
assets/tiles/corner-ne-2-walls-west.png
Normal file
|
After Width: | Height: | Size: 442 B |
BIN
assets/tiles/corner-ne-3-walls.png
Normal file
|
After Width: | Height: | Size: 442 B |
BIN
assets/tiles/corner-nw-1-wall.png
Normal file
|
After Width: | Height: | Size: 313 B |
BIN
assets/tiles/corner-nw-2-walls-east.png
Normal file
|
After Width: | Height: | Size: 317 B |
BIN
assets/tiles/corner-nw-2-walls-south.png
Normal file
|
After Width: | Height: | Size: 311 B |
BIN
assets/tiles/corner-nw-3-walls.png
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
assets/tiles/corner-se-1-wall.png
Normal file
|
After Width: | Height: | Size: 408 B |
BIN
assets/tiles/corner-se-2-walls-north.png
Normal file
|
After Width: | Height: | Size: 409 B |
BIN
assets/tiles/corner-se-2-walls-west.png
Normal file
|
After Width: | Height: | Size: 448 B |
BIN
assets/tiles/corner-se-3-walls.png
Normal file
|
After Width: | Height: | Size: 449 B |
BIN
assets/tiles/corner-sw-1-wall.png
Normal file
|
After Width: | Height: | Size: 408 B |
BIN
assets/tiles/corner-sw-2-walls-east.png
Normal file
|
After Width: | Height: | Size: 446 B |
BIN
assets/tiles/corner-sw-2-walls-north.png
Normal file
|
After Width: | Height: | Size: 410 B |
BIN
assets/tiles/corner-sw-3-walls.png
Normal file
|
After Width: | Height: | Size: 446 B |
BIN
assets/tiles/full-0-walls.png
Normal file
|
After Width: | Height: | Size: 142 B |
BIN
assets/tiles/full-1-wall.png
Normal file
|
After Width: | Height: | Size: 154 B |
BIN
assets/tiles/full-2-walls.png
Normal file
|
After Width: | Height: | Size: 159 B |
BIN
assets/tiles/full-3-walls.png
Normal file
|
After Width: | Height: | Size: 162 B |
BIN
assets/tiles/full-4-walls.png
Normal file
|
After Width: | Height: | Size: 164 B |
82
src/assets.rs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
pub struct TileImage {
|
||||||
|
name: &'static str,
|
||||||
|
thumbnail_handle: Handle<Image>,
|
||||||
|
tile_handle: Handle<Image>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub struct AssetLibrary {
|
||||||
|
tile_images: Vec<TileImage>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AssetLibrary {
|
||||||
|
fn new(asset_server: &AssetServer) -> Self {
|
||||||
|
let tile_names = vec![
|
||||||
|
"corner-ne-1-wall",
|
||||||
|
"corner-ne-2-walls-south",
|
||||||
|
"corner-ne-2-walls-west",
|
||||||
|
"corner-ne-3-walls",
|
||||||
|
"corner-nw-1-wall",
|
||||||
|
"corner-nw-2-walls-south",
|
||||||
|
"corner-nw-2-walls-east",
|
||||||
|
"corner-nw-3-walls",
|
||||||
|
"corner-se-1-wall",
|
||||||
|
"corner-se-2-walls-north",
|
||||||
|
"corner-se-2-walls-west",
|
||||||
|
"corner-se-3-walls",
|
||||||
|
"corner-sw-1-wall",
|
||||||
|
"corner-sw-2-walls-north",
|
||||||
|
"corner-sw-2-walls-east",
|
||||||
|
"corner-sw-3-walls",
|
||||||
|
"full-0-walls",
|
||||||
|
"full-1-wall",
|
||||||
|
"full-2-walls",
|
||||||
|
"full-3-walls",
|
||||||
|
"full-4-walls",
|
||||||
|
];
|
||||||
|
|
||||||
|
let tile_images = tile_names
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.map(|name| {
|
||||||
|
let thumbnail_path = Path::new("thumbnails").join(name).with_extension("png");
|
||||||
|
let tile_path = Path::new("tiles").join(name).with_extension("png");
|
||||||
|
|
||||||
|
let thumbnail_handle = asset_server.load::<Image>(thumbnail_path);
|
||||||
|
let tile_handle = asset_server.load::<Image>(tile_path);
|
||||||
|
|
||||||
|
TileImage {
|
||||||
|
name,
|
||||||
|
thumbnail_handle,
|
||||||
|
tile_handle,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Self { tile_images }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_thumbnail(&self, name: &str) -> Option<Handle<Image>> {
|
||||||
|
self
|
||||||
|
.tile_images
|
||||||
|
.iter()
|
||||||
|
.find(|&tile| tile.name == name)
|
||||||
|
.map(|tile| tile.thumbnail_handle.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_tile(&self, name: &str) -> Option<Handle<Image>> {
|
||||||
|
self
|
||||||
|
.tile_images
|
||||||
|
.iter()
|
||||||
|
.find(|&tile| tile.name == name)
|
||||||
|
.map(|tile| tile.tile_handle.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load_assets(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
|
let asset_library = AssetLibrary::new(&asset_server);
|
||||||
|
commands.insert_resource(asset_library);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
use bevy::{prelude::*, window::WindowResolution};
|
use bevy::{prelude::*, window::WindowResolution};
|
||||||
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
|
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
|
||||||
|
|
||||||
|
mod assets;
|
||||||
mod card;
|
mod card;
|
||||||
mod constants;
|
mod constants;
|
||||||
mod widgets;
|
mod widgets;
|
||||||
@@ -16,5 +17,6 @@ fn main() {
|
|||||||
}))
|
}))
|
||||||
.add_plugins(EguiPlugin::default())
|
.add_plugins(EguiPlugin::default())
|
||||||
.add_plugins(WorldInspectorPlugin::new())
|
.add_plugins(WorldInspectorPlugin::new())
|
||||||
|
.add_systems(Startup, assets::load_assets)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|||||||