Struct RootInitializer

Source
pub struct RootInitializer<'a> { /* private fields */ }
Expand description

Helper struct for the Root console initialization

This is the type that should be used to initialize the Root console (either directly or indirectly, by calling Root::initializer). It uses method chaining to provide an easy-to-use interface. It exposes the following configuration options for the Root console:

  • size: this determines the size of the console window in characters
  • title: the main window’s title
  • fullscreen: determines if the main window will start in fullscreen mode
  • font: selects a bitmap font and sets its layout. See FontLayout for the possible layouts. The path argument can be a str, Path, String or anything else that implements AsRef<Path>.
  • font_type: only use this if you want to use a greyscale font. See FontType for the possible values.
  • font_dimensions: the dimensions for the given bitmap font. This is automatically deduced from the font layout, only use this if you really need it (providing wrong values will ruin the font display).
  • renderer: sets the console renderer. See the Renderer enum for the valid options.

The initializer provides sane defaults even there are no options explicitly specified, but it is recommended to at least set the size and the window title.

§Examples

Initializing the Root console using Root::initializer instead of explicitly creating a RootInitializer instance:

use tcod::console::{Root, FontLayout, Renderer};

fn main() {
    let mut root = Root::initializer()
        .size(80, 20)
        .title("Example")
        .fullscreen(true)
        .font("terminal.png", FontLayout::AsciiInCol)
        .renderer(Renderer::GLSL)
        .init();
}

Implementations§

Source§

impl<'a> RootInitializer<'a>

Source

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

Source

pub fn size(&mut self, width: i32, height: i32) -> &mut RootInitializer<'a>

Source

pub fn title<T>(&mut self, title: T) -> &mut RootInitializer<'a>
where T: AsRef<str> + 'a,

Source

pub fn fullscreen(&mut self, is_fullscreen: bool) -> &mut RootInitializer<'a>

Source

pub fn font<P>( &mut self, path: P, font_layout: FontLayout, ) -> &mut RootInitializer<'a>
where P: AsRef<Path> + 'a,

Source

pub fn font_type(&mut self, font_type: FontType) -> &mut RootInitializer<'a>

Source

pub fn font_dimensions( &mut self, horizontal: i32, vertical: i32, ) -> &mut RootInitializer<'a>

Source

pub fn renderer(&mut self, renderer: Renderer) -> &mut RootInitializer<'a>

Source

pub fn init(&self) -> Root

Auto Trait Implementations§

§

impl<'a> Freeze for RootInitializer<'a>

§

impl<'a> !RefUnwindSafe for RootInitializer<'a>

§

impl<'a> !Send for RootInitializer<'a>

§

impl<'a> !Sync for RootInitializer<'a>

§

impl<'a> Unpin for RootInitializer<'a>

§

impl<'a> !UnwindSafe for RootInitializer<'a>

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.