Skip to main content

MapModes

Struct MapModes 

Source
pub struct MapModes { /* private fields */ }
Expand description

The anvil-map.modes service.

Implementations§

Source§

impl MapModes

Source

pub fn get(host: &Host) -> Option<Self>

The service; None without anvil-map.

Source

pub fn c_api(&self) -> Table<AnvilMapModesService>

The C table, for what this crate does not wrap.

Source

pub fn register(&self, info: &ModeInfo<'_>) -> Result<Mode>

Registers a mode with no lines of its own in the tooltip, which then shows the province’s name and owner only. A pool of 13 numbers is lent in the order modes register: a fourteenth is Unsupported, and so is any mode when another loader of map modes runs. A taken id is AlreadyExists; a bad id, label, description or sprite is InvalidArgument.

Source

pub fn register_with_tooltip<F>( &self, info: &ModeInfo<'_>, describe: F, ) -> Result<Mode>
where F: Fn(Mode, i32) -> Option<String> + Send + Sync + 'static,

Registers a mode whose tooltip lines describe gives: for a province ID, the lines (separated by \n), or None for none. It runs on the main thread after a frame of the main loop, where World may be read, for the province under the cursor while the mode is shown; keep it short. Text past the buffer anvil-map gives is cut at a whole character.

Source

pub fn set_colors(&self, mode: Mode, colors: &[u32]) -> Result<()>

Hands over the colours of mode: colors[i] for the province with ID i (see rgb and NO_COLOR); provinces past the slice and province 0 keep the political colour. The slice is copied. Only while a session runs (WrongPhase otherwise, also when it ends during the call: the slice is dropped); more entries than the session’s province limit, or a colour with a top byte other than 0 or 0xFF, is InvalidArgument.

Source

pub fn mode_id(&self, number: i32) -> Option<&'static str>

The id of the plugin mode that borrowed number, a value of the game’s map mode enum; None for the game’s own modes.

Source

pub fn shown(&self) -> Option<Mode>

The plugin mode shown on the map as of anvil-map’s last step.

Source

pub fn id(&self, mode: Mode) -> Option<&'static str>

The id of mode.

Source

pub fn show(&self, mode: Mode) -> Result<()>

Shows mode on the map, as its button does: anvil-map sets it in its next step, and anvil-map.shown follows there. Any thread while a session runs (WrongPhase otherwise); Unsupported with an older anvil-map or without its hooks.

Trait Implementations§

Source§

impl Clone for MapModes

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MapModes

Source§

impl Debug for MapModes

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.