pub struct Root { /* private fields */ }
Implementations§
Source§impl Root
impl Root
Sourcepub fn initializer<'a>() -> RootInitializer<'a>
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();
Sourcepub fn is_fullscreen(&self) -> bool
pub fn is_fullscreen(&self) -> bool
Returns with true when the Root
console is in fullscreen mode.
Sourcepub fn set_fullscreen(&mut self, fullscreen: bool)
pub fn set_fullscreen(&mut self, fullscreen: bool)
Toggles between windowed and fullscreen mode.
Sourcepub fn get_fading_color(&self) -> Color
pub fn get_fading_color(&self) -> Color
Returns the current fade color (previously set by set_fade
).
Sourcepub fn set_fade(&mut self, fade: u8, fading_color: Color)
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).
Sourcepub fn wait_for_keypress(&mut self, flush: bool) -> Key
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.
Sourcepub fn check_for_keypress(&self, status: KeyPressFlags) -> Option<Key>
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.
Sourcepub fn window_closed(&self) -> bool
pub fn window_closed(&self) -> bool
Returns with true if the Root
console has been closed.
Sourcepub fn set_window_title<T>(&mut self, title: T)
pub fn set_window_title<T>(&mut self, title: T)
Sets the main window’s title to the string specified in the argument.
Sourcepub fn render_credits(&self, x: i32, y: i32, alpha: bool) -> bool
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.
Sourcepub fn map_ascii_code_to_font(
&mut self,
ascii_code: i32,
font_char_x: i32,
font_char_y: i32,
)
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 mapfont_char_x/font_char_y
: The coordinate of the character in the bitmap font (in characters, not pixels)
Sourcepub fn map_ascii_codes_to_font(
&mut self,
ascii_code: i32,
nb_codes: i32,
font_char_x: i32,
font_char_y: i32,
)
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
Sourcepub fn map_string_to_font(
&mut self,
s: &str,
font_char_x: i32,
font_char_y: i32,
)
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 mapfont_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
impl AsNative<*mut c_void> for Root
unsafe fn as_native(&self) -> &TCOD_console_t
unsafe fn as_native_mut(&mut self) -> &mut TCOD_console_t
Source§impl Console for Root
impl Console for Root
Source§fn get_alignment(&self) -> TextAlignment
fn get_alignment(&self) -> TextAlignment
Console
instance. For all the possible
text alignment options, see the documentation for
TextAlignment.Source§fn set_alignment(&mut self, alignment: TextAlignment)
fn set_alignment(&mut self, alignment: TextAlignment)
Source§fn set_key_color(&mut self, color: Color)
fn set_key_color(&mut self, color: Color)
Source§fn get_default_background(&mut self) -> Color
fn get_default_background(&mut self) -> Color
clear
, put_char
, etc.Source§fn set_default_background(&mut self, color: Color)
fn set_default_background(&mut self, color: Color)
clear
, put_char
, etc.Source§fn set_default_foreground(&mut self, color: Color)
fn set_default_foreground(&mut self, color: Color)
Source§fn get_char_background(&self, x: i32, y: i32) -> Color
fn get_char_background(&self, x: i32, y: i32) -> Color
Source§fn get_char_foreground(&self, x: i32, y: i32) -> Color
fn get_char_foreground(&self, x: i32, y: i32) -> Color
Source§fn get_background_flag(&self) -> BackgroundFlag
fn get_background_flag(&self) -> BackgroundFlag
Source§fn set_background_flag(&mut self, background_flag: BackgroundFlag)
fn set_background_flag(&mut self, background_flag: BackgroundFlag)
Source§fn get_char(&self, x: i32, y: i32) -> char
fn get_char(&self, x: i32, y: i32) -> char
x, y
Source§fn set_char(&mut self, x: i32, y: i32, c: char)
fn set_char(&mut self, x: i32, y: i32, c: char)
x, y
.Source§fn set_char_background(
&mut self,
x: i32,
y: i32,
color: Color,
background_flag: BackgroundFlag,
)
fn set_char_background( &mut self, x: i32, y: i32, color: Color, background_flag: BackgroundFlag, )
Source§fn set_char_foreground(&mut self, x: i32, y: i32, color: Color)
fn set_char_foreground(&mut self, x: i32, y: i32, color: Color)
Source§fn put_char(
&mut self,
x: i32,
y: i32,
glyph: char,
background_flag: BackgroundFlag,
)
fn put_char( &mut self, x: i32, y: i32, glyph: char, background_flag: BackgroundFlag, )
Source§fn put_char_ex(
&mut self,
x: i32,
y: i32,
glyph: char,
foreground: Color,
background: Color,
)
fn put_char_ex( &mut self, x: i32, y: i32, glyph: char, foreground: Color, background: Color, )
Source§fn print<T>(&mut self, x: i32, y: i32, text: T)
fn print<T>(&mut self, x: i32, y: i32, text: T)
x
and y
coordinates depend on the TextAlignment set in the console: Read moreSource§fn print_rect<T>(&mut self, x: i32, y: i32, width: i32, height: i32, text: T)
fn print_rect<T>(&mut self, x: i32, y: i32, width: i32, height: i32, text: T)
Source§fn print_ex<T>(
&mut self,
x: i32,
y: i32,
background_flag: BackgroundFlag,
alignment: TextAlignment,
text: T,
)
fn print_ex<T>( &mut self, x: i32, y: i32, background_flag: BackgroundFlag, alignment: TextAlignment, text: T, )
Source§fn print_rect_ex<T>(
&mut self,
x: i32,
y: i32,
width: i32,
height: i32,
background_flag: BackgroundFlag,
alignment: TextAlignment,
text: T,
)
fn print_rect_ex<T>( &mut self, x: i32, y: i32, width: i32, height: i32, background_flag: BackgroundFlag, alignment: TextAlignment, text: T, )
print_ex
and print_rect
Source§fn get_height_rect<T>(
&self,
x: i32,
y: i32,
width: i32,
height: i32,
text: T,
) -> i32
fn get_height_rect<T>( &self, x: i32, y: i32, width: i32, height: i32, text: T, ) -> i32
print_rect
or print_rect_ex
.