Skip to content

Commit

Permalink
Merge branch 'shadps4-emu:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolix29 authored Sep 26, 2024
2 parents dbcb8ef + 1d23f40 commit 7d54e26
Show file tree
Hide file tree
Showing 45 changed files with 593 additions and 271 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: shadps4
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ jobs:
target: desktop
arch: win64_msvc2019_64
archives: qtbase qttools
modules: qtmultimedia

- name: Cache CMake Configuration
uses: actions/cache@v4
Expand Down Expand Up @@ -237,6 +238,7 @@ jobs:
target: desktop
arch: clang_64
archives: qtbase qttools
modules: qtmultimedia

- name: Cache CMake Configuration
uses: actions/cache@v4
Expand Down Expand Up @@ -341,7 +343,7 @@ jobs:
submodules: recursive

- name: Install dependencies
run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential qt6-base-dev qt6-tools-dev
run: sudo apt-get update && sudo apt install -y libx11-dev libxext-dev libwayland-dev libfuse2 clang build-essential qt6-base-dev qt6-tools-dev qt6-multimedia-dev

- name: Cache CMake Configuration
uses: actions/cache@v4
Expand Down
64 changes: 0 additions & 64 deletions .reuse/dep5

This file was deleted.

6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ add_subdirectory(externals)
include_directories(src)

if(ENABLE_QT_GUI)
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent LinguistTools Network)
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent LinguistTools Network Multimedia)
qt_standard_project_setup()
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOMOC ON)
Expand Down Expand Up @@ -653,6 +653,8 @@ qt_add_resources(RESOURCE_FILES src/shadps4.qrc)
set(QT_GUI src/qt_gui/about_dialog.cpp
src/qt_gui/about_dialog.h
src/qt_gui/about_dialog.ui
src/qt_gui/background_music_player.cpp
src/qt_gui/background_music_player.h
src/qt_gui/cheats_patches.cpp
src/qt_gui/cheats_patches.h
src/qt_gui/check_update.cpp
Expand Down Expand Up @@ -760,7 +762,7 @@ else()
endif()

if (ENABLE_QT_GUI)
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network)
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network Qt6::Multimedia)
add_definitions(-DENABLE_QT_GUI)
endif()

Expand Down
78 changes: 78 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version = 1

[[annotations]]
path = [
"REUSE.toml",
"CMakeSettings.json",
".github/FUNDING.yml",
".github/shadps4.desktop",
".github/shadps4.png",
".gitmodules",
"documents/changelog.txt",
"documents/Quickstart/2.png",
"documents/Screenshots/Bloodborne.png",
"documents/Screenshots/Sonic Mania.png",
"documents/Screenshots/Undertale.png",
"documents/Screenshots/We are DOOMED.png",
"scripts/ps4_names.txt",
"src/images/about_icon.png",
"src/images/controller_icon.png",
"src/images/dump_icon.png",
"src/images/exit_icon.png",
"src/images/file_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/grid_icon.png",
"src/images/iconsize_icon.png",
"src/images/list_icon.png",
"src/images/list_mode_icon.png",
"src/images/pause_icon.png",
"src/images/play_icon.png",
"src/images/refresh_icon.png",
"src/images/settings_icon.png",
"src/images/stop_icon.png",
"src/images/shadPS4.icns",
"src/images/shadps4.ico",
"src/images/themes_icon.png",
"src/images/update_icon.png",
"src/shadps4.qrc",
"src/shadps4.rc",
]
precedence = "aggregate"
SPDX-FileCopyrightText = "shadPS4 Emulator Project"
SPDX-License-Identifier = "GPL-2.0-or-later"

[[annotations]]
path = "externals/cmake-modules/**"
precedence = "aggregate"
SPDX-FileCopyrightText = "2009-2010 Iowa State University"
SPDX-License-Identifier = "BSL-1.0"

[[annotations]]
path = "externals/renderdoc/**"
precedence = "aggregate"
SPDX-FileCopyrightText = "2019-2024 Baldur Karlsson"
SPDX-License-Identifier = "MIT"

[[annotations]]
path = "externals/stb_image.h"
precedence = "aggregate"
SPDX-FileCopyrightText = "2017 Sean Barrett"
SPDX-License-Identifier = "MIT"

