mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
search rectangle
This commit is contained in:
parent
95ff89f622
commit
dfb10bdfcb
@ -54,6 +54,8 @@
|
||||
"vcmi.radialWheel.moveDown" : "Move down",
|
||||
"vcmi.radialWheel.moveBottom" : "Move to bottom",
|
||||
|
||||
"vcmi.spellBook.search" : "search...",
|
||||
|
||||
"vcmi.mainMenu.serverConnecting" : "Connecting...",
|
||||
"vcmi.mainMenu.serverAddressEnter" : "Enter address:",
|
||||
"vcmi.mainMenu.serverConnectionFailed" : "Failed to connect",
|
||||
|
@ -54,6 +54,8 @@
|
||||
"vcmi.radialWheel.moveDown" : "Nach unten bewegen",
|
||||
"vcmi.radialWheel.moveBottom" : "Ganz nach unten bewegen",
|
||||
|
||||
"vcmi.spellBook.search" : "suchen...",
|
||||
|
||||
"vcmi.mainMenu.serverConnecting" : "Verbinde...",
|
||||
"vcmi.mainMenu.serverAddressEnter" : "Addresse eingeben:",
|
||||
"vcmi.mainMenu.serverConnectionFailed" : "Verbindung fehlgeschlagen",
|
||||
|
@ -43,8 +43,6 @@ public:
|
||||
//on which page we left spellbook
|
||||
int spellbookLastPageBattle = 0;
|
||||
int spellbookLastPageAdvmap = 0;
|
||||
std::string spellbookLastFilterBattle = "";
|
||||
std::string spellbookLastFilterAdvmap = "";
|
||||
int spellbookLastTabBattle = 4;
|
||||
int spellbookLastTabAdvmap = 4;
|
||||
|
||||
|
@ -127,8 +127,19 @@ CSpellWindow::CSpellWindow(const CGHeroInstance * _myHero, CPlayerInterface * _m
|
||||
|
||||
pos = background->center(Point(pos.w/2 + pos.x, pos.h/2 + pos.y));
|
||||
|
||||
searchBox = std::make_shared<CTextInput>(Rect(10, isBigSpellbook ? 8 : 20, pos.w-20, 16), FONT_MEDIUM, std::bind(&CSpellWindow::searchInput, this));
|
||||
searchBox->setText(battleSpellsOnly ? myInt->localState->spellbookSettings.spellbookLastFilterBattle : myInt->localState->spellbookSettings.spellbookLastFilterAdvmap);
|
||||
if(settings["general"]["enableUiEnhancements"].Bool())
|
||||
{
|
||||
Rect r(90, isBigSpellbook ? 480 : 420, isBigSpellbook ? 160 : 110, 16);
|
||||
const ColorRGBA rectangleColor = ColorRGBA(0, 0, 0, 75);
|
||||
const ColorRGBA borderColor = ColorRGBA(128, 100, 75);
|
||||
const ColorRGBA grayedColor = ColorRGBA(158, 130, 105);
|
||||
searchBoxRectangle = std::make_shared<TransparentFilledRectangle>(r.resize(1), rectangleColor, borderColor);
|
||||
searchBoxDescription = std::make_shared<CLabel>(r.center().x, r.center().y, FONT_SMALL, ETextAlignment::CENTER, grayedColor, CGI->generaltexth->translate("vcmi.spellBook.search"));
|
||||
|
||||
searchBox = std::make_shared<CTextInput>(r, FONT_SMALL, std::bind(&CSpellWindow::searchInput, this));
|
||||
searchBox->removeFocus();
|
||||
searchBox->setText("");
|
||||
}
|
||||
|
||||
processSpells();
|
||||
|
||||
@ -241,6 +252,9 @@ std::shared_ptr<IImage> CSpellWindow::createBigSpellBook()
|
||||
|
||||
void CSpellWindow::searchInput()
|
||||
{
|
||||
if(searchBox)
|
||||
searchBoxDescription->setEnabled(searchBox->getText().empty());
|
||||
|
||||
processSpells();
|
||||
|
||||
int cp = 0;
|
||||
@ -258,7 +272,8 @@ void CSpellWindow::processSpells()
|
||||
mySpells.reserve(CGI->spellh->objects.size());
|
||||
for(const CSpell * spell : CGI->spellh->objects)
|
||||
{
|
||||
if(!spell->isCreatureAbility() && myHero->canCastThisSpell(spell) && boost::algorithm::contains(boost::algorithm::to_lower_copy(spell->getNameTranslated()), boost::algorithm::to_lower_copy(searchBox->getText())))
|
||||
bool searchTextFound = !searchBox || boost::algorithm::contains(boost::algorithm::to_lower_copy(spell->getNameTranslated()), boost::algorithm::to_lower_copy(searchBox->getText()));
|
||||
if(!spell->isCreatureAbility() && myHero->canCastThisSpell(spell) && searchTextFound)
|
||||
mySpells.push_back(spell);
|
||||
}
|
||||
std::sort(mySpells.begin(), mySpells.end(), spellsorter);
|
||||
@ -321,7 +336,6 @@ void CSpellWindow::fexitb()
|
||||
{
|
||||
(myInt->battleInt ? myInt->localState->spellbookSettings.spellbookLastTabBattle : myInt->localState->spellbookSettings.spellbookLastTabAdvmap) = selectedTab;
|
||||
(myInt->battleInt ? myInt->localState->spellbookSettings.spellbookLastPageBattle : myInt->localState->spellbookSettings.spellbookLastPageAdvmap) = currentPage;
|
||||
(myInt->battleInt ? myInt->localState->spellbookSettings.spellbookLastFilterBattle : myInt->localState->spellbookSettings.spellbookLastFilterAdvmap) = searchBox->getText();
|
||||
|
||||
close();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class CGStatusBar;
|
||||
class CPlayerInterface;
|
||||
class CSpellWindow;
|
||||
class CTextInput;
|
||||
class TransparentFilledRectangle;
|
||||
|
||||
/// The spell window
|
||||
class CSpellWindow : public CWindowObject
|
||||
@ -82,6 +83,8 @@ class CSpellWindow : public CWindowObject
|
||||
std::vector<std::shared_ptr<InteractiveArea>> interactiveAreas;
|
||||
|
||||
std::shared_ptr<CTextInput> searchBox;
|
||||
std::shared_ptr<TransparentFilledRectangle> searchBoxRectangle;
|
||||
std::shared_ptr<CLabel> searchBoxDescription;
|
||||
|
||||
bool isBigSpellbook;
|
||||
int spellsPerPage;
|
||||
|
Loading…
Reference in New Issue
Block a user