Skip to content

Commit

Permalink
Add the option to not display autotiles in the tilepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Dec 24, 2023
1 parent f6843f5 commit d959e73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions crates/components/src/tilepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl Tilepicker {
&update_state.graphics,
update_state.filesystem,
tileset,
true,
)?;

Ok(Self {
Expand Down
15 changes: 10 additions & 5 deletions crates/graphics/src/tilepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,24 @@ impl Tilepicker {
graphics_state: &GraphicsState,
filesystem: &impl luminol_filesystem::FileSystem,
tileset: &luminol_data::rpg::Tileset,
include_autotiles: bool,
) -> anyhow::Result<Self> {
let atlas = graphics_state
.atlas_loader
.load_atlas(graphics_state, filesystem, tileset)?;
let tileset_size = egui::vec2(256., atlas.tileset_height as f32 + 32.);

let tilepicker_data = (47..(384 + 47))
.step_by(48)
.chain(384..(atlas.tileset_height as i16 / 32 * 8 + 384))
.collect_vec();
let tilepicker_data = if include_autotiles {
(47..(384 + 47))
.step_by(48)
.chain(384..(atlas.tileset_height as i16 / 32 * 8 + 384))
.collect_vec()
} else {
(384..(atlas.tileset_height as i16 / 32 * 8 + 384)).collect_vec()
};
let tilepicker_data = luminol_data::Table3::new_data(
8,
1 + (atlas.tileset_height / 32) as usize,
include_autotiles as usize + (atlas.tileset_height / 32) as usize, // bool as usize => 0 = false, 1 = true (saving us an if)
1,
tilepicker_data,
);
Expand Down

0 comments on commit d959e73

Please sign in to comment.