Skip to content

Commit 218a9b6

Browse files
Added sound module disable option, fixed games project building
- Refactored cmake build options for modules - added new option MODULE_SOUNDS_ENABLED - fixed UITranformComponent usage in game projects - disabled blur by default - fixed codacy issues
1 parent f36901d commit 218a9b6

23 files changed

+133
-82
lines changed

CMakeLists.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1212

1313
option(BUILD_SANDBOX "build sandbox projects" ON)
1414
option(BUILD_GAMES "build games" ON)
15-
option(EDITOR_MODE "Enable ImGUI editor overlay" ON)
1615
option(PROFILE_MODE "Enable functions profiling" ON)
17-
option(THREE_D_MODE "Enable 3D module with Assimp support" ON)
16+
option(MODULE_EDITOR_ENABLED "Enable ImGUI-based editor" ON)
17+
option(MODULE_3D_ENABLED "Enable 3D module with Assimp support" ON)
18+
option(MODULE_SOUND_ENABLED "Enable sound module with irrklang support" ON)
1819

1920
if(WIN32)
2021
add_compile_definitions(
@@ -25,16 +26,20 @@ else()
2526
message("This is not supported platform for now!")
2627
endif()
2728

28-
if (EDITOR_MODE)
29-
add_compile_definitions(EDITOR_MODE)
30-
endif()
31-
3229
if (PROFILE_MODE)
3330
add_compile_definitions(PROFILE_MODE)
3431
endif()
3532

36-
if (THREE_D_MODE)
37-
add_compile_definitions(THREE_D_MODE)
33+
if (MODULE_EDITOR_ENABLED)
34+
add_compile_definitions(MODULE_EDITOR_ENABLED)
35+
endif()
36+
37+
if (MODULE_3D_ENABLED)
38+
add_compile_definitions(MODULE_3D_ENABLED)
39+
endif()
40+
41+
if (MODULE_SOUND_ENABLED)
42+
add_compile_definitions(MODULE_SOUND_ENABLED)
3843
endif()
3944

4045
add_subdirectory(Engine)
@@ -43,7 +48,7 @@ set(ElvenEngine_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
4348

4449

4550
if (BUILD_SANDBOX)
46-
if (THREE_D_MODE)
51+
if (MODULE_3D_ENABLED)
4752
add_subdirectory(Sandbox3D)
4853
set(STARTUP_PROJECT_NAME "Sandbox3D")
4954
else()

Engine/CMakeLists.txt

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ set(ENGINE_HEADERS
7878
)
7979

8080
#editor stuff
81-
if (EDITOR_MODE)
81+
if (MODULE_EDITOR_ENABLED)
8282
set(ENGINE_HEADERS
8383
${ENGINE_HEADERS}
8484
"src/Editor/ImGuiOverlay.h"
@@ -148,7 +148,7 @@ set(ENGINE_SOURCES
148148
${ENGINE_HEADERS}
149149
)
150150

151-
if (EDITOR_MODE)
151+
if (MODULE_EDITOR_ENABLED)
152152
set(ENGINE_SOURCES
153153
${ENGINE_SOURCES}
154154
"src/Editor/ImGuiOverlay.cpp"
@@ -180,22 +180,32 @@ ${VENDOR_PATH}/spdlog/include
180180
${VENDOR_PATH}/stb/include
181181
${VENDOR_PATH}/json/include
182182
${VENDOR_PATH}/freetype/include
183-
${VENDOR_PATH}/irrklang/include
184183
${VENDOR_PATH}/fmt/include
185-
${VENDOR_PATH}/assimp/include
186-
${PROJECT_SOURCE_DIR}/build_vendor/assimp/include # include generated config.h for assimp
187184
)
188185

189-
if (EDITOR_MODE)
186+
if (MODULE_EDITOR_ENABLED)
190187
set(ENGINE_INCLUDE_DIRS
191188
${ENGINE_INCLUDE_DIRS}
192189
${VENDOR_PATH}/imgui/include
193190
)
194191
endif()
195192

196-
target_include_directories(${LIBRARY_NAME}
197-
PUBLIC ${ENGINE_INCLUDE_DIRS}
198-
)
193+
if (MODULE_SOUND_ENABLED)
194+
set(ENGINE_INCLUDE_DIRS
195+
${ENGINE_INCLUDE_DIRS}
196+
${VENDOR_PATH}/irrklang/include
197+
)
198+
endif()
199+
200+
if (MODULE_3D_ENABLED)
201+
set(ENGINE_INCLUDE_DIRS
202+
${ENGINE_INCLUDE_DIRS}
203+
${VENDOR_PATH}/assimp/include
204+
${PROJECT_SOURCE_DIR}/build_vendor/assimp/include # include generated config.h for assimp
205+
)
206+
endif()
207+
208+
target_include_directories(${LIBRARY_NAME} PUBLIC ${ENGINE_INCLUDE_DIRS})
199209

200210
set(VENDOR_PATH_DEBUG ${PROJECT_SOURCE_DIR}/build_vendor/lib/Debug/)
201211
set(VENDOR_PATH_RELEASE ${PROJECT_SOURCE_DIR}/build_vendor/lib/Release/)
@@ -206,39 +216,48 @@ find_library(spdlog_d NAMES spdlogd PATHS ${VENDOR_PATH_DEBUG})
206216
find_library(stb_d NAMES stb PATHS ${VENDOR_PATH_DEBUG})
207217
find_library(freetype_d NAMES freetyped PATHS ${VENDOR_PATH_DEBUG})
208218
find_library(fmt_d NAMES fmtd PATHS ${VENDOR_PATH_DEBUG})
209-
find_library(imgui_d NAMES imgui imguid PATHS ${VENDOR_PATH_DEBUG})
210-
find_library(assimp_d NAMES assimp-vc143-mtd PATHS ${VENDOR_PATH_DEBUG})
211-
find_library(zlib_d NAMES zlibstaticd PATHS ${VENDOR_PATH_DEBUG})
212-
213219
find_library(glad NAMES glad PATHS ${VENDOR_PATH_RELEASE})
214220
find_library(glfw NAMES glfw3 PATHS ${VENDOR_PATH_RELEASE})
215221
find_library(spdlog NAMES spdlog PATHS ${VENDOR_PATH_RELEASE})
216222
find_library(stb NAMES stb PATHS ${VENDOR_PATH_RELEASE})
217223
find_library(freetype NAMES freetype PATHS ${VENDOR_PATH_RELEASE})
218224
find_library(fmt NAMES fmt PATHS ${VENDOR_PATH_RELEASE})
219-
find_library(imgui NAMES imgui PATHS ${VENDOR_PATH_RELEASE})
220-
find_library(irrklang NAMES irrKlang.lib PATHS ${VENDOR_PATH}/irrklang/lib)
221-
find_library(assimp NAMES assimp-vc143-mt PATHS ${VENDOR_PATH_RELEASE})
222-
find_library(zlib NAMES zlibstatic PATHS ${VENDOR_PATH_RELEASE})
223225

224226
set(VENDOR
225-
debug ${glfw_d} optimized ${glfw}
226-
debug ${glad_d} optimized ${glad}
227-
debug ${spdlog_d} optimized ${spdlog}
228-
debug ${stb_d} optimized ${stb}
229-
debug ${freetype_d} optimized ${freetype}
230-
debug ${irrklang} optimized ${irrklang}
231-
debug ${fmt_d} optimized ${fmt}
227+
debug ${glfw_d} optimized ${glfw}
228+
debug ${glad_d} optimized ${glad}
229+
debug ${spdlog_d} optimized ${spdlog}
230+
debug ${stb_d} optimized ${stb}
231+
debug ${freetype_d} optimized ${freetype}
232+
debug ${fmt_d} optimized ${fmt}
232233
)
233234

234-
if (EDITOR_MODE)
235+
if (MODULE_EDITOR_ENABLED)
236+
find_library(imgui_d NAMES imgui imguid PATHS ${VENDOR_PATH_DEBUG})
237+
find_library(imgui NAMES imgui PATHS ${VENDOR_PATH_RELEASE})
238+
235239
set(VENDOR
236240
${VENDOR}
237241
debug ${imgui_d} optimized ${imgui}
242+
243+
)
244+
endif()
245+
246+
if (MODULE_SOUND_ENABLED)
247+
find_library(irrklang NAMES irrKlang.lib PATHS ${VENDOR_PATH}/irrklang/lib)
248+
249+
set(VENDOR
250+
${VENDOR}
251+
debug ${irrklang} optimized ${irrklang}
238252
)
239253
endif()
240254

241-
if (THREE_D_MODE)
255+
if (MODULE_3D_ENABLED)
256+
find_library(assimp_d NAMES assimp-vc143-mtd PATHS ${VENDOR_PATH_DEBUG})
257+
find_library(zlib_d NAMES zlibstaticd PATHS ${VENDOR_PATH_DEBUG})
258+
find_library(assimp NAMES assimp-vc143-mt PATHS ${VENDOR_PATH_RELEASE})
259+
find_library(zlib NAMES zlibstatic PATHS ${VENDOR_PATH_RELEASE})
260+
242261
set(VENDOR
243262
${VENDOR}
244263
debug ${assimp_d} optimized ${assimp}

Engine/src/Core/Application.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Application::Application()
4949
gAudioManager.Init();
5050
gSceneManager.Init();
5151

52-
#if EDITOR_MODE
52+
#if MODULE_EDITOR_ENABLED
5353
if (gEngineSettings.enableEditor) {
5454
m_imGuiOverlay.Init();
5555
m_editor.OnInit();
@@ -80,7 +80,7 @@ Application::~Application()
8080
{
8181
OnDestroy();
8282

83-
#if EDITOR_MODE
83+
#if MODULE_EDITOR_ENABLED
8484
if (gEngineSettings.enableEditor) {
8585
m_imGuiOverlay.Shutdown();
8686
}
@@ -153,7 +153,7 @@ void Application::Run()
153153
m_renderer.EndScene();
154154
}
155155

156-
#if EDITOR_MODE
156+
#if MODULE_EDITOR_ENABLED
157157
if (gEngineSettings.enableEditor) {
158158
PROFILE_SCOPE("ImGui Render in: ");
159159
m_imGuiOverlay.Begin();

Engine/src/Core/Application.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "Renderer/Renderer.h"
88
#include "Scene/Entity.h"
99

10-
#if EDITOR_MODE
10+
#if MODULE_EDITOR_ENABLED
1111
# include "Editor/Editor.h"
1212
# include "Editor/ImGuiOverlay.h"
1313
#endif
@@ -48,7 +48,7 @@ class Application {
4848
virtual void OnUpdate(float dt) {};
4949
virtual void OnRender(float dt) {};
5050
virtual void OnProcessInput(float dt) {};
51-
#if EDITOR_MODE
51+
#if MODULE_EDITOR_ENABLED
5252
virtual void OnImguiRender() {};
5353
#endif
5454
virtual void OnDestroy() {};
@@ -76,7 +76,7 @@ class Application {
7676
ecs::Entity m_fpsCounterEntityId { 0 };
7777
bool m_isPaused { false };
7878

79-
#if EDITOR_MODE
79+
#if MODULE_EDITOR_ENABLED
8080
ImGuiOverlay m_imGuiOverlay;
8181
editor::Editor m_editor;
8282
#endif

Engine/src/Editor/Editor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ void DrawPostProcessSettings(Renderer& renderer)
105105
const bool is_selected = (currentIndex == i);
106106
if (ImGui::Selectable(items[i], is_selected)) {
107107
currentIndex = i;
108-
itemStr = items[currentIndex];
109108
postProcessor.GradientMaskType = static_cast<PostProcessor::BlurGradientMaskType>(currentIndex);
110109
}
111110

@@ -125,7 +124,7 @@ void DrawPostProcessSettings(Renderer& renderer)
125124
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
126125
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f);
127126

128-
ImGui::Image((void*)(intptr_t)postProcessor.GetMaskTextureId(), ImVec2(kMaskPreviewWidth, kMaskPreviewHeight), uv_min, uv_max, tint_col, border_col);
127+
ImGui::Image(reinterpret_cast<void*>((intptr_t)postProcessor.GetMaskTextureId()), ImVec2(kMaskPreviewWidth, kMaskPreviewHeight), uv_min, uv_max, tint_col, border_col);
129128
ImGui::TreePop();
130129
}
131130
}

Engine/src/Editor/Panels/SceneHierarchyPanel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void SceneHierarchyPanel::DrawEntity(const ecs::Entity parentEntity)
160160
nodeName = fmt::format("Entity_{}", m_entityNameCounter++);
161161
}
162162

163-
const bool opened = ImGui::TreeNodeEx((void*)(intptr_t)nodeEntity, flags, nodeName.c_str());
163+
const bool opened = ImGui::TreeNodeEx(reinterpret_cast<void*>((intptr_t)nodeEntity), flags, nodeName.c_str());
164164
if (ImGui::IsItemClicked()) {
165165
m_selectedEntity = nodeEntity;
166166
}

Engine/src/Elven.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "Events/EventManager.h"
2222

23-
#if EDITOR_MODE
23+
#if MODULE_EDITOR_ENABLED
2424
# include "Editor/ImGuiOverlay.h"
2525
#endif
2626

Engine/src/Renderer/PostProcessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PostProcessor {
3838
void CreateExponentialGradientMask(unsigned char* data);
3939

4040
public:
41-
bool IsBlurEnabled { true };
41+
bool IsBlurEnabled { false };
4242
int BlurMaskThreshold { 0 };
4343
BlurGradientMaskType GradientMaskType { BlurGradientMaskType::Linear };
4444

Engine/src/Resources/AudioManager.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
#include "Core/Profiler.h"
55
#include "Core/Timer.h"
66

7-
#include <irrKlang.h>
7+
#if MODULE_SOUND_ENABLED
8+
# include <irrKlang.h>
9+
#endif
810

911
namespace elv {
1012

1113
AudioManager gAudioManager;
1214

1315
void AudioManager::Init()
1416
{
17+
#if MODULE_SOUND_ENABLED
1518
m_engine = irrklang::createIrrKlangDevice();
19+
#else
20+
EL_CORE_WARN("Sound module is disabled!")
21+
#endif
1622
}
1723

1824
void AudioManager::Shutdown()
1925
{
26+
#if MODULE_SOUND_ENABLED
2027
for (auto& it : m_sounds) {
2128
if (it.second.sound) {
2229
it.second.sound->stop();
@@ -27,10 +34,13 @@ void AudioManager::Shutdown()
2734
}
2835

2936
m_engine->drop();
37+
#else
38+
#endif
3039
}
3140

3241
void AudioManager::AddSound(const std::string& name, const std::string& path)
3342
{
43+
#if MODULE_SOUND_ENABLED
3444
irrklang::ISoundSource* source = nullptr;
3545
{
3646
PROFILE_TO_LOG(fmt::format("Audio file {} is loaded in:", name));
@@ -39,20 +49,24 @@ void AudioManager::AddSound(const std::string& name, const std::string& path)
3949
if (source) {
4050
m_sounds.insert({ name, { nullptr, source } });
4151
}
52+
#endif
4253
}
4354

4455
void AudioManager::SetVolume(const std::string& name, float volume)
4556
{
57+
#if MODULE_SOUND_ENABLED
4658
auto it = m_sounds.find(name);
4759
if (it != m_sounds.end() && it->second.sound) {
4860
it->second.sound->setVolume(volume);
4961
} else {
5062
EL_CORE_WARN("Set volume failed: {0} sound isn't exist.", name);
5163
}
64+
#endif
5265
}
5366

5467
void AudioManager::Play(const std::string& name, bool looped)
5568
{
69+
#if MODULE_SOUND_ENABLED
5670
auto it = m_sounds.find(name);
5771
if (it != m_sounds.end()) {
5872
if (it->second.sound) {
@@ -69,20 +83,24 @@ void AudioManager::Play(const std::string& name, bool looped)
6983
} else {
7084
EL_CORE_WARN("Audio play failed: {0} isn't exist.", name);
7185
}
86+
#endif
7287
}
7388

7489
void AudioManager::Pause(const std::string& name)
7590
{
91+
#if MODULE_SOUND_ENABLED
7692
auto it = m_sounds.find(name);
7793
if (it != m_sounds.end() && it->second.sound) {
7894
it->second.sound->setIsPaused(true);
7995
} else {
8096
EL_CORE_WARN("Audio pause failed: {0} isn't exist.", name);
8197
}
98+
#endif
8299
}
83100

84101
void AudioManager::Stop(const std::string& name)
85102
{
103+
#if MODULE_SOUND_ENABLED
86104
auto it = m_sounds.find(name);
87105
if (it != m_sounds.end() && it->second.sound) {
88106
it->second.sound->stop();
@@ -91,15 +109,18 @@ void AudioManager::Stop(const std::string& name)
91109
} else {
92110
EL_CORE_WARN("Audio stop failed: {0} isn't exist.", name);
93111
}
112+
#endif
94113
}
95114
std::vector<std::string> AudioManager::GetSounds() const
96115
{
97116
std::vector<std::string> names;
117+
#if MODULE_SOUND_ENABLED
98118

99119
for (const auto soundInfo : m_sounds) {
100120
names.emplace_back(soundInfo.first);
101121
}
102122

123+
#endif
103124
return names;
104125
}
105126
} // namespace elv

0 commit comments

Comments
 (0)