1 #ifndef EDITOR_COMPONENTS_CONVERSATIONTREE_HPP
2 #define EDITOR_COMPONENTS_CONVERSATIONTREE_HPP
4 #include <BLIB/Graphics.hpp>
5 #include <BLIB/Interfaces/GUI.hpp>
20 using Ptr = std::shared_ptr<ConversationTree>;
46 using ClickCb = std::function<void(
unsigned int)>;
60 void update(
const std::vector<core::file::Conversation::Node>& nodes);
72 const std::vector<Node>&
getNodes()
const {
return renderNodes; }
77 const std::vector<Edge>&
getEdges()
const {
return edges; }
106 std::vector<Node> renderNodes;
107 std::vector<Edge> edges;
108 unsigned int selected;
110 unsigned int treeVersion;
113 bool highlightSelected;
117 void onDrag(
const bl::gui::Event& dragEvent);
118 virtual bool handleScroll(
const bl::gui::Event& zoomEvent)
override;
119 void onClick(
const bl::gui::Event& clickEvent);
121 sf::FloatRect getVirtualBounds()
const;
123 sf::Vector2f transformToTreeCoord(
const sf::Vector2f& point)
const;
125 virtual void update(
float dt)
override;
126 virtual sf::Vector2f minimumRequisition()
const override;
127 virtual bl::gui::rdr::Component* doPrepareRender(bl::gui::rdr::Renderer& renderer)
override;
All classes and functionality used for implementing the game editor.
Building block of conversations. A conversation is a tree of nodes and each node is an action that ha...
Special component that renders a clickable tree view of a conversation.
void setSelected(unsigned int i)
Set the selected node index.
const std::vector< Edge > & getEdges() const
Used by the renderer component.
unsigned int getTreeVersion() const
Used by the renderer component.
static constexpr float NodeRadiusSquared
unsigned int getSelectedNode() const
Used by the renderer component.
const glm::vec2 & getCamCenter() const
Used by the renderer component.
std::function< void(unsigned int)> ClickCb
Called when a node is clicked.
bool shouldHighlightSelectedNode() const
Used by the renderer component.
static constexpr float Spacing
void update(const std::vector< core::file::Conversation::Node > &nodes)
Updates the rendered tree with the new nodes.
float getCamZoom() const
Used by the renderer component.
static Ptr create(const ClickCb &clickCb)
Construct a new Conversation Tree component.
std::shared_ptr< ConversationTree > Ptr
static constexpr float NodePadding
const std::vector< Node > & getNodes() const
Used by the renderer component.
static constexpr float NodeRadius
void setup(const sf::Vector2f &pos, const core::file::Conversation::Node &src, unsigned int i, bool terminator)