|
Zappy GUI
C++ graphic client: renderer, camera, network
|
A renderer that uses Raylib to display the game state graphically. More...
#include <RaylibRenderer.hpp>
Inheritance diagram for RaylibRenderer:
Collaboration diagram for RaylibRenderer:Classes | |
| struct | WindowSnapshot |
Public Member Functions | |
| RaylibRenderer ()=default | |
| ~RaylibRenderer () override=default | |
| void | init () override |
| void | render () override |
| void | handleInput () override |
| bool | shouldClose () override |
| void | shutdown () override |
| void | setDevMode (bool dev, int port, const std::string &machine) override |
| std::optional< int > | getPendingSpeedChange () override |
Public Member Functions inherited from ARenderer | |
| void | setState (const GameState &state) override final |
Public Member Functions inherited from IRenderer | |
| virtual | ~IRenderer ()=default |
Private Member Functions | |
| void | _render3D () |
| void | _render2D () |
| void | _drawSelectionHighlight () |
| void | _initTeamColors () |
| Color | _getTeamColor (const std::string &teamName) |
| int | _getScaledFontSize (int baseFontSize) const |
| void | _updateSelection (float deltaTime) |
| void | _performRaycast () |
| void | _drawBehaviorParticles (const VisualState &visual) |
| std::vector< std::vector< const Player * > > | _groupPlayersByVisualProximity () const |
| Vector3 | _groupLabelAnchor (const std::vector< const Player * > &group) const |
| void | _drawSelectionArrow (Vector3 basePos, float modelTopY) const |
| void | _drawSpeedSlider () |
Private Attributes | |
| CameraController | _cam |
| Model | _playerModel = {} |
| Color | _playerModelBaseMats [6] = {} |
| Model | _eggModel = {} |
| Color | _eggModelBaseMats [2] = {} |
| Model | _foodModel = {} |
| Model | _crystalModel = {} |
| Shader | _lightingShader = {} |
| Light | _sun = {} |
| int | _shaderViewPosLoc = -1 |
| std::unordered_map< std::string, Color > | _teamColors |
| SelectionFinder::Selection | _selection |
| TileSlotMap | _tileSlotMap |
| SpeedSlider | _speedSlider |
| WinScreen | _winScreen |
| PlayerPanel | _playerPanel |
| HudWidget | _hudWidget |
| EntityTooltipWidget | _entityTooltip |
| std::unique_ptr< IBackground > | _background |
| std::optional< int > | _pendingSpeed |
| WindowSnapshot | _savedWindow |
| bool | _devMode = false |
| int | _devPort = -1 |
| std::string | _devMachine |
Static Private Attributes | |
| static constexpr std::string_view | PLAYER_MODEL_PATH = "gui/assets/models/rimuru.glb" |
| static constexpr std::string_view | EGG_MODEL_PATH = "gui/assets/models/egg.glb" |
| static constexpr std::string_view | FOOD_MODEL_PATH = "gui/assets/models/apple.glb" |
| static constexpr std::string_view | CRYSTAL_MODEL_PATH = "gui/assets/models/crystal.glb" |
| static constexpr std::string_view | FONT_PATH = "gui/assets/fonts/JetBrainsMono-Bold.ttf" |
| static constexpr float | PLAYER_MODEL_SIZE = 0.25f |
| static constexpr float | EGG_MODEL_SIZE = 0.15f |
| static constexpr float | FOOD_MODEL_SIZE = 1.0f |
| static constexpr float | CRYSTAL_MODEL_SIZE = 2.0f |
| static constexpr float | RESOURCE_SPHERE_BASE_SIZE = 0.05f |
| static constexpr float | TILE_SIZE = 1.0f |
| static constexpr float | SELECTION_LINE_THICKNESS = 5.0f |
| static constexpr float | SELECTION_WIREFRAME_THICKNESS = 5.0f |
| static constexpr Color | SELECTION_COLOR = {128, 0, 128, 255} |
Additional Inherited Members | |
Protected Attributes inherited from ARenderer | |
| const GameState * | _state = nullptr |
A renderer that uses Raylib to display the game state graphically.
Definition at line 26 of file RaylibRenderer.hpp.
|
default |
|
overridedefault |
|
private |
Definition at line 284 of file RaylibRenderer.cpp.
References VisualState::behaviors.
Referenced by _render3D().
Here is the caller graph for this function:
|
private |
Definition at line 500 of file RaylibRenderer.cpp.
References SELECTION_COLOR.
Referenced by _drawSelectionHighlight().
Here is the caller graph for this function:
|
private |
Definition at line 359 of file RaylibRenderer.cpp.
References _drawSelectionArrow(), _eggModel, _playerModel, _selection, ARenderer::_state, _tileSlotMap, GridRenderer::drawTileHighlight(), SelectionFinder::Egg, EGG_MODEL_SIZE, WorldState::eggs, TileSlotMap::eggSlot(), WorldState::height, SelectionFinder::Selection::id, SelectionFinder::None, SelectionFinder::Player, PLAYER_MODEL_SIZE, WorldState::players, VisualState::pos, VisualState::scale, SELECTION_COLOR, SELECTION_LINE_THICKNESS, TileSlotMap::slotOffset(), SelectionFinder::Tile, TILE_SIZE, RenderingHelper::tileToWorld(), SelectionFinder::Selection::tileX, SelectionFinder::Selection::tileY, SelectionFinder::Selection::type, WorldState::width, GameState::world, Egg::x, and Egg::y.
Referenced by _render3D().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 353 of file RaylibRenderer.cpp.
References _getScaledFontSize(), _speedSlider, ARenderer::_state, SpeedSlider::draw(), SpeedSlider::syncFromServer(), and GameState::timeUnit.
Referenced by _render2D().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 423 of file RaylibRenderer.cpp.
Referenced by _drawSpeedSlider(), _render2D(), and render().
Here is the caller graph for this function:
|
private |
Definition at line 415 of file RaylibRenderer.cpp.
References _teamColors.
Referenced by _render2D(), _render3D(), handleInput(), and render().
Here is the caller graph for this function:
|
private |
Definition at line 485 of file RaylibRenderer.cpp.
References ARenderer::_state, WorldState::height, TILE_SIZE, RenderingHelper::tileToWorld(), WorldState::width, GameState::world, Player::x, and Player::y.
Referenced by _render2D().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 450 of file RaylibRenderer.cpp.
References ARenderer::_state, WorldState::players, TILE_SIZE, and GameState::world.
Referenced by _render2D().
Here is the caller graph for this function:
|
private |
Definition at line 407 of file RaylibRenderer.cpp.
References ARenderer::_state, _teamColors, ColorPalette::getTeamColor(), WorldState::teams, and GameState::world.
Referenced by render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 434 of file RaylibRenderer.cpp.
References _cam, _eggModel, _playerModel, _selection, ARenderer::_state, _tileSlotMap, CameraController::camera(), EGG_MODEL_SIZE, SelectionFinder::findFromRay(), SelectionFinder::getEmptySelection(), SelectionFinder::None, PLAYER_MODEL_SIZE, TILE_SIZE, and SelectionFinder::Selection::type.
Referenced by handleInput().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 303 of file RaylibRenderer.cpp.
References _cam, _drawSpeedSlider(), _entityTooltip, _getScaledFontSize(), _getTeamColor(), _groupLabelAnchor(), _groupPlayersByVisualProximity(), _playerPanel, _selection, ARenderer::_state, _winScreen, TooltipRenderer::Builder::addLine(), TooltipRenderer::BottomCenter, CameraController::camera(), TooltipRenderer::create(), EntityTooltipWidget::draw(), PlayerPanel::draw(), WinScreen::draw(), TooltipRenderer::Builder::draw(), GameState::gameDurationSeconds, GameState::gameDurationTicks, I18n::get(), WinScreen::handleInput(), CameraController::isFollowActive(), I18n::PLAYER_HEAD_LEVEL, PLAYER_MODEL_SIZE, TooltipRenderer::Builder::setAnchor(), TooltipRenderer::Builder::setBackgroundColor(), TooltipRenderer::Builder::setBorderColor(), TooltipRenderer::Builder::setBorderThickness(), WinScreen::setDuration(), EntityTooltipWidget::setFollowActive(), TooltipRenderer::Builder::setFontSize(), TooltipRenderer::Builder::setPadding(), EntityTooltipWidget::setSelection(), EntityTooltipWidget::setTeamColorFunc(), PlayerPanel::setTeamColorFunc(), WinScreen::setWinner(), EntityTooltipWidget::setWorld(), PlayerPanel::setWorld(), GameState::winnerTeam, and GameState::world.
Referenced by render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 227 of file RaylibRenderer.cpp.
References _background, _cam, _crystalModel, _drawBehaviorParticles(), _drawSelectionHighlight(), _eggModel, _eggModelBaseMats, _foodModel, _getTeamColor(), _playerModel, _playerModelBaseMats, ARenderer::_state, _tileSlotMap, WorldState::at(), CameraController::camera(), CRYSTAL_MODEL_SIZE, EntityRenderer::drawEgg(), EntityRenderer::drawPlayer(), EntityRenderer::drawResources(), GridRenderer::drawTiles(), WorldState::dyingPlayers, EGG_MODEL_SIZE, WorldState::eggs, TileSlotMap::eggSlot(), FOOD_MODEL_SIZE, WorldState::height, PLAYER_MODEL_SIZE, WorldState::players, WorldState::purgeDyingPlayers(), RESOURCE_SPHERE_BASE_SIZE, TileSlotMap::resourceRotation(), TileSlotMap::slotOffset(), TileSlotMap::syncEggs(), TILE_SIZE, RenderingHelper::tileToWorld(), TileSlotMap::updateResourceSlots(), WorldState::width, and GameState::world.
Referenced by render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 448 of file RaylibRenderer.cpp.
Referenced by render().
Here is the caller graph for this function:
|
overridevirtual |
Reimplemented from ARenderer.
Definition at line 400 of file RaylibRenderer.cpp.
References _pendingSpeed.
|
overridevirtual |
Implements IRenderer.
Definition at line 134 of file RaylibRenderer.cpp.
References _cam, _devMachine, _devMode, _devPort, _entityTooltip, _getTeamColor(), _hudWidget, _pendingSpeed, _performRaycast(), _playerPanel, _selection, _speedSlider, ARenderer::_state, I18n::EN, CameraController::enterFreecam(), CameraController::exitFreecam(), CameraController::followedPlayerId(), I18n::FR, I18n::getLanguage(), PlayerPanel::getPendingSelection(), SpeedSlider::getPendingSpeedChange(), CameraController::handleInput(), EntityTooltipWidget::handleInput(), PlayerPanel::handleInput(), SpeedSlider::handleInput(), CameraController::isFollowActive(), EntityTooltipWidget::isFollowButtonHovered(), CameraController::isFreecamActive(), PlayerPanel::isOpen(), SpeedSlider::PANEL_HEIGHT, SpeedSlider::PANEL_WIDTH, SelectionFinder::Player, EntityTooltipWidget::popFollowRequest(), HudWidget::setDevMode(), EntityTooltipWidget::setFollowActive(), I18n::setLanguage(), EntityTooltipWidget::setSelection(), EntityTooltipWidget::setTeamColorFunc(), EntityTooltipWidget::setWorld(), PlayerPanel::setWorld(), CameraController::startFollow(), CameraController::stopFollow(), and GameState::world.
Here is the call graph for this function:
|
overridevirtual |
Implements IRenderer.
Definition at line 19 of file RaylibRenderer.cpp.
References _background, _cam, _crystalModel, _eggModel, _eggModelBaseMats, _foodModel, _lightingShader, _pendingSpeed, _playerModel, _playerModelBaseMats, _savedWindow, _selection, _shaderViewPosLoc, _speedSlider, _sun, _tileSlotMap, _winScreen, TileSlotMap::clear(), CRYSTAL_MODEL_PATH, EGG_MODEL_PATH, FONT_PATH, FOOD_MODEL_PATH, RaylibRenderer::WindowSnapshot::fullscreen, SelectionFinder::getEmptySelection(), RaylibRenderer::WindowSnapshot::height, CameraController::init(), TextRenderer::loadFont(), RaylibRenderer::WindowSnapshot::monitor, PLAYER_MODEL_PATH, RaylibRenderer::WindowSnapshot::position, SpeedSlider::reset(), WinScreen::reset(), RaylibRenderer::WindowSnapshot::valid, and RaylibRenderer::WindowSnapshot::width.
Here is the call graph for this function:
|
overridevirtual |
Implements IRenderer.
Definition at line 97 of file RaylibRenderer.cpp.
References _background, _cam, _getScaledFontSize(), _getTeamColor(), _hudWidget, _initTeamColors(), _lightingShader, _render2D(), _render3D(), _shaderViewPosLoc, ARenderer::_state, _updateSelection(), CameraController::camera(), HudWidget::draw(), WorldState::height, GameState::serverUptimeSeconds, HudWidget::setServerUptime(), HudWidget::setTeamColorFunc(), HudWidget::setTimeUnit(), HudWidget::setWorld(), GameState::timeUnit, CameraController::update(), WorldState::width, and GameState::world.
Here is the call graph for this function:
|
overridevirtual |
Reimplemented from ARenderer.
Definition at line 197 of file RaylibRenderer.cpp.
References _devMachine, _devMode, _devPort, _hudWidget, and HudWidget::setDevMode().
Here is the call graph for this function:
|
overridevirtual |
Implements IRenderer.
Definition at line 195 of file RaylibRenderer.cpp.
References _winScreen, and WinScreen::quitRequested().
Here is the call graph for this function:
|
overridevirtual |
Implements IRenderer.
Definition at line 205 of file RaylibRenderer.cpp.
References _background, _crystalModel, _eggModel, _foodModel, _lightingShader, _playerModel, _savedWindow, TextRenderer::unloadFont(), and RaylibRenderer::WindowSnapshot::width.
Here is the call graph for this function:
|
private |
Definition at line 81 of file RaylibRenderer.hpp.
Referenced by _render3D(), init(), render(), and shutdown().
|
private |
Definition at line 56 of file RaylibRenderer.hpp.
Referenced by _performRaycast(), _render2D(), _render3D(), handleInput(), init(), and render().
|
private |
Definition at line 66 of file RaylibRenderer.hpp.
Referenced by _render3D(), init(), and shutdown().
|
private |
Definition at line 95 of file RaylibRenderer.hpp.
Referenced by handleInput(), and setDevMode().
|
private |
Definition at line 93 of file RaylibRenderer.hpp.
Referenced by handleInput(), and setDevMode().
|
private |
Definition at line 94 of file RaylibRenderer.hpp.
Referenced by handleInput(), and setDevMode().
|
private |
Definition at line 61 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight(), _performRaycast(), _render3D(), init(), and shutdown().
|
private |
Definition at line 62 of file RaylibRenderer.hpp.
Referenced by _render3D(), and init().
|
private |
Definition at line 80 of file RaylibRenderer.hpp.
Referenced by _render2D(), and handleInput().
|
private |
Definition at line 64 of file RaylibRenderer.hpp.
Referenced by _render3D(), init(), and shutdown().
|
private |
Definition at line 79 of file RaylibRenderer.hpp.
Referenced by handleInput(), render(), and setDevMode().
|
private |
Definition at line 68 of file RaylibRenderer.hpp.
Referenced by init(), render(), and shutdown().
|
private |
Definition at line 82 of file RaylibRenderer.hpp.
Referenced by getPendingSpeedChange(), handleInput(), and init().
|
private |
Definition at line 58 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight(), _performRaycast(), _render3D(), init(), and shutdown().
|
private |
Definition at line 59 of file RaylibRenderer.hpp.
Referenced by _render3D(), and init().
|
private |
Definition at line 78 of file RaylibRenderer.hpp.
Referenced by _render2D(), and handleInput().
|
private |
Definition at line 91 of file RaylibRenderer.hpp.
Referenced by init(), and shutdown().
|
private |
Definition at line 74 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight(), _performRaycast(), _render2D(), handleInput(), and init().
|
private |
Definition at line 70 of file RaylibRenderer.hpp.
|
private |
Definition at line 76 of file RaylibRenderer.hpp.
Referenced by _drawSpeedSlider(), handleInput(), and init().
|
private |
Definition at line 69 of file RaylibRenderer.hpp.
Referenced by init().
|
private |
Definition at line 72 of file RaylibRenderer.hpp.
Referenced by _getTeamColor(), and _initTeamColors().
|
private |
Definition at line 75 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight(), _performRaycast(), _render3D(), and init().
|
private |
Definition at line 77 of file RaylibRenderer.hpp.
Referenced by _render2D(), init(), and shouldClose().
|
staticconstexprprivate |
Definition at line 43 of file RaylibRenderer.hpp.
Referenced by init().
|
staticconstexprprivate |
Definition at line 49 of file RaylibRenderer.hpp.
Referenced by _render3D().
|
staticconstexprprivate |
Definition at line 41 of file RaylibRenderer.hpp.
Referenced by init().
|
staticconstexprprivate |
Definition at line 47 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight(), _performRaycast(), and _render3D().
|
staticconstexprprivate |
Definition at line 44 of file RaylibRenderer.hpp.
Referenced by init().
|
staticconstexprprivate |
Definition at line 42 of file RaylibRenderer.hpp.
Referenced by init().
|
staticconstexprprivate |
Definition at line 48 of file RaylibRenderer.hpp.
Referenced by _render3D().
|
staticconstexprprivate |
Definition at line 40 of file RaylibRenderer.hpp.
Referenced by init().
|
staticconstexprprivate |
Definition at line 46 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight(), _performRaycast(), _render2D(), and _render3D().
|
staticconstexprprivate |
Definition at line 50 of file RaylibRenderer.hpp.
Referenced by _render3D().
|
staticconstexprprivate |
Definition at line 54 of file RaylibRenderer.hpp.
Referenced by _drawSelectionArrow(), and _drawSelectionHighlight().
|
staticconstexprprivate |
Definition at line 52 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight().
|
staticconstexprprivate |
Definition at line 53 of file RaylibRenderer.hpp.
|
staticconstexprprivate |
Definition at line 51 of file RaylibRenderer.hpp.
Referenced by _drawSelectionHighlight(), _groupLabelAnchor(), _groupPlayersByVisualProximity(), _performRaycast(), and _render3D().