Compare commits
1 Commits
main
...
ceb83d5ab3
| Author | SHA1 | Date | |
|---|---|---|---|
| ceb83d5ab3 |
@@ -75,6 +75,7 @@ set(SRC_CXX_FILES "./src/main.cpp"
|
|||||||
"./src/selection_menu.cpp"
|
"./src/selection_menu.cpp"
|
||||||
"./src/selection.cpp"
|
"./src/selection.cpp"
|
||||||
"./src/paterns_menu.cpp"
|
"./src/paterns_menu.cpp"
|
||||||
|
"./src/patern_preview.cpp"
|
||||||
"${rlImGui_SOURCE_DIR}/rlImGui.cpp"
|
"${rlImGui_SOURCE_DIR}/rlImGui.cpp"
|
||||||
"${imgui_SOURCE_DIR}/imgui.cpp"
|
"${imgui_SOURCE_DIR}/imgui.cpp"
|
||||||
"${imgui_SOURCE_DIR}/imgui_draw.cpp"
|
"${imgui_SOURCE_DIR}/imgui_draw.cpp"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class SelectionMenu;
|
|||||||
class ControlMenu;
|
class ControlMenu;
|
||||||
class Selection;
|
class Selection;
|
||||||
class PaternsMenu;
|
class PaternsMenu;
|
||||||
|
class PaternPreview;
|
||||||
|
|
||||||
typedef struct ctx {
|
typedef struct ctx {
|
||||||
std::shared_ptr<World> world = nullptr;
|
std::shared_ptr<World> world = nullptr;
|
||||||
@@ -32,6 +33,7 @@ typedef struct ctx {
|
|||||||
std::shared_ptr<ControlMenu> control_menu = nullptr;
|
std::shared_ptr<ControlMenu> control_menu = nullptr;
|
||||||
std::shared_ptr<Selection> selection = nullptr;
|
std::shared_ptr<Selection> selection = nullptr;
|
||||||
std::shared_ptr<PaternsMenu> paterns_menu = nullptr;
|
std::shared_ptr<PaternsMenu> paterns_menu = nullptr;
|
||||||
|
std::shared_ptr<PaternPreview> patern_preview = nullptr;
|
||||||
nlohmann::json config_json;
|
nlohmann::json config_json;
|
||||||
std::filesystem::path program_dir;
|
std::filesystem::path program_dir;
|
||||||
} ctx;
|
} ctx;
|
||||||
|
|||||||
29
includes/patern_preview.hpp
Normal file
29
includes/patern_preview.hpp
Normal 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
32
src/patern_preview.cpp
Normal 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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <paterns_menu.hpp>
|
#include <paterns_menu.hpp>
|
||||||
|
#include <patern_preview.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace gol {
|
namespace gol {
|
||||||
@@ -77,9 +78,8 @@ void PaternsMenu::display() {
|
|||||||
for (auto patern_name : paterns_name_list_) {
|
for (auto patern_name : paterns_name_list_) {
|
||||||
ImGui::PushID(patern_name.c_str());
|
ImGui::PushID(patern_name.c_str());
|
||||||
if (ImGui::Button(patern_name.c_str()) &&
|
if (ImGui::Button(patern_name.c_str()) &&
|
||||||
loadPatern(paterns_paths_list_[patern_name])) {
|
loadPatern(paterns_paths_list_[patern_name])) {
|
||||||
// TODO: If patern is loaded successfuly, start the preview in the
|
context_->patern_preview->start();
|
||||||
// editor
|
|
||||||
}
|
}
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
ImGui::SameLine(ImGui::GetWindowWidth() - 57.);
|
ImGui::SameLine(ImGui::GetWindowWidth() - 57.);
|
||||||
|
|||||||
Reference in New Issue
Block a user