Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / src/entities/pult.hpp

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

C++ 72.3% C 26.2%
git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gz
src/entities/pult.hpp 1.3 KB · 68 lines raw
#pragma once

#include <string>

#include "entities/solid_box.hpp"
#include "utils/globals.hpp"
#include "utils/light.hpp"
#include "text/handler.hpp"

namespace
Nimbin
{
class Camera;
class GlRenderer;


enum class PultAction : uint8_t {
    ScrollEditorUp,
    ScrollEditorDown,
    ClearEditor,
    Compile,
    RunProgram,
    ConnectProgram,
    ConnectEditor,
};


struct PultButton final : public SolidBox
{
    std::string label;

    PultAction  action;

    double press_timer { 0.0   };

    bool   pressed     { false };
    bool   player_on   { false };

    PultButton(const std::string& lbl, PultAction act, Vec3 world_pos);

    void press();
    void tick (double dt);
    void draw (GlRenderer& gl, const Camera& cam, const Light& light) const override;
};


struct Pult : public SolidBox
{
    static constexpr float W = 0.50f;
    static constexpr float H = 0.28f;
    static constexpr float D = 0.40f;

    Text::Handler   label;
    DynArray<PultButton*>
                buttons;
    std::string name;

    float half_w { W };
    float half_d { D };

    Pult(const std::string& n, Vec3 world_pos,
         float half_width = W, float half_depth = D);

    void tick(double dt);
    void draw(GlRenderer& gl, const Camera& cam, const Light& light) const override;
};

} // namespace Nimbin