[[annotations]]
path = "externals/tracy/**"
precedence = "aggregate"
SPDX-FileCopyrightText = "2017-2024 Bartosz Taudul <[email protected]>"
SPDX-License-Identifier = "BSD-3-Clause"

[[annotations]]
path = "src/imgui/renderer/fonts/NotoSansJP-Regular.ttf"
precedence = "aggregate"
SPDX-FileCopyrightText = "2012 Google Inc. All Rights Reserved."
SPDX-License-Identifier = "OFL-1.1"
4 changes: 2 additions & 2 deletions documents/building-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Normal x86-based computers, follow:
1. Open "MSYS2 MINGW64" from your new applications
2. Run `pacman -Syu`, let it complete;
3. Run `pacman -S --needed git mingw-w64-x86_64-binutils mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-ffmpeg`
1. Optional (Qt only): run `pacman -S --needed mingw-w64-x86_64-qt6-base mingw-w64-x86_64-qt6-tools`
1. Optional (Qt only): run `pacman -S --needed mingw-w64-x86_64-qt6-base mingw-w64-x86_64-qt6-tools mingw-w64-x86_64-qt6-multimedia`
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
5. Run `cd shadPS4`
6. Run `cmake -S . -B build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
Expand All @@ -94,7 +94,7 @@ ARM64-based computers, follow:
1. Open "MSYS2 CLANGARM64" from your new applications
2. Run `pacman -Syu`, let it complete;
3. Run `pacman -S --needed git mingw-w64-clang-aarch64-binutils mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-cmake mingw-w64-clang-aarch64-ninja mingw-w64-clang-aarch64-ffmpeg`
1. Optional (Qt only): run `pacman -S --needed mingw-w64-clang-aarch64-qt6-base mingw-w64-clang-aarch64-qt6-tools`
1. Optional (Qt only): run `pacman -S --needed mingw-w64-clang-aarch64-qt6-base mingw-w64-clang-aarch64-qt6-tools mingw-w64-clang-aarch64-qt6-multimedia`
4. Run `git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4`
5. Run `cd shadPS4`
6. Run `cmake -S . -B build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"`
Expand Down
55 changes: 44 additions & 11 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@
#include <fstream>
#include <string>
#include <fmt/core.h>
#include <fmt/xchar.h> // for wstring support
#include <toml.hpp>
#include "common/logging/formatter.h"
#include "config.h"

namespace toml {
template <typename TC, typename K>
std::filesystem::path find_fs_path_or(const basic_value<TC>& v, const K& ky,
std::filesystem::path opt) {
try {
auto str = find<std::string>(v, ky);
std::u8string u8str{(char8_t*)&str.front(), (char8_t*)&str.back() + 1};
return std::filesystem::path{u8str};
} catch (...) {
return opt;
}
}
} // namespace toml

