[][src]Struct genie::HotkeyInfo

pub struct HotkeyInfo { /* fields omitted */ }

Represents a HKI file containing hotkey settings.

Implementations

impl HotkeyInfo[src]

pub fn from<R>(input: &mut R) -> Result<HotkeyInfo, Error> where
    R: Read
[src]

Reads a hotkey info file.

pub fn write_to<W>(&self, output: &mut W) -> Result<(), Error> where
    W: Write
[src]

Writes a hotkey info file.

pub fn version(&self) -> f32[src]

Gets the file version.

use std::fs::File;
use genie_hki::HotkeyInfo;
let mut f = File::open("test/files/aoc1.hki")?;
let info = HotkeyInfo::from(&mut f).expect("failed to read file");
assert_eq!(info.version(), 1.0);

let mut f = File::open("test/files/hd0.hki")?;
let info = HotkeyInfo::from(&mut f).expect("failed to read file");
assert_eq!(info.version(), 3.0);

pub fn group(&self, group_id: usize) -> Option<&HotkeyGroup>[src]

Returns an immutable reference to a hotkey group, if that group exists.

use std::fs::File;
use genie_hki::{HotkeyInfo, HotkeyGroupId};
let mut f = File::open("test/files/aoc1.hki")?;
let info = HotkeyInfo::from(&mut f).expect("failed to read file");
assert!(info.group(HotkeyGroupId::Villager as usize).is_some());
assert!(info.group(HotkeyGroupId::Mill as usize).is_none());

pub fn group_mut(&mut self, group_id: usize) -> Option<&mut HotkeyGroup>[src]

Returns a mutable reference to a hotkey group, if that group exists.

pub fn num_groups(&self) -> usize[src]

Returns the number of hotkey groups in this info's hotkey file.

use std::fs::File;
use genie_hki::HotkeyInfo;

let mut f = File::open("test/files/aoc1.hki")?;
let info = HotkeyInfo::from(&mut f).expect("failed to read file");
assert_eq!(14, info.num_groups());

let mut f = File::open("test/files/wk.hki")?;
let info = HotkeyInfo::from(&mut f).expect("failed to read file");
assert_eq!(15, info.num_groups());

pub fn iter(&self) -> impl Iterator<Item = &HotkeyGroup>[src]

Returns an iterator over the hotkey groups present in this info's hotkey file.

pub fn unbind_key(
    &self,
    group_index: usize,
    key_index: usize
) -> Result<HotkeyInfo, IndexError>
[src]

Returns a HotkeyInfo struct equivalent to this HotkeyInfo, but with the key at index key_index of the group given by group_index unbound. Returns an error if either index does not exist.

pub fn bind_key(
    &self,
    group_index: usize,
    key_index: usize,
    key: i32,
    ctrl: bool,
    alt: bool,
    shift: bool
) -> Result<HotkeyInfo, IndexError>
[src]

Returns a HotkeyInfo struct equivalent to this HotkeyInfo, but with the key at index key_index of the group given by group_index bound with the given key and key modifiers. Returns an error if either index does not exist.

pub fn bindings_per_keycode(&self) -> HashMap<i32, Vec<Hotkey>, RandomState>[src]

Returns a map keycode -> vec[hotkey1, hotkey2, ... hotkeyn] mapping every used keybinding to all of the hotkeys to which it is assigned.

Note hotkeys may have different behavior in different contexts, such as A producing an archer when an Archery Range is selected and a militia when a Barracks is selected.

pub fn to_string_lang(
    &self,
    lang_file: &LangFile,
    him: &HotkeyInfoMetadata
) -> String
[src]

Returns a string representation of this HotkeyInfo struct using the strings from lang_file and the group name sting keys given in him.

Panics

Panics if the number of hotkeys in any group of this file differs from the number of hotkeys given to that group in him.

Trait Implementations

impl Clone for HotkeyInfo[src]

impl Debug for HotkeyInfo[src]

impl Display for HotkeyInfo[src]

impl IntoIterator for HotkeyInfo[src]

type Item = HotkeyGroup

The type of the elements being iterated over.

type IntoIter = IntoIter<HotkeyGroup>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a HotkeyInfo[src]

type Item = &'a HotkeyGroup

The type of the elements being iterated over.

type IntoIter = Iter<'a, HotkeyGroup>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut HotkeyInfo[src]

type Item = &'a mut HotkeyGroup

The type of the elements being iterated over.

type IntoIter = IterMut<'a, HotkeyGroup>

Which kind of iterator are we turning this into?

impl PartialEq<HotkeyInfo> for HotkeyInfo[src]

impl StructuralPartialEq for HotkeyInfo[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.