1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-21 17:17:06 +02:00

fast search

This commit is contained in:
Laserlicht 2024-10-01 21:36:45 +02:00
parent 07aa7bac3c
commit e86b694b22
5 changed files with 15 additions and 6 deletions

View File

@ -114,7 +114,8 @@ std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
{ EShortcut::ADVENTURE_MOVE_HERO_NW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, -1}); } },
{ EShortcut::ADVENTURE_MOVE_HERO_NN, optionHeroSelected(), [this]() { this->moveHeroDirectional({ 0, -1}); } },
{ EShortcut::ADVENTURE_MOVE_HERO_NE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, -1}); } },
{ EShortcut::ADVENTURE_SEARCH, optionSidePanelActive(),[this]() { this->search(); } }
{ EShortcut::ADVENTURE_SEARCH, optionSidePanelActive(),[this]() { this->search(false); } },
{ EShortcut::ADVENTURE_SEARCH_CONTINUE, optionSidePanelActive(),[this]() { this->search(true); } }
};
return result;
}
@ -462,7 +463,7 @@ void AdventureMapShortcuts::zoom( int distance)
owner.hotkeyZoom(distance, false);
}
void AdventureMapShortcuts::search()
void AdventureMapShortcuts::search(bool next)
{
// get all relevant objects
std::vector<ObjectInstanceID> visitableObjInstances;
@ -501,8 +502,8 @@ void AdventureMapShortcuts::search()
for(auto & obj : textCountList)
texts.push_back(obj.first + " (" + std::to_string(obj.second) + ")");
GH.windows().createAndPushWindow<CObjectListWindow>(texts, nullptr, CGI->generaltexth->translate("vcmi.adventureMap.search.hover"), CGI->generaltexth->translate("vcmi.adventureMap.search.help"),
[this, textCountList, visitableObjInstances](int index)
// function to center element from list on map
auto selectObjOnMap = [this, textCountList, visitableObjInstances](int index)
{
auto selObj = textCountList[index].first;
@ -520,7 +521,12 @@ void AdventureMapShortcuts::search()
auto objInst = LOCPLINT->cb->getObjInstance(selVisitableObjInstances[searchPos]);
owner.centerOnObject(objInst);
searchLast = VLC->objtypeh->getObjectName(objInst->getObjGroupIndex(), objInst->getObjTypeIndex());
}, lastSel);
};
if(next)
selectObjOnMap(lastSel);
else
GH.windows().createAndPushWindow<CObjectListWindow>(texts, nullptr, CGI->generaltexth->translate("vcmi.adventureMap.search.hover"), CGI->generaltexth->translate("vcmi.adventureMap.search.help"), [selectObjOnMap](int index){ selectObjOnMap(index); }, lastSel);
}
void AdventureMapShortcuts::nextObject()

View File

@ -76,7 +76,7 @@ class AdventureMapShortcuts
void nextTown();
void nextObject();
void zoom( int distance);
void search();
void search(bool next);
void moveHeroDirectional(const Point & direction);
public:

View File

@ -162,6 +162,7 @@ enum class EShortcut
ADVENTURE_TO_MAIN_MENU,
ADVENTURE_QUIT_GAME,
ADVENTURE_SEARCH,
ADVENTURE_SEARCH_CONTINUE,
// Move hero one tile in specified direction. Bound to cursors & numpad buttons
ADVENTURE_MOVE_HERO_SW,

View File

@ -210,6 +210,7 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
{"adventureZoomOut", EShortcut::ADVENTURE_ZOOM_OUT },
{"adventureZoomReset", EShortcut::ADVENTURE_ZOOM_RESET },
{"adventureSearch", EShortcut::ADVENTURE_SEARCH },
{"adventureSearchContinue", EShortcut::ADVENTURE_SEARCH_CONTINUE },
{"battleToggleHeroesStats", EShortcut::BATTLE_TOGGLE_HEROES_STATS},
{"battleToggleQueue", EShortcut::BATTLE_TOGGLE_QUEUE },
{"battleUseCreatureSpell", EShortcut::BATTLE_USE_CREATURE_SPELL },

View File

@ -57,6 +57,7 @@
"adventureZoomOut": "Keypad -",
"adventureZoomReset": "Backspace",
"adventureSearch": "Ctrl+F",
"adventureSearchContinue": "Alt+F",
"battleAutocombat": "A",
"battleAutocombatEnd": "Q",
"battleCastSpell": "C",