// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp #pragma once #ifndef NDK_SERVER #ifndef NDK_CONSOLE_HPP #define NDK_CONSOLE_HPP #include #include #include #include #include #include #include #include namespace Nz { struct WindowEvent; } namespace Ndk { class AbstractTextAreaWidget; class Console; class Entity; class RichTextAreaWidget; class ScrollAreaWidget; class TextAreaWidget; using ConsoleHandle = Nz::ObjectHandle; class NDK_API Console : public BaseWidget, public Nz::HandledObject { public: Console(BaseWidget* parent); Console(const Console& console) = delete; Console(Console&& console) = default; ~Console() = default; void AddLine(const Nz::String& text, const Nz::Color& color = Nz::Color::White); void Clear(); void ClearFocus(); inline unsigned int GetCharacterSize() const; inline const RichTextAreaWidget* GetHistory() const; inline const TextAreaWidget* GetInput() const; inline const Nz::FontRef& GetTextFont() const; void SetCharacterSize(unsigned int size); void SetFocus(); void SetTextFont(Nz::FontRef font); Console& operator=(const Console& console) = delete; Console& operator=(Console&& console) = default; NazaraSignal(OnCommand, Console* /*console*/, const Nz::String& /*command*/); private: void ExecuteInput(const AbstractTextAreaWidget* textArea, bool* ignoreDefaultAction); void Layout() override; struct Line { Nz::Color color; Nz::String text; }; std::size_t m_historyPosition; std::vector m_commandHistory; std::vector m_historyLines; ScrollAreaWidget* m_historyArea; RichTextAreaWidget* m_history; TextAreaWidget* m_input; Nz::FontRef m_defaultFont; unsigned int m_characterSize; unsigned int m_maxHistoryLines; }; } #include #endif // NDK_CONSOLE_HPP #endif // NDK_SERVER