Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
system_utils.cpp
Go to the documentation of this file.
1/*
2Olympus Game Engine V2 2025
3Nicolas Chereau
4nchereau@gmail.com
5
6purpose:
7
8Notes:
9
10*/
11
12#include "system_utils.h"
13#include "..\gameengine.h"
14#include "..\PanelManager.h"
15
16void LoadOlympeConfig(const char* filename)
17{
20
21 std::ifstream ifs(filename);
22 if (!ifs) {
23 SYSTEM_LOG << "Config file '" << filename << "' not found — using defaults " << GameEngine::screenWidth << "x" << GameEngine::screenHeight << "\n";
24 return;
25 }
26
27 std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
28
29 // Extract screen width and height
32
33 if (extract_json_int(content, "screen_width", w) || extract_json_int(content, "screenWidth", w) || extract_json_int(content, "width", w)) {}
34 if (extract_json_int(content, "screen_height", h) || extract_json_int(content, "screenHeight", h) || extract_json_int(content, "screen_heigth", h) || extract_json_int(content, "height", h)) {}
35
36 if (w > 0) GameEngine::screenWidth = w;
37 if (h > 0) GameEngine::screenHeight = h;
38
39 SYSTEM_LOG << "Config loaded from '" << filename << "': " << GameEngine::screenWidth << "x" << GameEngine::screenHeight << "\n";
40
41 // Extract Log Panel data
42 if (extract_json_int(content, "log_panel_width", PanelManager::LogPanelWidth)) {}
43 if (extract_json_int(content, "log_panel_height", PanelManager::LogPanelHeight)) {}
44 if (extract_json_int(content, "log_panel_posx", PanelManager::LogPanelPosX)) {}
45 if (extract_json_int(content, "log_panel_posy", PanelManager::LogPanelPosY)) {}
46
47 // Extract Object Inspector Panel data
48 if (extract_json_int(content, "inspector_panel_width", PanelManager::InspectorPanelWidth)) {}
49 if (extract_json_int(content, "inspector_panel_height", PanelManager::InspectorPanelHeight)) {}
50 if (extract_json_int(content, "inspector_panel_posx", PanelManager::InspectorPanelPosX)) {}
51 if (extract_json_int(content, "inspector_panel_posy", PanelManager::InspectorPanelPosY)) {}
52
53 // Extract Tree View Panel data
54 if (extract_json_int(content, "treeview_panel_width", PanelManager::TreeViewPanelWidth)) {}
55 if (extract_json_int(content, "treeview_panel_height", PanelManager::TreeViewPanelHeight)) {}
56 if (extract_json_int(content, "treeview_panel_posx", PanelManager::TreeViewPanelPosX)) {}
57 if (extract_json_int(content, "treeview_panel_posy", PanelManager::TreeViewPanelPosY)) {}
58
59 /* "object_panel_width" : 200,
60 "object_panel_height" : 400,
61 "object_panel_posx" : 700,
62 "object_panel_posy" : 0,
63
64 "treeview_panel_width" : 300,
65 "treeview_panel_height" : 600,
66 "treeview_panel_posx" : 700,
67 "treeview_panel_posy" : 400,/**/
68}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static int screenWidth
Screen width in pixels.
Definition GameEngine.h:123
static int screenHeight
Screen height in pixels.
Definition GameEngine.h:126
static int LogPanelHeight
static int TreeViewPanelPosX
static int LogPanelPosX
static int InspectorPanelHeight
static int InspectorPanelWidth
static int InspectorPanelPosY
static int LogPanelWidth
static int TreeViewPanelPosY
static int LogPanelPosY
static int InspectorPanelPosX
static int TreeViewPanelHeight
static int TreeViewPanelWidth
static const int DEFAULT_WINDOW_HEIGHT
static const int DEFAULT_WINDOW_WIDTH
void LoadOlympeConfig(const char *filename)
#define SYSTEM_LOG
static bool extract_json_int(const std::string &json, const std::string &key, int &out)