From 63659224fd0503a5ef13cb8350c2a05a05825bd7 Mon Sep 17 00:00:00 2001 From: Shihan42 Date: Mon, 20 Feb 2023 18:18:00 +0100 Subject: [PATCH] Add new EditBox for searching to console layout --- apps/openmw/mwgui/console.cpp | 15 +++++++++++++-- apps/openmw/mwgui/console.hpp | 4 +++- files/data/mygui/openmw_console.layout | 5 +++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 5a936d2862..4519ed9bd5 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -144,11 +144,15 @@ namespace MWGui getWidget(mCommandLine, "edit_Command"); getWidget(mHistory, "list_History"); + getWidget(mSearchTerm, "edit_SearchTerm"); // Set up the command line box mCommandLine->eventEditSelectAccept += newDelegate(this, &Console::acceptCommand); - mCommandLine->eventKeyButtonPressed += newDelegate(this, &Console::keyPress); + mCommandLine->eventKeyButtonPressed += newDelegate(this, &Console::commandBoxKeyPress); + // Set up the search term box + mSearchTerm->eventKeyButtonReleased += newDelegate(this, &Console::searchTermBoxKeyRelease); + // Set up the log window mHistory->setOverflowToTheLeft(true); @@ -254,7 +258,7 @@ namespace MWGui return c == ' ' || c == '\t'; } - void Console::keyPress(MyGUI::Widget* _sender, MyGUI::KeyCode key, MyGUI::Char _char) + void Console::commandBoxKeyPress(MyGUI::Widget* _sender, MyGUI::KeyCode key, MyGUI::Char _char) { if (MyGUI::InputManager::getInstance().isControlPressed()) { @@ -343,6 +347,13 @@ 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(); diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index 0b0c8dd7d7..8e86ae7bd2 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -28,6 +28,7 @@ namespace MWGui MyGUI::EditBox* mCommandLine; MyGUI::EditBox* mHistory; + MyGUI::EditBox* mSearchTerm; typedef std::list StringList; @@ -77,7 +78,8 @@ namespace MWGui void updateConsoleTitle(); - void keyPress(MyGUI::Widget* _sender, MyGUI::KeyCode key, MyGUI::Char _char); + void commandBoxKeyPress(MyGUI::Widget* _sender, MyGUI::KeyCode key, MyGUI::Char _char); + void searchTermBoxKeyRelease(MyGUI::Widget* _sender, MyGUI::KeyCode key); void acceptCommand(MyGUI::EditBox* _sender); diff --git a/files/data/mygui/openmw_console.layout b/files/data/mygui/openmw_console.layout index 3584002e92..6af10ec3a0 100644 --- a/files/data/mygui/openmw_console.layout +++ b/files/data/mygui/openmw_console.layout @@ -23,5 +23,10 @@ + + + + +