Struct Root

Source
pub struct Root { /* private fields */ }

Implementations§

Source§

impl Root

Source

pub fn initializer<'a>() -> RootInitializer<'a>

Returns an instance of a RootInitializer object, which can be used to customize the initialization of the Root console. Note that only RootInitializer::init will return the actual Root console instance. For a full list of initialization options, see the RootInitializer documentation.

§Examples
use tcod::console::Root;

let mut root = Root::initializer()
    .size(80, 20)
    .title("Example")
    .fullscreen(true)
    .init();
Source

pub fn is_fullscreen(&self) -> bool

Returns with true when the Root console is in fullscreen mode.

Source

pub fn set_fullscreen(&mut self, fullscreen: bool)

Toggles between windowed and fullscreen mode.

Source

pub fn is_active(&self) -> bool

Returns true if the Root console is currently active.

Source

pub fn has_focus(&self) -> bool

Returns true if the Root console has focus.

Source

pub fn get_fade(&self) -> u8

Returns the current fade amount (previously set by set_fade).

Source

pub fn get_fading_color(&self) -> Color

Returns the current fade color (previously set by set_fade).

Source

pub fn set_fade(&mut self, fade: u8, fading_color: Color)

This function defines the fading parameters, allowing to easily fade the game screen to/from a color. Once they are defined, the fading parameters are valid for ever. You don’t have to call setFade for each rendered frame (unless you change the fading parameters).

Source

pub fn wait_for_keypress(&mut self, flush: bool) -> Key

This function will wait for a keypress event from the user, returning the KeyState that represents the event. If flush is true, all pending keypresses are flushed from the keyboard buffer. If false, it returns the first element from it.

Source

pub fn check_for_keypress(&self, status: KeyPressFlags) -> Option<Key>

This function checks if the user pressed a key. It returns the KeyState representing the event if they have, or None if they have not.

Source

pub fn window_closed(&self) -> bool

Returns with true if the Root console has been closed.

Source

pub fn flush(&mut self)

Flushes the contents of the Root console onto the screen.

Source

pub fn set_window_title<T>(&mut self, title: T)
where T: AsRef<str>,

Sets the main window’s title to the string specified in the argument.

Source

pub fn render_credits(&self, x: i32, y: i32, alpha: bool) -> bool

Embeds libtcod credits in a console. Returns true when the credits screen is finished.

Source

pub fn map_ascii_code_to_font( &mut self, ascii_code: i32, font_char_x: i32, font_char_y: i32, )

Maps a single ASCII code to a character in a bitmap font.

§Arguments
  • ascii_code: The ASCII code to map
  • font_char_x/font_char_y: The coordinate of the character in the bitmap font (in characters, not pixels)
Source

pub fn map_ascii_codes_to_font( &mut self, ascii_code: i32, nb_codes: i32, font_char_x: i32, font_char_y: i32, )

Maps consecutive ASCII codes to consecutive characters in a bitmap font.

