From: <gi...@cr...> - 2025-07-18 18:15:11
|
via bd44c153c20f292a9553762e1000ff4a829e58c6 (commit) via ddc175b71db3e5e30be89bcb8db3c5b0f90795c6 (commit) via 7c270478f45cb984fb51f46a9c79657e6890f6ed (commit) from b117d8a9e7f2e9a6408b85e652c84bb349c154c1 (commit) ----------------------------------------------------------------------- commit bd44c153c20f292a9553762e1000ff4a829e58c6 Author: DracoOmega <dra...@gm...> Date: Fri Jul 18 15:41:38 2025 -0230 Allow < > to additionally switch pages in drop menu (dilly) And also refactor slightly. commit ddc175b71db3e5e30be89bcb8db3c5b0f90795c6 Author: DracoOmega <dra...@gm...> Date: Fri Jul 18 15:41:00 2025 -0230 Return 'i' menu to previous behavior Perhaps at some point of shuffling deck chairs, we will arrive at a better future. commit 7c270478f45cb984fb51f46a9c79657e6890f6ed Author: DracoOmega <dra...@gm...> Date: Fri Jul 18 15:33:41 2025 -0230 Fix showing incorrect inventory pages in a number of menus (dilly) ----------------------------------------------------------------------- Summary of changes: crawl-ref/source/invent.cc | 68 +++++++++++++++++++++++----------------------- crawl-ref/source/invent.h | 1 - 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index 8a7085b07e..895e638bb9 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -402,6 +402,9 @@ int InvMenu::pre_process(int key) void InvMenu::cycle_page(int dir) { + if (!(flags & MF_PAGED_INVENTORY)) + return; + const static int modes[] = { OSEL_GEAR, @@ -457,38 +460,35 @@ void InvMenu::cycle_page(int dir) update_title(); } -bool InvMenu::process_key(int key) -{ - if (key == CK_LEFT && (flags & MF_PAGED_INVENTORY)) - { - cycle_page(-1); - return true; - } - else if (key == CK_RIGHT && (flags & MF_PAGED_INVENTORY)) - { - cycle_page(1); - return true; - } - - return Menu::process_key(key); -} - bool InvMenu::process_command(command_type cmd) { - if (cmd == CMD_MENU_ACCEPT_SELECTION && (flags & MF_PAGED_INVENTORY)) - { - get_selected(&sel); - return false; - } - else if (cmd == CMD_MENU_EXIT && (flags & MF_PAGED_INVENTORY)) + if (flags & MF_PAGED_INVENTORY) { - // Must clear offscreen selection or exiting the menu will still act - // upon those items. - for (size_t i = 0; i < ARRAYSZ(offscreen_sel); ++i) - offscreen_sel[i].clear(); - sel.clear(); - lastch = CK_ESCAPE; // XX is this correct? - return is_set(MF_UNCANCEL) && !crawl_state.seen_hups; + if (cmd == CMD_MENU_ACCEPT_SELECTION) + { + get_selected(&sel); + return false; + } + else if (cmd == CMD_MENU_EXIT) + { + // Must clear offscreen selection or exiting the menu will still act + // upon those items. + for (size_t i = 0; i < ARRAYSZ(offscreen_sel); ++i) + offscreen_sel[i].clear(); + sel.clear(); + lastch = CK_ESCAPE; // XX is this correct? + return is_set(MF_UNCANCEL) && !crawl_state.seen_hups; + } + else if (cmd == CMD_MENU_LEFT || cmd == CMD_MENU_PAGE_UP) + { + cycle_page(-1); + return true; + } + else if (cmd == CMD_MENU_RIGHT || cmd == CMD_MENU_PAGE_DOWN) + { + cycle_page(1); + return true; + } } return Menu::process_command(cmd); @@ -1482,8 +1482,9 @@ static int _invent_select(const char *title = nullptr, menu.set_title(title); // Cycle through all pages to properly apply pre-selections immediately. - for (int i = 0; i < 4; ++i) - menu.cycle_page(1); + if (flags & MF_PAGED_INVENTORY) + for (int i = 0; i < 4; ++i) + menu.cycle_page(1); menu.show(true); @@ -1495,9 +1496,8 @@ static int _invent_select(const char *title = nullptr, void display_inventory() { - InvMenu menu(MF_SINGLESELECT | MF_ALLOW_FORMATTING | MF_SECONDARY_SCROLL - | MF_PAGED_INVENTORY); - menu.load_inv_items(OSEL_GEAR, -1); + InvMenu menu(MF_SINGLESELECT | MF_ALLOW_FORMATTING | MF_SECONDARY_SCROLL); + menu.load_inv_items(OSEL_ANY, -1); menu.set_type(menu_type::describe); menu.show(true); diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h index b2d2ba4ec2..2cff466cab 100644 --- a/crawl-ref/source/invent.h +++ b/crawl-ref/source/invent.h @@ -181,7 +181,6 @@ protected: void select_item_index(int idx, int qty) override; bool examine_index(int i) override; int pre_process(int key) override; - bool process_key(int key) override; bool process_command(command_type cmd) override; string get_select_count_string(int count) const override; virtual bool skip_process_command(int keyin) override; -- Dungeon Crawl Stone Soup |