diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 4519ed9bd5..9236d7e384 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -27,6 +27,8 @@ #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" +#include + namespace MWGui { class ConsoleInterpreterContext : public MWScript::InterpreterContext @@ -145,13 +147,17 @@ namespace MWGui getWidget(mCommandLine, "edit_Command"); getWidget(mHistory, "list_History"); getWidget(mSearchTerm, "edit_SearchTerm"); + getWidget(mNextButton, "button_Next"); + getWidget(mPreviousButton, "button_Previous"); // Set up the command line box mCommandLine->eventEditSelectAccept += newDelegate(this, &Console::acceptCommand); mCommandLine->eventKeyButtonPressed += newDelegate(this, &Console::commandBoxKeyPress); // Set up the search term box - mSearchTerm->eventKeyButtonReleased += newDelegate(this, &Console::searchTermBoxKeyRelease); + mSearchTerm->eventEditSelectAccept += newDelegate(this, &Console::acceptSearchTerm); + mNextButton->eventMouseButtonClick += newDelegate(this, &Console::findNextOccurrence); + mPreviousButton->eventMouseButtonClick += newDelegate(this, &Console::findPreviousOccurence); // Set up the log window mHistory->setOverflowToTheLeft(true); @@ -347,13 +353,6 @@ namespace MWGui } } - void Console::searchTermBoxKeyRelease(MyGUI::Widget* _sender, MyGUI::KeyCode key) - { - const std::string& searchTerm = mSearchTerm->getOnlyText(); - if (searchTerm.empty()) - return; - } - void Console::acceptCommand(MyGUI::EditBox* _sender) { const std::string& cm = mCommandLine->getOnlyText(); @@ -381,6 +380,31 @@ namespace MWGui execute(cm); } + void Console::acceptSearchTerm(MyGUI::EditBox* _sender) + { + const std::string& searchTerm = mSearchTerm->getOnlyText(); + if (searchTerm.length() <= 3) + return; + + auto result = mHistory->getOnlyText().find(searchTerm); + + // result ist nur der Index des Chars + // gescrollt wird aber mit Pixelwerten + // also muss man irgendwie umrechnen, welche Zeile welchem Pixelwert entspricht + mHistory->setTextSelection(result, result + searchTerm.length()); + mHistory->setVScrollPosition(result); + } + + void Console::findNextOccurrence(MyGUI::Widget* _sender) + { + print("Next"); + } + + void Console::findPreviousOccurence(MyGUI::Widget* _sender) + { + print("Prev"); + } + std::string Console::complete(std::string input, std::vector& matches) { std::string output = input; diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index 8e86ae7bd2..562a5f3200 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -29,6 +29,8 @@ namespace MWGui MyGUI::EditBox* mCommandLine; MyGUI::EditBox* mHistory; MyGUI::EditBox* mSearchTerm; + MyGUI::Button* mNextButton; + MyGUI::Button* mPreviousButton; typedef std::list StringList; @@ -79,10 +81,12 @@ namespace MWGui void updateConsoleTitle(); void commandBoxKeyPress(MyGUI::Widget* _sender, MyGUI::KeyCode key, MyGUI::Char _char); - void searchTermBoxKeyRelease(MyGUI::Widget* _sender, MyGUI::KeyCode key); - void acceptCommand(MyGUI::EditBox* _sender); + void acceptSearchTerm(MyGUI::EditBox* _sender); + void findNextOccurrence(MyGUI::Widget* _sender); + void findPreviousOccurence(MyGUI::Widget* _sender); + std::string complete(std::string input, std::vector& matches); Compiler::Extensions mExtensions; diff --git a/files/data/mygui/openmw_console.layout b/files/data/mygui/openmw_console.layout index 6af10ec3a0..ccb18e1ba6 100644 --- a/files/data/mygui/openmw_console.layout +++ b/files/data/mygui/openmw_console.layout @@ -24,9 +24,19 @@ - + + + + + + + + + + +