mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-19 12:02:24 +02:00
fast search
This commit is contained in:
parent
07aa7bac3c
commit
e86b694b22
@ -114,7 +114,8 @@ std::vector<AdventureMapShortcutState> AdventureMapShortcuts::getShortcuts()
|
|||||||
{ EShortcut::ADVENTURE_MOVE_HERO_NW, optionHeroSelected(), [this]() { this->moveHeroDirectional({-1, -1}); } },
|
{ 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_NN, optionHeroSelected(), [this]() { this->moveHeroDirectional({ 0, -1}); } },
|
||||||
{ EShortcut::ADVENTURE_MOVE_HERO_NE, optionHeroSelected(), [this]() { this->moveHeroDirectional({+1, -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;
|
return result;
|
||||||
}
|
}
|
||||||
@ -462,7 +463,7 @@ void AdventureMapShortcuts::zoom( int distance)
|
|||||||
owner.hotkeyZoom(distance, false);
|
owner.hotkeyZoom(distance, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdventureMapShortcuts::search()
|
void AdventureMapShortcuts::search(bool next)
|
||||||
{
|
{
|
||||||
// get all relevant objects
|
// get all relevant objects
|
||||||
std::vector<ObjectInstanceID> visitableObjInstances;
|
std::vector<ObjectInstanceID> visitableObjInstances;
|
||||||
@ -501,8 +502,8 @@ void AdventureMapShortcuts::search()
|
|||||||
for(auto & obj : textCountList)
|
for(auto & obj : textCountList)
|
||||||
texts.push_back(obj.first + " (" + std::to_string(obj.second) + ")");
|
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"),
|
// function to center element from list on map
|
||||||
[this, textCountList, visitableObjInstances](int index)
|
auto selectObjOnMap = [this, textCountList, visitableObjInstances](int index)
|
||||||
{
|
{
|
||||||
auto selObj = textCountList[index].first;
|
auto selObj = textCountList[index].first;
|
||||||
|
|
||||||
@ -520,7 +521,12 @@ void AdventureMapShortcuts::search()
|
|||||||
auto objInst = LOCPLINT->cb->getObjInstance(selVisitableObjInstances[searchPos]);
|
auto objInst = LOCPLINT->cb->getObjInstance(selVisitableObjInstances[searchPos]);
|
||||||
owner.centerOnObject(objInst);
|
owner.centerOnObject(objInst);
|
||||||
searchLast = VLC->objtypeh->getObjectName(objInst->getObjGroupIndex(), objInst->getObjTypeIndex());
|
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()
|
void AdventureMapShortcuts::nextObject()
|
||||||
|
@ -76,7 +76,7 @@ class AdventureMapShortcuts
|
|||||||
void nextTown();
|
void nextTown();
|
||||||
void nextObject();
|
void nextObject();
|
||||||
void zoom( int distance);
|
void zoom( int distance);
|
||||||
void search();
|
void search(bool next);
|
||||||
void moveHeroDirectional(const Point & direction);
|
void moveHeroDirectional(const Point & direction);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -162,6 +162,7 @@ enum class EShortcut
|
|||||||
ADVENTURE_TO_MAIN_MENU,
|
ADVENTURE_TO_MAIN_MENU,
|
||||||
ADVENTURE_QUIT_GAME,
|
ADVENTURE_QUIT_GAME,
|
||||||
ADVENTURE_SEARCH,
|
ADVENTURE_SEARCH,
|
||||||
|
ADVENTURE_SEARCH_CONTINUE,
|
||||||
|
|
||||||
// Move hero one tile in specified direction. Bound to cursors & numpad buttons
|
// Move hero one tile in specified direction. Bound to cursors & numpad buttons
|
||||||
ADVENTURE_MOVE_HERO_SW,
|
ADVENTURE_MOVE_HERO_SW,
|
||||||
|
@ -210,6 +210,7 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
|
|||||||
{"adventureZoomOut", EShortcut::ADVENTURE_ZOOM_OUT },
|
{"adventureZoomOut", EShortcut::ADVENTURE_ZOOM_OUT },
|
||||||
{"adventureZoomReset", EShortcut::ADVENTURE_ZOOM_RESET },
|
{"adventureZoomReset", EShortcut::ADVENTURE_ZOOM_RESET },
|
||||||
{"adventureSearch", EShortcut::ADVENTURE_SEARCH },
|
{"adventureSearch", EShortcut::ADVENTURE_SEARCH },
|
||||||
|
{"adventureSearchContinue", EShortcut::ADVENTURE_SEARCH_CONTINUE },
|
||||||
{"battleToggleHeroesStats", EShortcut::BATTLE_TOGGLE_HEROES_STATS},
|
{"battleToggleHeroesStats", EShortcut::BATTLE_TOGGLE_HEROES_STATS},
|
||||||
{"battleToggleQueue", EShortcut::BATTLE_TOGGLE_QUEUE },
|
{"battleToggleQueue", EShortcut::BATTLE_TOGGLE_QUEUE },
|
||||||
{"battleUseCreatureSpell", EShortcut::BATTLE_USE_CREATURE_SPELL },
|
{"battleUseCreatureSpell", EShortcut::BATTLE_USE_CREATURE_SPELL },
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
"adventureZoomOut": "Keypad -",
|
"adventureZoomOut": "Keypad -",
|
||||||
"adventureZoomReset": "Backspace",
|
"adventureZoomReset": "Backspace",
|
||||||
"adventureSearch": "Ctrl+F",
|
"adventureSearch": "Ctrl+F",
|
||||||
|
"adventureSearchContinue": "Alt+F",
|
||||||
"battleAutocombat": "A",
|
"battleAutocombat": "A",
|
||||||
"battleAutocombatEnd": "Q",
|
"battleAutocombatEnd": "Q",
|
||||||
"battleCastSpell": "C",
|
"battleCastSpell": "C",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user