pub struct UserInterface {
pub assets: Assets,
pub state: State,
pub controller: Controller,
pub keymap: Keymap,
pub canvas: Canvas,
/* private fields */
}Expand description
Defines the user interface.
Fields§
§assets: Assets§state: State§controller: Controller§keymap: Keymap§canvas: CanvasImplementations§
Source§impl UserInterface
impl UserInterface
Sourcepub fn new<T, C>(games: T, controller: C, keymap: Keymap) -> Self
pub fn new<T, C>(games: T, controller: C, keymap: Keymap) -> Self
Creates the initial user interface state.
Sourcepub fn min_hex_diameter(&self) -> f64
pub fn min_hex_diameter(&self) -> f64
Returns the minimum allowed hex diameter, which limits zooming out.
Sourcepub fn max_hex_diameter(&self) -> f64
pub fn max_hex_diameter(&self) -> f64
Returns the maximum allowed hex diameter, which limits zooming in.
pub fn handle_key_press(&mut self, event: &KeyPress) -> UiResponse
pub fn respond(&mut self, response: UiResponse)
Sourcepub fn map_size(&self) -> (i32, i32)
pub fn map_size(&self) -> (i32, i32)
Returns the dimensions of the current game map, in pixels.
Sourcepub fn zoom_and_redraw(&mut self)
pub fn zoom_and_redraw(&mut self)
Requests the drawing area to update its size, and redraws the current game state.
This should be called when the user has zoomed in or zoomed out.
Sourcepub fn reset_and_redraw(&mut self)
pub fn reset_and_redraw(&mut self)
Resets the drawing surface, requests the drawing area to update its size, and redraws the current game state.
This should only be called when the active game has changed (e.g., when creating a new game or loading a saved game).
Sourcepub fn set_default_title(&mut self)
pub fn set_default_title(&mut self)
Sets the window title to the game name, replacing any state-specific title.
Sourcepub fn ping(&mut self, dest: PingDest) -> UiResponse
pub fn ping(&mut self, dest: PingDest) -> UiResponse
Responds to an event triggered by something other than a UI event (e.g., a message from a task running in a separate thread).
Sourcepub fn new_game(&mut self, game_ix: usize) -> UiResponse
pub fn new_game(&mut self, game_ix: usize) -> UiResponse
Creates a new game, identified by index into the game library.
Sourcepub fn load_game(&mut self, path: PathBuf) -> UiResponse
pub fn load_game(&mut self, path: PathBuf) -> UiResponse
Loads a saved game state from path.
Sourcepub fn save_game(&mut self, path: PathBuf) -> UiResponse
pub fn save_game(&mut self, path: PathBuf) -> UiResponse
Saves the current game state to path.
Sourcepub fn save_image(&self, path: PathBuf, image: ImageSurface) -> UiResponse
pub fn save_image(&self, path: PathBuf, image: ImageSurface) -> UiResponse
Saves an image to path.
Auto Trait Implementations§
impl Freeze for UserInterface
impl !RefUnwindSafe for UserInterface
impl !Send for UserInterface
impl !Sync for UserInterface
impl Unpin for UserInterface
impl !UnwindSafe for UserInterface
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more