mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-08 20:53:28 +08:00
more fixes to make sure nothing working wrong on game
This commit is contained in:
@@ -295,7 +295,7 @@ public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(DysonSwarm), "GameTick")]
|
[HarmonyPatch(typeof(DysonSwarm), nameof(DysonSwarm.GameTick))]
|
||||||
public static void DysonSwarm_GameTick_Prefix(DysonSwarm __instance, long time)
|
public static void DysonSwarm_GameTick_Prefix(DysonSwarm __instance, long time)
|
||||||
{
|
{
|
||||||
var index = __instance.starData.index;
|
var index = __instance.starData.index;
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(StorageComponent), "GetItemCount", typeof(int))]
|
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.GetItemCount), typeof(int))]
|
||||||
public static void GetItemCountPatch(StorageComponent __instance, int itemId, ref int __result)
|
public static void GetItemCountPatch(StorageComponent __instance, int itemId, ref int __result)
|
||||||
{
|
{
|
||||||
if (__result > 99) return;
|
if (__result > 99) return;
|
||||||
|
|||||||
@@ -64,19 +64,19 @@ public static class GamePatch
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyBeforeGameSave")]
|
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyBeforeGameSave))]
|
||||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnAssemblerRecipePick")]
|
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnAssemblerRecipePick))]
|
||||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnGameBegin")]
|
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnGameBegin))]
|
||||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnMechaForgeTaskComplete")]
|
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnMechaForgeTaskComplete))]
|
||||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnUnlockTech")]
|
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnUnlockTech))]
|
||||||
[HarmonyPatch(typeof(AbnormalityLogic), "NotifyOnUseConsole")]
|
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.NotifyOnUseConsole))]
|
||||||
private static bool DisableAbnormalLogic()
|
private static bool DisableAbnormalLogic()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(AbnormalityLogic), "InitDeterminators")]
|
[HarmonyPatch(typeof(AbnormalityLogic), nameof(AbnormalityLogic.InitDeterminators))]
|
||||||
private static void DisableAbnormalDeterminators(AbnormalityLogic __instance)
|
private static void DisableAbnormalDeterminators(AbnormalityLogic __instance)
|
||||||
{
|
{
|
||||||
_savedDeterminators = __instance.determinators;
|
_savedDeterminators = __instance.determinators;
|
||||||
|
|||||||
@@ -62,18 +62,18 @@ public static class ResourcePatch
|
|||||||
private class FastMining : PatchImpl<FastMining>
|
private class FastMining : PatchImpl<FastMining>
|
||||||
{
|
{
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))]
|
[HarmonyPatch(typeof(FactorySystem), nameof(FactorySystem.GameTick), typeof(long), typeof(bool))]
|
||||||
[HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), typeof(int))]
|
[HarmonyPatch(typeof(FactorySystem), nameof(FactorySystem.GameTick), typeof(long), typeof(bool), typeof(int), typeof(int), typeof(int))]
|
||||||
[HarmonyPatch(typeof(ItemProto), "GetPropValue")]
|
[HarmonyPatch(typeof(ItemProto), nameof(ItemProto.GetPropValue))]
|
||||||
[HarmonyPatch(typeof(PlanetTransport), "GameTick")]
|
[HarmonyPatch(typeof(PlanetTransport), nameof(PlanetTransport.GameTick))]
|
||||||
[HarmonyPatch(typeof(UIMinerWindow), "_OnUpdate")]
|
[HarmonyPatch(typeof(UIMinerWindow), nameof(UIMinerWindow._OnUpdate))]
|
||||||
[HarmonyPatch(typeof(UIMiningUpgradeLabel), "Update")]
|
[HarmonyPatch(typeof(UIMiningUpgradeLabel), nameof(UIMiningUpgradeLabel.Update))]
|
||||||
[HarmonyPatch(typeof(UIPlanetDetail), "OnPlanetDataSet")]
|
[HarmonyPatch(typeof(UIPlanetDetail), nameof(UIPlanetDetail.OnPlanetDataSet))]
|
||||||
[HarmonyPatch(typeof(UIPlanetDetail), "RefreshDynamicProperties")]
|
[HarmonyPatch(typeof(UIPlanetDetail), nameof(UIPlanetDetail.RefreshDynamicProperties))]
|
||||||
[HarmonyPatch(typeof(UIStarDetail), "OnStarDataSet")]
|
[HarmonyPatch(typeof(UIStarDetail), nameof(UIStarDetail.OnStarDataSet))]
|
||||||
[HarmonyPatch(typeof(UIStarDetail), "RefreshDynamicProperties")]
|
[HarmonyPatch(typeof(UIStarDetail), nameof(UIStarDetail.RefreshDynamicProperties))]
|
||||||
[HarmonyPatch(typeof(UIStationStorage), "RefreshValues")]
|
[HarmonyPatch(typeof(UIStationStorage), nameof(UIStationStorage.RefreshValues))]
|
||||||
[HarmonyPatch(typeof(UIVeinCollectorPanel), "_OnUpdate")]
|
[HarmonyPatch(typeof(UIVeinCollectorPanel), nameof(UIVeinCollectorPanel._OnUpdate))]
|
||||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
{
|
{
|
||||||
var matcher = new CodeMatcher(instructions, generator);
|
var matcher = new CodeMatcher(instructions, generator);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class HideTips : BaseUnityPlugin
|
|||||||
class HideMenuDemo
|
class HideMenuDemo
|
||||||
{
|
{
|
||||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(DSPGame), "StartDemoGame", typeof(int))]
|
[HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartDemoGame), typeof(int))]
|
||||||
private static bool DSPGame_StartDemoGame_Prefix()
|
private static bool DSPGame_StartDemoGame_Prefix()
|
||||||
{
|
{
|
||||||
if (DSPGame.Game != null)
|
if (DSPGame.Game != null)
|
||||||
@@ -188,7 +188,7 @@ class HideMenuDemo
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(VFPreload), "IsMenuDemoLoaded")]
|
[HarmonyPatch(typeof(VFPreload), nameof(VFPreload.IsMenuDemoLoaded))]
|
||||||
private static bool VFPreload_IsMenuDemoLoaded_Prefix(ref bool __result)
|
private static bool VFPreload_IsMenuDemoLoaded_Prefix(ref bool __result)
|
||||||
{
|
{
|
||||||
__result = true;
|
__result = true;
|
||||||
@@ -196,18 +196,18 @@ class HideMenuDemo
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(DSPGame), "LateUpdate")]
|
[HarmonyPatch(typeof(DSPGame), nameof(DSPGame.LateUpdate))]
|
||||||
[HarmonyPatch(typeof(GameMain), "LateUpdate")]
|
[HarmonyPatch(typeof(GameMain), nameof(GameMain.LateUpdate))]
|
||||||
[HarmonyPatch(typeof(GameMain), "FixedUpdate")]
|
[HarmonyPatch(typeof(GameMain), nameof(GameMain.FixedUpdate))]
|
||||||
[HarmonyPatch(typeof(GameMain), "Update")]
|
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Update))]
|
||||||
[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
|
[HarmonyPatch(typeof(GameCamera), nameof(GameCamera.LateUpdate))]
|
||||||
private static bool DSPGame_LateUpdate_Prefix()
|
private static bool DSPGame_LateUpdate_Prefix()
|
||||||
{
|
{
|
||||||
return !DSPGame.IsMenuDemo;
|
return !DSPGame.IsMenuDemo;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
[HarmonyPriority(Priority.First), HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(GameMain), "Begin")]
|
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||||
private static bool GameMain_Begin_Prefix()
|
private static bool GameMain_Begin_Prefix()
|
||||||
{
|
{
|
||||||
if (!DSPGame.IsMenuDemo) return true;
|
if (!DSPGame.IsMenuDemo) return true;
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ public static class WinApi
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
int CountBitsSet(ulong mask)
|
static int CountBitsSet(ulong mask)
|
||||||
{
|
{
|
||||||
var count = 0;
|
var count = 0;
|
||||||
while (mask != 0)
|
while (mask != 0)
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(StarSimulator), "LateUpdate")]
|
[HarmonyPatch(typeof(StarSimulator), nameof(StarSimulator.LateUpdate))]
|
||||||
private static IEnumerable<CodeInstruction> StarSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
private static IEnumerable<CodeInstruction> StarSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
{
|
{
|
||||||
var matcher = new CodeMatcher(instructions, generator);
|
var matcher = new CodeMatcher(instructions, generator);
|
||||||
@@ -384,7 +384,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(PlanetSimulator), "LateUpdate")]
|
[HarmonyPatch(typeof(PlanetSimulator), nameof(PlanetSimulator.LateUpdate))]
|
||||||
private static IEnumerable<CodeInstruction> PlanetSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
private static IEnumerable<CodeInstruction> PlanetSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
{
|
{
|
||||||
// var vec = (NightlightEnabled ? GameMain.mainPlayer.transform.up : (Quaternion.Inverse(localPlanet.runtimeRotation) * (__instance.planetData.star.uPosition - __instance.planetData.uPosition).normalized));
|
// var vec = (NightlightEnabled ? GameMain.mainPlayer.transform.up : (Quaternion.Inverse(localPlanet.runtimeRotation) * (__instance.planetData.star.uPosition - __instance.planetData.uPosition).normalized));
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
public static ConfigEntry<bool> EnableWindowResizeEnabled;
|
public static ConfigEntry<bool> EnableWindowResizeEnabled;
|
||||||
public static ConfigEntry<bool> LoadLastWindowRectEnabled;
|
public static ConfigEntry<bool> LoadLastWindowRectEnabled;
|
||||||
|
|
||||||
public static ConfigEntry<int> MouseCursorScaleUpMultiplier;
|
|
||||||
|
|
||||||
// public static ConfigEntry<bool> AutoSaveOptEnabled;
|
// public static ConfigEntry<bool> AutoSaveOptEnabled;
|
||||||
public static ConfigEntry<bool> ConvertSavesFromPeaceEnabled;
|
public static ConfigEntry<bool> ConvertSavesFromPeaceEnabled;
|
||||||
public static ConfigEntry<Vector4> LastWindowRect;
|
public static ConfigEntry<Vector4> LastWindowRect;
|
||||||
@@ -87,11 +85,6 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
FixLastWindowRect();
|
FixLastWindowRect();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
MouseCursorScaleUpMultiplier.SettingChanged += (_, _) =>
|
|
||||||
{
|
|
||||||
MouseCursorScaleUp.NeedReloadCursors = true;
|
|
||||||
MouseCursorScaleUp.Enable(MouseCursorScaleUpMultiplier.Value > 1);
|
|
||||||
};
|
|
||||||
// AutoSaveOptEnabled.SettingChanged += (_, _) => AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
// AutoSaveOptEnabled.SettingChanged += (_, _) => AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
||||||
ConvertSavesFromPeaceEnabled.SettingChanged += (_, _) => ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
ConvertSavesFromPeaceEnabled.SettingChanged += (_, _) => ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
||||||
ProfileBasedSaveFolderEnabled.SettingChanged += (_, _) => RefreshSavePath();
|
ProfileBasedSaveFolderEnabled.SettingChanged += (_, _) => RefreshSavePath();
|
||||||
@@ -123,8 +116,6 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
|
EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
|
||||||
MouseCursorScaleUp.NeedReloadCursors = false;
|
|
||||||
MouseCursorScaleUp.Enable(MouseCursorScaleUpMultiplier.Value > 1);
|
|
||||||
// AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
// AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
|
||||||
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
|
||||||
Enable(true);
|
Enable(true);
|
||||||
@@ -136,8 +127,6 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
{
|
{
|
||||||
Enable(false);
|
Enable(false);
|
||||||
EnableWindowResize.Enable(false);
|
EnableWindowResize.Enable(false);
|
||||||
MouseCursorScaleUp.NeedReloadCursors = false;
|
|
||||||
MouseCursorScaleUp.Enable(false);
|
|
||||||
// AutoSaveOpt.Enable(false);
|
// AutoSaveOpt.Enable(false);
|
||||||
ConvertSavesFromPeace.Enable(false);
|
ConvertSavesFromPeace.Enable(false);
|
||||||
}
|
}
|
||||||
@@ -160,7 +149,7 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPriority(Priority.First)]
|
[HarmonyPriority(Priority.First)]
|
||||||
[HarmonyPatch(typeof(GameConfig), "gameSaveFolder", MethodType.Getter)]
|
[HarmonyPatch(typeof(GameConfig), nameof(GameConfig.gameSaveFolder), MethodType.Getter)]
|
||||||
public static void GameConfig_gameSaveFolder_Postfix(ref string __result)
|
public static void GameConfig_gameSaveFolder_Postfix(ref string __result)
|
||||||
{
|
{
|
||||||
if (!ProfileBasedSaveFolderEnabled.Value || string.IsNullOrEmpty(WindowFunctions.ProfileName)) return;
|
if (!ProfileBasedSaveFolderEnabled.Value || string.IsNullOrEmpty(WindowFunctions.ProfileName)) return;
|
||||||
@@ -298,7 +287,7 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
var matcher = new CodeMatcher(instructions, generator);
|
var matcher = new CodeMatcher(instructions, generator);
|
||||||
var label1 = generator.DefineLabel();
|
var label1 = generator.DefineLabel();
|
||||||
matcher.MatchForward(false,
|
matcher.MatchForward(false,
|
||||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Screen), nameof(Screen.SetResolution), [typeof(int), typeof(int), typeof(bool), typeof(int)]))
|
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Screen), nameof(Screen.SetResolution), [typeof(int), typeof(int), typeof(FullScreenMode), typeof(RefreshRate)]))
|
||||||
).Advance(1).Labels.Add(label1);
|
).Advance(1).Labels.Add(label1);
|
||||||
matcher.Start().Insert(
|
matcher.Start().Insert(
|
||||||
Transpilers.EmitDelegate(() =>
|
Transpilers.EmitDelegate(() =>
|
||||||
@@ -601,131 +590,4 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchSetCallbackFlag(PatchCallbackFlag.CallOnDisableAfterUnpatch)]
|
|
||||||
private class MouseCursorScaleUp : PatchImpl<MouseCursorScaleUp>
|
|
||||||
{
|
|
||||||
public static bool NeedReloadCursors;
|
|
||||||
|
|
||||||
protected override void OnEnable()
|
|
||||||
{
|
|
||||||
if (!NeedReloadCursors) return;
|
|
||||||
if (!UICursor.loaded) return;
|
|
||||||
UICursor.loaded = false;
|
|
||||||
UICursor.LoadCursors();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnDisable()
|
|
||||||
{
|
|
||||||
if (!NeedReloadCursors) return;
|
|
||||||
if (!UICursor.loaded) return;
|
|
||||||
UICursor.loaded = false;
|
|
||||||
UICursor.LoadCursors();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyTranspiler]
|
|
||||||
[HarmonyPatch(typeof(UICursor), nameof(UICursor.LoadCursors))]
|
|
||||||
private static IEnumerable<CodeInstruction> UICursor_LoadCursors_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
|
||||||
{
|
|
||||||
var matcher = new CodeMatcher(instructions, generator);
|
|
||||||
/*
|
|
||||||
matcher.MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Ldc_I4_S),
|
|
||||||
new CodeMatch(OpCodes.Newarr)
|
|
||||||
);
|
|
||||||
var startPos = matcher.Pos;
|
|
||||||
matcher.Advance(2).MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Stsfld, AccessTools.Field(typeof(UICursor), nameof(UICursor.cursorTexs)))
|
|
||||||
);
|
|
||||||
var endPos = matcher.Pos + 1;
|
|
||||||
matcher.Start().Advance(startPos).RemoveInstructions(endPos - startPos);
|
|
||||||
matcher.InsertAndAdvance(
|
|
||||||
Transpilers.EmitDelegate(() =>
|
|
||||||
{
|
|
||||||
var pluginfolder = Util.PluginFolder;
|
|
||||||
UICursor.cursorTexs =
|
|
||||||
[
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-transfer.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-target-in.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-target-out.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-target-a.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-target-b.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-ban.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-delete.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-reform.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-dyson-node-create.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-painter.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-eyedropper.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-eraser.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-upgrade.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-downgrade.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-blank.png"),
|
|
||||||
Util.LoadTexture($"{pluginfolder}/assets/cursor/cursor-remove.png")
|
|
||||||
];
|
|
||||||
})
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
matcher.MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Stsfld, AccessTools.Field(typeof(UICursor), nameof(UICursor.cursorHots))),
|
|
||||||
new CodeMatch(OpCodes.Ldc_I4_1),
|
|
||||||
new CodeMatch(OpCodes.Stsfld, AccessTools.Field(typeof(UICursor), nameof(UICursor.loaded)))
|
|
||||||
).Advance(1).InsertAndAdvance(
|
|
||||||
Transpilers.EmitDelegate(() =>
|
|
||||||
{
|
|
||||||
var multiplier = MouseCursorScaleUpMultiplier.Value;
|
|
||||||
for (var i = 0; i < UICursor.cursorTexs.Length; i++)
|
|
||||||
{
|
|
||||||
var cursor = UICursor.cursorTexs[i];
|
|
||||||
if (cursor == null) continue;
|
|
||||||
var newWidth = 32 * multiplier;
|
|
||||||
var newHeight = 32 * multiplier;
|
|
||||||
if (cursor.width == newWidth && cursor.height == newHeight) continue;
|
|
||||||
UICursor.cursorTexs[i] = ResizeTexture2D(cursor, newWidth, newHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (multiplier <= 1) return;
|
|
||||||
for (var i = UICursor.cursorHots.Length - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
UICursor.cursorHots[i] = new Vector2(UICursor.cursorHots[i].x * multiplier, UICursor.cursorHots[i].y * multiplier);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
).MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
|
||||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Cursor), nameof(Cursor.SetCursor), [typeof(Texture2D), typeof(Vector2), typeof(CursorMode)]))
|
|
||||||
).SetInstruction(new CodeInstruction(OpCodes.Ldc_I4_1));
|
|
||||||
return matcher.InstructionEnumeration();
|
|
||||||
|
|
||||||
Texture2D ResizeTexture2D(Texture2D texture2D, int targetWidth, int targetHeight)
|
|
||||||
{
|
|
||||||
var oldActive = RenderTexture.active;
|
|
||||||
var rt = new RenderTexture(targetWidth, targetHeight, 32)
|
|
||||||
{
|
|
||||||
antiAliasing = 8
|
|
||||||
};
|
|
||||||
RenderTexture.active = rt;
|
|
||||||
Graphics.Blit(texture2D, rt);
|
|
||||||
rt.ResolveAntiAliasedSurface();
|
|
||||||
var result = new Texture2D(targetWidth, targetHeight, texture2D.format, false);
|
|
||||||
result.ReadPixels(new Rect(0, 0, targetWidth, targetHeight), 0, 0);
|
|
||||||
result.filterMode = FilterMode.Trilinear;
|
|
||||||
result.Apply();
|
|
||||||
RenderTexture.active = oldActive;
|
|
||||||
rt.Release();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyTranspiler]
|
|
||||||
[HarmonyPatch(typeof(UICursor), nameof(UICursor.cursorIndexApply), MethodType.Setter)]
|
|
||||||
private static IEnumerable<CodeInstruction> UICursor_set_cursorIndexApply_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
|
||||||
{
|
|
||||||
var matcher = new CodeMatcher(instructions, generator);
|
|
||||||
matcher.Start().MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Ldc_I4_0),
|
|
||||||
new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(Cursor), nameof(Cursor.SetCursor), [typeof(Texture2D), typeof(Vector2), typeof(CursorMode)]))
|
|
||||||
).SetInstruction(new CodeInstruction(OpCodes.Ldc_I4_1));
|
|
||||||
return matcher.InstructionEnumeration();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -850,7 +850,7 @@ public static class LogisticsPatch
|
|||||||
|
|
||||||
var sliderBgPrefab = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Station Window/storage-box-0/slider-bg");
|
var sliderBgPrefab = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Station Window/storage-box-0/slider-bg");
|
||||||
|
|
||||||
_tipPrefab = Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Scene UIs/Vein Marks/vein-tip-prefab"), _stationTipsRoot.transform);
|
_tipPrefab = Object.Instantiate(GameObject.Find("UI Root/Overlay Canvas/In Game/Scene UIs/Vein Marks/vein-tips/vein-tip-prefab"), _stationTipsRoot.transform);
|
||||||
_tipPrefab.name = "tipPrefab";
|
_tipPrefab.name = "tipPrefab";
|
||||||
Object.Destroy(_tipPrefab.GetComponent<UIVeinDetailNode>());
|
Object.Destroy(_tipPrefab.GetComponent<UIVeinDetailNode>());
|
||||||
var image = _tipPrefab.GetComponent<Image>();
|
var image = _tipPrefab.GetComponent<Image>();
|
||||||
|
|||||||
@@ -41,29 +41,6 @@ public class PersistPatch : PatchImpl<PersistPatch>
|
|||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch to fix the issue that warning popup on VeinUtil upgraded to level 8000+
|
|
||||||
[HarmonyTranspiler]
|
|
||||||
[HarmonyPatch(typeof(ABN_VeinsUtil), nameof(ABN_VeinsUtil.CheckValue))]
|
|
||||||
private static IEnumerable<CodeInstruction> ABN_VeinsUtil_CheckValue_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
|
||||||
{
|
|
||||||
var matcher = new CodeMatcher(instructions, generator);
|
|
||||||
matcher.MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Ldelem_R8),
|
|
||||||
new CodeMatch(OpCodes.Conv_R4),
|
|
||||||
new CodeMatch(OpCodes.Add),
|
|
||||||
new CodeMatch(OpCodes.Stloc_1)
|
|
||||||
);
|
|
||||||
// loc1 = Mathf.Round(n * 1000f) / 1000f;
|
|
||||||
matcher.Advance(3).Insert(
|
|
||||||
new CodeInstruction(OpCodes.Ldc_R4, 1000f),
|
|
||||||
new CodeInstruction(OpCodes.Mul),
|
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Mathf), nameof(Mathf.Round))),
|
|
||||||
new CodeInstruction(OpCodes.Ldc_R4, 1000f),
|
|
||||||
new CodeInstruction(OpCodes.Div)
|
|
||||||
);
|
|
||||||
return matcher.InstructionEnumeration();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bring popup tip window to top layer
|
// Bring popup tip window to top layer
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(UIButton), nameof(UIButton.LateUpdate))]
|
[HarmonyPatch(typeof(UIButton), nameof(UIButton.LateUpdate))]
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ public abstract class MyWindowManager
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
//_Create -> _Init
|
//_Create -> _Init
|
||||||
[HarmonyPostfix, HarmonyPatch(typeof(UIGame), "_OnCreate")]
|
[HarmonyPostfix, HarmonyPatch(typeof(UIGame), nameof(UIGame._OnCreate))]
|
||||||
public static void UIGame__OnCreate_Postfix()
|
public static void UIGame__OnCreate_Postfix()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -638,7 +638,7 @@ public abstract class MyWindowManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
[HarmonyPostfix, HarmonyPatch(typeof(UIGame), "_OnFree")]
|
[HarmonyPostfix, HarmonyPatch(typeof(UIGame), nameof(UIGame._OnFree))]
|
||||||
public static void UIGame__OnFree_Postfix()
|
public static void UIGame__OnFree_Postfix()
|
||||||
{
|
{
|
||||||
foreach (var win in Windows)
|
foreach (var win in Windows)
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public static class UIConfigWindow
|
|||||||
I18N.Add("Tech/Combat/UI", "Tech/Combat/UI", "科研/战斗/UI");
|
I18N.Add("Tech/Combat/UI", "Tech/Combat/UI", "科研/战斗/UI");
|
||||||
I18N.Add("Enable game window resize", "Enable game window resize (maximum box and thick frame)", "可调整游戏窗口大小(可最大化和拖动边框)");
|
I18N.Add("Enable game window resize", "Enable game window resize (maximum box and thick frame)", "可调整游戏窗口大小(可最大化和拖动边框)");
|
||||||
I18N.Add("Remeber window position and size on last exit", "Remeber window position and size on last exit", "记住上次退出时的窗口位置和大小");
|
I18N.Add("Remeber window position and size on last exit", "Remeber window position and size on last exit", "记住上次退出时的窗口位置和大小");
|
||||||
I18N.Add("Scale up mouse cursor", "Scale up mouse cursor", "放大鼠标指针");
|
|
||||||
/*
|
/*
|
||||||
I18N.Add("Better auto-save mechanism", "Better auto-save mechanism", "更好的自动存档机制");
|
I18N.Add("Better auto-save mechanism", "Better auto-save mechanism", "更好的自动存档机制");
|
||||||
I18N.Add("Better auto-save mechanism tips", "Auto saves are stored in 'Save\\AutoSaves' folder, filenames are combined with cluster address and date-time", "自动存档会以星区地址和日期时间组合为文件名存储在'Save\\AutoSaves'文件夹中");
|
I18N.Add("Better auto-save mechanism tips", "Auto saves are stored in 'Save\\AutoSaves' folder, filenames are combined with cluster address and date-time", "自动存档会以星区地址和日期时间组合为文件名存储在'Save\\AutoSaves'文件夹中");
|
||||||
@@ -294,6 +293,7 @@ public static class UIConfigWindow
|
|||||||
|
|
||||||
private static void CreateUI(MyConfigWindow wnd, RectTransform trans)
|
private static void CreateUI(MyConfigWindow wnd, RectTransform trans)
|
||||||
{
|
{
|
||||||
|
UnityEngine.UI.Text txt;
|
||||||
_windowTrans = trans;
|
_windowTrans = trans;
|
||||||
wnd.AddTabGroup(trans, "UXAssist", "tab-group-uxassist");
|
wnd.AddTabGroup(trans, "UXAssist", "tab-group-uxassist");
|
||||||
var tab1 = wnd.AddTab(trans, "General");
|
var tab1 = wnd.AddTab(trans, "General");
|
||||||
@@ -302,9 +302,6 @@ public static class UIConfigWindow
|
|||||||
wnd.AddCheckBox(x, y, tab1, GamePatch.EnableWindowResizeEnabled, "Enable game window resize");
|
wnd.AddCheckBox(x, y, tab1, GamePatch.EnableWindowResizeEnabled, "Enable game window resize");
|
||||||
y += 36f;
|
y += 36f;
|
||||||
wnd.AddCheckBox(x, y, tab1, GamePatch.LoadLastWindowRectEnabled, "Remeber window position and size on last exit");
|
wnd.AddCheckBox(x, y, tab1, GamePatch.LoadLastWindowRectEnabled, "Remeber window position and size on last exit");
|
||||||
y += 36f;
|
|
||||||
var txt = wnd.AddText2(x + 2f, y, tab1, "Scale up mouse cursor", 15, "text-scale-up-mouse-cursor");
|
|
||||||
wnd.AddSlider(x + txt.preferredWidth + 7f, y + 6f, tab1, GamePatch.MouseCursorScaleUpMultiplier, [1, 2, 3, 4], "0x", 100f);
|
|
||||||
/*
|
/*
|
||||||
y += 30f;
|
y += 30f;
|
||||||
wnd.AddCheckBox(x, y, tab1, GamePatch.AutoSaveOptEnabled, "Better auto-save mechanism");
|
wnd.AddCheckBox(x, y, tab1, GamePatch.AutoSaveOptEnabled, "Better auto-save mechanism");
|
||||||
|
|||||||
@@ -69,8 +69,6 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
"Load last window position and size when game starts");
|
"Load last window position and size when game starts");
|
||||||
GamePatch.LastWindowRect = Config.Bind("Game", "LastWindowRect", new Vector4(0f, 0f, 0f, 0f),
|
GamePatch.LastWindowRect = Config.Bind("Game", "LastWindowRect", new Vector4(0f, 0f, 0f, 0f),
|
||||||
"Last window position and size");
|
"Last window position and size");
|
||||||
GamePatch.MouseCursorScaleUpMultiplier = Config.Bind("Game", "MouseCursorScaleUpMultiplier", 1,
|
|
||||||
"Mouse cursor scale up multiplier");
|
|
||||||
GamePatch.ProfileBasedSaveFolderEnabled = Config.Bind("Game", "ProfileBasedSaveFolder", false,
|
GamePatch.ProfileBasedSaveFolderEnabled = Config.Bind("Game", "ProfileBasedSaveFolder", false,
|
||||||
"Profile-based save folder");
|
"Profile-based save folder");
|
||||||
GamePatch.ProfileBasedOptionEnabled = Config.Bind("Game", "ProfileBasedOption", false,
|
GamePatch.ProfileBasedOptionEnabled = Config.Bind("Game", "ProfileBasedOption", false,
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public static class EpicDifficulty
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(GameDesc), "get_oilAmountMultiplier")]
|
[HarmonyPatch(typeof(GameDesc), nameof(GameDesc.oilAmountMultiplier), MethodType.Getter)]
|
||||||
private static IEnumerable<CodeInstruction> GameDesc_get_oilAmountMultiplier_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
private static IEnumerable<CodeInstruction> GameDesc_get_oilAmountMultiplier_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
{
|
{
|
||||||
var matcher = new CodeMatcher(instructions, generator);
|
var matcher = new CodeMatcher(instructions, generator);
|
||||||
|
|||||||
Reference in New Issue
Block a user