CInGameConsole.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * CInGameConsole.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../gui/CIntObject.h"
  12. class CInGameConsole : public CIntObject
  13. {
  14. private:
  15. struct TextState
  16. {
  17. std::string text;
  18. uint32_t timeOnScreen;
  19. };
  20. /// Currently visible texts in the overlay
  21. std::vector<TextState> texts;
  22. /// protects texts
  23. boost::mutex texts_mx;
  24. /// previously entered texts, for up/down arrows to work
  25. std::vector<std::string> previouslyEntered;
  26. /// displayed entry from previouslyEntered - if none it's -1
  27. int prevEntDisp;
  28. /// timeout for new texts (in ms)
  29. static constexpr int defaultTimeout = 10000;
  30. /// how many texts can be displayed simultaneously
  31. static constexpr int maxDisplayedTexts = 10;
  32. std::weak_ptr<IStatusBar> currentStatusBar;
  33. std::string enteredText;
  34. public:
  35. void print(const std::string & txt);
  36. void tick(uint32_t msPassed) override;
  37. void show(SDL_Surface * to) override;
  38. void showAll(SDL_Surface * to) override;
  39. void keyPressed(EShortcut key) override;
  40. void textInputed(const std::string & enteredText) override;
  41. void textEdited(const std::string & enteredText) override;
  42. void startEnteringText();
  43. void endEnteringText(bool processEnteredText);
  44. void refreshEnteredText();
  45. CInGameConsole();
  46. };