pub struct MapModes { /* private fields */ }Expand description
The anvil-map.modes service.
Implementations§
Source§impl MapModes
impl MapModes
Sourcepub fn c_api(&self) -> Table<AnvilMapModesService>
pub fn c_api(&self) -> Table<AnvilMapModesService>
The C table, for what this crate does not wrap.
Sourcepub fn register(&self, info: &ModeInfo<'_>) -> Result<Mode>
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.
Sourcepub fn register_with_tooltip<F>(
&self,
info: &ModeInfo<'_>,
describe: F,
) -> Result<Mode>
pub fn register_with_tooltip<F>( &self, info: &ModeInfo<'_>, describe: F, ) -> Result<Mode>
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.
Sourcepub fn set_colors(&self, mode: Mode, colors: &[u32]) -> Result<()>
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.
Sourcepub fn mode_id(&self, number: i32) -> Option<&'static str>
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.
Sourcepub fn shown(&self) -> Option<Mode>
pub fn shown(&self) -> Option<Mode>
The plugin mode shown on the map as of anvil-map’s last step.
Sourcepub fn show(&self, mode: Mode) -> Result<()>
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.
Sourcepub fn set_legend(&self, mode: Mode, entries: &[(u32, &str)]) -> Result<()>
pub fn set_legend(&self, mode: Mode, entries: &[(u32, &str)]) -> Result<()>
Gives mode a legend: each colour (see rgb) and what it means,
in order, at most LEGEND_MAX. anvil-map shows it in a window of
Anvil’s overlay while the mode is shown; an empty slice removes it.
Any thread, any time; it lasts across sessions. InvalidArgument for
too many entries, NO_COLOR, or a label that is empty or longer
than 64 bytes; Unsupported with an anvil-map before 1.26.0.