Skip to content

Commit

Permalink
Commit code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ActualMandM committed Feb 5, 2024
1 parent b379e2f commit 2434662
Show file tree
Hide file tree
Showing 13 changed files with 1,077 additions and 0 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/reloaded.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Script to build and publish a Reloaded Mod.
# by Sewer56

# Produces:
# - Build to Upload to GameBanana
# - Build to Upload to GitHub
# - Build to Upload to NuGet
# - Changelog

# When pushing a tag
# - Upload to GitHub Releases
# - Upload to Reloaded NuGet Repository (if GitHub Secret RELOADED_NUGET_KEY is specified)

name: Build and Publish Reloaded Mod

on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
workflow_dispatch:

env:
PUBLISH_COMMON_PATH: ./Publish/ToUpload/

PUBLISH_GAMEBANANA_PATH: ./Publish/ToUpload/GameBanana
PUBLISH_GITHUB_PATH: ./Publish/ToUpload/Generic
PUBLISH_NUGET_PATH: ./Publish/ToUpload/NuGet

PUBLISH_CHANGELOG_PATH: ./Publish/Changelog.md
PUBLISH_PATH: ./Publish

RELOADEDIIMODS: .

# Default value is official Reloaded package server.
NUGET_URL: http://packages.sewer56.moe:5000/v3/index.json

IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }}
RELEASE_TAG: ${{ github.ref_name }}

jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: pwsh

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: 'recursive'

- name: Setup .NET Core SDK (5.0)
uses: actions/[email protected]
with:
dotnet-version: 5.0.x

- name: Setup .NET Core SDK (6.0)
uses: actions/[email protected]
with:
dotnet-version: 6.0.x

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Setup AutoChangelog
run: npm install -g auto-changelog

- name: Create Changelog
run: |
[System.IO.Directory]::CreateDirectory("$env:PUBLISH_PATH")
if ($env:IS_RELEASE -eq 'true') {
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --starting-version "$env:RELEASE_TAG" --output "$env:PUBLISH_CHANGELOG_PATH"
}
else {
auto-changelog --sort-commits date --hide-credit --template keepachangelog --commit-limit false --unreleased --output "$env:PUBLISH_CHANGELOG_PATH"
}
- name: Build
run: ./Publish.ps1 -ChangelogPath "$env:PUBLISH_CHANGELOG_PATH"

