Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / src/systems/wall_connection.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/systems/wall_connection.hpp 1.7 KB · 73 lines raw
#pragma once

#include <string>

#include "text/token.hpp"


namespace
Nimbin
{

class Camera;
class GlRenderer;
struct Light;
namespace Text { class Handler; }


namespace Wall
{

class Connection
{
public:
    enum class Target : uint8_t { None, Program, Editor };

    void    update(double dt, const Camera& cam, float aspect, float fov_y);
    void    render(GlRenderer& gl, const Camera& cam, const Light& light) const;
    void    end   ();

    bool    is_Active () const { return _target != Target::None; }
    Target  get_Target() const { return _target; }

    void    set_ProgramBuffer   (const std::string& buffer);
    void    clear_ProgramPreview();

    void    begin_Program(const Vec3& pult_pos);
    void    begin_Editor (const Vec3& pult_pos, const Text::Handler& editor);


private:
    bool   _cmd_pos_init { false };
    bool   _showcmd_pos_init { false };
    float  _cmd_yaw      { 0.0f };
    double _blink        { 0.0 };

    Target _target { Target::None };

    const Text::Handler* _editor { nullptr };

    Text::TokenPtr _cmdline;
    Text::TokenPtr _showcmd;
    Text::TokenPtr _prog_input;

    Vec3 _cmd_pos     {};
    Vec3 _showcmd_pos {};
    Vec3 _pult_pos    {};

    std::string _cmd_last;
    std::string _showcmd_last;
    std::string _prog_last;

    void rebuild_Cmdline       (const std::string& text);
    void rebuild_ShowCmd       (const std::string& text);
    void rebuild_ProgramPreview(const std::string& buffer);
    void draw_EditorCursor (GlRenderer& gl, const Camera& cam, const Light& light) const;
    void draw_ProgramCursor(GlRenderer& gl, const Camera& cam, const Light& light) const;
    void draw_Electric     (GlRenderer& gl, const Camera& cam) const;
};


} // namespace Wall

} // namespace Nimbin