Compare commits

...

1 Commits

Author SHA1 Message Date
ceb83d5ab3 wip 2026-01-14 13:33:48 +01:00
5 changed files with 67 additions and 3 deletions

View File

@@ -75,6 +75,7 @@ set(SRC_CXX_FILES "./src/main.cpp"
"./src/selection_menu.cpp"
"./src/selection.cpp"
"./src/paterns_menu.cpp"
"./src/patern_preview.cpp"
"${rlImGui_SOURCE_DIR}/rlImGui.cpp"
"${imgui_SOURCE_DIR}/imgui.cpp"
"${imgui_SOURCE_DIR}/imgui_draw.cpp"

View File

@@ -22,6 +22,7 @@ class SelectionMenu;
class ControlMenu;
class Selection;
class PaternsMenu;
class PaternPreview;
typedef struct ctx {
std::shared_ptr<World> world = nullptr;
@@ -32,6 +33,7 @@ typedef struct ctx {
std::shared_ptr<ControlMenu> control_menu = nullptr;
std::shared_ptr<Selection> selection = nullptr;
std::shared_ptr<PaternsMenu> paterns_menu = nullptr;
std::shared_ptr<PaternPreview> patern_preview = nullptr;
nlohmann::json config_json;
std::filesystem::path program_dir;
} ctx;

View File

@@ -0,0 +1,29 @@
/*
* File name: patern_preview.hpp
* Author: lejulien
* Date created: 01-01-1970 00:59:59
// Date modified: 12-01-2026 21:30:10
* ------
*/
#pragma once
#include <memory>
#include <context.hpp>
namespace gol {
class PaternPreview {
public:
PaternPreview(std::shared_ptr<ctx>);
~PaternPreview() = default;
void update();
void display();
void start();
private:
bool is_started = false;
std::shared_ptr<ctx> context_;
};
} // namespace gol

32
src/patern_preview.cpp Normal file
View File

@@ -0,0 +1,32 @@
/*
* File name: patern_preview.cpp
* Author: lejulien
* Date created: 01-01-1970 00:59:59
// Date modified: 12-01-2026 21:30:10
* ------
*/
#include <patern_preview.hpp>
namespace gol {
PaternPreview::PaternPreview(std::shared_ptr<ctx> context): context_(context) {}
void PaternPreview::start() {
// TODO: load patern from pater menu
is_started = true;
}
void PaternPreview::update() {
if (!is_started) return;
// gather mousePos
// if right click stop the preview
// if left click, apply patern to current world
// mouse should pass through any present windows
}
void PaternPreview::display() {
}
};

View File

@@ -14,6 +14,7 @@
#include <fstream>
#include <iostream>
#include <paterns_menu.hpp>
#include <patern_preview.hpp>
#include <sstream>
namespace gol {
@@ -78,8 +79,7 @@ void PaternsMenu::display() {
ImGui::PushID(patern_name.c_str());
if (ImGui::Button(patern_name.c_str()) &&
loadPatern(paterns_paths_list_[patern_name])) {
// TODO: If patern is loaded successfuly, start the preview in the
// editor
context_->patern_preview->start();
}
ImGui::PopID();
ImGui::SameLine(ImGui::GetWindowWidth() - 57.);