- name: Upload GitHub Release Artifact
uses: actions/[email protected]
with:
# Artifact name
name: GitHub Release
# A file, directory or wildcard pattern that describes what to upload
path: |
${{ env.PUBLISH_GITHUB_PATH }}/*
- name: Upload GameBanana Release Artifact
uses: actions/[email protected]
with:
# Artifact name
name: GameBanana Release
# A file, directory or wildcard pattern that describes what to upload
path: |
${{ env.PUBLISH_GAMEBANANA_PATH }}/*
- name: Upload NuGet Release Artifact
uses: actions/[email protected]
with:
# Artifact name
name: NuGet Release
# A file, directory or wildcard pattern that describes what to upload
path: |
${{ env.PUBLISH_NUGET_PATH }}/*
- name: Upload Changelog Artifact
uses: actions/[email protected]
with:
# Artifact name
name: Changelog
# A file, directory or wildcard pattern that describes what to upload
path: ${{ env.PUBLISH_CHANGELOG_PATH }}
retention-days: 0

- name: Upload to GitHub Releases (on Tag)
uses: softprops/[email protected]
if: env.IS_RELEASE == 'true'
with:
# Path to load note-worthy description of changes in release from
body_path: ${{ env.PUBLISH_CHANGELOG_PATH }}
# Newline-delimited list of path globs for asset files to upload
files: |
${{ env.PUBLISH_GITHUB_PATH }}/*
- name: Push to NuGet (on Tag)
env:
NUGET_KEY: ${{ secrets.RELOADED_NUGET_KEY }}
if: env.IS_RELEASE == 'true'
run: |
if ([string]::IsNullOrEmpty("$env:NUGET_KEY"))
{
Write-Host "NuGet Repository Key (GitHub Secrets -> RELOADED_NUGET_KEY) Not Specified. Skipping."
return
}
$items = Get-ChildItem -Path "$env:PUBLISH_NUGET_PATH/*.nupkg"
Foreach ($item in $items)
{
Write-Host "Pushing $item"
dotnet nuget push "$item" -k "$env:NUGET_KEY" -s "$env:NUGET_URL" --skip-duplicate
}
9 changes: 9 additions & 0 deletions BuildLinked.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set Working Directory
Split-Path $MyInvocation.MyCommand.Path | Push-Location
[Environment]::CurrentDirectory = $PWD

Remove-Item "$env:RELOADEDIIMODS/hifipc.nopillarbox/*" -Force -Recurse
dotnet publish "./hifipc.nopillarbox.csproj" -c Release -o "$env:RELOADEDIIMODS/hifipc.nopillarbox" /p:OutputPath="./bin/Release" /p:ReloadedILLink="true"

# Restore Working Directory
Pop-Location
77 changes: 77 additions & 0 deletions Mod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Reloaded.Hooks.ReloadedII.Interfaces;
using Reloaded.Memory.Interfaces;
using Reloaded.Memory.Sigscan;
using Reloaded.Memory;
using Reloaded.Mod.Interfaces;
using System.Diagnostics;
using hifipc.nopillarbox.Template;

namespace hifipc.nopillarbox
{
/// <summary>
/// Your mod logic goes here.
/// </summary>
public class Mod : ModBase // <= Do not Remove.
{
/// <summary>
/// Provides access to the mod loader API.
/// </summary>
private readonly IModLoader _modLoader;

/// <summary>
/// Provides access to the Reloaded.Hooks API.
/// </summary>
/// <remarks>This is null if you remove dependency on Reloaded.SharedLib.Hooks in your mod.</remarks>
private readonly IReloadedHooks? _hooks;

/// <summary>
/// Provides access to the Reloaded logger.
/// </summary>
private readonly ILogger _logger;

/// <summary>
/// Entry point into the mod, instance that created this class.
/// </summary>
private readonly IMod _owner;

/// <summary>
/// The configuration of the currently executing mod.
/// </summary>
private readonly IModConfig _modConfig;

public Mod(ModContext context)
{
_modLoader = context.ModLoader;
_hooks = context.Hooks;
_logger = context.Logger;
_owner = context.Owner;
_modConfig = context.ModConfig;

var currentProcess = Process.GetCurrentProcess();
var mainModule = currentProcess.MainModule;

var scanner = new Scanner(currentProcess, mainModule);
var res = scanner.FindPattern("F6 41 30 01 45 0F 29 43 ??");
if (res.Found)
{
nint address = mainModule!.BaseAddress + res.Offset;

_logger.WriteLineAsync($"[{_modConfig.ModId}] Signature found at 0x{address:X}");

Memory.Instance.SafeWrite(
(nuint)(address + 3), new byte[] { 0x00 }
);
}
else
{
_logger.WriteLineAsync($"[{_modConfig.ModId}] Signature not found, mod will not work!", System.Drawing.Color.Red);
}
}

#region For Exports, Serialization etc.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public Mod() { }
#pragma warning restore CS8618
#endregion
}
}
23 changes: 23 additions & 0 deletions ModConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"ModId": "hifipc.nopillarbox",
"ModName": "Pillar/Letter Box Removal",
"ModAuthor": "M&M",
"ModVersion": "1.0.0",
"ModDescription": "Removes the pillar/letter boxing from certain scenes and all cutscenes. Will cause some visual issues.",
"ModDll": "hifipc.nopillarbox.dll",
"ModIcon": "Preview.png",
"ModR2RManagedDll32": "x86/hifipc.nopillarbox.dll",
"ModR2RManagedDll64": "x64/hifipc.nopillarbox.dll",
"ModNativeDll32": "",
"ModNativeDll64": "",
"IsLibrary": false,
"ReleaseMetadataFileName": "hifipc.nopillarbox.ReleaseMetadata.json",
"PluginData": {},
"IsUniversalMod": false,
"ModDependencies": [ "reloaded.sharedlib.hooks" ],
"OptionalDependencies": [],
"SupportedAppId": [
"hi-fi-rush.exe"
],
"ProjectUrl": ""
}
Binary file added Preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2434662

Please sign in to comment.