[]Struct rltk::Rltk

pub struct Rltk {
    pub width_pixels: u32,
    pub height_pixels: u32,
    pub original_height_pixels: u32,
    pub original_width_pixels: u32,
    pub fps: f32,
    pub frame_time_ms: f32,
    pub active_console: usize,
    pub key: Option<VirtualKeyCode>,
    pub mouse_pos: (i32, i32),
    pub left_click: bool,
    pub shift: bool,
    pub control: bool,
    pub alt: bool,
    pub web_button: Option<String>,
    pub quitting: bool,
    pub post_scanlines: bool,
    pub post_screenburn: bool,
}

A BTerm context.

Fields

width_pixels: u32height_pixels: u32original_height_pixels: u32original_width_pixels: u32fps: f32frame_time_ms: f32active_console: usizekey: Option<VirtualKeyCode>mouse_pos: (i32, i32)left_click: boolshift: boolcontrol: boolalt: boolweb_button: Option<String>quitting: boolpost_scanlines: boolpost_screenburn: bool

Methods

impl BTerm

pub fn init_raw<S, T>(
    width_pixels: T,
    height_pixels: T,
    window_title: S,
    platform_hints: InitHints
) -> Result<BTerm, Box<dyn Error + 'static + Send + Sync>> where
    S: ToString,
    T: TryInto<u32>, 

Initializes an OpenGL context and a window, stores the info in the BTerm structure.

pub fn init_simple8x8<S, T>(
    width_chars: T,
    height_chars: T,
    window_title: S,
    path_to_shaders: S
) -> BTerm where
    S: ToString,
    T: TryInto<u32>, 

Deprecated since 0.6.2:

Please migrate to the BTermBuilder system instead.

Quick initialization for when you just want an 8x8 font terminal

pub fn init_simple8x16<S, T>(
    width_chars: T,
    height_chars: T,
    window_title: S,
    path_to_shaders: S
) -> BTerm where
    S: ToString,
    T: TryInto<u32>, 

Deprecated since 0.6.2:

Please migrate to the BTermBuilder system instead.

Quick initialization for when you just want an 8x16 VGA font terminal

pub fn register_console(
    &mut self,
    new_console: Box<dyn Console + 'static>,
    font_index: usize
) -> usize

Registers a new console terminal for output, and returns its handle number.

pub fn register_console_no_bg(
    &mut self,
    new_console: Box<dyn Console + 'static>,
    font_index: usize
) -> usize

Registers a new console terminal for output, and returns its handle number. This variant requests that the new console not render background colors, so it can be layered on top of other consoles.

pub fn register_fancy_console(
    &mut self,
    new_console: Box<dyn Console + 'static>,
    font_index: usize
) -> usize

Registers a new console terminal for output, and returns its handle number. This variant requests that the new console not render background colors, so it can be layered on top of other consoles.

pub fn register_sprite_console(
    &mut self,
    new_console: Box<dyn Console + 'static>
) -> usize

Registers a new Sprite-based console

pub fn set_active_console(&mut self, id: usize)

Sets the currently active console number.

pub fn mouse_pos(&self) -> (i32, i32)

Applies the current physical mouse position to the active console, and translates the coordinates into that console's coordinate space.

pub fn mouse_point(&self) -> Point

Applies the current physical mouse position to the active console, and translates the coordinates into that console's coordinate space.

pub fn quit(&mut self)

Tells the game to quit

pub fn render_xp_sprite(&mut self, xp: &XpFile, x: i32, y: i32)

