mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-27 16:09:07 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime;
|
||||
using RRUI;
|
||||
using RRUI.Data;
|
||||
using UnityEngine;
|
||||
|
||||
internal static class DynamicUiPrefabRepair
|
||||
{
|
||||
private static bool reportedMissing;
|
||||
|
||||
internal static void Apply(Harmony harmony)
|
||||
{
|
||||
harmony.Patch(AccessTools.PropertyGetter(typeof(DynamicUIConfig), "Instance"),
|
||||
postfix: new HarmonyMethod(typeof(DynamicUiPrefabRepair), nameof(Repair)));
|
||||
}
|
||||
|
||||
private static void Repair(DynamicUIConfig __result)
|
||||
{
|
||||
if (__result == null) return;
|
||||
var standard = __result.DynamicFloatPrefab_MultiSelectConfig;
|
||||
var pro = __result.DynamicProUXFloatPrefab_MultiSelectConfig;
|
||||
var fallback = Compatible(standard) ? standard : Compatible(pro) ? pro : null;
|
||||
if (fallback == null)
|
||||
{
|
||||
if (!reportedMissing)
|
||||
{
|
||||
reportedMissing = true;
|
||||
RadicadeEacBypassPlugin.LogSource.LogWarning(
|
||||
"[DynamicUI] No compatible multi-select float prefab is available; leaving the missing mapping visible.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
_ = __result.LandscapePrefabsByType;
|
||||
_ = __result.PortraitPrefabsByType;
|
||||
_ = __result.ProUXPrefabsByType;
|
||||
RepairMap(__result.landscapePrefabsByType, fallback, "landscape");
|
||||
RepairMap(__result.portraitPrefabsByType, fallback, "portrait");
|
||||
RepairMap(__result.proUXPrefabsByType, fallback, "ProUX");
|
||||
}
|
||||
|
||||
private static bool Compatible(GameObject prefab) => prefab != null &&
|
||||
prefab.GetComponentInChildren<DynamicFloatInputFieldModelController_MultiSelectConfig>(true) != null;
|
||||
|
||||
private static void RepairMap(Il2CppSystem.Collections.Generic.Dictionary<Il2CppSystem.Type, GameObject> map,
|
||||
GameObject fallback, string layout)
|
||||
{
|
||||
if (map == null) return;
|
||||
var key = Il2CppType.Of<JNHHEBGEAMP>();
|
||||
if (map.ContainsKey(key) && map[key] != null) return;
|
||||
map[key] = fallback;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user