Console: Add support for text color
This commit is contained in:
parent
8e4df4cadc
commit
1ea653ab5b
|
|
@ -285,6 +285,7 @@ Nazara Development Kit:
|
||||||
- ⚠️ Console class is no longer bound to a LuaState and now has a OnCommand signal
|
- ⚠️ Console class is no longer bound to a LuaState and now has a OnCommand signal
|
||||||
- ⚠️ Made AbstractTextAreaWidget which is inherited by TextAreaWidget
|
- ⚠️ Made AbstractTextAreaWidget which is inherited by TextAreaWidget
|
||||||
- ⚠️ Added RichTextAreaWidget
|
- ⚠️ Added RichTextAreaWidget
|
||||||
|
- ⚠️ Console now supports text color in history
|
||||||
|
|
||||||
# 0.4:
|
# 0.4:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ namespace Ndk
|
||||||
class AbstractTextAreaWidget;
|
class AbstractTextAreaWidget;
|
||||||
class Console;
|
class Console;
|
||||||
class Entity;
|
class Entity;
|
||||||
|
class RichTextAreaWidget;
|
||||||
class ScrollAreaWidget;
|
class ScrollAreaWidget;
|
||||||
class TextAreaWidget;
|
class TextAreaWidget;
|
||||||
|
|
||||||
|
|
@ -46,7 +47,7 @@ namespace Ndk
|
||||||
void ClearFocus();
|
void ClearFocus();
|
||||||
|
|
||||||
inline unsigned int GetCharacterSize() const;
|
inline unsigned int GetCharacterSize() const;
|
||||||
inline const TextAreaWidget* GetHistory() const;
|
inline const RichTextAreaWidget* GetHistory() const;
|
||||||
inline const TextAreaWidget* GetInput() const;
|
inline const TextAreaWidget* GetInput() const;
|
||||||
inline const Nz::FontRef& GetTextFont() const;
|
inline const Nz::FontRef& GetTextFont() const;
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ namespace Ndk
|
||||||
std::vector<Nz::String> m_commandHistory;
|
std::vector<Nz::String> m_commandHistory;
|
||||||
std::vector<Line> m_historyLines;
|
std::vector<Line> m_historyLines;
|
||||||
ScrollAreaWidget* m_historyArea;
|
ScrollAreaWidget* m_historyArea;
|
||||||
TextAreaWidget* m_history;
|
RichTextAreaWidget* m_history;
|
||||||
TextAreaWidget* m_input;
|
TextAreaWidget* m_input;
|
||||||
Nz::FontRef m_defaultFont;
|
Nz::FontRef m_defaultFont;
|
||||||
unsigned int m_characterSize;
|
unsigned int m_characterSize;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Ndk
|
||||||
* \return History of the console
|
* \return History of the console
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline const TextAreaWidget* Console::GetHistory() const
|
inline const RichTextAreaWidget* Console::GetHistory() const
|
||||||
{
|
{
|
||||||
return m_history;
|
return m_history;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@
|
||||||
#include <NDK/Widgets.hpp>
|
#include <NDK/Widgets.hpp>
|
||||||
#include <NDK/World.hpp>
|
#include <NDK/World.hpp>
|
||||||
|
|
||||||
///TODO: For now is unable to display different color in the history, it needs a RichTextDrawer to do so
|
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
|
|
@ -42,7 +40,7 @@ namespace Ndk
|
||||||
m_maxHistoryLines(200)
|
m_maxHistoryLines(200)
|
||||||
{
|
{
|
||||||
// History
|
// History
|
||||||
m_history = Add<TextAreaWidget>();
|
m_history = Add<RichTextAreaWidget>();
|
||||||
m_history->EnableBackground(true);
|
m_history->EnableBackground(true);
|
||||||
m_history->EnableLineWrap(true);
|
m_history->EnableLineWrap(true);
|
||||||
m_history->SetReadOnly(true);
|
m_history->SetReadOnly(true);
|
||||||
|
|
@ -112,6 +110,7 @@ namespace Ndk
|
||||||
m_historyLines.erase(m_historyLines.begin());
|
m_historyLines.erase(m_historyLines.begin());
|
||||||
|
|
||||||
m_historyLines.emplace_back(Line{ color, text });
|
m_historyLines.emplace_back(Line{ color, text });
|
||||||
|
m_history->SetTextColor(color);
|
||||||
m_history->AppendText(text + '\n');
|
m_history->AppendText(text + '\n');
|
||||||
m_history->Resize(m_history->GetPreferredSize());
|
m_history->Resize(m_history->GetPreferredSize());
|
||||||
m_historyArea->Resize(m_historyArea->GetSize());
|
m_historyArea->Resize(m_historyArea->GetSize());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue