Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produce Native Reloaded-II Package in CI #39

Merged
merged 3 commits into from
Mar 31, 2024
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
71 changes: 60 additions & 11 deletions .github/workflows/create_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ on:
version:
description: 'Release version number'
required: true


defaults:
run:
shell: pwsh

jobs:
build:
runs-on: windows-latest
Expand All @@ -28,20 +32,65 @@ jobs:
repository: "ThirteenAG/Ultimate-ASI-Loader"
latest: true
fileName: "Ultimate-ASI-Loader_x64.zip"
- run: unzip Ultimate-ASI-Loader_x64.zip -d .\; echo [GlobalSets]`nDontLoadFromDllMain=0 > .\dsound.ini; C:\msys64\usr\bin\wget.exe -O .\UltimateASILoader_LICENSE.md https://raw.githubusercontent.com/ThirteenAG/Ultimate-ASI-Loader/master/license
- run: mkdir .\zip\Gamepass\P3R\Binaries\WinGDK; mkdir .\zip\Steam\P3R\Binaries\Win64

- name: Prepare Ultimate ASI Loader
run: |
unzip Ultimate-ASI-Loader_x64.zip -d .\
C:\msys64\usr\bin\wget.exe -O .\UltimateASILoader_LICENSE.md https://raw.githubusercontent.com/ThirteenAG/Ultimate-ASI-Loader/master/license

- name: Create Directory Structure
run: |
mkdir .\zip\Gamepass\P3R\Binaries\WinGDK
mkdir .\zip\Steam\P3R\Binaries\Win64
mkdir .\zip\Reloaded-II

# Xbox
- run: cp ${{ github.event.repository.name }}.asi .\zip\Gamepass\P3R\Binaries\WinGDK\; cp ${{ github.event.repository.name }}.ini .\zip\Gamepass\P3R\Binaries\WinGDK\
- run: cp dsound.ini .\zip\Gamepass\P3R\Binaries\WinGDK\; cp dinput8.dll .\zip\Gamepass\P3R\Binaries\WinGDK\dsound.dll; cp UltimateASILoader_LICENSE.md .\zip\Gamepass\P3R\Binaries\WinGDK\; New-Item -Path ".\zip\Gamepass\EXTRACT_TO_GAME_FOLDER" -ItemType File
- run: cd .\zip\Gamepass; 7z a -r -tzip ..\..\${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Xbox.zip .\*
- name: Prepare Xbox Files
run: |
cp ${{ github.event.repository.name }}.asi .\zip\Gamepass\P3R\Binaries\WinGDK\
cp ${{ github.event.repository.name }}.ini .\zip\Gamepass\P3R\Binaries\WinGDK\
cp dinput8.dll .\zip\Gamepass\P3R\Binaries\WinGDK\dsound.dll
cp UltimateASILoader_LICENSE.md .\zip\Gamepass\P3R\Binaries\WinGDK\
New-Item -Path ".\zip\Gamepass\EXTRACT_TO_GAME_FOLDER" -ItemType File

- name: Create Xbox Zip
run: |
cd .\zip\Gamepass
7z a -r -tzip ..\..\${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Xbox.zip .\*

# Steam
- run: cp ${{ github.event.repository.name }}.asi .\zip\Steam\P3R\Binaries\Win64\; cp ${{ github.event.repository.name }}.ini .\zip\Steam\P3R\Binaries\Win64\
- run: cp dsound.ini .\zip\Steam\P3R\Binaries\Win64\; cp dinput8.dll .\zip\Steam\P3R\Binaries\Win64\dsound.dll; cp UltimateASILoader_LICENSE.md .\zip\Steam\P3R\Binaries\Win64\; New-Item -Path ".\zip\Steam\EXTRACT_TO_GAME_FOLDER" -ItemType File
- run: cd .\zip\Steam; 7z a -r -tzip ..\..\${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Steam.zip .\*

- name: Prepare Steam Files
run: |
cp ${{ github.event.repository.name }}.asi .\zip\Steam\P3R\Binaries\Win64\
cp ${{ github.event.repository.name }}.ini .\zip\Steam\P3R\Binaries\Win64\
cp dinput8.dll .\zip\Steam\P3R\Binaries\Win64\dsound.dll
cp UltimateASILoader_LICENSE.md .\zip\Steam\P3R\Binaries\Win64\
New-Item -Path ".\zip\Steam\EXTRACT_TO_GAME_FOLDER" -ItemType File

- name: Create Steam Zip
run: |
cd .\zip\Steam
7z a -r -tzip ..\..\${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Steam.zip .\*

# Reloaded-II
- name: Prepare Reloaded-II Files
run: |
cp ${{ github.event.repository.name }}.asi .\zip\Reloaded-II\
cp ${{ github.event.repository.name }}.ini .\zip\Reloaded-II\
cp assets\r2-package\ModConfig.json .\zip\Reloaded-II\

$pathToJson = ".\zip\Reloaded-II\ModConfig.json"
$version = "${{ github.event.inputs.version }}".TrimStart('v') # Remove 'v' prefix from version
(Get-Content $pathToJson -Raw) -replace '<REPLACED_VERSION_IN_CI>', $version | Set-Content $pathToJson

- name: Create Reloaded-II Zip
run: |
cd .\zip\Reloaded-II
7z a -r -tzip ..\..\${{ github.event.repository.name }}_Reloaded-II.zip .\*

- uses: ncipollo/release-action@v1
with:
artifacts: "${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Steam.zip, ${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Xbox.zip"
artifacts: "${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Steam.zip, ${{ github.event.repository.name }}_${{ github.event.inputs.version }}_Xbox.zip, ${{ github.event.repository.name }}_Reloaded-II.zip"
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.version }}
name: "${{ github.event.inputs.version }}"
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,20 @@ This is a fix that adds custom resolutions, ultrawide support and more to Person
- Open up the game properties in Steam and add `WINEDLLOVERRIDES="dsound=n,b" %command%` to the launch options.

<details>
<summary>If you want to use Reloaded II mods alongside P3RFix</summary>
<summary>Installing P3RFix as a Reloaded II Mod</summary>

*This applies to both Windows and Steam Deck/Linux*

Note: Reloaded II **might not work** if you use the **Game Pass/MS Store version of P3R** (see [this page](https://gamebanana.com/tuts/17165) if you want help with that) so it's recommended to only follow these steps if you are using the Steam version.

Before starting, make sure to **delete any P3RFix files** inside of the game's files **if you have already have used this fix** previously (*P3RFix.ini*, *P3RFix.asi*, *dsound.ini* and *dsound.dll*)

To make sure P3RFix loads alongside any Reloaded II mods you are using, follow these steps:

- Set up Reloaded II and enable any mods you want as per the instructions on [GameBanana](https://gamebanana.com/tuts/17156).
- In Reloaded II go to *Edit Application*, *Advanced Tools & Options*, *Deploy ASI Loader*.
![asiloader_reloaded](https://github.com/Lyall/P3RFix/assets/695941/79ad9641-ee10-48b0-a04f-ecc72908ad83)
- Once this is done, open the game's binary folder (e.g. "**steamapps\common\P3R\P3R\Binaries\Win64**" for Steam).
- You should see a *scripts* folder which Reloaded II created when deploying the ASI Loader.
- Move *P3RFix.asi* into this folder.
- Install the P3RFix Reloaded-II package.
- ![pulse-browser_9bf87yUHiU](https://github.com/Lyall/P3RFix/assets/6697380/9a0b6bdf-ebda-45e2-a292-7858107c3435)

- Drag and drop `P3RFix_Reloaded-II.zip` onto the Reloaded-II window. (Alternatively: [Manual Install](https://reloaded-project.github.io/Reloaded-II/QuickStart/))

- Enable it in your `Reloaded-II` mod list.
- You should now be able to start the game and see both P3RFix and Reloaded II mods working.

</details>
Expand Down
33 changes: 33 additions & 0 deletions assets/r2-package/ModConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"ModId": "p3rpc.p3rfix",
"ModName": "P3RFix",
"ModAuthor": "Lyatt",
"ModVersion": "<REPLACED_VERSION_IN_CI>",
"ModDescription": "An \u0027Essentials\u0027 mod for P3R. Edit `P3RFix.ini` in Mod Folder to configure settings.",
"ModDll": "",
"ModIcon": "",
"ModR2RManagedDll32": "",
"ModR2RManagedDll64": "",
"ModNativeDll32": "",
"ModNativeDll64": "P3RFix.asi",
"Tags": [],
"CanUnload": null,
"HasExports": null,
"IsLibrary": false,
"ReleaseMetadataFileName": "p3rpc.p3rfix.ReleaseMetadata.json",
"PluginData": {
"GitHubRelease": {
"UserName": "Lyall",
"RepositoryName": "P3RFix",
"UseReleaseTag": true,
"AssetFileName": "P3RFix_Reloaded-II.zip"
}
},
"IsUniversalMod": false,
"ModDependencies": [],
"OptionalDependencies": [],
"SupportedAppId": [
"p3r.exe"
],
"ProjectUrl": "https://github.com/Lyall/P3RFix"
}
19 changes: 14 additions & 5 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <safetyhook.hpp>

HMODULE baseModule = GetModuleHandle(NULL);
HMODULE thisModule;

// Logger and config setup
inipp::Ini<char> ini;
Expand All @@ -16,6 +17,7 @@ string sLogFile = "P3RFix.log";
string sConfigFile = "P3RFix.ini";
string sExeName;
filesystem::path sExePath;
filesystem::path sThisModulePath;
std::pair DesktopDimensions = { 0,0 };

// Ini Variables
Expand Down Expand Up @@ -128,6 +130,12 @@ LRESULT __stdcall NewWndProc(HWND window, UINT message_type, WPARAM w_param, LPA

void Logging()
{
// Get this module path
WCHAR thisModulePath[_MAX_PATH] = { 0 };
GetModuleFileNameW(thisModule, thisModulePath, MAX_PATH);
sThisModulePath = thisModulePath;
sThisModulePath = sThisModulePath.remove_filename();

// Get game name and exe path
WCHAR exePath[_MAX_PATH] = { 0 };
GetModuleFileNameW(baseModule, exePath, MAX_PATH);
Expand All @@ -139,14 +147,14 @@ void Logging()
{
try
{
logger = spdlog::basic_logger_st(sFixName.c_str(), sExePath.string() + sLogFile, true);
logger = spdlog::basic_logger_st(sFixName.c_str(), sThisModulePath.string() + sLogFile, true);
spdlog::set_default_logger(logger);

spdlog::flush_on(spdlog::level::debug);
spdlog::info("----------");
spdlog::info("{} v{} loaded.", sFixName.c_str(), sFixVer.c_str());
spdlog::info("----------");
spdlog::info("Path to logfile: {}", sExePath.string() + sLogFile);
spdlog::info("Path to logfile: {}", sThisModulePath.string() + sLogFile);
spdlog::info("----------");

// Log module details
Expand All @@ -169,19 +177,19 @@ void Logging()
void ReadConfig()
{
// Initialise config
std::ifstream iniFile(sExePath.string() + sConfigFile);
std::ifstream iniFile(sThisModulePath.string() + sConfigFile);
if (!iniFile)
{
AllocConsole();
FILE* dummy;
freopen_s(&dummy, "CONOUT$", "w", stdout);
std::cout << "" << sFixName.c_str() << " v" << sFixVer.c_str() << " loaded." << std::endl;
std::cout << "ERROR: Could not locate config file." << std::endl;
std::cout << "ERROR: Make sure " << sConfigFile.c_str() << " is located in " << sExePath.string().c_str() << std::endl;
std::cout << "ERROR: Make sure " << sConfigFile.c_str() << " is located in " << sThisModulePath.string().c_str() << std::endl;
}
else
{
spdlog::info("Path to config file: {}", sExePath.string() + sConfigFile);
spdlog::info("Path to config file: {}", sThisModulePath.string() + sConfigFile);
ini.parse(iniFile);
}

Expand Down Expand Up @@ -753,6 +761,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
{
case DLL_PROCESS_ATTACH:
{
thisModule = hModule;
HANDLE mainHandle = CreateThread(NULL, 0, Main, 0, NULL, 0);
if (mainHandle)
{
Expand Down