namespace Config {

static bool isNeo = false;
static bool isFullscreen = false;
static bool playBGM = false;
static u32 screenWidth = 1280;
static u32 screenHeight = 720;
static s32 gpuId = -1; // Vulkan physical device index. Set to negative for auto select
Expand All @@ -36,7 +53,7 @@ static bool vkMarkers = false;
static bool vkCrashDiagnostic = false;

// Gui
std::string settings_install_dir = "";
std::filesystem::path settings_install_dir = {};
u32 main_window_geometry_x = 400;
u32 main_window_geometry_y = 400;
u32 main_window_geometry_w = 1280;
Expand Down Expand Up @@ -64,6 +81,10 @@ bool isFullscreenMode() {
return isFullscreen;
}

bool getPlayBGM() {
return playBGM;
}

u32 getScreenWidth() {
return screenWidth;
}
Expand Down Expand Up @@ -220,6 +241,10 @@ void setFullscreenMode(bool enable) {
isFullscreen = enable;
}

void setPlayBGM(bool enable) {
playBGM = enable;
}

void setLanguage(u32 language) {
m_language = language;
}
Expand Down Expand Up @@ -258,7 +283,7 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
main_window_geometry_w = w;
main_window_geometry_h = h;
}
void setGameInstallDir(const std::string& dir) {
void setGameInstallDir(const std::filesystem::path& dir) {
settings_install_dir = dir;
}
void setMainWindowTheme(u32 theme) {
Expand Down Expand Up @@ -314,7 +339,7 @@ u32 getMainWindowGeometryW() {
u32 getMainWindowGeometryH() {
return main_window_geometry_h;
}
std::string getGameInstallDir() {
std::filesystem::path getGameInstallDir() {
return settings_install_dir;
}
u32 getMainWindowTheme() {
Expand Down Expand Up @@ -369,7 +394,10 @@ void load(const std::filesystem::path& path) {
toml::value data;

try {
data = toml::parse(path);
std::ifstream ifs;
ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit);
ifs.open(path, std::ios_base::binary);
data = toml::parse(ifs, std::string{fmt::UTF(path.filename().u8string()).data});
} catch (std::exception& ex) {
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
return;
Expand All @@ -379,6 +407,7 @@ void load(const std::filesystem::path& path) {

isNeo = toml::find_or<bool>(general, "isPS4Pro", false);
isFullscreen = toml::find_or<bool>(general, "Fullscreen", false);
playBGM = toml::find_or<bool>(general, "playBGM", false);
logFilter = toml::find_or<std::string>(general, "logFilter", "");
logType = toml::find_or<std::string>(general, "logType", "sync");
userName = toml::find_or<std::string>(general, "userName", "shadPS4");
Expand Down Expand Up @@ -434,7 +463,7 @@ void load(const std::filesystem::path& path) {
mw_themes = toml::find_or<int>(gui, "theme", 0);
m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);
settings_install_dir = toml::find_or<std::string>(gui, "installDir", "");
settings_install_dir = toml::find_fs_path_or(gui, "installDir", {});
main_window_geometry_x = toml::find_or<int>(gui, "geometry_x", 0);
main_window_geometry_y = toml::find_or<int>(gui, "geometry_y", 0);
main_window_geometry_w = toml::find_or<int>(gui, "geometry_w", 0);
Expand All @@ -458,21 +487,24 @@ void save(const std::filesystem::path& path) {
std::error_code error;
if (std::filesystem::exists(path, error)) {
try {
data = toml::parse(path);
std::ifstream ifs;
ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit);
ifs.open(path, std::ios_base::binary);
data = toml::parse(ifs, std::string{fmt::UTF(path.filename().u8string()).data});
} catch (const std::exception& ex) {
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
return;
}
} else {
if (error) {
fmt::print("Filesystem error accessing {} (error: {})\n", path.string(),
error.message().c_str());
fmt::print("Filesystem error: {}\n", error.message());
}
fmt::print("Saving new configuration file {}\n", path.string());
fmt::print("Saving new configuration file {}\n", fmt::UTF(path.u8string()));
}

data["General"]["isPS4Pro"] = isNeo;
data["General"]["Fullscreen"] = isFullscreen;
data["General"]["playBGM"] = playBGM;
data["General"]["logFilter"] = logFilter;
data["General"]["logType"] = logType;
data["General"]["userName"] = userName;
Expand Down Expand Up @@ -504,7 +536,7 @@ void save(const std::filesystem::path& path) {
data["GUI"]["gameTableMode"] = m_table_mode;
data["GUI"]["mw_width"] = m_window_size_W;
data["GUI"]["mw_height"] = m_window_size_H;
data["GUI"]["installDir"] = settings_install_dir;
data["GUI"]["installDir"] = std::string{fmt::UTF(settings_install_dir.u8string()).data};
data["GUI"]["geometry_x"] = main_window_geometry_x;
data["GUI"]["geometry_y"] = main_window_geometry_y;
data["GUI"]["geometry_w"] = main_window_geometry_w;
Expand All @@ -524,6 +556,7 @@ void save(const std::filesystem::path& path) {
void setDefaultValues() {
isNeo = false;
isFullscreen = false;
playBGM = false;
screenWidth = 1280;
screenHeight = 720;
logFilter = "";
Expand All @@ -550,4 +583,4 @@ void setDefaultValues() {
gpuId = -1;
}

} // namespace Config
} // namespace Config
Loading

0 comments on commit 7d54e26

Please sign in to comment.