mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 00:53:39 +08:00
WIP for UXAssist new features
This commit is contained in:
@@ -29,4 +29,11 @@ public static class KeyBindings
|
||||
|
||||
return new CombineKey((int)shortcut.MainKey, mod, ECombineKeyAction.OnceClick, false);
|
||||
}
|
||||
|
||||
public static bool IsKeyPressing(this PressKeyBind keyBind)
|
||||
{
|
||||
var defBind = keyBind.defaultBind;
|
||||
var overrideKey = VFInput.override_keys[defBind.id];
|
||||
return overrideKey.IsNull() ? defBind.key.GetKey() : overrideKey.GetKey();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,25 +27,27 @@ public class PatchSetCallbackFlagAttribute(PatchCallbackFlag flag) : Attribute
|
||||
|
||||
public class PatchImpl<T> where T : PatchImpl<T>, new()
|
||||
{
|
||||
private static T Instance { get; } = new();
|
||||
protected static T Instance { get; } = new();
|
||||
|
||||
private Harmony _patch;
|
||||
protected Harmony _patch;
|
||||
|
||||
public static void Enable(bool enable)
|
||||
{
|
||||
var thisInstance = Instance;
|
||||
if (enable)
|
||||
{
|
||||
if (thisInstance._patch != null) return;
|
||||
var guid = typeof(T).GetCustomAttribute<PatchGuidAttribute>()?.Guid ?? $"PatchImpl.{typeof(T).FullName ?? typeof(T).ToString()}";
|
||||
var callOnEnableBefore = typeof(T).GetCustomAttributes<PatchSetCallbackFlagAttribute>().Any(n => n.Flag == PatchCallbackFlag.CallOnEnableBeforePatch);
|
||||
if (callOnEnableBefore) thisInstance.OnEnable();
|
||||
thisInstance._patch ??= Harmony.CreateAndPatchAll(typeof(T), guid);
|
||||
thisInstance._patch = Harmony.CreateAndPatchAll(typeof(T), guid);
|
||||
if (!callOnEnableBefore) thisInstance.OnEnable();
|
||||
return;
|
||||
}
|
||||
if (thisInstance._patch == null) return;
|
||||
var callOnDisableAfter = typeof(T).GetCustomAttributes<PatchSetCallbackFlagAttribute>().Any(n => n.Flag == PatchCallbackFlag.CallOnDisableAfterUnpatch);
|
||||
if (!callOnDisableAfter) thisInstance.OnDisable();
|
||||
thisInstance._patch?.UnpatchSelf();
|
||||
thisInstance._patch.UnpatchSelf();
|
||||
thisInstance._patch = null;
|
||||
if (callOnDisableAfter) thisInstance.OnDisable();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
public static ConfigEntry<bool> TankFastFillInAndTakeOutEnabled;
|
||||
public static ConfigEntry<int> TankFastFillInAndTakeOutMultiplier;
|
||||
public static ConfigEntry<bool> CutConveyorBeltEnabled;
|
||||
public static ConfigEntry<bool> TweakBuildingBufferEnabled;
|
||||
public static ConfigEntry<int> ReceiverBufferCount;
|
||||
public static ConfigEntry<int> AssemblerBufferTimeMultiplier;
|
||||
public static ConfigEntry<int> AssemblerBufferMininumMultiplier;
|
||||
|
||||
private static PressKeyBind _doNotRenderEntitiesKey;
|
||||
private static PressKeyBind _offgridfForPathsKey;
|
||||
private static PressKeyBind _cutConveyorBeltKey;
|
||||
@@ -89,8 +94,12 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
DragBuildPowerPolesAlternatelyEnabled.SettingChanged += (_, _) => DragBuildPowerPoles.AlternatelyChanged();
|
||||
BeltSignalsForBuyOutEnabled.SettingChanged += (_, _) => BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
|
||||
TankFastFillInAndTakeOutEnabled.SettingChanged += (_, _) => TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
|
||||
TankFastFillInAndTakeOutMultiplier.SettingChanged += (_, _) => { UpdateTankFastFillInAndTakeOutMultiplierRealValue(); };
|
||||
TankFastFillInAndTakeOutMultiplier.SettingChanged += (_, _) => UpdateTankFastFillInAndTakeOutMultiplierRealValue();
|
||||
CutConveyorBeltEnabled.SettingChanged += (_, _) => CutConveyorBelt.Enable(CutConveyorBeltEnabled.Value);
|
||||
TweakBuildingBufferEnabled.SettingChanged += (_, _) => TweakBuildingBuffer.Enable(TweakBuildingBufferEnabled.Value);
|
||||
AssemblerBufferTimeMultiplier.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshAssemblerBufferMultipliers();
|
||||
AssemblerBufferMininumMultiplier.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshAssemblerBufferMultipliers();
|
||||
ReceiverBufferCount.SettingChanged += (_, _) => TweakBuildingBuffer.RefreshReceiverBufferCount();
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
@@ -110,6 +119,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
BeltSignalsForBuyOut.Enable(BeltSignalsForBuyOutEnabled.Value);
|
||||
TankFastFillInAndTakeOut.Enable(TankFastFillInAndTakeOutEnabled.Value);
|
||||
CutConveyorBelt.Enable(CutConveyorBeltEnabled.Value);
|
||||
TweakBuildingBuffer.Enable(TweakBuildingBufferEnabled.Value);
|
||||
|
||||
Enable(true);
|
||||
UpdateTankFastFillInAndTakeOutMultiplierRealValue();
|
||||
@@ -119,6 +129,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
{
|
||||
Enable(false);
|
||||
|
||||
TweakBuildingBuffer.Enable(false);
|
||||
CutConveyorBelt.Enable(false);
|
||||
TankFastFillInAndTakeOut.Enable(false);
|
||||
BeltSignalsForBuyOut.Enable(false);
|
||||
@@ -705,13 +716,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private static bool CheckOffgridForPathsKeyPressed()
|
||||
{
|
||||
ref var bind = ref _offgridfForPathsKey.defaultBind;
|
||||
ref var key = ref VFInput.override_keys[bind.id];
|
||||
return key.IsNull() ? bind.key.GetKey() : key.GetKey();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.UpdateRaycast))]
|
||||
public static IEnumerable<CodeInstruction> AllowOffGridConstructionForPath(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
@@ -736,7 +740,8 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
var jmp0 = generator.DefineLabel();
|
||||
var jmp1 = generator.DefineLabel();
|
||||
matcher.InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(OffGridBuilding), nameof(CheckOffgridForPathsKeyPressed))),
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(FactoryPatch), nameof(_offgridfForPathsKey))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(KeyBindings), nameof(KeyBindings.IsKeyPressing))),
|
||||
new CodeInstruction(OpCodes.Brfalse, jmp0),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
@@ -1963,12 +1968,10 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
|
||||
private class CutConveyorBelt : PatchImpl<CutConveyorBelt>
|
||||
{
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlayerController), nameof(PlayerController.GameTick))]
|
||||
private static void PlayerController_GameTick_Postfix(PlayerController __instance)
|
||||
{
|
||||
if (DSPGame.IsMenuDemo) return;
|
||||
if (!_cutConveyorBeltKey.keyValue) return;
|
||||
var raycast = __instance.cmd.raycast;
|
||||
if (raycast == null) return;
|
||||
@@ -1979,4 +1982,83 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
Functions.FactoryFunctions.CutConveyorBelt(cargoTraffic, beltId);
|
||||
}
|
||||
}
|
||||
|
||||
private class TweakBuildingBuffer : PatchImpl<TweakBuildingBuffer>
|
||||
{
|
||||
public static void RefreshReceiverBufferCount()
|
||||
{
|
||||
if (!TweakBuildingBufferEnabled.Value) return;
|
||||
/* re-patch to use new value */
|
||||
var patch = Instance._patch;
|
||||
patch.Unpatch(AccessTools.Method(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.GameTick_Gamma)), AccessTools.Method(typeof(TweakBuildingBuffer), nameof(PowerGeneratorComponent_GameTick_Gamma_Transpiler)));
|
||||
patch.Patch(AccessTools.Method(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.GameTick_Gamma)), null, null, new HarmonyMethod(typeof(TweakBuildingBuffer), nameof(PowerGeneratorComponent_GameTick_Gamma_Transpiler)));
|
||||
}
|
||||
|
||||
public static void RefreshAssemblerBufferMultipliers()
|
||||
{
|
||||
if (!TweakBuildingBufferEnabled.Value) return;
|
||||
/* re-patch to use new value */
|
||||
var patch = Instance._patch;
|
||||
patch.Unpatch(AccessTools.Method(typeof(AssemblerComponent), nameof(AssemblerComponent.UpdateNeeds)), AccessTools.Method(typeof(TweakBuildingBuffer), nameof(AssemblerComponent_UpdateNeeds_Transpiler)));
|
||||
patch.Patch(AccessTools.Method(typeof(AssemblerComponent), nameof(AssemblerComponent.UpdateNeeds)), null, null, new HarmonyMethod(typeof(TweakBuildingBuffer), nameof(AssemblerComponent_UpdateNeeds_Transpiler)));
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.GameTick_Gamma))]
|
||||
private static IEnumerable<CodeInstruction> PowerGeneratorComponent_GameTick_Gamma_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
/*
|
||||
* Patch:
|
||||
* bool flag3 = keyFrame && useIon && (float)this.catalystPoint < 72000f;
|
||||
* To:
|
||||
* bool flag3 = keyFrame && useIon && this.catalystPoint < 3600 * ReceiverBufferCount.Value;
|
||||
*/
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PowerGeneratorComponent), nameof(PowerGeneratorComponent.catalystPoint))),
|
||||
new CodeMatch(OpCodes.Conv_R4),
|
||||
new CodeMatch(OpCodes.Ldc_R4, 72000f),
|
||||
new CodeMatch(OpCodes.Clt)
|
||||
);
|
||||
matcher.Advance(2).RemoveInstructions(2).Insert(new CodeInstruction(OpCodes.Ldc_I4, ReceiverBufferCount.Value * 3600));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(AssemblerComponent), nameof(AssemblerComponent.UpdateNeeds))]
|
||||
private static IEnumerable<CodeInstruction> AssemblerComponent_UpdateNeeds_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
/*
|
||||
* Patch:
|
||||
* int num2 = this.speedOverride * 180 / this.timeSpend + 1;
|
||||
* if (num2 < 2)
|
||||
* {
|
||||
* num2 = 2;
|
||||
* }
|
||||
* To:
|
||||
* int num2 = this.speedOverride * 60 * (AssemblerBufferTimeMultiplier.Value - 1) * 60 / this.timeSpend + 1;
|
||||
* if (num2 < AssemblerBufferMininumMultiplier.Value)
|
||||
* {
|
||||
* num2 = AssemblerBufferMininumMultiplier.Value;
|
||||
* }
|
||||
*/
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldarg_0),
|
||||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(AssemblerComponent), nameof(AssemblerComponent.speedOverride))),
|
||||
new CodeMatch(OpCodes.Ldc_I4, 180),
|
||||
new CodeMatch(OpCodes.Mul)
|
||||
);
|
||||
matcher.Advance(2).Operand = (AssemblerBufferTimeMultiplier.Value - 1) * 60;
|
||||
matcher.Advance(2).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ldc_I4_2),
|
||||
new CodeMatch(ci => ci.opcode == OpCodes.Bge_S || ci.opcode == OpCodes.Bge),
|
||||
new CodeMatch(OpCodes.Ldc_I4_2)
|
||||
);
|
||||
matcher.Operand = AssemblerBufferMininumMultiplier.Value;
|
||||
matcher.Advance(2).Operand = AssemblerBufferMininumMultiplier.Value;
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using UXAssist.Common;
|
||||
|
||||
namespace UXAssist.Patches;
|
||||
|
||||
public static class PlayerPatch
|
||||
public class PlayerPatch: PatchImpl<PlayerPatch>
|
||||
{
|
||||
public static ConfigEntry<bool> EnhancedMechaForgeCountControlEnabled;
|
||||
public static ConfigEntry<bool> HideTipsForSandsChangesEnabled;
|
||||
@@ -17,6 +17,7 @@ public static class PlayerPatch
|
||||
public static ConfigEntry<bool> AutoBoostEnabled;
|
||||
public static ConfigEntry<double> DistanceToWarp;
|
||||
private static PressKeyBind _autoDriveKey;
|
||||
private static PressKeyBind _showAllAstrosNameKey;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
@@ -27,8 +28,20 @@ public static class PlayerPatch
|
||||
name = "ToggleAutoCruise",
|
||||
canOverride = true
|
||||
});
|
||||
I18N.Add("KEYToggleAutoCruise", "Toggle auto-cruise", "切换自动巡航");
|
||||
I18N.Add("AutoCruiseOn", "Auto-cruise enabled", "已启用自动巡航");
|
||||
I18N.Add("AutoCruiseOff", "Auto-cruise disabled", "已禁用自动巡航");
|
||||
|
||||
_showAllAstrosNameKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
|
||||
{
|
||||
key = new CombineKey(0, CombineKey.ALT_COMB, ECombineKeyAction.OnceClick, false),
|
||||
conflictGroup = KeyBindConflict.UI | KeyBindConflict.KEYBOARD_KEYBIND,
|
||||
name = "ShowAllAstrosName",
|
||||
canOverride = true
|
||||
}
|
||||
);
|
||||
I18N.Add("KEYShowAllAstrosName", "Keep pressing to show all astros' name", "按住显示所有星球名称");
|
||||
|
||||
EnhancedMechaForgeCountControlEnabled.SettingChanged += (_, _) => EnhancedMechaForgeCountControl.Enable(EnhancedMechaForgeCountControlEnabled.Value);
|
||||
HideTipsForSandsChangesEnabled.SettingChanged += (_, _) => HideTipsForSandsChanges.Enable(HideTipsForSandsChangesEnabled.Value);
|
||||
AutoNavigationEnabled.SettingChanged += (_, _) => AutoNavigation.Enable(AutoNavigationEnabled.Value);
|
||||
@@ -39,6 +52,7 @@ public static class PlayerPatch
|
||||
EnhancedMechaForgeCountControl.Enable(EnhancedMechaForgeCountControlEnabled.Value);
|
||||
HideTipsForSandsChanges.Enable(HideTipsForSandsChangesEnabled.Value);
|
||||
AutoNavigation.Enable(AutoNavigationEnabled.Value);
|
||||
Enable(true);
|
||||
}
|
||||
|
||||
public static void OnUpdate()
|
||||
@@ -51,11 +65,32 @@ public static class PlayerPatch
|
||||
|
||||
public static void Uninit()
|
||||
{
|
||||
Enable(false);
|
||||
EnhancedMechaForgeCountControl.Enable(false);
|
||||
HideTipsForSandsChanges.Enable(false);
|
||||
AutoNavigation.Enable(false);
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(UIStarmapStar), nameof(UIStarmapStar._OnLateUpdate))]
|
||||
private static IEnumerable<CodeInstruction> UIStarmapStar__OnLateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
Label? br = null;
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(UIStarmapStar), nameof(UIStarmapStar.projectedCoord))),
|
||||
new CodeMatch(ci => ci.IsLdloc()),
|
||||
new CodeMatch(ci => ci.Branches(out br))
|
||||
);
|
||||
matcher.Advance(3);
|
||||
matcher.InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(PlayerPatch), nameof(_showAllAstrosNameKey))),
|
||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(KeyBindings), nameof(KeyBindings.IsKeyPressing))),
|
||||
new CodeInstruction(OpCodes.Brtrue, br.Value)
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
private class EnhancedMechaForgeCountControl: PatchImpl<EnhancedMechaForgeCountControl>
|
||||
{
|
||||
[HarmonyTranspiler]
|
||||
|
||||
@@ -271,6 +271,12 @@ public class MyWindow : ManualBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public class RangeValueMapper<T>(int min, int max) : ValueMapper<T>
|
||||
{
|
||||
public override int Min => min;
|
||||
public override int Max => max;
|
||||
}
|
||||
|
||||
public MySlider AddSlider<T>(float x, float y, RectTransform parent, ConfigEntry<T> config, ValueMapper<T> valueMapper, string format = "G", float width = 0f)
|
||||
{
|
||||
var slider = MySlider.CreateSlider(x, y, parent, OnConfigValueChanged(config), valueMapper.Min, valueMapper.Max, format, width);
|
||||
|
||||
@@ -89,6 +89,10 @@ public static class UIConfigWindow
|
||||
"打开面板时自动将鼠标指向物品设为筛选条件\n在控制面板物流塔列表中右键点击物品图标快速设置为筛选条件");
|
||||
I18N.Add("Real-time logistic stations info panel", "Real-time logistic stations info panel", "物流运输站实时信息面板");
|
||||
I18N.Add("Show status bars for storage items", "Show status bars for storage items", "显示存储物品状态条");
|
||||
I18N.Add("Tweak building buffers", "Tweak building buffers", "调整建筑输入缓冲");
|
||||
I18N.Add("Assembler buffer time multiplier(in seconds)", "Assembler buffer time multiplier(in seconds)", "工厂配方缓冲时间倍率(秒)");
|
||||
I18N.Add("Assembler buffer minimum multiplier", "Assembler buffer minimum multiplier", "工厂配方缓冲最小倍率");
|
||||
I18N.Add("Ray Receiver Graviton Lens buffer count", "Ray Receiver Graviton Lens buffer count", "射线接收器透镜缓冲数量");
|
||||
I18N.Add("Auto navigation on sailings", "Auto navigation on sailings", "宇宙航行时自动导航");
|
||||
I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航");
|
||||
I18N.Add("Auto boost", "Auto boost", "自动加速");
|
||||
@@ -251,32 +255,43 @@ public static class UIConfigWindow
|
||||
checkBoxForMeasureTextWidth = wnd.AddCheckBox(x, y, tab2, FactoryPatch.TreatStackingAsSingleEnabled, "Treat stack items as single in monitor components");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.QuickBuildAndDismantleLabsEnabled, "Quick build and dismantle stacking labs");
|
||||
|
||||
{
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.DragBuildPowerPolesEnabled, "Drag building power poles in maximum connection range");
|
||||
y += 30f;
|
||||
var alternatelyCheckBox = wnd.AddCheckBox(x + 20f, y, tab2, FactoryPatch.DragBuildPowerPolesAlternatelyEnabled, "Build Tesla Tower and Wireless Power Tower alternately", 13);
|
||||
FactoryPatch.DragBuildPowerPolesEnabled.SettingChanged += AlternatelyCheckBoxChanged;
|
||||
wnd.OnFree += () => { FactoryPatch.DragBuildPowerPolesEnabled.SettingChanged -= AlternatelyCheckBoxChanged; };
|
||||
AlternatelyCheckBoxChanged(null, null);
|
||||
|
||||
void AlternatelyCheckBoxChanged(object o, EventArgs e)
|
||||
{
|
||||
alternatelyCheckBox.SetEnable(FactoryPatch.DragBuildPowerPolesEnabled.Value);
|
||||
}
|
||||
}
|
||||
|
||||
y += 36f;
|
||||
checkBoxForMeasureTextWidth = wnd.AddCheckBox(x, y, tab2, FactoryPatch.ProtectVeinsFromExhaustionEnabled, "Protect veins from exhaustion");
|
||||
wnd.AddTipsButton2(x + checkBoxForMeasureTextWidth.Width + 5f, y + 6f, tab2, "Protect veins from exhaustion", "Protect veins from exhaustion tips", "protect-veins-tips");
|
||||
|
||||
{
|
||||
y += 36f;
|
||||
var cb = wnd.AddCheckBox(x, y, tab2, FactoryPatch.TankFastFillInAndTakeOutEnabled, "Fast fill in to and take out from tanks");
|
||||
x += cb.Width + 5f;
|
||||
txt = wnd.AddText2(x, y + 2f, tab2, "Speed Ratio", 13, "text-tank-fast-fill-speed-ratio");
|
||||
var tankSlider = wnd.AddSlider(x + txt.preferredWidth + 5f, y + 7f, tab2, FactoryPatch.TankFastFillInAndTakeOutMultiplier, [2, 5, 10, 20, 50, 100, 500, 1000], "G", 100f).WithSmallerHandle();
|
||||
EventHandler tankSettingChanged = (_, _) =>
|
||||
FactoryPatch.TankFastFillInAndTakeOutEnabled.SettingChanged += TankSettingChanged;
|
||||
wnd.OnFree += () => { FactoryPatch.TankFastFillInAndTakeOutEnabled.SettingChanged -= TankSettingChanged; };
|
||||
TankSettingChanged(null, null);
|
||||
|
||||
void TankSettingChanged(object o, EventArgs e)
|
||||
{
|
||||
tankSlider.SetEnable(FactoryPatch.TankFastFillInAndTakeOutEnabled.Value);
|
||||
};
|
||||
FactoryPatch.TankFastFillInAndTakeOutEnabled.SettingChanged += tankSettingChanged;
|
||||
wnd.OnFree += () => { FactoryPatch.TankFastFillInAndTakeOutEnabled.SettingChanged -= tankSettingChanged; };
|
||||
tankSettingChanged(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y += 36f;
|
||||
checkBoxForMeasureTextWidth = wnd.AddCheckBox(x, y, tab2, FactoryPatch.ProtectVeinsFromExhaustionEnabled, "Protect veins from exhaustion");
|
||||
wnd.AddTipsButton2(x + checkBoxForMeasureTextWidth.Width + 5f, y + 6f, tab2, "Protect veins from exhaustion", "Protect veins from exhaustion tips", "protect-veins-tips");
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.DragBuildPowerPolesEnabled, "Drag building power poles in maximum connection range");
|
||||
y += 36f;
|
||||
var alternatelyCheckBox = wnd.AddCheckBox(x + 20f, y, tab2, FactoryPatch.DragBuildPowerPolesAlternatelyEnabled, "Build Tesla Tower and Wireless Power Tower alternately", 13);
|
||||
EventHandler alternatelyCheckBoxChanged = (_, _) => { alternatelyCheckBox.SetEnable(FactoryPatch.DragBuildPowerPolesEnabled.Value); };
|
||||
FactoryPatch.DragBuildPowerPolesEnabled.SettingChanged += alternatelyCheckBoxChanged;
|
||||
wnd.OnFree += () => { FactoryPatch.DragBuildPowerPolesEnabled.SettingChanged -= alternatelyCheckBoxChanged; };
|
||||
alternatelyCheckBoxChanged(null, null);
|
||||
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.DoNotRenderEntitiesEnabled, "Do not render factory entities");
|
||||
y += 36f;
|
||||
@@ -307,35 +322,70 @@ public static class UIConfigWindow
|
||||
y += 36f;
|
||||
checkBoxForMeasureTextWidth = wnd.AddCheckBox(x, y, tab2, LogisticsPatch.LogisticsConstrolPanelImprovementEnabled, "Logistics Control Panel Improvement");
|
||||
wnd.AddTipsButton2(x + checkBoxForMeasureTextWidth.Width + 5f, y + 6f, tab2, "Logistics Control Panel Improvement", "Logistics Control Panel Improvement tips", "lcp-improvement-tips");
|
||||
|
||||
{
|
||||
y += 36f;
|
||||
var cb0 = wnd.AddCheckBox(x, y, tab2, LogisticsPatch.RealtimeLogisticsInfoPanelEnabled, "Real-time logistic stations info panel");
|
||||
y += 36f;
|
||||
var cb1 = wnd.AddCheckBox(x + 20f, y, tab2, LogisticsPatch.RealtimeLogisticsInfoPanelBarsEnabled, "Show status bars for storage items", 13);
|
||||
EventHandler anySettingsChanged = (_, _) =>
|
||||
var realtimeLogisticsInfoPanelCheckBox = wnd.AddCheckBox(x, y, tab2, LogisticsPatch.RealtimeLogisticsInfoPanelEnabled, "Real-time logistic stations info panel");
|
||||
y += 30f;
|
||||
var realtimeLogisticsInfoPanelBarsCheckBox = wnd.AddCheckBox(x + 20f, y, tab2, LogisticsPatch.RealtimeLogisticsInfoPanelBarsEnabled, "Show status bars for storage items", 13);
|
||||
if (AuxilaryfunctionWrapper.ShowStationInfo != null)
|
||||
{
|
||||
AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged += RealtimeLogisticsInfoPanelChanged;
|
||||
wnd.OnFree += () => { AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged -= RealtimeLogisticsInfoPanelChanged; };
|
||||
}
|
||||
LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.SettingChanged += RealtimeLogisticsInfoPanelChanged;
|
||||
wnd.OnFree += () => { LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.SettingChanged -= RealtimeLogisticsInfoPanelChanged; };
|
||||
RealtimeLogisticsInfoPanelChanged(null, null);
|
||||
|
||||
void RealtimeLogisticsInfoPanelChanged(object o, EventArgs e)
|
||||
{
|
||||
if (AuxilaryfunctionWrapper.ShowStationInfo == null)
|
||||
{
|
||||
cb0.SetEnable(true);
|
||||
cb1.SetEnable(LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value);
|
||||
realtimeLogisticsInfoPanelCheckBox.SetEnable(true);
|
||||
realtimeLogisticsInfoPanelBarsCheckBox.SetEnable(LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
var on = !AuxilaryfunctionWrapper.ShowStationInfo.Value;
|
||||
cb0.SetEnable(on);
|
||||
cb1.SetEnable(on & LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value);
|
||||
realtimeLogisticsInfoPanelCheckBox.SetEnable(on);
|
||||
realtimeLogisticsInfoPanelBarsCheckBox.SetEnable(on & LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value);
|
||||
if (!on)
|
||||
{
|
||||
LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.Value = false;
|
||||
}
|
||||
};
|
||||
if (AuxilaryfunctionWrapper.ShowStationInfo != null)
|
||||
{
|
||||
AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged += anySettingsChanged;
|
||||
wnd.OnFree += () => { AuxilaryfunctionWrapper.ShowStationInfo.SettingChanged -= anySettingsChanged; };
|
||||
}
|
||||
LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.SettingChanged += anySettingsChanged;
|
||||
wnd.OnFree += () => { LogisticsPatch.RealtimeLogisticsInfoPanelEnabled.SettingChanged -= anySettingsChanged; };
|
||||
anySettingsChanged(null, null);
|
||||
}
|
||||
|
||||
{
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab2, FactoryPatch.TweakBuildingBufferEnabled, "Tweak building buffers");
|
||||
y += 30f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab2, "Assembler buffer time multiplier(in seconds)", 13);
|
||||
var nx1 = txt.preferredWidth + 5f;
|
||||
y += 30f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab2, "Assembler buffer minimum multiplier", 13);
|
||||
var nx2 = txt.preferredWidth + 5f;
|
||||
y += 30f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab2, "Ray Receiver Graviton Lens buffer count", 13);
|
||||
var nx3 = txt.preferredWidth + 5f;
|
||||
y -= 60f;
|
||||
var mx = Mathf.Max(nx1, nx2, nx3) + 20f;
|
||||
var assemblerBufferTimeMultiplierSlider = wnd.AddSlider(x + mx, y + 5f, tab2, FactoryPatch.AssemblerBufferTimeMultiplier, new MyWindow.RangeValueMapper<int>(2, 10), "0", 80f).WithSmallerHandle();
|
||||
y += 30f;
|
||||
var assemblerBufferMininumMultiplierSlider = wnd.AddSlider(x + mx, y + 5f, tab2, FactoryPatch.AssemblerBufferMininumMultiplier, new MyWindow.RangeValueMapper<int>(2, 10), "0", 80f).WithSmallerHandle();
|
||||
y += 30f;
|
||||
var receiverBufferCountSlider = wnd.AddSlider(x + mx, y + 5f, tab2, FactoryPatch.ReceiverBufferCount, new MyWindow.RangeValueMapper<int>(1, 20), "0", 80f).WithSmallerHandle();
|
||||
FactoryPatch.TweakBuildingBufferEnabled.SettingChanged += TweakBuildingBufferChanged;
|
||||
wnd.OnFree += () => { FactoryPatch.TweakBuildingBufferEnabled.SettingChanged -= TweakBuildingBufferChanged; };
|
||||
TweakBuildingBufferChanged(null, null);
|
||||
|
||||
void TweakBuildingBufferChanged(object o, EventArgs e)
|
||||
{
|
||||
assemblerBufferTimeMultiplierSlider.SetEnable(FactoryPatch.TweakBuildingBufferEnabled.Value);
|
||||
assemblerBufferMininumMultiplierSlider.SetEnable(FactoryPatch.TweakBuildingBufferEnabled.Value);
|
||||
receiverBufferCountSlider.SetEnable(FactoryPatch.TweakBuildingBufferEnabled.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var tab3 = wnd.AddTab(trans, "Player/Mecha");
|
||||
x = 0f;
|
||||
@@ -348,24 +398,28 @@ public static class UIConfigWindow
|
||||
y += 36f;
|
||||
checkBoxForMeasureTextWidth = wnd.AddCheckBox(x, y, tab3, PlayerPatch.EnhancedMechaForgeCountControlEnabled, "Enhanced count control for hand-make");
|
||||
wnd.AddTipsButton2(x + checkBoxForMeasureTextWidth.Width + 5f, y + 6f, tab3, "Enhanced count control for hand-make", "Enhanced count control for hand-make tips", "enhanced-count-control-tips");
|
||||
|
||||
{
|
||||
y += 36f;
|
||||
wnd.AddCheckBox(x, y, tab3, PlayerPatch.AutoNavigationEnabled, "Auto navigation on sailings");
|
||||
y += 26f;
|
||||
var navcb1 = wnd.AddCheckBox(x + 20f, y, tab3, PlayerPatch.AutoCruiseEnabled, "Enable auto-cruise", 13);
|
||||
var autoCruiseCheckBox = wnd.AddCheckBox(x + 20f, y, tab3, PlayerPatch.AutoCruiseEnabled, "Enable auto-cruise", 13);
|
||||
y += 26f;
|
||||
var navcb2 = wnd.AddCheckBox(x + 20f, y, tab3, PlayerPatch.AutoBoostEnabled, "Auto boost", 13);
|
||||
var autoBoostCheckBox = wnd.AddCheckBox(x + 20f, y, tab3, PlayerPatch.AutoBoostEnabled, "Auto boost", 13);
|
||||
y += 32f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab3, "Distance to use warp", 15, "text-distance-to-warp");
|
||||
var navSlider = wnd.AddSlider(x + 20f + txt.preferredWidth + 5f, y + 6f, tab3, PlayerPatch.DistanceToWarp, new DistanceMapper(), "0.0", 100f);
|
||||
EventHandler navSettingChanged = (_, _) =>
|
||||
var navDistanceSlider = wnd.AddSlider(x + 20f + txt.preferredWidth + 5f, y + 6f, tab3, PlayerPatch.DistanceToWarp, new DistanceMapper(), "0.0", 100f);
|
||||
PlayerPatch.AutoNavigationEnabled.SettingChanged += NavSettingChanged;
|
||||
wnd.OnFree += () => { PlayerPatch.AutoNavigationEnabled.SettingChanged -= NavSettingChanged; };
|
||||
NavSettingChanged(null, null);
|
||||
|
||||
void NavSettingChanged(object o, EventArgs e)
|
||||
{
|
||||
navcb1.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
navcb2.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
navSlider.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
};
|
||||
PlayerPatch.AutoNavigationEnabled.SettingChanged += navSettingChanged;
|
||||
wnd.OnFree += () => { PlayerPatch.AutoNavigationEnabled.SettingChanged -= navSettingChanged; };
|
||||
navSettingChanged(null, null);
|
||||
autoCruiseCheckBox.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
autoBoostCheckBox.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
navDistanceSlider.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var tab4 = wnd.AddTab(trans, "Dyson Sphere");
|
||||
x = 0f;
|
||||
|
||||
@@ -138,6 +138,11 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
||||
FactoryPatch.TankFastFillInAndTakeOutMultiplier = Config.Bind("Factory", "TankFastFillInAndTakeOutMultiplier", 1000, "Speed multiplier for fast filling in to and takeing out from tanks");
|
||||
FactoryPatch.CutConveyorBeltEnabled = Config.Bind("Factory", "CutConveyorBeltShortcut", false,
|
||||
"Cut conveyor belt (with shortcut key)");
|
||||
FactoryPatch.TweakBuildingBufferEnabled = Config.Bind("Factory", "TweakBuildingBuffer", false,
|
||||
"Tweak buffer count for assemblers and power generators");
|
||||
FactoryPatch.AssemblerBufferTimeMultiplier = Config.Bind("Factory", "AssemblerBufferTimeMultiplier", 4, new ConfigDescription("Assembler buffer time multiplier in seconds", new AcceptableValueRange<int>(2, 10)));
|
||||
FactoryPatch.AssemblerBufferMininumMultiplier = Config.Bind("Factory", "AssemblerBufferMininumMultiplier", 4, new ConfigDescription("Assembler buffer minimum multiplier", new AcceptableValueRange<int>(2, 10)));
|
||||
FactoryPatch.ReceiverBufferCount = Config.Bind("Factory", "ReceiverBufferCount", 1, new ConfigDescription("Ray Receiver Graviton Lens buffer count", new AcceptableValueRange<int>(1, 20)));
|
||||
LogisticsPatch.LogisticsCapacityTweaksEnabled = Config.Bind("Factory", "LogisticsCapacityTweaks", true,
|
||||
"Logistics capacity related tweaks");
|
||||
LogisticsPatch.AllowOverflowInLogisticsEnabled = Config.Bind("Factory", "AllowOverflowInLogistics", false,
|
||||
@@ -173,7 +178,6 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
||||
I18N.Init();
|
||||
I18N.Add("UXAssist Config", "UXAssist Config", "UX助手设置");
|
||||
I18N.Add("KEYOpenUXAssistConfigWindow", "Open UXAssist Config Window", "打开UX助手设置面板");
|
||||
I18N.Add("KEYToggleAutoCruise", "Toggle auto-cruise", "切换自动巡航");
|
||||
|
||||
// UI Patches
|
||||
GameLogic.Enable(true);
|
||||
|
||||
Reference in New Issue
Block a user