1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

search rectangle

This commit is contained in:
Laserlicht 2023-12-08 22:52:34 +01:00 committed by GitHub
parent 95ff89f622
commit dfb10bdfcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 6 deletions

View File

@ -54,6 +54,8 @@
"vcmi.radialWheel.moveDown" : "Move down", "vcmi.radialWheel.moveDown" : "Move down",
"vcmi.radialWheel.moveBottom" : "Move to bottom", "vcmi.radialWheel.moveBottom" : "Move to bottom",
"vcmi.spellBook.search" : "search...",
"vcmi.mainMenu.serverConnecting" : "Connecting...", "vcmi.mainMenu.serverConnecting" : "Connecting...",
"vcmi.mainMenu.serverAddressEnter" : "Enter address:", "vcmi.mainMenu.serverAddressEnter" : "Enter address:",
"vcmi.mainMenu.serverConnectionFailed" : "Failed to connect", "vcmi.mainMenu.serverConnectionFailed" : "Failed to connect",

View File

@ -54,6 +54,8 @@
"vcmi.radialWheel.moveDown" : "Nach unten bewegen", "vcmi.radialWheel.moveDown" : "Nach unten bewegen",
"vcmi.radialWheel.moveBottom" : "Ganz nach unten bewegen", "vcmi.radialWheel.moveBottom" : "Ganz nach unten bewegen",
"vcmi.spellBook.search" : "suchen...",
"vcmi.mainMenu.serverConnecting" : "Verbinde...", "vcmi.mainMenu.serverConnecting" : "Verbinde...",
"vcmi.mainMenu.serverAddressEnter" : "Addresse eingeben:", "vcmi.mainMenu.serverAddressEnter" : "Addresse eingeben:",
"vcmi.mainMenu.serverConnectionFailed" : "Verbindung fehlgeschlagen", "vcmi.mainMenu.serverConnectionFailed" : "Verbindung fehlgeschlagen",

View File

@ -43,8 +43,6 @@ public:
//on which page we left spellbook //on which page we left spellbook
int spellbookLastPageBattle = 0; int spellbookLastPageBattle = 0;
int spellbookLastPageAdvmap = 0; int spellbookLastPageAdvmap = 0;
std::string spellbookLastFilterBattle = "";
std::string spellbookLastFilterAdvmap = "";
int spellbookLastTabBattle = 4; int spellbookLastTabBattle = 4;
int spellbookLastTabAdvmap = 4; int spellbookLastTabAdvmap = 4;

View File

@ -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)); 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)); if(settings["general"]["enableUiEnhancements"].Bool())
searchBox->setText(battleSpellsOnly ? myInt->localState->spellbookSettings.spellbookLastFilterBattle : myInt->localState->spellbookSettings.spellbookLastFilterAdvmap); {
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(); processSpells();
@ -241,6 +252,9 @@ std::shared_ptr<IImage> CSpellWindow::createBigSpellBook()
void CSpellWindow::searchInput() void CSpellWindow::searchInput()
{ {
if(searchBox)
searchBoxDescription->setEnabled(searchBox->getText().empty());
processSpells(); processSpells();
int cp = 0; int cp = 0;
@ -258,7 +272,8 @@ void CSpellWindow::processSpells()
mySpells.reserve(CGI->spellh->objects.size()); mySpells.reserve(CGI->spellh->objects.size());
for(const CSpell * spell : CGI->spellh->objects) 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); mySpells.push_back(spell);
} }
std::sort(mySpells.begin(), mySpells.end(), spellsorter); 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.spellbookLastTabBattle : myInt->localState->spellbookSettings.spellbookLastTabAdvmap) = selectedTab;
(myInt->battleInt ? myInt->localState->spellbookSettings.spellbookLastPageBattle : myInt->localState->spellbookSettings.spellbookLastPageAdvmap) = currentPage; (myInt->battleInt ? myInt->localState->spellbookSettings.spellbookLastPageBattle : myInt->localState->spellbookSettings.spellbookLastPageAdvmap) = currentPage;
(myInt->battleInt ? myInt->localState->spellbookSettings.spellbookLastFilterBattle : myInt->localState->spellbookSettings.spellbookLastFilterAdvmap) = searchBox->getText();
close(); close();
} }

View File

@ -27,6 +27,7 @@ class CGStatusBar;
class CPlayerInterface; class CPlayerInterface;
class CSpellWindow; class CSpellWindow;
class CTextInput; class CTextInput;
class TransparentFilledRectangle;
/// The spell window /// The spell window
class CSpellWindow : public CWindowObject class CSpellWindow : public CWindowObject
@ -82,6 +83,8 @@ class CSpellWindow : public CWindowObject
std::vector<std::shared_ptr<InteractiveArea>> interactiveAreas; std::vector<std::shared_ptr<InteractiveArea>> interactiveAreas;
std::shared_ptr<CTextInput> searchBox; std::shared_ptr<CTextInput> searchBox;
std::shared_ptr<TransparentFilledRectangle> searchBoxRectangle;
std::shared_ptr<CLabel> searchBoxDescription;
bool isBigSpellbook; bool isBigSpellbook;
int spellsPerPage; int spellsPerPage;