use crate::content; use cgmath::{Deg, Point2, Point3}; /// The location of a UI element, in one of a few /// possible coordinate systems. /// /// Positive Y always points up, /// positive X always points right. #[derive(Debug, Clone)] pub enum AnchoredUiPosition { /// Position of this sprite's center, /// relative to the nw corner of the window. NwC(Point2), /// Position of this sprite's nw corner, /// relative to the nw corner of the window. NwNw(Point2), /// Position of this sprite's ne corner, /// relative to the nw corner of the window. NwNe(Point2), /// Position of this sprite's sw corner, /// relative to the nw corner of the window. NwSw(Point2), /// Position of this sprite's se corner, /// relative to the nw corner of the window. NwSe(Point2), } /// A sprite that represents a ui element #[derive(Debug, Clone)] pub struct UiSprite { /// The texture to use for this sprite pub texture: content::TextureHandle, /// This object's position, in logical (dpi-adjusted) pixels pub pos: AnchoredUiPosition, /// This sprite's color will be multiplied by this value. /// If this is None, color will not be changed. pub color: Option<[f32; 4]>, /// The size of this sprite, in logical (dpi-adjusted) pixels pub dimensions: Point2, /// This sprite's rotation, measured ccw pub angle: Deg, } /// A sprite that represents a world object: /// Ships, planets, debris, etc #[derive(Debug, Clone)] pub struct ObjectSprite { /// The texture to use for this sprite pub texture: content::TextureHandle, /// This object's center, in world coordinates. pub pos: Point3, /// The size of this sprite, /// given as height in world units. pub size: f32, /// This sprite's rotation /// (relative to north, measured ccw) /// Note that this is different from the angle used by our physics system. pub angle: Deg, /// Sprites that should be drawn relative to this sprite. pub children: Option>, } /// A sprite that is drawn relative to an ObjectSprite. #[derive(Debug, Clone)] pub struct ObjectSubSprite { /// The sprite texture to draw pub texture: content::TextureHandle, /// This object's position, in world coordinates. /// This is relative to this sprite's parent. pub pos: Point3, /// The size of this sprite, /// given as height in world units. pub size: f32, /// This sprite's rotation /// (relative to north, measured ccw) /// Just as position, this is relative to this /// subsprite's parent sprite. pub angle: Deg, }