Compare commits

..

4 Commits

Author SHA1 Message Date
95a7d6ea9a Adding controls to control_menu 2026-01-10 22:55:53 +01:00
8aee4cdc53 Adding new context with world & config_json 2026-01-10 22:40:17 +01:00
24729d11f3 Update file headers 2026-01-10 22:01:15 +01:00
e8c0c460d9 Disable selection when patern menu is selected 2026-01-10 21:40:24 +01:00
12 changed files with 263 additions and 174 deletions

View File

@@ -70,6 +70,7 @@ set(SRC_CXX_FILES "./src/main.cpp"
"./src/rules.cpp" "./src/rules.cpp"
"./src/world.cpp" "./src/world.cpp"
"./src/render.cpp" "./src/render.cpp"
"./src/control_menu.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"

24
includes/context.hpp Normal file
View File

@@ -0,0 +1,24 @@
/*
* File name: context.hpp
* Author: lejulien
* Date created: 01-01-1970 00:59:59
// Date modified: 10-01-2026 22:24:41
* ------
*/
#pragma once
#include <nlohmann/json.hpp>
#include <memory>
#include <world.hpp>
namespace gol {
typedef struct ctx {
std::shared_ptr<World> world = nullptr;
nlohmann::json config_json;
} ctx;
} // namespace gol

40
includes/control_menu.hpp Normal file
View File

@@ -0,0 +1,40 @@
/*
* File name: control_menu.hpp
* Author: lejulien
* Date created: 10-01-2026 22:00:33
// Date modified: 10-01-2026 22:45:10
* ------
*/
#pragma once
#include <context.hpp>
namespace gol {
class ControlMenu {
public:
ControlMenu(ctx context);
~ControlMenu() = default;
void update();
void display();
private:
ctx context_;
public: // Keep those public for easy access
int fps_ctrl_ = false;
int cell_size_ctrl_ = false;
bool play_ctrl_ = true;
bool step_ctrl_ = false;
bool step_back_ctrl_ = false;
bool rand_ctrl_ = false;
bool edit_ctrl_ = false;
bool clear_ctrl_ = false;
bool settings_window_ = false;
bool paterns_ctrl_ = false;
int width_ctrl_ = false;
int height_ctrl_ = false;
bool dark_theme_ctrl_ = false;
bool apply_ctrl_ = false;
};
} // namespace gol

View File

@@ -1,14 +1,10 @@
/* ************************************************************************** */ /*
/* */ * File name: render.hpp
/* / ) */ * Author: lejulien
/* render.hpp (\__/) ( ( */ * Date created: 10-01-2026 21:54:12
/* ) ( ) ) */ // Date modified: 10-01-2026 22:00:37
/* By: lejulien <leo.julien.42@gmail.com> ={ }= / / */ * ------
/* ) `-------/ / */ */
/* Created: 2023/01/09 12:44:54 by lejulien ( / */
/* Updated: 2023/01/14 16:51:15 by lejulien \ | */
/* */
/* ************************************************************************** */
#include "world.hpp" #include "world.hpp"

View File

@@ -1,14 +1,10 @@
/* ************************************************************************** */ /*
/* */ * File name: rules.hpp
/* / ) */ * Author: lejulien
/* rules.hpp (\__/) ( ( */ * Date created: 09-01-2026 23:59:55
/* ) ( ) ) */ * Date modified: 10-01-2026 21:49:44
/* By: lejulien <leo.julien.42@gmail.com> ={ }= / / */ * ------
/* ) `-------/ / */ */
/* Created: 2023/01/09 12:16:47 by lejulien ( / */
/* Updated: 2023/01/14 16:47:04 by lejulien \ | */
/* */
/* ************************************************************************** */
#include "world.hpp" #include "world.hpp"

View File

@@ -1,3 +1,11 @@
/*
* File name: types.hpp
* Author: lejulien
* Date created: 09-01-2026 23:59:55
* Date modified: 10-01-2026 21:49:36
* ------
*/
#pragma once #pragma once
enum class MenuState { enum class MenuState {

View File

@@ -1,3 +1,11 @@
/*
* File name: world.hpp
* Author: lejulien
* Date created: 09-01-2026 23:59:55
* Date modified: 10-01-2026 21:49:31
* ------
*/
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>

30
src/control_menu.cpp Normal file
View File

@@ -0,0 +1,30 @@
/*
* File name: control_menu.cpp
* Author: lejulien
* Date created: 10-01-2026 22:12:44
// Date modified: 10-01-2026 22:43:36
* ------
*/
#include <control_menu.hpp>
namespace gol {
ControlMenu::ControlMenu(ctx context):context_(context) {
fps_ctrl_ = context.config_json["fps"].get<int>();
cell_size_ctrl_ = context.config_json["cell_size"].get<int>();
play_ctrl_ = true;
step_ctrl_ = false;
step_back_ctrl_ = false;
rand_ctrl_ = false;
edit_ctrl_ = false;
clear_ctrl_ = false;
settings_window_ = false;
paterns_ctrl_ = false;
width_ctrl_ = context.config_json["screen_width"].get<int>();
height_ctrl_ = context.config_json["screen_height"].get<int>();
dark_theme_ctrl_ = context.config_json["dark_theme"].get<bool>();
apply_ctrl_ = false;
}
} // namespace gol

View File

@@ -1,17 +1,27 @@
/*
* File name: main.cpp
* Author: lejulien
* Date created: 10-01-2026 21:59:32
// Date modified: 10-01-2026 22:55:11
* ------
*/
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <filesystem> #include <filesystem>
#include <unistd.h> #include <unistd.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "../includes/render.hpp" #include <imgui.h>
#include "../includes/rules.hpp" #include <raylib.h>
#include "../includes/world.hpp" #include <rlImGui.h>
#include "../includes/types.hpp"
#include "imgui.h"
#include "raylib.h"
#include "rlImGui.h"
#include <render.hpp>
#include <rules.hpp>
#include <world.hpp>
#include <types.hpp>
#include <context.hpp>
#include <control_menu.hpp>
Vector2 snapToGrid(Vector2 screen, int cell_size) { Vector2 snapToGrid(Vector2 screen, int cell_size) {
return {static_cast<float>(round(screen.x / cell_size) * cell_size), return {static_cast<float>(round(screen.x / cell_size) * cell_size),
@@ -24,9 +34,9 @@ Vector2i screenToGrid(Vector2 screen, int cell_size) {
} }
int main(int ac, char **av) { int main(int ac, char **av) {
gol::ctx context;
// Load or default config // Load or default config
const std::string config_file_name = "config.json"; const std::string config_file_name = "config.json";
nlohmann::json config_json;
MenuState menu_state = MenuState::NONE; MenuState menu_state = MenuState::NONE;
std::fstream config_file(config_file_name, std::ios::in | std::ios::out); std::fstream config_file(config_file_name, std::ios::in | std::ios::out);
@@ -47,7 +57,7 @@ int main(int ac, char **av) {
// Try reading the configuration // Try reading the configuration
try { try {
config_file.seekg(0); config_file.seekg(0);
config_file >> config_json; config_file >> context.config_json;
} catch (const nlohmann::json::parse_error &e) { } catch (const nlohmann::json::parse_error &e) {
std::cerr << "An error occured while loading config : " << e.what() std::cerr << "An error occured while loading config : " << e.what()
<< std::endl; << std::endl;
@@ -58,61 +68,49 @@ int main(int ac, char **av) {
config_file.close(); config_file.close();
// Check config values or populate them // Check config values or populate them
if (!config_json.contains("cell_size") || if (!context.config_json.contains("cell_size") ||
(config_json["cell_size"] < 4 || config_json["cell_size"] > 100)) { (context.config_json["cell_size"] < 4 || context.config_json["cell_size"] > 100)) {
config_json["cell_size"] = 10; context.config_json["cell_size"] = 10;
} }
if (!config_json.contains("screen_width") || if (!context.config_json.contains("screen_width") ||
(config_json["screen_width"] < 800 || (context.config_json["screen_width"] < 800 ||
config_json["screen_width"] > 1920)) { context.config_json["screen_width"] > 1920)) {
config_json["screen_width"] = 800; context.config_json["screen_width"] = 800;
} }
if (!config_json.contains("screen_height") || if (!context.config_json.contains("screen_height") ||
(config_json["screen_height"] < 600 || (context.config_json["screen_height"] < 600 ||
config_json["screen_height"] > 1200)) { context.config_json["screen_height"] > 1200)) {
config_json["screen_height"] = 600; context.config_json["screen_height"] = 600;
} }
if (!config_json.contains("dark_theme")) { if (!context.config_json.contains("dark_theme")) {
config_json["dark_theme"] = true; context.config_json["dark_theme"] = true;
} }
if (!config_json.contains("fps") || if (!context.config_json.contains("fps") ||
(config_json["fps"] < 0 || config_json["fps"] > 30)) { (context.config_json["fps"] < 0 || context.config_json["fps"] > 30)) {
config_json["fps"] = 800; context.config_json["fps"] = 800;
} }
InitWindow(config_json["screen_width"], config_json["screen_height"], InitWindow(context.config_json["screen_width"], context.config_json["screen_height"],
&av[0][2]); &av[0][2]);
SetTargetFPS(60); SetTargetFPS(60);
rlImGuiSetup(config_json["dark_theme"]); rlImGuiSetup(context.config_json["dark_theme"]);
// Selection window // Selection window
RenderTexture2D selectionTexture = LoadRenderTexture(200, 200); RenderTexture2D selectionTexture = LoadRenderTexture(200, 200);
// Initialize objects // Initialize objects
World world(config_json["screen_width"].get<int>() / context.world = std::make_shared<World>(
config_json["cell_size"].get<int>(), context.config_json["screen_width"].get<int>() /
config_json["screen_height"].get<int>() / context.config_json["cell_size"].get<int>(),
config_json["cell_size"].get<int>()); context.config_json["screen_height"].get<int>() /
context.config_json["cell_size"].get<int>());
Rules rules = Rules(); Rules rules = Rules();
Render render(config_json["cell_size"]); Render render(context.config_json["cell_size"]);
// Imgui control menu // Imgui control menu
int fps_ctrl = config_json["fps"].get<int>(); gol::ControlMenu control_menu(context);
int cell_size_ctrl = config_json["cell_size"].get<int>();
bool play_ctrl = true;
bool step_ctrl = false;
bool step_back_ctrl = false;
bool rand_ctrl = false;
bool edit_ctrl = false;
bool clear_ctrl = false;
bool settings_window = false;
bool paterns_ctrl = false;
int width_ctrl = config_json["screen_width"].get<int>();
int height_ctrl = config_json["screen_height"].get<int>();
bool dark_theme_ctrl = config_json["dark_theme"].get<bool>();
bool apply_ctrl = false;
// Speed handling values // Speed handling values
float sim_speed = 1.0f; float sim_speed = 1.0f;
@@ -129,58 +127,58 @@ int main(int ac, char **av) {
std::string sel_txt_input_hint("patern name"); std::string sel_txt_input_hint("patern name");
// Setups // Setups
rules.setup(&world); rules.setup(&(*context.world));
// Diplay generations // Diplay generations
while (!WindowShouldClose()) { while (!WindowShouldClose()) {
if (menu_state == MenuState::PLAY || menu_state == MenuState::EDIT) { if (menu_state == MenuState::PLAY || menu_state == MenuState::EDIT) {
if (!play_ctrl && !edit_ctrl) { if (!control_menu.play_ctrl_ && !control_menu.edit_ctrl_) {
menu_state = MenuState::NONE; menu_state = MenuState::NONE;
} }
} }
// Frames shinenigans // Frames shinenigans
float deltaTime = GetFrameTime(); float deltaTime = GetFrameTime();
sim_speed = fps_ctrl / 10.0f; sim_speed = control_menu.fps_ctrl_ / 10.0f;
timePerUpdate = (1.0f / 10.0f) / sim_speed; timePerUpdate = (1.0f / 10.0f) / sim_speed;
auto gesture = GetGestureDetected(); auto gesture = GetGestureDetected();
auto mousePos = GetMousePosition(); auto mousePos = GetMousePosition();
if (rand_ctrl) { if (control_menu.rand_ctrl_) {
world.randomize(); context.world->randomize();
rand_ctrl = false; control_menu.rand_ctrl_ = false;
} }
if (clear_ctrl) { if (control_menu.clear_ctrl_) {
world.clear(); context.world->clear();
clear_ctrl = false; control_menu.clear_ctrl_ = false;
} }
if (edit_ctrl && play_ctrl) { if (control_menu.edit_ctrl_ && control_menu.play_ctrl_) {
if (menu_state == MenuState::PLAY) { if (menu_state == MenuState::PLAY) {
menu_state = MenuState::EDIT; menu_state = MenuState::EDIT;
play_ctrl = false; control_menu.play_ctrl_ = false;
} else if (menu_state == MenuState::EDIT) { } else if (menu_state == MenuState::EDIT) {
menu_state = MenuState::PLAY; menu_state = MenuState::PLAY;
edit_ctrl = false; control_menu.edit_ctrl_ = false;
} }
} else if (play_ctrl) { } else if (control_menu.play_ctrl_) {
menu_state = MenuState::PLAY; menu_state = MenuState::PLAY;
} else if (edit_ctrl) { } else if (control_menu.edit_ctrl_) {
menu_state = MenuState::EDIT; menu_state = MenuState::EDIT;
} }
if (edit_ctrl && IsMouseButtonPressed(0) && if (control_menu.edit_ctrl_ && IsMouseButtonPressed(0) &&
!ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) { !ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) {
menu_state = MenuState::EDIT; menu_state = MenuState::EDIT;
world.setCell(mousePos.x / config_json["cell_size"].get<int>(), context.world->setCell(mousePos.x / context.config_json["cell_size"].get<int>(),
mousePos.y / config_json["cell_size"].get<int>()); mousePos.y / context.config_json["cell_size"].get<int>());
} }
// Selection behaviour // Selection behaviour
if (!edit_ctrl && !play_ctrl) { if (!control_menu.edit_ctrl_ && !control_menu.play_ctrl_ && !control_menu.paterns_ctrl_ && !control_menu.settings_window_) {
if (gesture == GESTURE_TAP && !ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) { if (gesture == GESTURE_TAP && !ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) {
sel_pos = snapToGrid(mousePos, cell_size_ctrl); sel_pos = snapToGrid(mousePos, control_menu.cell_size_ctrl_);
selecting = true; selecting = true;
} }
if (ImGui::IsMouseReleased(0) && selecting == true && mousePos.x >=0 && mousePos.x < width_ctrl && mousePos.y >=0 && mousePos.y < height_ctrl ) { if (ImGui::IsMouseReleased(0) && selecting == true && mousePos.x >=0 && mousePos.x < control_menu.width_ctrl_ && mousePos.y >=0 && mousePos.y < control_menu.height_ctrl_ ) {
selecting = false; selecting = false;
Vector2i p1 = screenToGrid(sel_pos, cell_size_ctrl); Vector2i p1 = screenToGrid(sel_pos, control_menu.cell_size_ctrl_);
Vector2i p2 = screenToGrid(mousePos, cell_size_ctrl); Vector2i p2 = screenToGrid(mousePos, control_menu.cell_size_ctrl_);
// Get origin // Get origin
Vector2i orig = { Vector2i orig = {
(p1.x < p2.x)?p1.x:p2.x, (p1.x < p2.x)?p1.x:p2.x,
@@ -193,7 +191,7 @@ int main(int ac, char **av) {
}; };
// Ensure there is at least one cell selected // Ensure there is at least one cell selected
if (!(sel_size.x == 0 || sel_size.y == 0)) { if (!(sel_size.x == 0 || sel_size.y == 0)) {
sel_data = std::move(world.getSelection(orig, sel_size)); sel_data = std::move(context.world->getSelection(orig, sel_size));
sel_ctrl = true; sel_ctrl = true;
} }
} }
@@ -201,43 +199,43 @@ int main(int ac, char **av) {
if (!sel_ctrl) { if (!sel_ctrl) {
patern_name[0] = '\0'; patern_name[0] = '\0';
} }
if (step_ctrl) { if (control_menu.step_ctrl_) {
world.saveCompressed(); context.world->saveCompressed();
rules.update(); rules.update();
step_ctrl = false; control_menu.step_ctrl_ = false;
} }
if (step_back_ctrl) { if (control_menu.step_back_ctrl_) {
world.stepBack(); context.world->stepBack();
step_back_ctrl = false; control_menu.step_back_ctrl_ = false;
} }
if (apply_ctrl) { if (control_menu.apply_ctrl_) {
bool resize_needed = false; bool resize_needed = false;
config_json["fps"] = fps_ctrl; context.config_json["fps"] = control_menu.fps_ctrl_;
if (config_json["screen_width"].get<int>() != width_ctrl || if (context.config_json["screen_width"].get<int>() != control_menu.width_ctrl_ ||
config_json["screen_height"].get<int>() != height_ctrl) { context.config_json["screen_height"].get<int>() != control_menu.height_ctrl_) {
config_json["screen_width"] = width_ctrl; context.config_json["screen_width"] = control_menu.width_ctrl_;
config_json["screen_height"] = height_ctrl; context.config_json["screen_height"] = control_menu.height_ctrl_;
rlImGuiShutdown(); rlImGuiShutdown();
SetWindowSize(width_ctrl, height_ctrl); SetWindowSize(control_menu.width_ctrl_, control_menu.height_ctrl_);
rlImGuiSetup(dark_theme_ctrl); rlImGuiSetup(control_menu.dark_theme_ctrl_);
resize_needed = true; resize_needed = true;
} }
if (cell_size_ctrl != config_json["cell_size"].get<int>() || if (control_menu.cell_size_ctrl_ != context.config_json["cell_size"].get<int>() ||
resize_needed) { resize_needed) {
world.resize(config_json["screen_width"].get<int>() / cell_size_ctrl, context.world->resize(context.config_json["screen_width"].get<int>() / control_menu.cell_size_ctrl_,
config_json["screen_height"].get<int>() / cell_size_ctrl); context.config_json["screen_height"].get<int>() / control_menu.cell_size_ctrl_);
render.updateCellSize(cell_size_ctrl); render.updateCellSize(control_menu.cell_size_ctrl_);
rules.newWorld(&world); rules.newWorld(&(*context.world));
config_json["cell_size"] = cell_size_ctrl; context.config_json["cell_size"] = control_menu.cell_size_ctrl_;
} }
if (dark_theme_ctrl != config_json["dark_theme"]) { if (control_menu.dark_theme_ctrl_ != context.config_json["dark_theme"]) {
rlImGuiShutdown(); rlImGuiShutdown();
rlImGuiSetup(dark_theme_ctrl); rlImGuiSetup(control_menu.dark_theme_ctrl_);
config_json["dark_theme"] = dark_theme_ctrl; context.config_json["dark_theme"] = control_menu.dark_theme_ctrl_;
} }
apply_ctrl = false; control_menu.apply_ctrl_ = false;
settings_window = false; control_menu.settings_window_ = false;
} }
// Accumulate time and update simulation at the adjusted speed // Accumulate time and update simulation at the adjusted speed
@@ -247,15 +245,15 @@ int main(int ac, char **av) {
// Reset accumulator // Reset accumulator
deltaTimeAccumulator -= timePerUpdate; deltaTimeAccumulator -= timePerUpdate;
if (menu_state == MenuState::PLAY) { if (menu_state == MenuState::PLAY) {
world.saveCompressed(); context.world->saveCompressed();
rules.update(); rules.update();
} }
} }
BeginDrawing(); BeginDrawing();
ClearBackground(BLACK); ClearBackground(BLACK);
render.display(&world); render.display(&(*context.world));
if (selecting) { if (selecting) {
auto grid_mouse = snapToGrid(mousePos, cell_size_ctrl); auto grid_mouse = snapToGrid(mousePos, control_menu.cell_size_ctrl_);
bool sel_x_less = (sel_pos.x < grid_mouse.x); bool sel_x_less = (sel_pos.x < grid_mouse.x);
bool sel_y_less = (sel_pos.y < grid_mouse.y); bool sel_y_less = (sel_pos.y < grid_mouse.y);
DrawRectangleLines(((sel_x_less)? sel_pos.x: grid_mouse.x), ((sel_y_less)? sel_pos.y: grid_mouse.y), DrawRectangleLines(((sel_x_less)? sel_pos.x: grid_mouse.x), ((sel_y_less)? sel_pos.y: grid_mouse.y),
@@ -272,43 +270,43 @@ int main(int ac, char **av) {
ImVec2 menu_pos(3, 3); ImVec2 menu_pos(3, 3);
ImGui::SetNextWindowPos(menu_pos, ImGuiCond_Always); ImGui::SetNextWindowPos(menu_pos, ImGuiCond_Always);
ImGui::Begin("Control Panel", &control_panel_open, control_panel_flags); ImGui::Begin("Control Panel", &control_panel_open, control_panel_flags);
ImGui::Checkbox("Play", &play_ctrl); ImGui::Checkbox("Play", &control_menu.play_ctrl_);
if (ImGui::Button("Step")) { if (ImGui::Button("Step")) {
step_ctrl = true; control_menu.step_ctrl_ = true;
} }
if (ImGui::Button("Step Back")) { if (ImGui::Button("Step Back")) {
step_back_ctrl = true; control_menu.step_back_ctrl_ = true;
} }
ImGui::Checkbox("Edit", &edit_ctrl); ImGui::Checkbox("Edit", &control_menu.edit_ctrl_);
ImGui::Checkbox("Clear", &clear_ctrl); ImGui::Checkbox("Clear", &control_menu.clear_ctrl_);
ImGui::Checkbox("Randomize", &rand_ctrl); ImGui::Checkbox("Randomize", &control_menu.rand_ctrl_);
if (ImGui::Button((paterns_ctrl) ? "Hide paterns" : "Show paterns")) { if (ImGui::Button((control_menu.paterns_ctrl_) ? "Hide paterns" : "Show paterns")) {
paterns_ctrl = !paterns_ctrl; control_menu.paterns_ctrl_ = !control_menu.paterns_ctrl_;
} }
if (ImGui::Button((settings_window) ? "Hide settings" : "Show settings")) { if (ImGui::Button((control_menu.settings_window_) ? "Hide settings" : "Show settings")) {
settings_window = !settings_window; control_menu.settings_window_ = !control_menu.settings_window_;
} }
ImGui::Text("Generation: %zu", world.getCycle()); ImGui::Text("Generation: %zu", context.world->getCycle());
ImGui::End(); ImGui::End();
if (paterns_ctrl) { if (control_menu.paterns_ctrl_) {
ImGuiWindowFlags paterns_flags = ImGuiWindowFlags paterns_flags =
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize; ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize;
ImGui::SetNextWindowSize(ImVec2(150, 200), ImGuiCond_Always); ImGui::SetNextWindowSize(ImVec2(150, 200), ImGuiCond_Always);
ImGui::Begin("paterns", &paterns_ctrl, paterns_flags); ImGui::Begin("paterns", &control_menu.paterns_ctrl_, paterns_flags);
ImGui::Button("refresh"); ImGui::Button("refresh");
ImGui::End(); ImGui::End();
} }
if (settings_window) { if (control_menu.settings_window_) {
ImGuiWindowFlags settings_flags = ImGuiWindowFlags settings_flags =
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize; ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize;
ImGui::Begin("Settings", &settings_window, settings_flags); ImGui::Begin("Settings", &control_menu.settings_window_, settings_flags);
ImGui::SliderInt("Window Width", &width_ctrl, 800, 1920); ImGui::SliderInt("Window Width", &control_menu.width_ctrl_, 800, 1920);
ImGui::SliderInt("Window Height", &height_ctrl, 600, 1200); ImGui::SliderInt("Window Height", &control_menu.height_ctrl_, 600, 1200);
ImGui::SliderInt("FPS", &fps_ctrl, 0, 30); ImGui::SliderInt("FPS", &control_menu.fps_ctrl_, 0, 30);
ImGui::SliderInt("Cell Size", &cell_size_ctrl, 4, 100); ImGui::SliderInt("Cell Size", &control_menu.cell_size_ctrl_, 4, 100);
ImGui::Checkbox("Dark Theme", &dark_theme_ctrl); ImGui::Checkbox("Dark Theme", &control_menu.dark_theme_ctrl_);
if (ImGui::Button("Save & Apply")) { if (ImGui::Button("Save & Apply")) {
apply_ctrl = true; control_menu.apply_ctrl_ = true;
} }
ImGui::End(); ImGui::End();
} }
@@ -381,7 +379,7 @@ int main(int ac, char **av) {
EndDrawing(); EndDrawing();
} }
config_file.open(config_file_name, std::ios::out | std::ios::trunc); config_file.open(config_file_name, std::ios::out | std::ios::trunc);
config_file << config_json.dump(2); config_file << context.config_json.dump(2);
config_file.close(); config_file.close();
// Cleanup Selection texture // Cleanup Selection texture
UnloadRenderTexture(selectionTexture); UnloadRenderTexture(selectionTexture);

View File

@@ -1,14 +1,10 @@
/* ************************************************************************** */ /*
/* */ * File name: render.cpp
/* / ) */ * Author: lejulien
/* render.cpp (\__/) ( ( */ * Date created: 10-01-2026 21:49:04
/* ) ( ) ) */ // Date modified: 10-01-2026 21:59:56
/* By: lejulien <leo.julien.42@gmail.com> ={ }= / / */ * ------
/* ) `-------/ / */ */
/* Created: 2023/01/09 12:44:30 by lejulien ( / */
/* Updated: 2023/01/14 17:02:00 by lejulien \ | */
/* */
/* ************************************************************************** */
#include "../includes/render.hpp" #include "../includes/render.hpp"

View File

@@ -1,14 +1,10 @@
/* ************************************************************************** */ /*
/* */ * File name: rules.cpp
/* / ) */ * Author: lejulien
/* rules.cpp (\__/) ( ( */ * Date created: 10-01-2026 21:49:14
/* ) ( ) ) */ // Date modified: 10-01-2026 22:00:16
/* By: lejulien <leo.julien.42@gmail.com> ={ }= / / */ * ------
/* ) `-------/ / */ */
/* Created: 2023/01/09 12:18:36 by lejulien ( / */
/* Updated: 2023/01/14 16:47:01 by lejulien \ | */
/* */
/* ************************************************************************** */
#include "../includes/rules.hpp" #include "../includes/rules.hpp"
#include "../includes/world.hpp" #include "../includes/world.hpp"

View File

@@ -1,14 +1,10 @@
/* ************************************************************************** */ /*
/* */ * File name: world.cpp
/* / ) */ * Author: lejulien
/* world.cpp (\__/) ( ( */ * Date created: 09-01-2026 23:59:55
/* ) ( ) ) */ // Date modified: 10-01-2026 22:00:23
/* By: lejulien <leo.julien.42@gmail.com> ={ }= / / */ * ------
/* ) `-------/ / */ */
/* Created: 2023/01/09 12:25:55 by lejulien ( / */
/* Updated: 2023/01/14 17:06:54 by lejulien \ | */
/* */
/* ************************************************************************** */
#include "../includes/world.hpp" #include "../includes/world.hpp"