diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cf8e74..025fb29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,6 +230,7 @@ set(EMBEDDED_INPUT shader/blurV.vert shader/simpleMatrix.vert assets/liberation.ttf + assets/icon.png ) if (RGSS2) diff --git a/assets/icon.png b/assets/icon.png new file mode 100644 index 0000000..906f73b Binary files /dev/null and b/assets/icon.png differ diff --git a/assets/icon.svg b/assets/icon.svg new file mode 100644 index 0000000..f6a8aa9 --- /dev/null +++ b/assets/icon.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/mkxp.pro b/mkxp.pro index 0ee0547..78aee3e 100644 --- a/mkxp.pro +++ b/mkxp.pro @@ -202,7 +202,8 @@ EMBED = \ shader/blurV.vert \ shader/simpleMatrix.vert \ shader/tilemapvx.vert \ - assets/liberation.ttf + assets/liberation.ttf \ + assets/icon.png SHARED_FLUID { DEFINES += SHARED_FLUID diff --git a/src/main.cpp b/src/main.cpp index cd2ca59..23fc918 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,9 @@ #include #include +#include +#include +#include #include #include "sharedstate.h" @@ -37,9 +40,7 @@ #include "binding.h" -#include -#include -#include +#include "icon.png.xxd" static void rgssThreadError(RGSSThreadData *rtData, const std::string &msg) @@ -236,6 +237,16 @@ int main(int argc, char *argv[]) return 0; } + /* Setup application icon */ + SDL_RWops *iconSrc; + + if (conf.iconPath.empty()) + iconSrc = SDL_RWFromConstMem(assets_icon_png, assets_icon_png_len); + else + iconSrc = SDL_RWFromFile(conf.iconPath.c_str(), "rb"); + + SDL_Surface *iconImg = IMG_Load_RW(iconSrc, SDL_TRUE); + SDL_SetHint("SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "0"); SDL_Window *win; @@ -256,14 +267,10 @@ int main(int argc, char *argv[]) return 0; } - if (!conf.iconPath.empty()) + if (iconImg) { - SDL_Surface *iconImg = IMG_Load(conf.iconPath.c_str()); - if (iconImg) - { - SDL_SetWindowIcon(win, iconImg); - SDL_FreeSurface(iconImg); - } + SDL_SetWindowIcon(win, iconImg); + SDL_FreeSurface(iconImg); } EventThread eventThread;