osb/source/frontend/StarBaseScriptPane.hpp

54 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
2023-07-02 17:19:54 +10:00
#include "StarPane.hpp"
#include "StarLuaComponents.hpp"
#include "StarGuiReader.hpp"
namespace Star {
STAR_CLASS(CanvasWidget);
STAR_CLASS(BaseScriptPane);
// A more 'raw' script pane that doesn't depend on a world being present.
// Requires a derived class to provide a Lua root.
2023-07-04 22:36:27 +10:00
// Should maybe move into windowing?
2023-07-02 17:19:54 +10:00
class BaseScriptPane : public Pane {
public:
2024-11-24 12:51:55 +11:00
BaseScriptPane(Json config, bool construct = true);
2023-07-02 17:19:54 +10:00
virtual void show() override;
void displayed() override;
void dismissed() override;
void tick(float dt) override;
2023-07-02 17:19:54 +10:00
bool sendEvent(InputEvent const& event) override;
2023-07-29 02:12:03 +10:00
Json const& config() const;
Json const& rawConfig() const;
2023-07-02 17:19:54 +10:00
bool interactive() const override;
2023-07-02 17:19:54 +10:00
PanePtr createTooltip(Vec2I const& screenPosition) override;
Maybe<String> cursorOverride(Vec2I const& screenPosition) override;
protected:
virtual GuiReaderPtr reader() override;
2024-11-24 12:51:55 +11:00
void construct(Json config);
2023-07-02 17:19:54 +10:00
Json m_config;
2023-07-29 02:12:03 +10:00
Json m_rawConfig;
2023-07-02 17:19:54 +10:00
2023-07-04 22:36:27 +10:00
GuiReaderPtr m_reader;
2023-07-02 17:19:54 +10:00
Map<CanvasWidgetPtr, String> m_canvasClickCallbacks;
Map<CanvasWidgetPtr, String> m_canvasKeyCallbacks;
bool m_interactive;
2023-07-02 17:19:54 +10:00
bool m_callbacksAdded;
2024-11-24 12:51:55 +11:00
mutable LuaUpdatableComponent<LuaBaseComponent> m_script;
2023-07-02 17:19:54 +10:00
};
}