Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Page Up/Down to scroll through map list #31

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
}