Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "thirdparty/ShaderRecomp"]
path = thirdparty/ShaderRecomp
url = https://github.com/hedge-dev/ShaderRecomp.git
[submodule "thirdparty/libmspack"]
path = thirdparty/libmspack
url = https://github.com/kyz/libmspack
33 changes: 31 additions & 2 deletions UnleashedRecomp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,30 @@ set(SWA_UI_CXX_SOURCES
"ui/window.cpp"
)

set(SWA_INSTALL_CXX_SOURCES
"install/installer.cpp"
"install/iso_file_system.cpp"
"install/memory_mapped_file.cpp"
"install/xcontent_file_system.cpp"
"install/xex_patcher.cpp"
"install/hashes/apotos_shamar.cpp"
"install/hashes/chunnan.cpp"
"install/hashes/empire_city_adabat.cpp"
"install/hashes/game.cpp"
"install/hashes/holoska.cpp"
"install/hashes/mazuri.cpp"
"install/hashes/spagonia.cpp"
"install/hashes/update.cpp"
)

set(LIBMSPACK_PATH ${SWA_THIRDPARTY_ROOT}/libmspack/libmspack/mspack)

set(LIBMSPACK_C_SOURCES
${LIBMSPACK_PATH}/lzxd.c
)

set_source_files_properties(${LIBMSPACK_C_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)

set(SMOLV_SOURCE_DIR "${SWA_THIRDPARTY_ROOT}/ShaderRecomp/thirdparty/smol-v/source")

set(SWA_CXX_SOURCES
Expand All @@ -95,7 +119,8 @@ set(SWA_CXX_SOURCES
${SWA_HID_CXX_SOURCES}
${SWA_PATCHES_CXX_SOURCES}
${SWA_UI_CXX_SOURCES}

${SWA_INSTALL_CXX_SOURCES}
${LIBMSPACK_C_SOURCES}
"${SMOLV_SOURCE_DIR}/smolv.cpp"
)

Expand Down Expand Up @@ -127,6 +152,7 @@ find_package(Stb REQUIRED)
find_package(unofficial-concurrentqueue REQUIRED)
find_package(imgui CONFIG REQUIRED)
find_package(magic_enum CONFIG REQUIRED)
find_package(unofficial-tiny-aes-c CONFIG REQUIRED)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/D3D12)
add_custom_command(TARGET UnleashedRecomp POST_BUILD
Expand Down Expand Up @@ -163,12 +189,15 @@ target_link_libraries(UnleashedRecomp PRIVATE
Synchronization
imgui::imgui
magic_enum::magic_enum
unofficial::tiny-aes-c::tiny-aes-c
)

target_include_directories(UnleashedRecomp PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/api
${SWA_THIRDPARTY_ROOT}/ddspp
${SWA_THIRDPARTY_ROOT}/ddspp
${SWA_THIRDPARTY_ROOT}/TinySHA1
${LIBMSPACK_PATH}
${Stb_INCLUDE_DIR}
${SMOLV_SOURCE_DIR}
)
Expand Down
65 changes: 65 additions & 0 deletions UnleashedRecomp/install/directory_file_system.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

#include <filesystem>

#include "virtual_file_system.h"

struct DirectoryFileSystem : VirtualFileSystem
{
std::filesystem::path directoryPath;

DirectoryFileSystem(const std::filesystem::path &directoryPath)
{
this->directoryPath = directoryPath;
}

bool load(const std::string &path, uint8_t *fileData, size_t fileDataMaxByteCount) const override
{
std::ifstream fileStream(directoryPath / std::filesystem::path(std::u8string_view((const char8_t *)(path.c_str()))), std::ios::binary);
if (fileStream.is_open())
{
fileStream.read((char *)(fileData), fileDataMaxByteCount);
return !fileStream.bad();
}
else
{
return false;
}
}

size_t getSize(const std::string &path) const override
{
std::error_code ec;
size_t fileSize = std::filesystem::file_size(directoryPath / std::filesystem::path(std::u8string_view((const char8_t *)(path.c_str()))), ec);
if (!ec)
{
return fileSize;
}
else
{
return 0;
}
}

bool exists(const std::string &path) const override
{
if (path.empty())
{
return false;
}

return std::filesystem::exists(directoryPath / std::filesystem::path(std::u8string_view((const char8_t *)(path.c_str()))));
}

static std::unique_ptr<VirtualFileSystem> create(const std::filesystem::path &directoryPath)
{
if (std::filesystem::exists(directoryPath))
{
return std::make_unique<DirectoryFileSystem>(directoryPath);
}
else
{
return nullptr;
}
}
};
Loading