2017-07-13 10:26:03 +02:00
|
|
|
/*
|
2023-02-01 16:42:03 +02:00
|
|
|
* CInGameConsole.h, part of VCMI engine
|
2017-07-13 10:26:03 +02:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2012-06-13 16:04:06 +03:00
|
|
|
#pragma once
|
|
|
|
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../gui/CIntObject.h"
|
2012-06-13 16:04:06 +03:00
|
|
|
|
2014-07-13 18:39:45 +03:00
|
|
|
class CInGameConsole : public CIntObject
|
|
|
|
{
|
|
|
|
private:
|
2023-03-22 23:09:43 +02:00
|
|
|
struct TextState
|
|
|
|
{
|
|
|
|
std::string text;
|
|
|
|
uint32_t timeOnScreen;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Currently visible texts in the overlay
|
|
|
|
std::vector<TextState> texts;
|
|
|
|
|
|
|
|
/// previously entered texts, for up/down arrows to work
|
|
|
|
std::vector<std::string> previouslyEntered;
|
|
|
|
|
|
|
|
/// displayed entry from previouslyEntered - if none it's -1
|
|
|
|
int prevEntDisp;
|
|
|
|
|
|
|
|
/// timeout for new texts (in ms)
|
|
|
|
static constexpr int defaultTimeout = 10000;
|
|
|
|
|
|
|
|
/// how many texts can be displayed simultaneously
|
|
|
|
static constexpr int maxDisplayedTexts = 10;
|
2022-12-19 22:53:31 +02:00
|
|
|
|
|
|
|
std::weak_ptr<IStatusBar> currentStatusBar;
|
2014-07-13 18:39:45 +03:00
|
|
|
std::string enteredText;
|
2023-02-10 23:29:13 +02:00
|
|
|
|
2024-03-27 13:08:41 +02:00
|
|
|
/// Returns true if console is active and player is currently entering text
|
|
|
|
bool isEnteringText() const;
|
|
|
|
|
2024-03-18 19:52:53 +02:00
|
|
|
void showRecentChatHistory();
|
|
|
|
void addMessageSilent(const std::string & timeFormatted, const std::string & senderName, const std::string & messageText);
|
2023-02-10 23:29:13 +02:00
|
|
|
public:
|
2024-03-18 19:52:53 +02:00
|
|
|
void addMessage(const std::string & timeFormatted, const std::string & senderName, const std::string & messageText);
|
2014-07-13 18:39:45 +03:00
|
|
|
|
2023-03-22 23:09:43 +02:00
|
|
|
void tick(uint32_t msPassed) override;
|
2023-06-02 15:42:18 +02:00
|
|
|
void show(Canvas & to) override;
|
|
|
|
void showAll(Canvas & to) override;
|
2023-04-27 19:21:06 +02:00
|
|
|
void keyPressed(EShortcut key) override;
|
2023-02-02 20:16:41 +02:00
|
|
|
void textInputed(const std::string & enteredText) override;
|
|
|
|
void textEdited(const std::string & enteredText) override;
|
2023-07-04 17:42:52 +02:00
|
|
|
bool captureThisKey(EShortcut key) override;
|
2014-07-13 18:39:45 +03:00
|
|
|
|
|
|
|
void startEnteringText();
|
2023-01-06 22:01:00 +02:00
|
|
|
void endEnteringText(bool processEnteredText);
|
2014-07-13 18:39:45 +03:00
|
|
|
void refreshEnteredText();
|
|
|
|
|
2017-07-17 23:04:00 +02:00
|
|
|
CInGameConsole();
|
2014-07-13 18:39:45 +03:00
|
|
|
};
|