diff --git a/.github/workflows/scripts/linux-appimage-sdl.sh b/.github/workflows/scripts/linux-appimage-sdl.sh index d85aa6c4c..7c68c3902 100755 --- a/.github/workflows/scripts/linux-appimage-sdl.sh +++ b/.github/workflows/scripts/linux-appimage-sdl.sh @@ -17,5 +17,5 @@ chmod a+x linuxdeploy-plugin-checkrt-x86_64.sh # Build AppImage ./linuxdeploy-x86_64.AppImage --appdir AppDir ./linuxdeploy-plugin-checkrt-x86_64.sh --appdir AppDir -./linuxdeploy-x86_64.AppImage --appdir AppDir -d "$GITHUB_WORKSPACE"/dist/net.shadps4.shadPS4.desktop -e "$GITHUB_WORKSPACE"/build/shadps4 -i "$GITHUB_WORKSPACE"/src/images/net.shadps4.shadPS4.svg --output appimage +./linuxdeploy-x86_64.AppImage --appdir AppDir -d "$GITHUB_WORKSPACE"/src/dist/net.shadps4.shadPS4.desktop -e "$GITHUB_WORKSPACE"/build/shadps4 -i "$GITHUB_WORKSPACE"/src/dist/net.shadps4.shadPS4.svg --output appimage mv shadPS4-x86_64.AppImage Shadps4-sdl.AppImage diff --git a/CMakeLists.txt b/CMakeLists.txt index 262bf5cb0..7c15e02ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,7 +216,7 @@ set(EMULATOR_VERSION_MAJOR "0") set(EMULATOR_VERSION_MINOR "16") set(EMULATOR_VERSION_PATCH "1") -set_source_files_properties(src/shadps4.rc PROPERTIES COMPILE_DEFINITIONS "EMULATOR_VERSION_MAJOR=${EMULATOR_VERSION_MAJOR};EMULATOR_VERSION_MINOR=${EMULATOR_VERSION_MINOR};EMULATOR_VERSION_PATCH=${EMULATOR_VERSION_PATCH}") +set_source_files_properties(src/dist/shadps4.rc PROPERTIES COMPILE_DEFINITIONS "EMULATOR_VERSION_MAJOR=${EMULATOR_VERSION_MAJOR};EMULATOR_VERSION_MINOR=${EMULATOR_VERSION_MINOR};EMULATOR_VERSION_PATCH=${EMULATOR_VERSION_PATCH}") set(APP_VERSION_NUM "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH}") set(APP_VERSION "${APP_VERSION_NUM} WIP") @@ -810,10 +810,6 @@ set(COMMON src/common/logging/classes.h src/common/key_manager.h ) -if (APPLE) - list(APPEND COMMON src/common/apple.h src/common/apple.mm) -endif() - if (ENABLE_DISCORD_RPC) list(APPEND COMMON src/common/discord_rpc_handler.cpp src/common/discord_rpc_handler.h) endif() @@ -1168,6 +1164,10 @@ set(EMULATOR src/emulator.cpp src/sdl_window.cpp ) +if (APPLE) + list(APPEND EMULATOR src/sdl_window_apple.mm) +endif() + if(NOT ENABLE_TESTS) add_executable(shadps4 @@ -1252,8 +1252,8 @@ if (APPLE) target_link_libraries(shadps4 PRIVATE date::date-tz epoll-shim) # Create and embed Info.plist - set(INFO_PLIST_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/Info.plist) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dist/MacOSBundleInfo.plist.in ${INFO_PLIST_PATH}) + set(INFO_PLIST_PATH ${CMAKE_CURRENT_BINARY_DIR}/src/dist/Info.plist) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/dist/MacOSBundleInfo.plist.in ${INFO_PLIST_PATH}) target_link_options(shadps4 PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${INFO_PLIST_PATH}) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") target_link_libraries(shadps4 PRIVATE date::date-tz epoll-shim) @@ -1304,7 +1304,7 @@ if (WIN32) endif() if (WIN32) - target_sources(shadps4 PRIVATE src/shadps4.rc) + target_sources(shadps4 PRIVATE src/dist/shadps4.rc) endif() add_compile_definitions(BOOST_ASIO_STANDALONE) @@ -1324,20 +1324,20 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeRC.cmake") cmrc_add_resource_library(embedded-resources ALIAS res::embedded NAMESPACE res - src/images/shadps4.png - src/images/big_picture/folder.png - src/images/big_picture/settings.png - src/images/big_picture/experimental.png - src/images/big_picture/graphics.png - src/images/big_picture/controller.png - src/images/big_picture/trophy.png - src/images/big_picture/log.png - src/images/big_picture/profiles.png - src/images/trophy.wav - src/images/bronze.png - src/images/gold.png - src/images/platinum.png - src/images/silver.png) + src/resources/big_picture/controller.png + src/resources/big_picture/experimental.png + src/resources/big_picture/folder.png + src/resources/big_picture/graphics.png + src/resources/big_picture/log.png + src/resources/big_picture/profiles.png + src/resources/big_picture/settings.png + src/resources/big_picture/trophy.png + src/resources/bronze.png + src/resources/gold.png + src/resources/platinum.png + src/resources/shadps4.png + src/resources/silver.png + src/resources/trophy.wav) target_link_libraries(shadps4 PRIVATE res::embedded) # ImGui resources diff --git a/REUSE.toml b/REUSE.toml index 168309a5d..350d17e0f 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -3,7 +3,6 @@ version = 1 [[annotations]] path = [ "REUSE.toml", - "crowdin.yml", "CMakeSettings.json", "CMakeDarwinPresets.json", "CMakeLinuxPresets.json", @@ -12,76 +11,30 @@ path = [ ".github/FUNDING.yml", ".github/shadps4.png", ".gitmodules", - "dist/MacOSBundleInfo.plist.in", - "dist/net.shadps4.shadPS4.desktop", - "documents/changelog.md", - "documents/Quickstart/2.png", "documents/Screenshots/*", "documents/Screenshots/Linux/*", "documents/Screenshots/Windows/*", "flake.lock", "scripts/ps4_names.txt", - "src/images/bronze.png", - "src/images/gold.png", - "src/images/platinum.png", - "src/images/silver.png", - "src/images/about_icon.png", - "src/images/controller_icon.png", - "src/images/discord.png", - "src/images/dump_icon.png", - "src/images/exit_icon.png", - "src/images/favorite_icon.png", - "src/images/trophy_icon.png", - "src/images/flag_china.png", - "src/images/flag_eu.png", - "src/images/flag_jp.png", - "src/images/flag_unk.png", - "src/images/flag_us.png", - "src/images/flag_world.png", - "src/images/folder_icon.png", - "src/images/github.png", - "src/images/grid_icon.png", - "src/images/keyboard_icon.png", - "src/images/iconsize_icon.png", - "src/images/KBM.png", - "src/images/ko-fi.png", - "src/images/list_icon.png", - "src/images/list_mode_icon.png", - "src/images/pause_icon.png", - "src/images/play_icon.png", - "src/images/ps4_controller.png", - "src/images/restart_game_icon.png", - "src/images/refreshlist_icon.png", - "src/images/settings_icon.png", - "src/images/fullscreen_icon.png", - "src/images/stop_icon.png", - "src/images/utils_icon.png", - "src/images/shadPS4.icns", - "src/images/shadps4.ico", - "src/images/shadps4.png", - "src/images/net.shadps4.shadPS4.svg", - "src/images/themes_icon.png", - "src/images/update_icon.png", - "src/images/youtube.png", - "src/images/website.png", - "src/images/discord.svg", - "src/images/github.svg", - "src/images/ko-fi.svg", - "src/images/shadps4.svg", - "src/images/website.svg", - "src/images/youtube.svg", - "src/images/trophy.wav", - "src/images/hotkey.png", - "src/images/game_settings.png", - "src/images/big_picture/controller.png", - "src/images/big_picture/experimental.png", - "src/images/big_picture/folder.png", - "src/images/big_picture/graphics.png", - "src/images/big_picture/log.png", - "src/images/big_picture/settings.png", - "src/images/big_picture/trophy.png", - "src/images/big_picture/profiles.png", - "src/shadps4.rc", + "src/dist/MacOSBundleInfo.plist.in", + "src/dist/net.shadps4.shadPS4.desktop", + "src/dist/net.shadps4.shadPS4.svg", + "src/dist/shadps4.ico", + "src/dist/shadps4.rc", + "src/resources/big_picture/controller.png", + "src/resources/big_picture/experimental.png", + "src/resources/big_picture/folder.png", + "src/resources/big_picture/graphics.png", + "src/resources/big_picture/log.png", + "src/resources/big_picture/profiles.png", + "src/resources/big_picture/settings.png", + "src/resources/big_picture/trophy.png", + "src/resources/bronze.png", + "src/resources/gold.png", + "src/resources/platinum.png", + "src/resources/shadps4.png", + "src/resources/silver.png", + "src/resources/trophy.wav", ] precedence = "aggregate" SPDX-FileCopyrightText = "shadPS4 Emulator Project" diff --git a/documents/changelog.md b/documents/changelog.md index 766e1a09f..3d6c7cff9 100644 --- a/documents/changelog.md +++ b/documents/changelog.md @@ -1,3 +1,8 @@ + + v0.4.0 31/10/2024 - codename divicius ================= diff --git a/src/common/apple.h b/src/common/apple.h deleted file mode 100644 index 2c1d20c43..000000000 --- a/src/common/apple.h +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -namespace Common { - -void SetAppIcon(const std::filesystem::path& path); - -} // namespace Common diff --git a/src/common/apple.mm b/src/common/apple.mm deleted file mode 100644 index 2295d3628..000000000 --- a/src/common/apple.mm +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include -#include - -#include "common/apple.h" - -namespace Common { - -void SetAppIcon(const std::filesystem::path& path) { - @autoreleasepool { - NSString* path_str = [NSString stringWithUTF8String:path.native().c_str()]; - NSImage* base_icon = [[[NSImage alloc] initWithContentsOfFile:path_str] autorelease]; - - // Transform the icon to match native look-and-feel. - constexpr double ScaleFactor = 13.0 / 16.0; - constexpr double CornerRadiusFactor = 22.0 / 100.0; - - const double base_icon_width = base_icon.size.width; - const double base_icon_height = base_icon.size.height; - const double icon_width = base_icon_width * ScaleFactor; - const double icon_height = base_icon_height * ScaleFactor; - const double icon_x = (base_icon_width - icon_width) / 2.0; - const double icon_y = (base_icon_height - icon_height) / 2.0; - const double corner_radius_x = icon_width * CornerRadiusFactor; - const double corner_radius_y = icon_height * CornerRadiusFactor; - - NSRect bounds = NSMakeRect(icon_x, icon_y, icon_width, icon_height); - NSBezierPath* mask_path = [NSBezierPath bezierPathWithRoundedRect:bounds - xRadius:corner_radius_x - yRadius:corner_radius_y]; - - NSImage* rounded_icon = [[[NSImage alloc] initWithSize:base_icon.size] autorelease]; - [rounded_icon lockFocus]; - [mask_path addClip]; - [base_icon drawInRect:bounds - fromRect:NSZeroRect - operation:NSCompositingOperationSourceOver - fraction:1.0f]; - [rounded_icon unlockFocus]; - - [NSApp setApplicationIconImage:rounded_icon]; - } -} - -} // namespace Common diff --git a/src/core/libraries/np/trophy_ui.cpp b/src/core/libraries/np/trophy_ui.cpp index 74a7317b6..f5581cc4c 100644 --- a/src/core/libraries/np/trophy_ui.cpp +++ b/src/core/libraries/np/trophy_ui.cpp @@ -43,7 +43,7 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin fmt::UTF(trophyIconPath.u8string())); } - std::string pathString = "src/images/"; + std::string pathString = "src/resources/"; if (trophy_type == "P") { pathString += "platinum.png"; @@ -151,7 +151,7 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin file.close(); PlayWav(sound_data); } else { - auto soundFile = resource.open("src/images/trophy.wav"); + auto soundFile = resource.open("src/resources/trophy.wav"); sound_data = std::vector(soundFile.begin(), soundFile.end()); PlayWav(sound_data); } diff --git a/dist/MacOSBundleInfo.plist.in b/src/dist/MacOSBundleInfo.plist.in similarity index 100% rename from dist/MacOSBundleInfo.plist.in rename to src/dist/MacOSBundleInfo.plist.in diff --git a/dist/net.shadps4.shadPS4.desktop b/src/dist/net.shadps4.shadPS4.desktop similarity index 100% rename from dist/net.shadps4.shadPS4.desktop rename to src/dist/net.shadps4.shadPS4.desktop diff --git a/src/images/net.shadps4.shadPS4.svg b/src/dist/net.shadps4.shadPS4.svg similarity index 100% rename from src/images/net.shadps4.shadPS4.svg rename to src/dist/net.shadps4.shadPS4.svg diff --git a/src/images/shadps4.ico b/src/dist/shadps4.ico similarity index 100% rename from src/images/shadps4.ico rename to src/dist/shadps4.ico diff --git a/src/shadps4.rc b/src/dist/shadps4.rc similarity index 97% rename from src/shadps4.rc rename to src/dist/shadps4.rc index 9edccfbfd..d0620bd42 100644 --- a/src/shadps4.rc +++ b/src/dist/shadps4.rc @@ -10,7 +10,7 @@ LANGUAGE LANG_NEUTRAL, 0x8 // ICON -IDI_ICON1 ICON "images/shadps4.ico" +IDI_ICON1 ICON "shadps4.ico" // VERSION VS_VERSION_INFO VERSIONINFO diff --git a/src/emulator.cpp b/src/emulator.cpp index 275ccb875..da03ef8ca 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -431,9 +431,7 @@ void Emulator::Run(std::filesystem::path file, std::vector args, g_window = window.get(); std::filesystem::path icon_path = mnt->GetHostPath("/app0/sce_sys/icon0.png"); - if (std::filesystem::exists(icon_path)) { - window->SetIcon(icon_path); - } + window->SetIcon(icon_path); const auto& mount_data_dir = Common::FS::GetUserPath(Common::FS::PathType::GameDataDir); mnt->Mount(mount_data_dir, "/data"); diff --git a/src/images/KBM.png b/src/images/KBM.png deleted file mode 100644 index feab9fa0f..000000000 Binary files a/src/images/KBM.png and /dev/null differ diff --git a/src/images/about_icon.png b/src/images/about_icon.png deleted file mode 100644 index bbb517982..000000000 Binary files a/src/images/about_icon.png and /dev/null differ diff --git a/src/images/controller_icon.png b/src/images/controller_icon.png deleted file mode 100644 index 0d5556329..000000000 Binary files a/src/images/controller_icon.png and /dev/null differ diff --git a/src/images/discord.png b/src/images/discord.png deleted file mode 100644 index 9858f217e..000000000 Binary files a/src/images/discord.png and /dev/null differ diff --git a/src/images/discord.svg b/src/images/discord.svg deleted file mode 100644 index a2f630923..000000000 --- a/src/images/discord.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - diff --git a/src/images/dump_icon.png b/src/images/dump_icon.png deleted file mode 100644 index e267181f7..000000000 Binary files a/src/images/dump_icon.png and /dev/null differ diff --git a/src/images/exit_icon.png b/src/images/exit_icon.png deleted file mode 100644 index b54a3b38a..000000000 Binary files a/src/images/exit_icon.png and /dev/null differ diff --git a/src/images/favorite_icon.png b/src/images/favorite_icon.png deleted file mode 100644 index 743eb0fbe..000000000 Binary files a/src/images/favorite_icon.png and /dev/null differ diff --git a/src/images/flag_china.png b/src/images/flag_china.png deleted file mode 100644 index 33fcdfd86..000000000 Binary files a/src/images/flag_china.png and /dev/null differ diff --git a/src/images/flag_eu.png b/src/images/flag_eu.png deleted file mode 100644 index 461f814e1..000000000 Binary files a/src/images/flag_eu.png and /dev/null differ diff --git a/src/images/flag_jp.png b/src/images/flag_jp.png deleted file mode 100644 index fd056962a..000000000 Binary files a/src/images/flag_jp.png and /dev/null differ diff --git a/src/images/flag_unk.png b/src/images/flag_unk.png deleted file mode 100644 index 5c3810282..000000000 Binary files a/src/images/flag_unk.png and /dev/null differ diff --git a/src/images/flag_us.png b/src/images/flag_us.png deleted file mode 100644 index 7b0089af4..000000000 Binary files a/src/images/flag_us.png and /dev/null differ diff --git a/src/images/flag_world.png b/src/images/flag_world.png deleted file mode 100644 index 7b96dff11..000000000 Binary files a/src/images/flag_world.png and /dev/null differ diff --git a/src/images/folder_icon.png b/src/images/folder_icon.png deleted file mode 100644 index 899d2edf6..000000000 Binary files a/src/images/folder_icon.png and /dev/null differ diff --git a/src/images/fullscreen_icon.png b/src/images/fullscreen_icon.png deleted file mode 100644 index 719ffe4a1..000000000 Binary files a/src/images/fullscreen_icon.png and /dev/null differ diff --git a/src/images/game_settings.png b/src/images/game_settings.png deleted file mode 100644 index 614705228..000000000 Binary files a/src/images/game_settings.png and /dev/null differ diff --git a/src/images/github.png b/src/images/github.png deleted file mode 100644 index 7b61598cc..000000000 Binary files a/src/images/github.png and /dev/null differ diff --git a/src/images/github.svg b/src/images/github.svg deleted file mode 100644 index 1872a00ce..000000000 --- a/src/images/github.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - diff --git a/src/images/grid_icon.png b/src/images/grid_icon.png deleted file mode 100644 index c0bbbf4a0..000000000 Binary files a/src/images/grid_icon.png and /dev/null differ diff --git a/src/images/hotkey.png b/src/images/hotkey.png deleted file mode 100644 index 64777056f..000000000 Binary files a/src/images/hotkey.png and /dev/null differ diff --git a/src/images/iconsize_icon.png b/src/images/iconsize_icon.png deleted file mode 100644 index a6b9eaa7a..000000000 Binary files a/src/images/iconsize_icon.png and /dev/null differ diff --git a/src/images/keyboard_icon.png b/src/images/keyboard_icon.png deleted file mode 100644 index 021db61ff..000000000 Binary files a/src/images/keyboard_icon.png and /dev/null differ diff --git a/src/images/ko-fi.png b/src/images/ko-fi.png deleted file mode 100644 index ec0c94773..000000000 Binary files a/src/images/ko-fi.png and /dev/null differ diff --git a/src/images/ko-fi.svg b/src/images/ko-fi.svg deleted file mode 100644 index b8fd694fd..000000000 --- a/src/images/ko-fi.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - diff --git a/src/images/list_icon.png b/src/images/list_icon.png deleted file mode 100644 index ff089d4a3..000000000 Binary files a/src/images/list_icon.png and /dev/null differ diff --git a/src/images/list_mode_icon.png b/src/images/list_mode_icon.png deleted file mode 100644 index 9770e9412..000000000 Binary files a/src/images/list_mode_icon.png and /dev/null differ diff --git a/src/images/pause_icon.png b/src/images/pause_icon.png deleted file mode 100644 index 86bbc6acb..000000000 Binary files a/src/images/pause_icon.png and /dev/null differ diff --git a/src/images/play_icon.png b/src/images/play_icon.png deleted file mode 100644 index d50d404b7..000000000 Binary files a/src/images/play_icon.png and /dev/null differ diff --git a/src/images/ps4_controller.png b/src/images/ps4_controller.png deleted file mode 100644 index 0e2c1d4f1..000000000 Binary files a/src/images/ps4_controller.png and /dev/null differ diff --git a/src/images/refreshlist_icon.png b/src/images/refreshlist_icon.png deleted file mode 100644 index 7de6685b2..000000000 Binary files a/src/images/refreshlist_icon.png and /dev/null differ diff --git a/src/images/restart_game_icon.png b/src/images/restart_game_icon.png deleted file mode 100644 index 1e549e101..000000000 Binary files a/src/images/restart_game_icon.png and /dev/null differ diff --git a/src/images/settings_icon.png b/src/images/settings_icon.png deleted file mode 100644 index 81127bfa3..000000000 Binary files a/src/images/settings_icon.png and /dev/null differ diff --git a/src/images/shadPS4.icns b/src/images/shadPS4.icns deleted file mode 100644 index 0e26368db..000000000 Binary files a/src/images/shadPS4.icns and /dev/null differ diff --git a/src/images/shadps4.svg b/src/images/shadps4.svg deleted file mode 100644 index 0243f550b..000000000 --- a/src/images/shadps4.svg +++ /dev/null @@ -1,105 +0,0 @@ - - diff --git a/src/images/stop_icon.png b/src/images/stop_icon.png deleted file mode 100644 index 55b6b01c7..000000000 Binary files a/src/images/stop_icon.png and /dev/null differ diff --git a/src/images/themes_icon.png b/src/images/themes_icon.png deleted file mode 100644 index cc711011e..000000000 Binary files a/src/images/themes_icon.png and /dev/null differ diff --git a/src/images/trophy_icon.png b/src/images/trophy_icon.png deleted file mode 100644 index 559e7dbb2..000000000 Binary files a/src/images/trophy_icon.png and /dev/null differ diff --git a/src/images/update_icon.png b/src/images/update_icon.png deleted file mode 100644 index 517f91fa6..000000000 Binary files a/src/images/update_icon.png and /dev/null differ diff --git a/src/images/utils_icon.png b/src/images/utils_icon.png deleted file mode 100644 index 7dfa3aa00..000000000 Binary files a/src/images/utils_icon.png and /dev/null differ diff --git a/src/images/website.png b/src/images/website.png deleted file mode 100644 index e872e60a2..000000000 Binary files a/src/images/website.png and /dev/null differ diff --git a/src/images/website.svg b/src/images/website.svg deleted file mode 100644 index eddc0e194..000000000 --- a/src/images/website.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - diff --git a/src/images/youtube.png b/src/images/youtube.png deleted file mode 100644 index 2a69760e6..000000000 Binary files a/src/images/youtube.png and /dev/null differ diff --git a/src/images/youtube.svg b/src/images/youtube.svg deleted file mode 100644 index 977e2b7ff..000000000 --- a/src/images/youtube.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - diff --git a/src/imgui/big_picture/big_picture.cpp b/src/imgui/big_picture/big_picture.cpp index e4131dbc5..fdf77b484 100644 --- a/src/imgui/big_picture/big_picture.cpp +++ b/src/imgui/big_picture/big_picture.cpp @@ -4,17 +4,18 @@ #include #include -#include "big_picture.h" #include "common/logging/log.h" #include "core/devtools/layer.h" #include "core/emulator_settings.h" #include "core/file_format/psf.h" #include "emulator.h" +#include "imgui/big_picture/big_picture.h" +#include "imgui/big_picture/imgui_impl_sdl3_big_picture.h" +#include "imgui/big_picture/imgui_impl_sdlrenderer3.h" +#include "imgui/big_picture/settings_dialog_imgui.h" #include "imgui/imgui_std.h" #include "imgui/renderer/font_stack.h" -#include "imgui_impl_sdl3_big_picture.h" -#include "imgui_impl_sdlrenderer3.h" -#include "settings_dialog_imgui.h" +#include "sdl_window.h" namespace BigPictureMode { @@ -202,15 +203,15 @@ void Launch(char* executableName) { SDL_Window* window = SDL_CreateWindow("shadPS4 Big Picture Mode", 1280, 720, EmulatorSettings.IsFullScreen() ? SDL_WINDOW_FULLSCREEN : 0); - renderer = SDL_CreateRenderer(window, nullptr); - if (window == nullptr) { LOG_ERROR(ImGui, "SDL Window Creation Error: {}", SDL_GetError()); - SDL_DestroyRenderer(renderer); SDL_Quit(); return; } + Frontend::SetDefaultWindowIcon(window); + renderer = SDL_CreateRenderer(window, nullptr); + IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGui::StyleColorsDark(); diff --git a/src/imgui/big_picture/settings_dialog_imgui.cpp b/src/imgui/big_picture/settings_dialog_imgui.cpp index 85e066727..83289229b 100644 --- a/src/imgui/big_picture/settings_dialog_imgui.cpp +++ b/src/imgui/big_picture/settings_dialog_imgui.cpp @@ -187,14 +187,14 @@ SettingsWindow::SettingsWindow(bool gameRunning) : isGameRunning(gameRunning) { : texture = BigPictureMode::LoadSdlTextureData(texData); }; - loadTexture("src/images/big_picture/settings.png", generalTexture); - loadTexture("src/images/big_picture/experimental.png", experimentalTexture); - loadTexture("src/images/big_picture/graphics.png", graphicsTexture); - loadTexture("src/images/big_picture/controller.png", inputTexture); - loadTexture("src/images/big_picture/trophy.png", trophyTexture); - loadTexture("src/images/big_picture/log.png", logTexture); - loadTexture("src/images/big_picture/folder.png", foldersTexture); - loadTexture("src/images/big_picture/profiles.png", profilesTexture); + loadTexture("src/resources/big_picture/settings.png", generalTexture); + loadTexture("src/resources/big_picture/experimental.png", experimentalTexture); + loadTexture("src/resources/big_picture/graphics.png", graphicsTexture); + loadTexture("src/resources/big_picture/controller.png", inputTexture); + loadTexture("src/resources/big_picture/trophy.png", trophyTexture); + loadTexture("src/resources/big_picture/log.png", logTexture); + loadTexture("src/resources/big_picture/folder.png", foldersTexture); + loadTexture("src/resources/big_picture/profiles.png", profilesTexture); auto languageKeys = std::views::keys(languageMap); languageOptions.assign(languageKeys.begin(), languageKeys.end()); diff --git a/src/imgui/notifications_layer.cpp b/src/imgui/notifications_layer.cpp index f136313f0..e822610c1 100644 --- a/src/imgui/notifications_layer.cpp +++ b/src/imgui/notifications_layer.cpp @@ -16,10 +16,10 @@ std::queue notif_queue; std::mutex queueMtx; const std::map iconMap = { - {shadNotifications::stockIcons::shadPS4, "src/images/shadps4.png"}, - {shadNotifications::stockIcons::Settings, "src/images/big_picture/settings.png"}, - {shadNotifications::stockIcons::Profiles, "src/images/big_picture/profiles.png"}, - {shadNotifications::stockIcons::Input, "src/images/big_picture/controller.png"}, + {shadNotifications::stockIcons::shadPS4, "src/resources/shadps4.png"}, + {shadNotifications::stockIcons::Settings, "src/resources/big_picture/settings.png"}, + {shadNotifications::stockIcons::Profiles, "src/resources/big_picture/profiles.png"}, + {shadNotifications::stockIcons::Input, "src/resources/big_picture/controller.png"}, }; NotificationsUI::NotificationsUI(NotificationInfo info) { diff --git a/src/images/big_picture/controller.png b/src/resources/big_picture/controller.png similarity index 100% rename from src/images/big_picture/controller.png rename to src/resources/big_picture/controller.png diff --git a/src/images/big_picture/experimental.png b/src/resources/big_picture/experimental.png similarity index 100% rename from src/images/big_picture/experimental.png rename to src/resources/big_picture/experimental.png diff --git a/src/images/big_picture/folder.png b/src/resources/big_picture/folder.png similarity index 100% rename from src/images/big_picture/folder.png rename to src/resources/big_picture/folder.png diff --git a/src/images/big_picture/graphics.png b/src/resources/big_picture/graphics.png similarity index 100% rename from src/images/big_picture/graphics.png rename to src/resources/big_picture/graphics.png diff --git a/src/images/big_picture/log.png b/src/resources/big_picture/log.png similarity index 100% rename from src/images/big_picture/log.png rename to src/resources/big_picture/log.png diff --git a/src/images/big_picture/profiles.png b/src/resources/big_picture/profiles.png similarity index 100% rename from src/images/big_picture/profiles.png rename to src/resources/big_picture/profiles.png diff --git a/src/images/big_picture/settings.png b/src/resources/big_picture/settings.png similarity index 100% rename from src/images/big_picture/settings.png rename to src/resources/big_picture/settings.png diff --git a/src/images/big_picture/trophy.png b/src/resources/big_picture/trophy.png similarity index 100% rename from src/images/big_picture/trophy.png rename to src/resources/big_picture/trophy.png diff --git a/src/images/bronze.png b/src/resources/bronze.png similarity index 100% rename from src/images/bronze.png rename to src/resources/bronze.png diff --git a/src/images/gold.png b/src/resources/gold.png similarity index 100% rename from src/images/gold.png rename to src/resources/gold.png diff --git a/src/images/platinum.png b/src/resources/platinum.png similarity index 100% rename from src/images/platinum.png rename to src/resources/platinum.png diff --git a/src/images/shadps4.png b/src/resources/shadps4.png similarity index 100% rename from src/images/shadps4.png rename to src/resources/shadps4.png diff --git a/src/images/silver.png b/src/resources/silver.png similarity index 100% rename from src/images/silver.png rename to src/resources/silver.png diff --git a/src/images/trophy.wav b/src/resources/trophy.wav similarity index 100% rename from src/images/trophy.wav rename to src/resources/trophy.wav diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp index 9ea7b363a..db04f9912 100644 --- a/src/sdl_window.cpp +++ b/src/sdl_window.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "common/assert.h" @@ -30,9 +31,10 @@ #ifdef __APPLE__ #include -#include "common/apple.h" #endif +CMRC_DECLARE(res); + namespace Frontend { using namespace Libraries::Pad; @@ -178,52 +180,33 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller WindowSDL::~WindowSDL() = default; void WindowSDL::SetIcon(const std::filesystem::path& path) { -#ifdef __APPLE__ - // Use native path which matches system icon look-and-feel. - Common::SetAppIcon(path); -#else + if (!std::filesystem::exists(path)) { + LOG_WARNING(Core, "Could not find icon file '{}', using default icon.", + fmt::UTF(path.u8string())); + SetDefaultWindowIcon(window); + return; + } + Common::FS::IOFile file{path, Common::FS::FileAccessMode::Read, Common::FS::FileType::BinaryFile, Common::FS::FileShareFlag::ShareReadWrite}; if (!file.IsOpen()) { LOG_ERROR(Core, "Failed to open window icon file '{}'.", fmt::UTF(path.u8string())); + SetDefaultWindowIcon(window); return; } - const u64 file_size = file.GetSize(); - std::vector buf(file_size); - const size_t bytes_read = file.ReadRaw(buf.data(), file_size); + const u64 fileSize = file.GetSize(); + std::vector buf(fileSize); + const size_t bytesRead = file.ReadRaw(buf.data(), fileSize); file.Close(); - if (bytes_read < file_size) { + if (bytesRead < fileSize) { LOG_ERROR(Core, "Failed to read window icon file '{}'.", fmt::UTF(path.u8string())); + SetDefaultWindowIcon(window); return; } - int image_width = 0; - int image_height = 0; - constexpr int num_channels = 4; - unsigned char* image_data = - stbi_load_from_memory(buf.data(), static_cast(buf.size()), &image_width, &image_height, - nullptr, num_channels); - if (image_data == nullptr) { - LOG_ERROR(Core, "Failed to load window icon image '{}': {}", fmt::UTF(path.u8string()), - stbi_failure_reason()); - return; - } - SCOPE_EXIT { - stbi_image_free(image_data); - }; - - SDL_Surface* surface = SDL_CreateSurfaceFrom(image_width, image_height, SDL_PIXELFORMAT_RGBA32, - image_data, image_width * num_channels); - if (surface == nullptr) { - LOG_ERROR(Core, "Failed to create SDL surface for window icon: {}", SDL_GetError()); - } - if (!SDL_SetWindowIcon(window, surface)) { - LOG_ERROR(Core, "Failed to set SDL window icon: {}", SDL_GetError()); - } - SDL_DestroySurface(surface); -#endif + SetWindowIcon(window, buf); } void WindowSDL::WaitEvent() { @@ -474,4 +457,38 @@ void WindowSDL::OnGamepadEvent(const SDL_Event* event) { } } +#ifndef __APPLE__ +void SetWindowIcon(SDL_Window* window, const std::vector& png) { + int imageWidth = 0; + int imageHeight = 0; + constexpr int numChannels = 4; + unsigned char* imageData = stbi_load_from_memory(png.data(), png.size(), &imageWidth, + &imageHeight, nullptr, numChannels); + if (imageData == nullptr) { + LOG_ERROR(Core, "Failed to load window icon image: {}", stbi_failure_reason()); + return; + } + SCOPE_EXIT { + stbi_image_free(imageData); + }; + + SDL_Surface* surface = SDL_CreateSurfaceFrom(imageWidth, imageHeight, SDL_PIXELFORMAT_RGBA32, + imageData, imageWidth * numChannels); + if (surface == nullptr) { + LOG_ERROR(Core, "Failed to create SDL surface for window icon: {}", SDL_GetError()); + } + if (!SDL_SetWindowIcon(window, surface)) { + LOG_ERROR(Core, "Failed to set SDL window icon: {}", SDL_GetError()); + } + SDL_DestroySurface(surface); +} +#endif + +void SetDefaultWindowIcon(SDL_Window* window) { + const auto resource = cmrc::res::get_filesystem(); + const auto file = resource.open("src/resources/shadps4.png"); + const std::vector texData = std::vector(file.begin(), file.end()); + SetWindowIcon(window, texData); +} + } // namespace Frontend diff --git a/src/sdl_window.h b/src/sdl_window.h index 677c4c060..74526c695 100644 --- a/src/sdl_window.h +++ b/src/sdl_window.h @@ -94,4 +94,7 @@ private: bool is_open{true}; }; +void SetWindowIcon(SDL_Window* window, const std::vector& png); +void SetDefaultWindowIcon(SDL_Window* window); + } // namespace Frontend diff --git a/src/sdl_window_apple.mm b/src/sdl_window_apple.mm new file mode 100644 index 000000000..1758dc9d5 --- /dev/null +++ b/src/sdl_window_apple.mm @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include + +#include "sdl_window.h" + +namespace Frontend { + +void SetWindowIcon(SDL_Window* window, const std::vector& png) { + @autoreleasepool { + NSData* pngData = [NSData dataWithBytes:png.data() length:png.size()]; + NSImage* baseIcon = [[[NSImage alloc] initWithData:pngData] autorelease]; + + // Transform the icon to match native look-and-feel. + constexpr double ScaleFactor = 13.0 / 16.0; + constexpr double CornerRadiusFactor = 22.0 / 100.0; + + const double baseIconWidth = baseIcon.size.width; + const double baseIconHeight = baseIcon.size.height; + const double iconWidth = baseIconWidth * ScaleFactor; + const double iconHeight = baseIconHeight * ScaleFactor; + const double iconX = (baseIconWidth - iconWidth) / 2.0; + const double iconY = (baseIconHeight - iconHeight) / 2.0; + const double cornerRadiusX = iconWidth * CornerRadiusFactor; + const double cornerRadiusY = iconHeight * CornerRadiusFactor; + + NSRect bounds = NSMakeRect(iconX, iconY, iconWidth, iconHeight); + NSBezierPath* maskPath = [NSBezierPath bezierPathWithRoundedRect:bounds + xRadius:cornerRadiusX + yRadius:cornerRadiusY]; + + NSImage* nativeIcon = [[[NSImage alloc] initWithSize:baseIcon.size] autorelease]; + [nativeIcon lockFocus]; + [maskPath addClip]; + [baseIcon drawInRect:bounds + fromRect:NSZeroRect + operation:NSCompositingOperationSourceOver + fraction:1.0f]; + [nativeIcon unlockFocus]; + + [NSApp setApplicationIconImage:nativeIcon]; + } +} + +} // namespace Frontend