17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 16:49:21 +02:00
Files
maszyna/widgets/map.cppm
maj00r ce5ee288ff fix the clang CI build
Every module unit now includes the standard headers it uses. Declarations
reaching a unit only through an imported module's global module fragment
are reachable but not visible, so ADL misses the free operators older
libstdc++ declares beside a type - reproduced on ubuntu 24.04 (libstdc++
13), where gl/vao.cpp could not compare vector iterators.

Also drops a stale editor/editorSettings.hpp from the MSVC source list,
which broke the Windows configure step, silences the deliberate
include-in-purview warning in the glm wrapper, and removes GCC support:
clang or MSVC only.
2026-09-09 22:52:28 +02:00

163 lines
3.7 KiB
C++

module;
#include <string>
#include <utility>
#include <array>
#include <memory>
#include <vector>
#include "imgui/imgui.h"
export module eu07.widgets.map;
import eu07.gl.bindable;
import eu07.glm;
import eu07.global_include.interfaces.itexture;
import eu07.input.command;
import eu07.simcore;
import eu07.gl.shader;
import eu07.gl.renderbuffer;
import eu07.gl.ubo;
import eu07.rendering.geometrybank;
import eu07.model.texture;
import eu07.application.uilayer;
import eu07.widgets.map_objects;
import eu07.gl.framebuffer;
import eu07.rendering.frustum;
#ifdef WITH_OPENGL_MODERN
import eu07.rendering.opengl33renderer;
#endif
export {
#ifdef WITH_OPENGL_MODERN
#endif
namespace ui
{
class disambiguation_popup : public popup
{
map::sorted_object_list m_list;
public:
disambiguation_popup(ui_panel &panel, map::sorted_object_list &&list);
virtual void render_content() override;
};
class semaphore_window : public popup
{
std::shared_ptr<map::semaphore> m_sem;
command_relay m_relay;
public:
semaphore_window(ui_panel &panel, std::shared_ptr<map::semaphore> &&sem);
virtual void render_content() override;
};
class launcher_window : public popup
{
std::shared_ptr<map::launcher> m_switch;
command_relay m_relay;
public:
launcher_window(ui_panel &panel, std::shared_ptr<map::launcher> &&sw);
virtual void render_content() override;
};
class track_switch_window : public popup
{
std::shared_ptr<map::track_switch> m_switch;
command_relay m_relay;
public:
track_switch_window(ui_panel &panel, std::shared_ptr<map::track_switch> &&sw);
virtual bool render() override;
virtual void render_content() override;
};
class obstacle_insert_window : public popup
{
glm::dvec3 m_position;
std::vector<std::pair<std::string, std::string>> m_obstacles;
command_relay m_relay;
public:
obstacle_insert_window(ui_panel &panel, glm::dvec3 const &pos);
virtual void render_content() override;
};
class obstacle_remove_window : public popup
{
std::shared_ptr<map::obstacle> m_obstacle;
command_relay m_relay;
public:
obstacle_remove_window(ui_panel &panel, std::shared_ptr<map::obstacle> &&obstacle);
virtual void render_content() override;
};
class vehicle_click_window : public popup
{
std::shared_ptr<map::vehicle> m_vehicle;
command_relay m_relay;
std::array<char, 128> command_buf = { 0 };
int command_param1 = 0;
int command_param2 = 0;
public:
vehicle_click_window(ui_panel &panel, std::shared_ptr<map::vehicle> &&obstacle);
virtual void render_content() override;
};
class map_panel : public ui_panel
{
friend class track_switch_window;
std::unique_ptr<gl::program> m_track_shader;
std::unique_ptr<gl::program> m_poi_shader;
std::unique_ptr<gl::framebuffer> m_msaa_fb;
std::unique_ptr<gl::renderbuffer> m_msaa_rb;
texture_handle m_icon_atlas;
std::unique_ptr<gl::framebuffer> m_fb;
std::unique_ptr<opengl_texture> m_tex;
std::unique_ptr<gl::ubo> scene_ubo;
gl::scene_ubs scene_ubs;
std::vector<gfx::geometrybank_handle> m_section_handles;
map_colored_paths m_colored_paths;
bool m_widelines_supported;
const int fb_size = 1024;
glm::vec2 translate;
float zoom = 1.0f / 1000.0f;
enum { MODE_MANUAL = 0, MODE_CAMERA, MODE_VEHICLE } mode = MODE_MANUAL;
float get_vehicle_rotation();
void render_map_texture(glm::mat4 transform, glm::vec2 surface_size);
void render_labels(glm::mat4 transform, ImVec2 origin, glm::vec2 surface_size);
bool init_done = false;
std::vector<std::pair<TTrack*, int>> highlighted_switches;
public:
map_panel();
void render_contents() override;
};
void handle_map_object_click(ui_panel &parent, std::shared_ptr<map::map_object> &obj);
void handle_map_object_hover(std::shared_ptr<map::map_object> &obj);
} // namespace ui
} // export