WIP: Settings up settings menu

> TODO: Fix broken behaiour in the refacto process
This commit is contained in:
2026-01-12 21:34:41 +01:00
parent 24d8a092e4
commit 14126d6b5b
7 changed files with 221 additions and 103 deletions

View File

@@ -2,7 +2,7 @@
* File name: context.hpp
* Author: lejulien
* Date created: 01-01-1970 00:59:59
// Date modified: 12-01-2026 20:31:50
// Date modified: 12-01-2026 21:30:10
* ------
*/
@@ -14,12 +14,16 @@
class World;
class Rules;
class Render;
namespace gol {
class SettingsMenu;
typedef struct ctx {
std::shared_ptr<World> world = nullptr;
std::shared_ptr<Rules> rules = nullptr;
std::shared_ptr<Render> render = nullptr;
std::shared_ptr<SettingsMenu> settings_menu = nullptr;
nlohmann::json config_json;
} ctx;

View File

@@ -2,7 +2,7 @@
* File name: control_menu.hpp
* Author: lejulien
* Date created: 10-01-2026 22:00:33
// Date modified: 10-01-2026 22:45:10
// Date modified: 12-01-2026 20:50:02
* ------
*/
@@ -23,20 +23,13 @@ private:
ctx context_;
public: // Keep those public for easy access
MenuState menu_state_ = MenuState::NONE;
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

@@ -0,0 +1,44 @@
/*
* File name: settings_menu.hpp
* Author: lejulien
* Date created: 01-01-1970 00:59:59
// Date modified: 12-01-2026 21:28:03
* ------
*/
#pragma once
#include <context.hpp>
namespace gol {
class SettingsMenu {
public:
SettingsMenu(ctx &context);
~SettingsMenu() = default;
void update();
void display();
bool isOpen();
void Toogle();
// Getter/Setters
int getFPS();
void setFPS(int);
int getCellSize();
void setCellSize(int);
int getWidth();
void setWidth(int);
int getHeight();
void setHeight(int);
private:
ctx context_;
int fps_ctrl_ = false;
int cell_size_ctrl_ = false;
bool settings_window_ = false;
int width_ctrl_ = false;
int height_ctrl_ = false;
bool dark_theme_ctrl_ = false;
bool apply_ctrl_ = false;
};
} // namespace gol