From 83070fe50cbc237d4238e5a1c71711ba36d6f06e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 29 May 2021 00:38:41 +0200 Subject: [PATCH] PTM is now searchable --- menus.cpp | 2 +- yendor.cpp | 69 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/menus.cpp b/menus.cpp index 318d58cb..18fbc401 100644 --- a/menus.cpp +++ b/menus.cpp @@ -763,7 +763,7 @@ EX void showChangeMode() { dialog::add_action_confirmed([] { restart_game(rg::inv); }); dialog::addBoolItem(XLAT("pure tactics mode"), (tactic::on), 't'); - dialog::add_action_push_clear(tactic::showMenu); + dialog::add_action(tactic::start); dialog::addBoolItem(XLAT("Yendor Challenge"), (yendor::on), 'y'); dialog::add_action([] { diff --git a/yendor.cpp b/yendor.cpp index d72bb68c..644ce09d 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -943,25 +943,36 @@ EX namespace tactic { if(xc == 4) set_priority_board(LB_PURE_TACTICS_COOP); cmode = sm::ZOOMABLE; - mouseovers = XLAT("pure tactics mode") + " - " + mouseovers; + if(mouseovers == "" || mouseovers == " ") + mouseovers = XLAT("pure tactics mode"); + else + mouseovers = XLAT("pure tactics mode") + " - " + mouseovers; + + if(dialog::infix != "") mouseovers = mouseovers + " - " + dialog::infix; + else mouseovers = mouseovers + " - " + XLAT("press letters to search"); { dynamicval t(tactic::on, true); - generateLandList([] (eLand l) { return land_validity(l).flags & lv::appears_in_ptm; }); + generateLandList([] (eLand l) { + if(dialog::infix != "" && !dialog::hasInfix(linf[l].name)) return false; + return !!(land_validity(l).flags & lv::appears_in_ptm); + }); } int nl = isize(landlist); - int nlm; - int ofs = dialog::handlePage(nl, nlm, (nl+1)/2); - - int vf = min((vid.yres-64-vid.fsize) / nlm, vid.xres/40); + int nlm = nl; + int ofs = dialog::infix != "" ? 0 : dialog::handlePage(nl, nlm, (nl+1)/2); + + int vf = nlm ? min((vid.yres-64-vid.fsize) / nlm, vid.xres/40) : vid.xres/40; int xr = vid.xres / 64; if(on) record(specialland, items[treasureType(specialland)]); getcstat = SDLK_ESCAPE; + + map land_for; for(int i=0; i 0 ? its(lsc[xc][l][ii]) : "-", col, 16)) - getcstat = 1000 + i1; + getcstat = keyhere; if(displayfrZH(xr*(24+2*10), i0, 1, (vf-4)*4/5, its(recordsum[xc][l]) + " x" + its(tacmultiplier(l)), col, 0)) - getcstat = 1000 + i1; + getcstat = keyhere; } else { int m = landMultiplier(l); @@ -999,13 +1019,13 @@ EX namespace tactic { } } - dialog::displayPageButtons(3, true); + dialog::displayPageButtons(3, dialog::infix == ""); uploadScore(); if(on) unrecord(specialland); - if(getcstat >= 1000 && getcstat < 1000 + isize(landlist)) { - int ld = landlist[getcstat-1000]; + if(land_for.count(getcstat)) { + int ld = landlist[land_for.at(getcstat)]; subscoreboard scorehere; for(int i=0; i= 1000 && uni < 1000 + isize(landlist)) dialog::do_if_confirmed([uni] { - stop_game(); - specialland = landlist[uni - 1000]; - restart_game(tactic::on ? rg::nothing : rg::tactic); - }); + keyhandler = [land_for] (int sym, int uni) { + if(land_for.count(uni)) { + eLand ll = landlist[land_for.at(uni)]; + dialog::do_if_confirmed([ll] { + stop_game(); + specialland = ll; + restart_game(tactic::on ? rg::nothing : rg::tactic); + }); + } else if(uni == '0') { if(tactic::on) { stop_game(); @@ -1054,11 +1077,17 @@ EX namespace tactic { "Good luck, and have fun!" ); - else if(dialog::handlePageButtons(uni)) ; + else if(dialog::infix == "" && dialog::handlePageButtons(uni)) ; + else if(dialog::editInfix(uni)) ; else if(doexiton(sym, uni)) popScreen(); }; } + EX void start() { + dialog::infix = ""; + popScreenAll(); + pushScreen(tactic::showMenu); + } EX } map code_for;