Skip to main content

GridSkin

Trait GridSkin 

Source
pub trait GridSkin<U>: Debug {
    // Required methods
    fn name(&self) -> &'static str;
    fn tile_size(&self) -> (i32, i32);
    fn view_tiles(&self, area: Rect) -> (i32, i32);
    fn grid(&self, scene: &MapScene<U>, area: Rect) -> Grid;
    fn walk(&self) -> WalkSpeeds;
    fn paint(
        &self,
        looks: &Looks<'_>,
        scene: &MapScene<U>,
        area: Rect,
        units: &dyn UnitPainter<U>,
        buf: &mut GlyphBuffer,
    );

    // Provided methods
    fn zoom_levels(&self) -> &[i32] { ... }
    fn zoom(&self) -> Option<i32> { ... }
    fn at_zoom(&self, _zoom: i32) -> Option<Rc<dyn GridSkin<U>>> { ... }
    fn tile_px(
        &self,
        scene: &MapScene<U>,
        area: Rect,
        tile: Pos,
    ) -> Option<PxRect> { ... }
    fn tile_cells(
        &self,
        scene: &MapScene<U>,
        area: Rect,
        tile: Pos,
    ) -> Option<Rect> { ... }
}
Expand description

Paints grid maps of units U. The tile size is the skin’s: screens ask it how many tiles fit and where a tile is. A skin never changes the game: only the frame, how many tiles are on screen, and how fast a walk is shown.

Required Methods§

Source

fn name(&self) -> &'static str

A stable snake_case name for the kind of skin, e.g. "glyph".

Source

fn tile_size(&self) -> (i32, i32)

A map tile’s size on screen, across × down, in console pixels.

Source

fn view_tiles(&self, area: Rect) -> (i32, i32)

How many tiles, across × down, fit in a map area of area cells.

Source

fn grid(&self, scene: &MapScene<U>, area: Rect) -> Grid

Where scene’s tiles go when it is painted into area.

Source

fn walk(&self) -> WalkSpeeds

How fast a unit’s walk is shown under this skin.

Source

fn paint( &self, looks: &Looks<'_>, scene: &MapScene<U>, area: Rect, units: &dyn UnitPainter<U>, buf: &mut GlyphBuffer, )

Paints scene into the cells of area, its units by units: a painter the caller may build each frame, from what that frame paints with (see the module’s docs). Touches nothing outside it.

Provided Methods§

Source

fn zoom_levels(&self) -> &[i32]

The zooms it can draw the map at, smallest first: console pixels per pixel of its art. None if it can’t zoom (the glyph skin: its tile is two font cells).

Source

fn zoom(&self) -> Option<i32>

The zoom it draws at, or None if it can’t zoom.

Source

fn at_zoom(&self, _zoom: i32) -> Option<Rc<dyn GridSkin<U>>>

The same skin drawing at zoom, or None if zoom isn’t one of its zoom_levels.

Source

fn tile_px(&self, scene: &MapScene<U>, area: Rect, tile: Pos) -> Option<PxRect>

The console pixels of tile when scene is painted into area, or None if it isn’t visible. Menus and popups go beside it.

Source

fn tile_cells(&self, scene: &MapScene<U>, area: Rect, tile: Pos) -> Option<Rect>

The cells tile_px touches.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§