From b59e7605e93cd642da55b994d3ed18479ace89ce Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sat, 21 Nov 2020 09:35:15 +0000 Subject: [PATCH] sa2: add application icon. Signed-off-by: Andrea Odetti --- source/frontends/sa2/CMakeLists.txt | 3 +++ source/frontends/sa2/main.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/source/frontends/sa2/CMakeLists.txt b/source/frontends/sa2/CMakeLists.txt index 3eaeba05..aab73692 100644 --- a/source/frontends/sa2/CMakeLists.txt +++ b/source/frontends/sa2/CMakeLists.txt @@ -14,17 +14,20 @@ find_package(Boost REQUIRED ) find_package(SDL2 REQUIRED) +pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image) target_compile_features(sa2 PUBLIC cxx_std_17) target_include_directories(sa2 PRIVATE ${Boost_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} + ${SDL2_IMAGE_INCLUDE_DIRS} ) target_link_libraries(sa2 PRIVATE Boost::program_options ${SDL2_LIBRARIES} + ${SDL2_IMAGE_LIBRARIES} appleii common2 ) diff --git a/source/frontends/sa2/main.cpp b/source/frontends/sa2/main.cpp index b3ac39fd..8a8d7091 100644 --- a/source/frontends/sa2/main.cpp +++ b/source/frontends/sa2/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -12,6 +13,7 @@ #include "frontends/common2/utils.h" #include "frontends/common2/programoptions.h" #include "frontends/common2/timer.h" +#include #include "frontends/sa2/emulator.h" #include "frontends/sa2/gamepad.h" #include "frontends/sa2/sdirectsound.h" @@ -159,6 +161,16 @@ namespace return interval; } + void setApplicationIcon(const std::shared_ptr & win) + { + const std::string path = getResourcePath() + "APPLEWIN.ICO"; + std::shared_ptr icon(IMG_Load(path.c_str()), SDL_FreeSurface); + if (icon) + { + SDL_SetWindowIcon(win.get(), icon.get()); + } + } + } int MessageBox(HWND, const char * text, const char * caption, UINT type) @@ -225,6 +237,8 @@ void run_sdl(int argc, const char * argv []) return; } + setApplicationIcon(win); + std::shared_ptr ren(SDL_CreateRenderer(win.get(), options.sdlDriver, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), SDL_DestroyRenderer); if (!ren) {