feat(cheatenabler): add tech downgrade and make the tech modifiers upgradable

Rework `Unlock Tech with Key-Modifiers` into a full upgrade/downgrade feature,
ported from the standalone TechTweaks plugin.

- Holding Shift / Ctrl / Ctrl+Shift / Alt while clicking a tech adds 1 / 10 /
  100 / all levels and unlocks the direct prerequisites, as before.
- `Caps Lock` toggles a session downgrade mode; the same modifiers then
  subtract 1 / 10 / 100 levels or revert the tech to locked. Downgrading walks
  the dependent techs so no "prerequisite locked, dependent unlocked" state is
  left behind, and it reverts the upgrade values the tech had applied
  (`TechFuncRevert`), including the multiplicative, assignment and boolean
  `UnlockTechFunction` cases, so repeated up/down cycles do not drift.
- Toggling downgrade mode reports itself like the other toggles: a realtime tip
  popup plus the critical warning banner. The banner now shows on its own
  instead of requiring `Build without condition` or `No collision` to be on,
  and outranks both in the shared priority chains.
- The `?` button in the tech tree shows the full key reference, using the same
  title and text as the config panel's tip button. While the option is off, the
  button is absent and `Caps Lock` is inert, so the key cannot collide with
  other bindings.
- The option keeps its original `General/UnlockTech` config entry, so existing
  configurations carry over.

The old unlock-only handler in `Patches/GamePatch.cs` is replaced by
`Patches/TechTweaksPatch.cs`, which follows the repository's mod feature
lifecycle (per-frame input through the registry's `OnInputUpdate`).
This commit is contained in:
TTenYX authored and Soar Qin committed 2026-10-10 23:49:40 +08:00
1 parent 6a292e0816
commit 6ced106901
19 files changed
+2072 -143

No files matched your search

+64
View File
@@ -35,6 +35,29 @@ public static class Localization
public const string DisableAbnormalChecks = "Disable Abnormal Checks";
public const string Hotkey = "Hotkey";
public const string UnlockTechWithKeyModifiers = "Unlock Tech with Key-Modifiers";
public const string UnlockDowngradeTechWithKeyModifiers = "Quickly upgrade/downgrade tech with key-modifiers";
public const string TechDowngradeModeOn = "Tech downgrade mode ON!";
public const string TechDowngradeModeOff = "Tech downgrade mode OFF!";
public const string TechDowngradeModeWarning = "!!Tech downgrade mode is ON!!";
public const string TechModifierHelpBody = """
Click a tech on the tree while holding:
Shift: Tech level + 1
Ctrl: Tech level + 10
Ctrl + Shift: Tech level + 100
Alt: Tech level to MAX
Note: all direct prerequisites will be unlocked as well.
Press Caps Lock to toggle Tech Downgrade Mode: the key-modifiers above then decrease tech levels and revert the corresponding upgrade values.
Shift: Tech level - 1
Ctrl: Tech level - 10
Ctrl + Shift: Tech level - 100
Alt: revert to locked (level 0)
(Shift+Alt and Ctrl+Alt do nothing)
The features above come from the mod: CheatEnabler
""";
public const string PackageResizeSkippedOccupiedCells = "Package resize skipped: occupied cells would be removed";
public const string DevShortcuts = "Dev Shortcuts";
public const string DevShortcutsTips = "Dev Shortcuts Tips";
public const string UnlockTechWithKeyModifiersTips = "Unlock Tech with Key-Modifiers Tips";
@@ -145,6 +168,47 @@ public static class Localization
I18N.Add(DisableAbnormalChecks, "Disable Abnormal Checks", "关闭数据异常检查");
I18N.Add(Hotkey, "Hotkey", "快捷键");
I18N.Add(UnlockTechWithKeyModifiers, "Unlock Tech with Key-Modifiers", "使用组合键点击解锁科技");
I18N.Add(UnlockDowngradeTechWithKeyModifiers, "Quickly upgrade/downgrade tech with key-modifiers", "使用组合键快速升降级科技");
I18N.Add(TechDowngradeModeOn, "Tech downgrade mode ON!", "科技降级模式已开启!");
I18N.Add(TechDowngradeModeOff, "Tech downgrade mode OFF!", "科技降级模式已关闭!");
I18N.Add(TechDowngradeModeWarning, "!!Tech downgrade mode is ON!!", "!!科技降级模式已开启!!");
I18N.Add(TechModifierHelpBody, """
Click a tech on the tree while holding:
Shift: Tech level + 1
Ctrl: Tech level + 10
Ctrl + Shift: Tech level + 100
Alt: Tech level to MAX
Note: all direct prerequisites will be unlocked as well.
Press Caps Lock to toggle Tech Downgrade Mode: the key-modifiers above then decrease tech levels and revert the corresponding upgrade values.
Shift: Tech level - 1
Ctrl: Tech level - 10
Ctrl + Shift: Tech level - 100
Alt: revert to locked (level 0)
(Shift+Alt and Ctrl+Alt do nothing)
The features above come from the mod: CheatEnabler
""", """
按住以下组合键点击科技树:
Shift:科技等级 +1
Ctrl:科技等级 +10
Ctrl + Shift:科技等级 +100
Alt:科技等级升到最大
注意:所有直接前置科技也会被解锁。
按 Caps Lock 开启/关闭科技降级模式:开启后上述组合键变为降低科技等级,并回退对应升级数值。
Shift:科技等级 -1
Ctrl:科技等级 -10
Ctrl + Shift:科技等级 -100
Alt:直接回退到未解锁(0 级,锁定)
(Shift+Alt 与 Ctrl+Alt 无效果)
以上功能来源于MOD:CheatEnabler
""");
I18N.Add(PackageResizeSkippedOccupiedCells, "Package resize skipped: occupied cells would be removed",
"背包扩容回退已跳过:有物品的格子会被移除,未缩小背包");
I18N.Add(DevShortcuts, "Dev Shortcuts", "开发模式快捷键");
I18N.Add(DevShortcutsTips, """
Caution: Some function may trigger abnormal check!