Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
PlayerPanel.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <functional>
7#include <optional>
8#include <vector>
9
10#include "ButtonWidget.hpp"
11#include "IWidget.hpp"
12#include "SelectionFinder.hpp"
13#include "TooltipWidget.hpp"
14#include "core/WorldState.hpp"
15#include "raylib.h"
16
18class PlayerPanel : public IWidget {
19 public:
20 PlayerPanel() = default;
21 ~PlayerPanel() override = default;
22
25 void setWorld(const WorldState* world);
26
29 void draw(int scaledFontSize) const override;
30
33 bool handleInput() override;
34
37 std::optional<SelectionFinder::Selection> getPendingSelection();
38
41 bool isOpen() const { return _isOpen; }
42
44 void setTeamColorFunc(std::function<Color(const std::string&)> func)
45 {
46 _colorFunc = std::move(func);
47 }
48
49 private:
50 const WorldState* _world = nullptr;
51 bool _isOpen = false;
52 std::optional<SelectionFinder::Selection> _pendingSelection = std::nullopt;
53 std::function<Color(const std::string&)> _colorFunc;
54
56 mutable std::vector<ButtonWidget> _playerButtons;
57
58 static constexpr int PANEL_WIDTH = 400;
59 static constexpr int ROW_HEIGHT = 36;
60};
Reusable clickable button component.
Interface for GUI widgets.
Stateful tooltip panel component implementing IWidget.
Interface for GUI widgets.
Definition IWidget.hpp:11
Widget displaying players and allowing selection.
std::optional< SelectionFinder::Selection > _pendingSelection
void setTeamColorFunc(std::function< Color(const std::string &)> func)
Sets the team color resolution function.
bool isOpen() const
Checks if panel is currently open.
void draw(int scaledFontSize) const override
Draws the panel and player list.
const WorldState * _world
bool handleInput() override
Processes mouse clicks on player rows.
static constexpr int ROW_HEIGHT
std::function< Color(const std::string &)> _colorFunc
~PlayerPanel() override=default
PlayerPanel()=default
void setWorld(const WorldState *world)
Sets the world state pointer.
std::optional< SelectionFinder::Selection > getPendingSelection()
Gets and clears any pending selection made by the user.
static constexpr int PANEL_WIDTH
TooltipWidget _background
std::vector< ButtonWidget > _playerButtons
A configurable, stateful tooltip panel.
Represents the state of the world in the game, including the map size, tile contents,...