diff --git a/CMakeLists.txt b/CMakeLists.txt index 63f2562..a48a3ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,15 @@ INCLUDE_DIRECTORIES(engine/) SET(EngineSources engine/src/core/ICEApplication.cpp ) +IF (WIN32) + LIST(APPEND EngineSources + engine/src/platform/windows/WindowsPopup.cpp + ) +ELSEIF (UNIX) + LIST(APPEND EngineSources + engine/src/platform/posix/PosixPopup.cpp + ) +ENDIF() SET(PrecompiledHeader "pch.h") diff --git a/engine/ICEngine.hpp b/engine/ICEngine.hpp index 247f3a6..6063c2d 100644 --- a/engine/ICEngine.hpp +++ b/engine/ICEngine.hpp @@ -7,5 +7,6 @@ #include "src/core/Logger.hpp" #include "src/core/ICEApplication.hpp" +#include "src/platform/Platform.hpp" #endif //ICENGINE_HPP diff --git a/engine/src/platform/Platform.hpp b/engine/src/platform/Platform.hpp new file mode 100644 index 0000000..1baeecc --- /dev/null +++ b/engine/src/platform/Platform.hpp @@ -0,0 +1,14 @@ +// +// Created by illyum on 9/20/2024. +// + +#pragma once + +#include + +namespace Platform { + void ShowPopup(const char *message); + void ShowPopup(const char *title, const char *message); + void ShowPopup(const std::string &message); + void ShowPopup(const std::string &title, const std::string &message); +} diff --git a/engine/src/platform/posix/PosixPopup.cpp b/engine/src/platform/posix/PosixPopup.cpp new file mode 100644 index 0000000..06cd26a --- /dev/null +++ b/engine/src/platform/posix/PosixPopup.cpp @@ -0,0 +1,17 @@ +// +// Created by illyum on 9/20/2024. +// + +#include "../Platform.hpp" +#include + +namespace Platform { + + void ShowPopup(const char* message) { + std::string command = "zenity --info --text=\""; + command += message; + command += "\""; + system(command.c_str()); + } + +} diff --git a/engine/src/platform/windows/WindowsPopup.cpp b/engine/src/platform/windows/WindowsPopup.cpp new file mode 100644 index 0000000..0f02ad7 --- /dev/null +++ b/engine/src/platform/windows/WindowsPopup.cpp @@ -0,0 +1,25 @@ +// +// Created by illyum on 9/20/2024. +// + +#include +#include "../Platform.hpp" +#include + +namespace Platform { + void ShowPopup(const char *message) { + MessageBoxA(nullptr, message, "ICEngine", MB_OK); + } + + void ShowPopup(const char *title, const char *message) { + MessageBoxA(nullptr, message, title, MB_OK); + } + + void ShowPopup(const std::string &message) { + MessageBoxA(nullptr, message.c_str(), "ICEngine", MB_OK); + } + + void ShowPopup(const std::string &title, const std::string &message) { + MessageBoxA(nullptr, message.c_str(), title.c_str(), MB_OK); + } +}