-
Notifications
You must be signed in to change notification settings - Fork 961
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LinuxMessageBox class and cross-platform SimpleMessageBox alias
- Loading branch information
1 parent
70f42c6
commit e185847
Showing
6 changed files
with
53 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include <SDL2/SDL.h> | ||
|
||
#include "LinuxDynamicLibrary.h" | ||
|
||
class LinuxMessageBox { | ||
public: | ||
void showWarning(const char* title, const char* message) const noexcept | ||
{ | ||
showMessageBox(title, message, SDL_MESSAGEBOX_WARNING); | ||
} | ||
|
||
void showError(const char* title, const char* message) const noexcept | ||
{ | ||
showMessageBox(title, message, SDL_MESSAGEBOX_ERROR); | ||
} | ||
|
||
private: | ||
void showMessageBox(const char* title, const char* message, unsigned int flags) const noexcept | ||
{ | ||
if (showSimpleMessageBox) | ||
showSimpleMessageBox(flags, title, message, nullptr); | ||
} | ||
|
||
decltype(&SDL_ShowSimpleMessageBox) showSimpleMessageBox = LinuxDynamicLibrary{ "libSDL2-2.0.so.0" }.getFunctionAddress("SDL_ShowSimpleMessageBox").as<decltype(&SDL_ShowSimpleMessageBox)>(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include "Macros/IsPlatform.h" | ||
|
||
#if IS_WIN32() || IS_WIN64() | ||
|
||
#include "Windows/WindowsMessageBox.h" | ||
|
||
using SimpleMessageBox = WindowsMessageBox; | ||
|
||
#elif IS_LINUX() | ||
|
||
#include "Linux/LinuxMessageBox.h" | ||
|
||
using SimpleMessageBox = LinuxMessageBox; | ||
|
||
#endif |