From 91cf0d25d5180d41ae158d181c9e12fc97b84ca8 Mon Sep 17 00:00:00 2001 From: illyum Date: Fri, 20 Sep 2024 10:44:12 -0600 Subject: [PATCH] feat(platform): add platform specific popups Please note! These changes have not yet been tested on POSIX platforms (mac OR linux) so please do not expect them to work! --- CMakeLists.txt | 9 +++++++ engine/ICEngine.hpp | 1 + engine/src/platform/Platform.hpp | 14 +++++++++++ engine/src/platform/posix/PosixPopup.cpp | 17 +++++++++++++ engine/src/platform/windows/WindowsPopup.cpp | 25 ++++++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 engine/src/platform/Platform.hpp create mode 100644 engine/src/platform/posix/PosixPopup.cpp create mode 100644 engine/src/platform/windows/WindowsPopup.cpp 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); + } +}