Skip to content

Commit

Permalink
Merge pull request #31 from Froggy618157725/map_up_down_hotkey
Browse files Browse the repository at this point in the history
Add Page Up/Down to scroll through map list
  • Loading branch information
Froggy618157725 authored Jul 9, 2024
2 parents a98af45 + 60c4483 commit 125b97d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ received some polish!
- Added a dim outline when hovering over nametags
- Added a unit testing framework
- Currently used for sanity testing various loaders like maps and activities
- Added Page Up/Down to move up and down in the map list @Froggy618157725 in [#31](https://github.com/cohaereo/alkahest/pull/31)

### Changed

Expand Down
14 changes: 14 additions & 0 deletions crates/alkahest/src/gui/hotkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ pub const SHORTCUT_GAZE: egui::KeyboardShortcut =
pub const SHORTCUT_MAP_SWAP: egui::KeyboardShortcut =
egui::KeyboardShortcut::new(egui::Modifiers::NONE, egui::Key::I);

pub const SHORTCUT_MAP_PREV: egui::KeyboardShortcut =
egui::KeyboardShortcut::new(egui::Modifiers::NONE, egui::Key::PageUp);

pub const SHORTCUT_MAP_NEXT: egui::KeyboardShortcut =
egui::KeyboardShortcut::new(egui::Modifiers::NONE, egui::Key::PageDown);

pub fn process_hotkeys(ctx: &egui::Context, resources: &mut Resources) {
if ctx.input_mut(|i| i.consume_shortcut(&SHORTCUT_UNHIDE_ALL)) {
unhide_all(resources);
Expand All @@ -55,6 +61,14 @@ pub fn process_hotkeys(ctx: &egui::Context, resources: &mut Resources) {
}
}

if ctx.input_mut(|i| i.consume_shortcut(&SHORTCUT_MAP_PREV)) {
resources.get_mut::<MapList>().set_current_map_prev(resources);
}

if ctx.input_mut(|i| i.consume_shortcut(&SHORTCUT_MAP_NEXT)) {
resources.get_mut::<MapList>().set_current_map_next(resources);
}

if ctx.input_mut(|i| i.consume_shortcut(&SHORTCUT_GAZE)) {
goto_gaze(resources);
}
Expand Down
7 changes: 6 additions & 1 deletion crates/alkahest/src/gui/menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,17 @@ impl MenuBar {
// "Select 'Previous' Object"
// );

control_section_title!(ui, "Miscellaneous");
control_section_title!(ui, "Map Changing");

control_description!(
ui,
ICON_ALPHA_I_BOX_OUTLINE,
"Swap to Previous Map"
);

control_description!(ui, "Page Up", "Swap to Previous Map in List");

control_description!(ui, "Page Down", "Swap to Next Map in List");
});
});
});
Expand Down
12 changes: 12 additions & 0 deletions crates/alkahest/src/maplist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,16 @@ impl MapList {
discord::set_activity_from_map(map);
}
}

pub fn set_current_map_next(&mut self, resources: &Resources) {
if self.current_map + 1 < self.maps.len() {
self.set_current_map(resources, self.current_map + 1)
}
}

pub fn set_current_map_prev(&mut self, resources: &Resources) {
if self.current_map > 0 && self.maps.len() >= 1 {
self.set_current_map(resources, self.current_map - 1)
}
}
}

0 comments on commit 125b97d

Please sign in to comment.