[−][src]Struct genie::HotkeyInfo
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]
R: Read,
Reads a hotkey info file.
pub fn write_to<W>(&self, output: &mut W) -> Result<(), Error> where
W: Write,
[src]
W: Write,
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]
&self,
group_index: usize,
key_index: usize
) -> Result<HotkeyInfo, IndexError>
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]
&self,
group_index: usize,
key_index: usize,
key: i32,
ctrl: bool,
alt: bool,
shift: bool
) -> Result<HotkeyInfo, IndexError>
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]
&self,
lang_file: &LangFile,
him: &HotkeyInfoMetadata
) -> String
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]
fn clone(&self) -> HotkeyInfo
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for HotkeyInfo
[src]
impl Display for HotkeyInfo
[src]
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?
fn into_iter(self) -> <&'a mut HotkeyInfo as IntoIterator>::IntoIter
[src]
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?
fn into_iter(self) -> <&'a HotkeyInfo as IntoIterator>::IntoIter
[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?
fn into_iter(self) -> <HotkeyInfo as IntoIterator>::IntoIter
[src]
impl PartialEq<HotkeyInfo> for HotkeyInfo
[src]
fn eq(&self, other: &HotkeyInfo) -> bool
[src]
fn ne(&self, other: &HotkeyInfo) -> bool
[src]
impl StructuralPartialEq for HotkeyInfo
[src]
Auto Trait Implementations
impl RefUnwindSafe for HotkeyInfo
impl Send for HotkeyInfo
impl Sync for HotkeyInfo
impl Unpin for HotkeyInfo
impl UnwindSafe for HotkeyInfo
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,