Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
EntityTooltipWidget.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
9#include <functional>
10#include <string>
11
12#include "ButtonWidget.hpp"
13#include "IWidget.hpp"
14#include "SelectionFinder.hpp"
15#include "TooltipWidget.hpp"
16#include "core/WorldState.hpp"
17#include "raylib.h"
18
20 public:
22 ~EntityTooltipWidget() override = default;
23
25 void setWorld(const WorldState* world);
26 void setTeamColorFunc(std::function<Color(const std::string&)> func);
29 void setFollowActive(bool active);
30
33 int popFollowRequest();
34
36 bool isFollowButtonHovered() const;
37
38 void draw(int scaledFontSize) const override;
39 bool handleInput() override;
40
41 private:
42 const WorldState* _world = nullptr;
44 std::function<Color(const std::string&)> _colorFunc;
45 bool _followActive = false;
46
48 mutable int _scaledFontSize = 18;
49
52 mutable bool _btnHovered = false;
53 mutable float _btnW = BTN_W;
54
55 static constexpr float BTN_W = 120.0f;
56 static constexpr float BTN_H = 36.0f;
57 static constexpr float BTN_MARGIN = 10.0f; // gap inside panel below last line
58
59 void _rebuild() const;
60 bool _isPlayerCase() const;
61 void _positionButton() const;
62};
Reusable clickable button component.
Interface for GUI widgets.
Stateful tooltip panel component implementing IWidget.
A configurable, stateful clickable button.
void setSelection(const SelectionFinder::Selection &sel)
static constexpr float BTN_MARGIN
int popFollowRequest()
Returns and clears the pending follow target player id. Positive id = start follow....
void setTeamColorFunc(std::function< Color(const std::string &)> func)
void setFollowActive(bool active)
Tells the widget whether follow mode is currently active (affects button label/color).
void draw(int scaledFontSize) const override
Draws the widget.
bool handleInput() override
Processes user input.
static constexpr float BTN_H
~EntityTooltipWidget() override=default
bool isFollowButtonHovered() const
True when the follow button is hovered — use to block raycasts.
void setWorld(const WorldState *world)
SelectionFinder::Selection _selection
static constexpr float BTN_W
const WorldState * _world
std::function< Color(const std::string &)> _colorFunc
Interface for GUI widgets.
Definition IWidget.hpp:11
A configurable, stateful tooltip panel.
Represents the state of the world in the game, including the map size, tile contents,...