1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-31 00:07:39 +02:00

Implement various todo's and review suggestions

This commit is contained in:
Ivan Savenko
2024-03-27 13:08:41 +02:00
parent b9cd9a5822
commit 671b61c64e
12 changed files with 101 additions and 68 deletions

View File

@@ -66,8 +66,7 @@ void CInGameConsole::show(Canvas & to)
void CInGameConsole::tick(uint32_t msPassed)
{
// Check whether text input is active - we want to keep recent messages visible during this period
// FIXME: better check?
if(enteredText != "")
if(isEnteringText())
return;
size_t sizeBefore = texts.size();
@@ -125,7 +124,7 @@ void CInGameConsole::addMessage(const std::string & timeFormatted, const std::st
bool CInGameConsole::captureThisKey(EShortcut key)
{
if (enteredText.empty())
if (!isEnteringText())
return false;
switch (key)
@@ -148,7 +147,7 @@ void CInGameConsole::keyPressed (EShortcut key)
if (LOCPLINT->cingconsole != this)
return;
if(enteredText.empty() && key != EShortcut::GAME_ACTIVATE_CONSOLE)
if(!isEnteringText() && key != EShortcut::GAME_ACTIVATE_CONSOLE)
return; //because user is not entering any text
switch(key)
@@ -230,7 +229,7 @@ void CInGameConsole::textInputed(const std::string & inputtedText)
if (LOCPLINT->cingconsole != this)
return;
if(enteredText.empty())
if(!isEnteringText())
return;
enteredText.resize(enteredText.size()-1);
@@ -266,7 +265,7 @@ void CInGameConsole::startEnteringText()
if (!isActive())
return;
if(enteredText != "")
if(isEnteringText())
return;
assert(currentStatusBar.expired());//effectively, nullptr check
@@ -325,3 +324,7 @@ void CInGameConsole::refreshEnteredText()
statusbar->setEnteredText(enteredText);
}
bool CInGameConsole::isEnteringText() const
{
return !enteredText.empty();
}

View File

@@ -38,6 +38,9 @@ private:
std::weak_ptr<IStatusBar> currentStatusBar;
std::string enteredText;
/// Returns true if console is active and player is currently entering text
bool isEnteringText() const;
void showRecentChatHistory();
void addMessageSilent(const std::string & timeFormatted, const std::string & senderName, const std::string & messageText);
public: