Compare commits
4 Commits
pre-releas
...
main
Author | SHA1 | Date |
---|---|---|
|
1b1efbce6d | |
|
cdc4336ed5 | |
|
73f4e4b0f5 | |
|
54b75a869d |
|
@ -0,0 +1,4 @@
|
||||||
|
ln -s "C:\Users\Guus\AppData\LocalLow\Klei\Oxygen Not Included" Logs
|
||||||
|
ln -s "C:\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded" OxygenNotIncluded
|
||||||
|
ln -s "C:\Users\Guus\Documents\Klei\OxygenNotIncluded" OxygenNotIncludedData
|
||||||
|
ln -s "C:\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncluded_Data\Managed" Libs
|
|
@ -20,11 +20,11 @@ namespace PriorityUX {
|
||||||
|
|
||||||
public override void OnLoad(Harmony harmony) {
|
public override void OnLoad(Harmony harmony) {
|
||||||
Debug.Log("UX Mod Load");
|
Debug.Log("UX Mod Load");
|
||||||
Harmony.DEBUG = true;
|
// Harmony.DEBUG = true;
|
||||||
|
|
||||||
base.OnLoad(harmony);
|
base.OnLoad(harmony);
|
||||||
|
|
||||||
Debug.Log("UX Mod PostLoad base");
|
// Debug.Log("UX Mod PostLoad base");
|
||||||
|
|
||||||
PUtil.InitLibrary();
|
PUtil.InitLibrary();
|
||||||
LocString.CreateLocStringKeys(typeof(Strings.PRIORITYUX));
|
LocString.CreateLocStringKeys(typeof(Strings.PRIORITYUX));
|
||||||
|
|
|
@ -37,11 +37,11 @@ namespace PeterHan.PLib.Buildings {
|
||||||
private static void ApplyAlwaysOperational(GameObject go) {
|
private static void ApplyAlwaysOperational(GameObject go) {
|
||||||
// Remove default components that could make a building non-operational
|
// Remove default components that could make a building non-operational
|
||||||
if (go.TryGetComponent(out BuildingEnabledButton enabled))
|
if (go.TryGetComponent(out BuildingEnabledButton enabled))
|
||||||
Object.DestroyImmediate(enabled);
|
UnityEngine.Object.DestroyImmediate(enabled);
|
||||||
if (go.TryGetComponent(out Operational op))
|
if (go.TryGetComponent(out Operational op))
|
||||||
Object.DestroyImmediate(op);
|
UnityEngine.Object.DestroyImmediate(op);
|
||||||
if (go.TryGetComponent(out LogicPorts lp))
|
if (go.TryGetComponent(out LogicPorts lp))
|
||||||
Object.DestroyImmediate(lp);
|
UnityEngine.Object.DestroyImmediate(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
using System;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using KMod;
|
using KMod;
|
||||||
|
|
||||||
namespace PriorityUX {
|
namespace PriorityUX
|
||||||
|
{
|
||||||
[HarmonyDebug]
|
[HarmonyDebug]
|
||||||
[HarmonyPatch(typeof(Deconstructable))]
|
[HarmonyPatch(typeof(Deconstructable))]
|
||||||
public class DeconstructablePatches {
|
public class DeconstructablePatches
|
||||||
public static PrioritySetting getChorePriority() {
|
{
|
||||||
|
public static PrioritySetting getChorePriority()
|
||||||
|
{
|
||||||
Debug.Log("Getting deconstruct chore priority");
|
Debug.Log("Getting deconstruct chore priority");
|
||||||
if (Options.Instance.deconstructInheritPriority)
|
if (Options.Instance.deconstructInheritPriority)
|
||||||
return Utils.getLastPriority();
|
return Utils.getLastPriority();
|
||||||
|
@ -16,59 +20,63 @@ namespace PriorityUX {
|
||||||
return Utils.getDefaultPriority();
|
return Utils.getDefaultPriority();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(new Type[] { typeof(bool) })]
|
||||||
[HarmonyPatch("QueueDeconstruction")]
|
[HarmonyPatch("QueueDeconstruction")]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
static void QueueDeconstruction_Postfix(Deconstructable __instance) {
|
static void QueueDeconstruction_Postfix(Deconstructable __instance)
|
||||||
|
{
|
||||||
Prioritizable prioritizable = __instance.GetComponent<Prioritizable>();
|
Prioritizable prioritizable = __instance.GetComponent<Prioritizable>();
|
||||||
if (prioritizable != null) {
|
if (prioritizable != null)
|
||||||
|
{
|
||||||
Debug.Log("Updating deconstruct priority");
|
Debug.Log("Updating deconstruct priority");
|
||||||
prioritizable.SetMasterPriority(getChorePriority());
|
prioritizable.SetMasterPriority(getChorePriority());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
[HarmonyPatch("QueueDeconstruction")]
|
|
||||||
[HarmonyTranspiler]
|
|
||||||
static IEnumerable<CodeInstruction> QueueDeconstruction_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator ilGenerator) {
|
|
||||||
Harmony.DEBUG = true;
|
|
||||||
|
|
||||||
var priorityLocal = ilGenerator.DeclareLocal(typeof(int));
|
/*
|
||||||
var priorityClassLocal = ilGenerator.DeclareLocal(typeof(PriorityScreen.PriorityClass));
|
[HarmonyPatch("QueueDeconstruction")]
|
||||||
var tmpLocal0 = ilGenerator.DeclareLocal(typeof(int));
|
[HarmonyTranspiler]
|
||||||
var tmpLocal1 = ilGenerator.DeclareLocal(typeof(int));
|
static IEnumerable<CodeInstruction> QueueDeconstruction_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator ilGenerator) {
|
||||||
yield return CodeInstruction.Call(typeof(DeconstructablePatches), nameof(getChorePriority));
|
Harmony.DEBUG = true;
|
||||||
yield return new CodeInstruction(OpCodes.Dup);
|
|
||||||
// yield return new CodeInstruction(OpCodes.Pop);
|
|
||||||
// yield return new CodeInstruction(OpCodes.Pop);
|
|
||||||
yield return CodeInstruction.LoadField(typeof(PrioritySetting), nameof(PrioritySetting.priority_value));
|
|
||||||
yield return new CodeInstruction(OpCodes.Stloc, priorityLocal.LocalIndex);
|
|
||||||
yield return CodeInstruction.LoadField(typeof(PrioritySetting), nameof(PrioritySetting.priority_class));
|
|
||||||
yield return new CodeInstruction(OpCodes.Stloc, priorityClassLocal.LocalIndex);
|
|
||||||
|
|
||||||
ConstructorInfo choreConstructor = typeof(WorkChore<Deconstructable>).GetConstructors()[0];
|
var priorityLocal = ilGenerator.DeclareLocal(typeof(int));
|
||||||
// FieldInfo field = typeof(Deconstructable).GetField(nameof(Deconstructable.chore));
|
var priorityClassLocal = ilGenerator.DeclareLocal(typeof(PriorityScreen.PriorityClass));
|
||||||
foreach (var instruction in instructions) {
|
var tmpLocal0 = ilGenerator.DeclareLocal(typeof(int));
|
||||||
// IL_0087: ldc.i4.1
|
var tmpLocal1 = ilGenerator.DeclareLocal(typeof(int));
|
||||||
// IL_0088: ldc.i4.0 // priority_class
|
yield return CodeInstruction.Call(typeof(DeconstructablePatches), nameof(getChorePriority));
|
||||||
// IL_0089: ldc.i4.5 // priority_value
|
yield return new CodeInstruction(OpCodes.Dup);
|
||||||
// IL_008a: ldc.i4.1
|
// yield return new CodeInstruction(OpCodes.Pop);
|
||||||
// IL_008b: ldc.i4.1
|
// yield return new CodeInstruction(OpCodes.Pop);
|
||||||
// IL_008c: newobj instance void class WorkChore`1<class Deconstructable>::.ctor(class ChoreType, class ['Assembly-CSharp-firstpass']IStateMachineTarget, class ChoreProvider, bool, class [mscorlib]System.Action`1<class Chore>, class [mscorlib]System.Action`1<class Chore>, class [mscorlib]System.Action`1<class Chore>, bool, class ScheduleBlockType, bool, bool, class ['Assembly-CSharp-firstpass']KAnimFile, bool, bool, bool, valuetype PriorityScreen/PriorityClass, int32, bool, bool)
|
yield return CodeInstruction.LoadField(typeof(PrioritySetting), nameof(PrioritySetting.priority_value));
|
||||||
// IL_0091: stfld class Chore Deconstructable::chore
|
yield return new CodeInstruction(OpCodes.Stloc, priorityLocal.LocalIndex);
|
||||||
if (instruction.OperandIs(choreConstructor)) {
|
yield return CodeInstruction.LoadField(typeof(PrioritySetting), nameof(PrioritySetting.priority_class));
|
||||||
Debug.Log("PATCHING CHORE CONSTRUCTOR\n" + System.Environment.StackTrace);
|
yield return new CodeInstruction(OpCodes.Stloc, priorityClassLocal.LocalIndex);
|
||||||
yield return new CodeInstruction(OpCodes.Stloc, tmpLocal1.LocalIndex);
|
|
||||||
yield return new CodeInstruction(OpCodes.Stloc, tmpLocal0.LocalIndex);
|
ConstructorInfo choreConstructor = typeof(WorkChore<Deconstructable>).GetConstructors()[0];
|
||||||
yield return new CodeInstruction(OpCodes.Pop);
|
// FieldInfo field = typeof(Deconstructable).GetField(nameof(Deconstructable.chore));
|
||||||
yield return new CodeInstruction(OpCodes.Pop);
|
foreach (var instruction in instructions) {
|
||||||
yield return new CodeInstruction(OpCodes.Ldloc, priorityClassLocal.LocalIndex);
|
// IL_0087: ldc.i4.1
|
||||||
yield return new CodeInstruction(OpCodes.Ldloc, priorityLocal.LocalIndex);
|
// IL_0088: ldc.i4.0 // priority_class
|
||||||
yield return new CodeInstruction(OpCodes.Ldloc, tmpLocal0.LocalIndex);
|
// IL_0089: ldc.i4.5 // priority_value
|
||||||
yield return new CodeInstruction(OpCodes.Ldloc, tmpLocal1.LocalIndex);
|
// IL_008a: ldc.i4.1
|
||||||
|
// IL_008b: ldc.i4.1
|
||||||
|
// IL_008c: newobj instance void class WorkChore`1<class Deconstructable>::.ctor(class ChoreType, class ['Assembly-CSharp-firstpass']IStateMachineTarget, class ChoreProvider, bool, class [mscorlib]System.Action`1<class Chore>, class [mscorlib]System.Action`1<class Chore>, class [mscorlib]System.Action`1<class Chore>, bool, class ScheduleBlockType, bool, bool, class ['Assembly-CSharp-firstpass']KAnimFile, bool, bool, bool, valuetype PriorityScreen/PriorityClass, int32, bool, bool)
|
||||||
|
// IL_0091: stfld class Chore Deconstructable::chore
|
||||||
|
if (instruction.OperandIs(choreConstructor)) {
|
||||||
|
Debug.Log("PATCHING CHORE CONSTRUCTOR\n" + System.Environment.StackTrace);
|
||||||
|
yield return new CodeInstruction(OpCodes.Stloc, tmpLocal1.LocalIndex);
|
||||||
|
yield return new CodeInstruction(OpCodes.Stloc, tmpLocal0.LocalIndex);
|
||||||
|
yield return new CodeInstruction(OpCodes.Pop);
|
||||||
|
yield return new CodeInstruction(OpCodes.Pop);
|
||||||
|
yield return new CodeInstruction(OpCodes.Ldloc, priorityClassLocal.LocalIndex);
|
||||||
|
yield return new CodeInstruction(OpCodes.Ldloc, priorityLocal.LocalIndex);
|
||||||
|
yield return new CodeInstruction(OpCodes.Ldloc, tmpLocal0.LocalIndex);
|
||||||
|
yield return new CodeInstruction(OpCodes.Ldloc, tmpLocal1.LocalIndex);
|
||||||
|
yield return instruction;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
yield return instruction;
|
yield return instruction;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
yield return instruction;
|
} */
|
||||||
}
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,14 @@ namespace PriorityUX {
|
||||||
[HarmonyPatch(nameof(MaterialSelectionPanel.RefreshSelectors))]
|
[HarmonyPatch(nameof(MaterialSelectionPanel.RefreshSelectors))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
static void RefreshSelectorsPostfix(PriorityScreen ___priorityScreen) {
|
static void RefreshSelectorsPostfix(PriorityScreen ___priorityScreen) {
|
||||||
|
if (___priorityScreen == null) {
|
||||||
|
Debug.Log("RefreshSelectors ___priorityScreen is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Debug.Log("RefreshSelectors");
|
Debug.Log("RefreshSelectors");
|
||||||
Debug.Log("___priorityScreen.gameObject.activeSelf: " + ___priorityScreen.gameObject.activeSelf);
|
if (___priorityScreen.gameObject != null) {
|
||||||
|
Debug.Log("___priorityScreen.gameObject.activeSelf: " + ___priorityScreen.gameObject.activeSelf);
|
||||||
|
}
|
||||||
// if (___priorityScreen.gameObject.activeSelf)
|
// if (___priorityScreen.gameObject.activeSelf)
|
||||||
Utils.refreshPriorityScreen(___priorityScreen);
|
Utils.refreshPriorityScreen(___priorityScreen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,20 @@ namespace PriorityUX {
|
||||||
public static LocString TOOLTIP = "Used for reset and as a default priority";
|
public static LocString TOOLTIP = "Used for reset and as a default priority";
|
||||||
public static LocString CATEGORY = "Tweaks";
|
public static LocString CATEGORY = "Tweaks";
|
||||||
}
|
}
|
||||||
public static class ENABLEPRIORITYHOTKEYSEVERYWHERE {
|
public static class ENABLEKEYSFORBUILDING {
|
||||||
public static LocString NAME = "Enable priority keys everywhere";
|
public static LocString NAME = "Enable priority keys in the build menu";
|
||||||
public static LocString TOOLTIP = "Allows the 1-9 keys to select priority for all tools. Close the tool to open the building menus.";
|
public static LocString TOOLTIP = "Allows the 1-9 keys to select priority in the building menu. Close the tool to open the building menus.";
|
||||||
public static LocString CATEGORY = "Tweaks";
|
public static LocString CATEGORY = "Toggles";
|
||||||
|
}
|
||||||
|
public static class DECONSTRUCTINHERITPRIORITY {
|
||||||
|
public static LocString NAME = "Use last priority for deconstruction";
|
||||||
|
public static LocString TOOLTIP = "Use the last priority for deconstruction. If disabled, the default priority will be used every time the menu is opened.";
|
||||||
|
public static LocString CATEGORY = "Toggles";
|
||||||
|
}
|
||||||
|
public static class ENABLEKEYSFORALLTOOLS {
|
||||||
|
public static LocString NAME = "Enable priority keys for all tools";
|
||||||
|
public static LocString TOOLTIP = "Will enable the 1-9 keys for all tools.";
|
||||||
|
public static LocString CATEGORY = "Toggles";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
mod/build
13
mod/build
|
@ -1,15 +1,22 @@
|
||||||
#/bin/bash
|
#/bin/bash
|
||||||
|
|
||||||
msbuild=/Library/Frameworks/Mono.framework/Versions/6.12.0/bin/msbuild
|
msbuild=${msbuild:-/Library/Frameworks/Mono.framework/Versions/6.12.0/bin/msbuild}
|
||||||
|
|
||||||
ROOT=$( cd "$(dirname "$0")" ; pwd -P )
|
ROOT=$( cd "$(dirname "$0")" ; pwd -P )
|
||||||
pushd $ROOT
|
pushd $ROOT
|
||||||
|
|
||||||
# Do the build (need to use mono)
|
# Do the build (need to use mono)
|
||||||
$msbuild
|
# $msbuild
|
||||||
|
"$msbuild" -p:Configuration=Release
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
rm -rf dist
|
rm -rf dist
|
||||||
mkdir dist
|
mkdir dist
|
||||||
cp bin/Debug/net48/oni-prio.dll dist/
|
# cp bin/Debug/net48/oni-prio.dll dist/
|
||||||
|
cp bin/Release/net48/oni-prio.dll dist/
|
||||||
cp -r meta/* dist/
|
cp -r meta/* dist/
|
||||||
|
|
||||||
|
MODPATH=../OxygenNotIncludedData/mods/Local/PriorityUX
|
||||||
|
rm -rf $MODPATH
|
||||||
|
mkdir -p $MODPATH
|
||||||
|
cp dist/* $MODPATH
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net48</TargetFramework>
|
<TargetFramework>net48</TargetFramework>
|
||||||
<RootNamespace>oni_prio</RootNamespace>
|
<RootNamespace>oni_prio</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Assembly-CSharp-firstpass">
|
<Reference Include="Assembly-CSharp-firstpass">
|
||||||
|
|
|
@ -5,9 +5,9 @@ VisualStudioVersion = 17.0.31903.59
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "oni-prio", "mod\oni-prio.csproj", "{B5C0FB18-102D-434C-B8D7-2DDAE54367D6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "oni-prio", "mod\oni-prio.csproj", "{B5C0FB18-102D-434C-B8D7-2DDAE54367D6}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "reference\Assembly-CSharp.csproj", "{501D90AF-582D-4F90-9FE6-1479FBA92A4B}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "reference\Assembly-CSharp\Assembly-CSharp.csproj", "{501D90AF-582D-4F90-9FE6-1479FBA92A4B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-firstpass", "reference-firstpass\Assembly-CSharp-firstpass.csproj", "{F0AD7234-F5CE-4A5E-8E8A-F621F0B7C0A0}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-firstpass", "reference\Assembly-CSharp-firstpass\Assembly-CSharp-firstpass.csproj", "{F0AD7234-F5CE-4A5E-8E8A-F621F0B7C0A0}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
Loading…
Reference in New Issue