Skip to content

Commit cce0011

Browse files
committed
Adds warning messages, fixes clang-format
1 parent 69811c8 commit cce0011

File tree

4 files changed

+36
-40
lines changed

4 files changed

+36
-40
lines changed

editor/editor_system.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,15 @@ bool EditorSystem::initialize(const JSON::json& systemData)
172172
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(1.00f, 0.98f, 0.95f, 0.73f);
173173
}
174174

175-
// --- Load json theme data ---
175+
// Load json theme data
176176
for (const auto& entry : std::filesystem::directory_iterator("editor/themes"))
177177
{
178178
if (entry.path().extension() == ".json")
179179
{
180-
std::ifstream f(entry.path());
181-
nlohmann::json data;
180+
InputFileStream f(entry.path());
181+
JSON::json data;
182182
f >> data;
183-
m_ThemeDefinitions.push_back({ data.value("name", entry.path().stem().string()),
184-
entry.path().string(),
185-
data });
183+
m_ThemeDefinitions.push_back( { data.value("name", entry.path().stem().string()), entry.path().string(), data } );
186184
}
187185
}
188186

@@ -1013,7 +1011,8 @@ int EditorSystem::exportScene(const String& sceneName, const String& sceneFilePa
10131011
{
10141012
return;
10151013
}
1016-
m_IsCopyFailed = !OS::RelativeCopyFile(filePair.first, m_CurrExportDir + filePair.second); }));
1014+
m_IsCopyFailed = !OS::RelativeCopyFile(filePair.first, m_CurrExportDir + filePair.second);
1015+
}));
10171016
}
10181017

10191018
/// TODO: Fix the need for this dummy task (blocks the main thread while tasks are running)

editor/editor_system.h

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

33
#include "core/event_manager.h"
4-
#include "framework/system.h"
54
#include "script/interpreter.h"
5+
#include "framework/system.h"
66
#include "utility/imgui_helpers.h"
77

88
#include "vendor/ImGUI/imgui.h"
@@ -72,8 +72,7 @@ class EditorSystem : public System
7272
~EditorSystem();
7373

7474
void drawDefaultUI(float deltaMilliseconds);
75-
void drawProgressBar(Atomic<int>& progress, float& currentProgress,
76-
int& totalProgress);
75+
void drawProgressBar(Atomic<int>& progress, float& currentProgress, int& totalProgress);
7776

7877
void showDocumentation(const String& name, const sol::table& table);
7978

@@ -82,8 +81,7 @@ class EditorSystem : public System
8281
Variant saveBeforeQuit(const Event* event);
8382
Variant createNewScene(const Event* event);
8483
Variant createNewFile(const Event* event);
85-
int exportScene(const String& sceneName, const String& sceneFilePath,
86-
Atomic<int>& progress);
84+
int exportScene(const String& sceneName, const String& sceneFilePath, Atomic<int>& progress);
8785
void postExport();
8886

8987
Vector<ThemeDefinition> m_ThemeDefinitions;
@@ -103,24 +101,9 @@ class EditorSystem : public System
103101

104102
void openScene(String sceneName);
105103

106-
ImColor getWarningColor() const
107-
{
108-
return ColorToImColor((Color)ColorPresets::LightYellow);
109-
}
110-
ImColor getFatalColor() const
111-
{
112-
return ColorToImColor((Color)ColorPresets::IndianRed);
113-
}
114-
ImColor getSuccessColor() const
115-
{
116-
return ColorToImColor((Color)ColorPresets::LimeGreen);
117-
}
118-
ImColor getNormalColor() const
119-
{
120-
return ColorToImColor((Color)ColorPresets::White);
121-
}
122-
ImColor getLinkColor() const
123-
{
124-
return ColorToImColor((Color)ColorPresets::SteelBlue);
125-
}
104+
ImColor getWarningColor() const { return ColorToImColor((Color)ColorPresets::LightYellow); }
105+
ImColor getFatalColor() const { return ColorToImColor((Color)ColorPresets::IndianRed); }
106+
ImColor getSuccessColor() const { return ColorToImColor((Color)ColorPresets::LimeGreen); }
107+
ImColor getNormalColor() const { return ColorToImColor((Color)ColorPresets::White); }
108+
ImColor getLinkColor() const { return ColorToImColor((Color)ColorPresets::SteelBlue); }
126109
};

editor/themes/theme.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,40 @@
22

33
void setVec2(const JSON::json& j, const char* key, ImVec2& ref)
44
{
5-
if (j.contains(key) && j[key].is_array() && j[key].size() == 2)
5+
if (j.contains(key))
66
{
7-
ref = ImVec2(j[key][0], j[key][1]);
7+
if (j[key].is_array() && j[key].size() == 2)
8+
{
9+
ref = ImVec2(j[key][0], j[key][1]);
10+
return;
11+
}
12+
WARN("Theme key: " + key + " is not a valid array of size 2");
813
}
914
}
1015

1116
void setFloat(const JSON::json& j, const char* key, float& ref)
1217
{
1318
if (j.contains(key))
1419
{
15-
ref = j[key].get<float>();
20+
if (j[key].is_number())
21+
{
22+
ref = j[key].get<float>();
23+
return;
24+
}
25+
WARN("Theme key: " + key + " is not a valid number");
1626
}
1727
}
1828

1929
void setColor(const JSON::json& j, const char* key, ImVec4& ref)
2030
{
21-
if (j.contains(key) && j[key].is_array() && j[key].size() == 4)
31+
if (j.contains(key))
2232
{
23-
ref = ImVec4(j[key][0], j[key][1], j[key][2], j[key][3]);
33+
if (j[key].is_array() && j[key].size() == 4)
34+
{
35+
ref = ImVec4(j[key][0], j[key][1], j[key][2], j[key][3]);
36+
return;
37+
}
38+
WARN("Theme key: " + key + " is not a valid array of size 4");
2439
}
2540
}
2641

@@ -108,8 +123,7 @@ void ThemeDefinition::apply() const
108123
setColor(c, "TextSelectedBg", colors[ImGuiCol_TextSelectedBg]);
109124
setColor(c, "DragDropTarget", colors[ImGuiCol_DragDropTarget]);
110125
setColor(c, "NavHighlight", colors[ImGuiCol_NavHighlight]);
111-
setColor(c, "NavWindowingHighlight",
112-
colors[ImGuiCol_NavWindowingHighlight]);
126+
setColor(c, "NavWindowingHighlight", colors[ImGuiCol_NavWindowingHighlight]);
113127
setColor(c, "NavWindowingDimBg", colors[ImGuiCol_NavWindowingDimBg]);
114128
setColor(c, "ModalWindowDimBg", colors[ImGuiCol_ModalWindowDimBg]);
115129
}

editor/themes/theme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "common/types.h"
3+
#include "common/common.h"
44

55
struct ThemeDefinition
66
{

0 commit comments

Comments
 (0)