mln_engine/draw/
tile_render_data.rs1use crate::draw::dynamic_texture_atlas::{DynamicTextureAtlas, PageId};
2use crate::draw::store::Texture;
3
4#[derive(Clone, Debug, Default)]
8pub struct TileAtlasTextures {
9 glyph_page: Option<PageId>,
10 icon_page: Option<PageId>,
11 glyph: Option<Texture>,
12 icon: Option<Texture>,
13}
14
15impl TileAtlasTextures {
16 pub(crate) fn new(glyph: PageId, icon: PageId) -> Self {
18 TileAtlasTextures { glyph_page: Some(glyph), icon_page: Some(icon), glyph: None, icon: None }
19 }
20
21 pub(crate) fn resolve(&mut self, atlas: &DynamicTextureAtlas) {
23 if self.glyph.is_none() {
24 self.glyph = self.glyph_page.and_then(|page| atlas.page_texture(page)).cloned();
25 }
26 if self.icon.is_none() {
27 self.icon = self.icon_page.and_then(|page| atlas.page_texture(page)).cloned();
28 }
29 }
30
31 #[must_use]
33 pub fn glyph(&self) -> Option<&Texture> {
34 self.glyph.as_ref()
35 }
36
37 #[must_use]
39 pub fn icon(&self) -> Option<&Texture> {
40 self.icon.as_ref()
41 }
42}