From 1ea653ab5bf7f57764f680c429fe366935343799 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 22 Sep 2019 13:07:00 +0200 Subject: [PATCH] Console: Add support for text color --- ChangeLog.md | 1 + SDK/include/NDK/Console.hpp | 5 +++-- SDK/include/NDK/Console.inl | 2 +- SDK/src/NDK/Console.cpp | 5 ++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 07a90646e..a1f22e9e8 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -285,6 +285,7 @@ Nazara Development Kit: - ⚠️ Console class is no longer bound to a LuaState and now has a OnCommand signal - ⚠️ Made AbstractTextAreaWidget which is inherited by TextAreaWidget - ⚠️ Added RichTextAreaWidget +- ⚠️ Console now supports text color in history # 0.4: diff --git a/SDK/include/NDK/Console.hpp b/SDK/include/NDK/Console.hpp index 796a15588..3b4dbbe39 100644 --- a/SDK/include/NDK/Console.hpp +++ b/SDK/include/NDK/Console.hpp @@ -27,6 +27,7 @@ namespace Ndk class AbstractTextAreaWidget; class Console; class Entity; + class RichTextAreaWidget; class ScrollAreaWidget; class TextAreaWidget; @@ -46,7 +47,7 @@ namespace Ndk void ClearFocus(); inline unsigned int GetCharacterSize() const; - inline const TextAreaWidget* GetHistory() const; + inline const RichTextAreaWidget* GetHistory() const; inline const TextAreaWidget* GetInput() const; inline const Nz::FontRef& GetTextFont() const; @@ -73,7 +74,7 @@ namespace Ndk std::vector m_commandHistory; std::vector m_historyLines; ScrollAreaWidget* m_historyArea; - TextAreaWidget* m_history; + RichTextAreaWidget* m_history; TextAreaWidget* m_input; Nz::FontRef m_defaultFont; unsigned int m_characterSize; diff --git a/SDK/include/NDK/Console.inl b/SDK/include/NDK/Console.inl index 0e5733f75..3cd318ae3 100644 --- a/SDK/include/NDK/Console.inl +++ b/SDK/include/NDK/Console.inl @@ -19,7 +19,7 @@ namespace Ndk * \return History of the console */ - inline const TextAreaWidget* Console::GetHistory() const + inline const RichTextAreaWidget* Console::GetHistory() const { return m_history; } diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 292ea992c..67f3e69b2 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -10,8 +10,6 @@ #include #include -///TODO: For now is unable to display different color in the history, it needs a RichTextDrawer to do so - namespace Ndk { namespace @@ -42,7 +40,7 @@ namespace Ndk m_maxHistoryLines(200) { // History - m_history = Add(); + m_history = Add(); m_history->EnableBackground(true); m_history->EnableLineWrap(true); m_history->SetReadOnly(true); @@ -112,6 +110,7 @@ namespace Ndk m_historyLines.erase(m_historyLines.begin()); m_historyLines.emplace_back(Line{ color, text }); + m_history->SetTextColor(color); m_history->AppendText(text + '\n'); m_history->Resize(m_history->GetPreferredSize()); m_historyArea->Resize(m_historyArea->GetSize());