§Arguments
  • ascii_code: The first ASCII code to map
  • ’nb_codes`: Number of conescutive ASCII codes to map
  • font_char_x/font_char_y: The coordinate of the character in the bitmap font (in characters, not pixels) corresponding to the first ASCII code
Source

pub fn map_string_to_font( &mut self, s: &str, font_char_x: i32, font_char_y: i32, )

Maps ASCII codes from a string to consecutive characters in a bitmap font.

§Arguments
  • s: String containing ASCII codes to map
  • font_char_x/font_char_y: The coordinate of the character in the bitmap font (in characters, not pixels) corresponding to the first ASCII code in the string

Trait Implementations§

Source§

impl AsNative<*mut c_void> for Root

Source§

unsafe fn as_native(&self) -> &TCOD_console_t

Source§

unsafe fn as_native_mut(&mut self) -> &mut TCOD_console_t

Source§

impl Console for Root

Source§

fn get_alignment(&self) -> TextAlignment

Returns the default text alignment for the Console instance. For all the possible text alignment options, see the documentation for TextAlignment.
Source§

fn set_alignment(&mut self, alignment: TextAlignment)

Sets the default text alignment for the console. For all the possible text alignment options, see the documentation for TextAlignment.
Source§

fn set_key_color(&mut self, color: Color)

Sets a key color that will be ignored when blitting the contents of this console onto an other (essentially a transparent background color).
Source§

fn width(&self) -> i32

Returns the width of the console in characters.
Source§

fn height(&self) -> i32

Returns the height of the console in characters.
Source§

fn get_default_background(&mut self) -> Color

Return the console’s default background color. This is used in several other methods, like: clear, put_char, etc.
Source§

fn set_default_background(&mut self, color: Color)

Sets the console’s default background color. This is used in several other methods, like: clear, put_char, etc.
Source§

fn set_default_foreground(&mut self, color: Color)

Sets the console’s default foreground color. This is used in several printing functions.
Source§

fn get_char_background(&self, x: i32, y: i32) -> Color

Returns the background color of the cell at the specified coordinates.
Source§

fn get_char_foreground(&self, x: i32, y: i32) -> Color

Returns the foreground color of the cell at the specified coordinates.
Source§

fn get_background_flag(&self) -> BackgroundFlag

Returns the console’s current background flag. For a detailed explanation of the possible values, see BackgroundFlag.
Source§

fn set_background_flag(&mut self, background_flag: BackgroundFlag)

Sets the console’s current background flag. For a detailed explanation of the possible values, see BackgroundFlag.
Source§

fn get_char(&self, x: i32, y: i32) -> char

Returns the ASCII value of the cell located at x, y
Source§

fn set_char(&mut self, x: i32, y: i32, c: char)

Modifies the ASCII value of the cell located at x, y.
Source§

fn set_char_background( &mut self, x: i32, y: i32, color: Color, background_flag: BackgroundFlag, )

Changes the background color of the specified cell
Source§

fn set_char_foreground(&mut self, x: i32, y: i32, color: Color)

Changes the foreground color of the specified cell
Source§

fn put_char( &mut self, x: i32, y: i32, glyph: char, background_flag: BackgroundFlag, )

This function modifies every property of the given cell: Read more
Source§

fn put_char_ex( &mut self, x: i32, y: i32, glyph: char, foreground: Color, background: Color, )

Updates every propert of the given cell using explicit colors for the background and foreground.
Source§

fn clear(&mut self)

Clears the console with its default background color
Source§

fn print<T>(&mut self, x: i32, y: i32, text: T)
where Self: Sized, T: AsRef<[u8]> + TcodString,

Prints the text at the specified location. The position of the x and y coordinates depend on the TextAlignment set in the console: Read more
Source§

fn print_rect<T>(&mut self, x: i32, y: i32, width: i32, height: i32, text: T)
where Self: Sized, T: AsRef<[u8]> + TcodString,

Prints the text at the specified location in a rectangular area with the dimensions: (width; height). If the text is longer than the width the newlines will be inserted.
Source§

fn print_ex<T>( &mut self, x: i32, y: i32, background_flag: BackgroundFlag, alignment: TextAlignment, text: T, )
where Self: Sized, T: AsRef<[u8]> + TcodString,

Prints the text at the specified location with an explicit BackgroundFlag and TextAlignment.
Source§

fn print_rect_ex<T>( &mut self, x: i32, y: i32, width: i32, height: i32, background_flag: BackgroundFlag, alignment: TextAlignment, text: T, )
where Self: Sized, T: AsRef<[u8]> + TcodString,

Combines the functions of print_ex and print_rect
Source§

fn get_height_rect<T>( &self, x: i32, y: i32, width: i32, height: i32, text: T, ) -> i32
where Self: Sized, T: AsRef<[u8]> + TcodString,

Compute the height of a wrapped text printed using print_rect or print_rect_ex.
Source§

fn rect( &mut self, x: i32, y: i32, width: i32, height: i32, clear: bool, background_flag: BackgroundFlag, )

Fill a rectangle with the default background colour. Read more
Source§

fn horizontal_line( &mut self, x: i32, y: i32, length: i32, background_flag: BackgroundFlag, )

Draw a horizontal line. Read more
Source§

fn vertical_line( &mut self, x: i32, y: i32, length: i32, background_flag: BackgroundFlag, )

Draw a vertical line. Read more
Source§

fn print_frame<T>( &mut self, x: i32, y: i32, width: i32, height: i32, clear: bool, background_flag: BackgroundFlag, title: Option<T>, )
where Self: Sized, T: AsRef<str>,

Draw a window frame with an optional title. Read more

Auto Trait Implementations§

§

impl Freeze for Root

§

impl RefUnwindSafe for Root

§

impl Send for Root

§

impl Sync for Root

§

impl Unpin for Root

§

impl UnwindSafe for Root

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.