Sdk/Console: Turn console into a widget (WIP)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <Nazara/Utility/Event.hpp>
|
||||
#include <Nazara/Utility/Node.hpp>
|
||||
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <NDK/EntityOwner.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -26,13 +27,14 @@ namespace Ndk
|
||||
{
|
||||
class Console;
|
||||
class Entity;
|
||||
class TextAreaWidget;
|
||||
|
||||
using ConsoleHandle = Nz::ObjectHandle<Console>;
|
||||
|
||||
class NDK_API Console : public Nz::Node, public Nz::HandledObject<Console>
|
||||
class NDK_API Console : public BaseWidget, public Nz::HandledObject<Console>
|
||||
{
|
||||
public:
|
||||
Console(World& world, const Nz::Vector2f& size, Nz::LuaInstance& instance);
|
||||
Console(BaseWidget* parent, Nz::LuaInstance& instance);
|
||||
Console(const Console& console) = delete;
|
||||
Console(Console&& console) = default;
|
||||
~Console() = default;
|
||||
@@ -42,31 +44,22 @@ namespace Ndk
|
||||
void Clear();
|
||||
|
||||
inline unsigned int GetCharacterSize() const;
|
||||
inline const EntityHandle& GetHistory() const;
|
||||
inline const EntityHandle& GetHistoryBackground() const;
|
||||
inline const EntityHandle& GetInput() const;
|
||||
inline const EntityHandle& GetInputBackground() const;
|
||||
inline const Nz::Vector2f& GetSize() const;
|
||||
inline const TextAreaWidget* GetHistory() const;
|
||||
inline const TextAreaWidget* GetInput() const;
|
||||
inline const Nz::FontRef& GetTextFont() const;
|
||||
|
||||
inline bool IsVisible() const;
|
||||
|
||||
void SendCharacter(char32_t character);
|
||||
void SendEvent(const Nz::WindowEvent& event);
|
||||
void ResizeToContent() override;
|
||||
|
||||
void SetCharacterSize(unsigned int size);
|
||||
void SetSize(const Nz::Vector2f& size);
|
||||
void SetTextFont(Nz::FontRef font);
|
||||
|
||||
void Show(bool show = true);
|
||||
|
||||
Console& operator=(const Console& console) = delete;
|
||||
Console& operator=(Console&& console) = default;
|
||||
|
||||
private:
|
||||
void AddLineInternal(const Nz::String& text, const Nz::Color& color = Nz::Color::White);
|
||||
void ExecuteInput();
|
||||
void Layout();
|
||||
void Layout() override;
|
||||
void RefreshHistory();
|
||||
|
||||
struct Line
|
||||
@@ -78,20 +71,10 @@ namespace Ndk
|
||||
std::size_t m_historyPosition;
|
||||
std::vector<Nz::String> m_commandHistory;
|
||||
std::vector<Line> m_historyLines;
|
||||
EntityOwner m_historyBackground;
|
||||
EntityOwner m_history;
|
||||
EntityOwner m_input;
|
||||
EntityOwner m_inputBackground;
|
||||
TextAreaWidget* m_history;
|
||||
TextAreaWidget* m_input;
|
||||
Nz::FontRef m_defaultFont;
|
||||
Nz::LuaInstance& m_instance;
|
||||
Nz::SpriteRef m_historyBackgroundSprite;
|
||||
Nz::SpriteRef m_inputBackgroundSprite;
|
||||
Nz::SimpleTextDrawer m_historyDrawer;
|
||||
Nz::SimpleTextDrawer m_inputDrawer;
|
||||
Nz::TextSpriteRef m_historyTextSprite;
|
||||
Nz::TextSpriteRef m_inputTextSprite;
|
||||
Nz::Vector2f m_size;
|
||||
bool m_opened;
|
||||
unsigned int m_characterSize;
|
||||
unsigned int m_maxHistoryLines;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user