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
17 changes: 9 additions & 8 deletions .github/workflows/deploy-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ jobs:
sed -i "s/{VERSION_NUMBER}/${{ steps.semantic-release.outputs.new_release_version }}/" ./S1API/S1API.cs
sed -i "s/{VERSION_NUMBER}/${{ steps.semantic-release.outputs.new_release_version }}/" ./S1APILoader/S1APILoader.cs

- name: Run .NET build for MonoBepInEx
run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1

- name: Run .NET build for Il2CppBepInEx
run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0
# TODO (@MaxtorCoder): Temporarily disabling until BepInEx is building properly locally.
# - name: Run .NET build for MonoBepInEx
# run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1
#
# - name: Run .NET build for Il2CppBepInEx
# run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0

- name: Run .NET build for MonoMelon
run: dotnet build ./S1API.sln -c MonoMelon -f netstandard2.1
Expand All @@ -72,11 +73,11 @@ jobs:
run: |
mkdir -p ./artifacts/thunderstore/Plugins/S1API
cp ./S1APILoader/bin/MonoMelon/netstandard2.1/S1APILoader.dll ./artifacts/thunderstore/Plugins/S1APILoader.MelonLoader.dll
cp ./S1APILoader/bin/MonoBepInEx/netstandard2.1/S1APILoader.dll ./artifacts/thunderstore/Plugins/S1APILoader.BepInEx.dll
# cp ./S1APILoader/bin/MonoBepInEx/netstandard2.1/S1APILoader.dll ./artifacts/thunderstore/Plugins/S1APILoader.BepInEx.dll
cp ./S1API/bin/Il2CppMelon/net6.0/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Il2Cpp.MelonLoader.dll
cp ./S1API/bin/MonoMelon/netstandard2.1/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Mono.MelonLoader.dll
cp ./S1API/bin/Il2CppMelon/net6.0/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Il2Cpp.BepInEx.dll
cp ./S1API/bin/MonoMelon/netstandard2.1/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Mono.BepInEx.dll
# cp ./S1API/bin/Il2CppMelon/net6.0/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Il2Cpp.BepInEx.dll
# cp ./S1API/bin/MonoMelon/netstandard2.1/S1API.dll ./artifacts/thunderstore/Plugins/S1API/S1API.Mono.BepInEx.dll

- name: Publish artifact to Thunderstore
uses: GreenTF/upload-thunderstore-package@v4.3
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/verify-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ jobs:

- name: Restore .NET Dependencies
run: dotnet restore

- name: Run .NET build for MonoBepInEx
run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1

- name: Run .NET build for Il2CppBepInEx
run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0

# TODO (@MaxtorCoder): Temporarily disabling until BepInEx is building properly locally.
# - name: Run .NET build for MonoBepInEx
# run: dotnet build ./S1API.sln -c MonoBepInEx -f netstandard2.1
#
# - name: Run .NET build for Il2CppBepInEx
# run: dotnet build ./S1API.sln -c Il2CppBepInEx -f net6.0

- name: Run .NET build for MonoMelon
run: dotnet build ./S1API.sln -c MonoMelon -f netstandard2.1
Expand Down
61 changes: 61 additions & 0 deletions S1API/Internal/Patches/HomeScreen.Start.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using HarmonyLib;
using UnityEngine.SceneManagement;
using S1API.Internal.Utils;
using S1API.Internal.Abstraction;
using S1API.PhoneApp;
using S1API.Logging;

#if (IL2CPPMELON || IL2CPPBEPINEX)
using Il2CppScheduleOne.UI.Phone;
#else
using ScheduleOne.UI.Phone;
#endif

namespace S1API.Internal.Patches
{
/// <summary>
/// A Harmony patch for the Start method of the HomeScreen class, facilitating the registration and initialization of PhoneApps.
/// </summary>
[HarmonyPatch(typeof(HomeScreen), "Start")]
internal static class HomeScreen_Start_Patch
{
/// <summary>
/// A logging instance used for handling log messages pertaining to PhoneApp registration
/// and operations. Provides methods to log messages with different severity levels such
/// as Info, Warning, Error, and Fatal.
/// </summary>
private static readonly Log Logger = new Log("PhoneApp");

/// <summary>
/// Executes after the HomeScreen's Start method to handle the registration
/// and initialization of PhoneApps.
/// </summary>
/// <param name="__instance">The HomeScreen instance being targeted in the patch.</param>
static void Postfix(HomeScreen __instance)
{
if (__instance == null)
return;

// Re-register all PhoneApps
var phoneApps = ReflectionUtils.GetDerivedClasses<PhoneApp.PhoneApp>();
foreach (var type in phoneApps)
{
if (type.GetConstructor(Type.EmptyTypes) == null)
continue;

try
{
var instance = (PhoneApp.PhoneApp)Activator.CreateInstance(type)!;
((IRegisterable)instance).CreateInternal();
instance.SpawnUI(__instance);
instance.SpawnIcon(__instance);
}
catch (Exception e)
{
Logger.Warning($"[PhoneApp] Failed to register {type.FullName}: {e.Message}");
}
}
}
}
}
50 changes: 0 additions & 50 deletions S1API/Internal/Patches/PhoneAppPatches.cs

This file was deleted.

36 changes: 36 additions & 0 deletions S1API/Internal/Patches/PhoneAppRegistry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Collections.Generic;

namespace S1API.Internal.Patches
{
/// <summary>
/// Provides functionality for managing the registration of custom phone applications.
/// </summary>
/// <remarks>
/// This static class serves as a registry for tracking instances of phone applications.
/// Applications are added to a centralized list which can then be used for initialization or
/// interacting with registered applications at runtime.
/// </remarks>
internal static class PhoneAppRegistry
{
/// <summary>
/// A static readonly list that stores instances of phone applications registered via the <c>PhoneAppRegistry</c>.
/// </summary>
/// <remarks>
/// This list holds all registered instances of <see cref="PhoneApp"/> objects. Applications are added to this collection
/// whenever they are registered using the <c>PhoneAppRegistry.Register</c> method, which is typically called automatically
/// during the application's lifecycle.
/// It serves as a central repository for all in-game phone applications, enabling other systems to access and manage
/// these registered apps efficiently.
/// </remarks>
public static readonly List<PhoneApp.PhoneApp> RegisteredApps = new List<PhoneApp.PhoneApp>();

/// <summary>
/// Registers a specified phone app into the phone application registry.
/// </summary>
/// <param name="app">The PhoneApp instance to be registered.</param>
public static void Register(PhoneApp.PhoneApp app)
{
RegisteredApps.Add(app);
}
}
}
Loading