Render a REX Paint (https://www.gridsagegames.com/rexpaint/) file as a sprite. The sprite will be offset by offset_x and offset_y. Transparent cells will not be rendered.

pub fn to_xp_file(&self, width: usize, height: usize) -> XpFile

Saves the entire console stack to a REX Paint XP file. If your consoles are of varying sizes, the file format supports it - but REX doesn't. So you may want to avoid that. You can also get individual layers with to_xp_layer.

pub fn with_post_scanlines(&mut self, with_burn: bool)

Enable scanlines post-processing effect.

impl BTerm

Implements console-like BTerm. Note that this isn't a Console trait anymore, due to the need for helper generics.

pub fn get_char_size(&self) -> (u32, u32)

Gets the active console's size, in characters.

pub fn cls(&mut self)

Request that the active console clear itself to default values.

pub fn cls_bg<COLOR>(&mut self, background: COLOR) where
    COLOR: Into<RGBA>, 

Request that the active console clear itself to a specified background color. Has no effect on consoles that don't have a background color.

pub fn print<S, X, Y>(&mut self, x: X, y: Y, output: S) where
    S: ToString,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Print a string to the active console.

pub fn print_color<S, COLOR, COLOR2, X, Y>(
    &mut self,
    x: X,
    y: Y,
    fg: COLOR,
    bg: COLOR2,
    output: S
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    S: ToString,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Print a string to the active console, in color.

pub fn set<COLOR, COLOR2, GLYPH, X, Y>(
    &mut self,
    x: X,
    y: Y,
    fg: COLOR,
    bg: COLOR2,
    glyph: GLYPH
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    GLYPH: TryInto<u16>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Set a single tile located at x/y to the specified foreground/background colors, and glyph.

pub fn set_fancy<COLOR, COLOR2, GLYPH, ANGLE>(
    &mut self,
    position: Vec2,
    z_order: i32,
    rotation: ANGLE,
    scale: Vec2,
    fg: COLOR,
    bg: COLOR2,
    glyph: GLYPH
) where
    ANGLE: Into<Radians>,
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    GLYPH: TryInto<u16>, 

Set a tile with "fancy" additional attributes

pub fn set_bg<COLOR, X, Y>(&mut self, x: X, y: Y, bg: COLOR) where
    COLOR: Into<RGBA>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Sets the background color only of a specified tile.

pub fn draw_box<COLOR, COLOR2, X, Y, W, H>(
    &mut self,
    x: X,
    y: Y,
    width: W,
    height: H,
    fg: COLOR,
    bg: COLOR2
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    H: TryInto<i32>,
    W: TryInto<i32>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Draws a filled box, with single line characters.

pub fn draw_box_double<COLOR, COLOR2, X, Y, W, H>(
    &mut self,
    x: X,
    y: Y,
    width: W,
    height: H,
    fg: COLOR,
    bg: COLOR2
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    H: TryInto<i32>,
    W: TryInto<i32>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Draws a filled box, with double line characters.

pub fn draw_hollow_box<COLOR, COLOR2, X, Y, W, H>(
    &mut self,
    x: X,
    y: Y,
    width: W,
    height: H,
    fg: COLOR,
    bg: COLOR2
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    H: TryInto<i32>,
    W: TryInto<i32>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Draws a single-line box, without filling in the center.

pub fn draw_hollow_box_double<COLOR, COLOR2, X, Y, W, H>(
    &mut self,
    x: X,
    y: Y,
    width: W,
    height: H,
    fg: COLOR,
    bg: COLOR2
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    H: TryInto<i32>,
    W: TryInto<i32>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Draws a double-line box, without filling in the contents.

pub fn draw_bar_horizontal<COLOR, COLOR2, X, Y, W, N, MAX>(
    &mut self,
    x: X,
    y: Y,
    width: W,
    n: N,
    max: MAX,
    fg: COLOR,
    bg: COLOR2
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    MAX: TryInto<i32>,
    N: TryInto<i32>,
    W: TryInto<i32>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Draws a horizontal bar, suitable for health-bars or progress bars.

pub fn draw_bar_vertical<COLOR, COLOR2, X, Y, H, N, MAX>(
    &mut self,
    x: X,
    y: Y,
    height: H,
    n: N,
    max: MAX,
    fg: COLOR,
    bg: COLOR2
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    H: TryInto<i32>,
    MAX: TryInto<i32>,
    N: TryInto<i32>,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Draws a vertical bar, suitable for health-bars or progress bars.

pub fn fill_region<COLOR, COLOR2, GLYPH>(
    &mut self,
    target: Rect,
    glyph: GLYPH,
    fg: COLOR,
    bg: COLOR2
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    GLYPH: TryInto<u16>, 

Fills a target region with the specified color/glyph combo.

pub fn print_centered<S, Y>(&mut self, y: Y, text: S) where
    S: ToString,
    Y: TryInto<i32>, 

Prints centered text, centered across the whole line

pub fn print_color_centered<S, COLOR, COLOR2, Y>(
    &mut self,
    y: Y,
    fg: COLOR,
    bg: COLOR2,
    text: S
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    S: ToString,
    Y: TryInto<i32>, 

Prints centered text, centered across the whole line - in color

pub fn print_centered_at<S, X, Y>(&mut self, x: X, y: Y, text: S) where
    S: ToString,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Prints text, centered on an arbitrary point

pub fn print_color_centered_at<S, COLOR, COLOR2, X, Y>(
    &mut self,
    x: X,
    y: Y,
    fg: COLOR,
    bg: COLOR2,
    text: S
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    S: ToString,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Prints colored text, centered on an arbitrary point

pub fn print_right<S, X, Y>(&mut self, x: X, y: Y, text: S) where
    S: ToString,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Prints right-aligned text

pub fn print_color_right<S, COLOR, COLOR2, X, Y>(
    &mut self,
    x: X,
    y: Y,
    fg: COLOR,
    bg: COLOR2,
    text: S
) where
    COLOR: Into<RGBA>,
    COLOR2: Into<RGBA>,
    S: ToString,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Prints right-aligned text, in color

pub fn printer<S, X, Y>(
    &mut self,
    x: X,
    y: Y,
    output: S,
    align: TextAlign,
    background: Option<RGBA>
) where
    S: ToString,
    X: TryInto<i32>,
    Y: TryInto<i32>, 

Print a colorized string with the color encoding defined inline. For example: printer(1, 1, "#[blue]This blue text contains a #[pink]pink#[] word") You can get the same effect with a TextBlock, but this can be easier. Thanks to doryen_rs for the idea.

pub fn to_xp_layer(&self) -> XpLayer

Exports the current layer to a REX Paint file

pub fn set_offset(&mut self, x: f32, y: f32)

Sets the active offset for the current layer

pub fn set_scale(&mut self, scale: f32, center_x: i32, center_y: i32)

Sets the active scale for the current layer

pub fn get_scale(&self) -> (f32, i32, i32)

Gets the active scale for the current layer

pub fn set_clipping(&mut self, clipping: Option<Rect>)

Permits the creation of an arbitrary clipping rectangle. It's a really good idea to make sure that this rectangle is entirely valid.

pub fn get_clipping(&self) -> Option<Rect>

Returns the current arbitrary clipping rectangle, None if there isn't one.

pub fn set_all_fg_alpha(&mut self, alpha: f32)

Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).

pub fn set_all_bg_alpha(&mut self, alpha: f32)

Sets ALL tiles background alpha (only tiles that exist, in sparse consoles).

pub fn set_all_alpha(&mut self, fg: f32, bg: f32)

Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).

pub fn set_translation_mode(
    &mut self,
    console: usize,
    translation: CharacterTranslationMode
)

Sets the character translation mode on a console

pub fn set_active_font(
    &mut self,
    font_index: usize,
    resize_to_natural_dimensions: bool
)

Change the active font for the layer. DO NOT USE WITH AMETHYST YET.

pub fn set_char_size(&mut self, width: u32, height: u32)

Manually override the character size for the current terminal. Use with caution!

pub fn set_char_size_and_resize_window(&mut self, _width: u32, _height: u32)

Manually override the character size for the current terminal. Use with caution!

pub fn screenshot<S>(&mut self, filename: S) where
    S: ToString

Take a screenshot - Native only

pub fn register_spritesheet(&mut self, ss: SpriteSheet) -> usize

Register a sprite sheet (OpenGL - native or WASM - only)

pub fn add_sprite(
    &mut self,
    destination: Rect,
    z_order: i32,
    tint: RGBA,
    index: usize
)

Add a sprite to the current console

Trait Implementations

impl Clone for BTerm

impl Debug for BTerm

Auto Trait Implementations

impl RefUnwindSafe for BTerm

impl Send for BTerm

impl Sync for BTerm

impl Unpin for BTerm

impl UnwindSafe for BTerm

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,