Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions assets/bundles/bundle-mdtx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ stat.ammo_capacity = 子弹容量
settings.category.settingV2 = [gold]MindustryX
settingV2.reset = [red]恢复默认设置
settingV2.onlyModified = 只看已修改的设置
settingV2.shortcut = 配置快捷键
settingV2.shortcut.current = 当前快捷键:{0}
settingV2.shortcut.mode = 模式:{0}
settingV2.shortcut.mode.toggle = 切换
settingV2.shortcut.mode.hold = 按住
settingV2.shortcut.rebind = 重新绑定
settingV2.shortcut.capture = 按下任意快捷键进行绑定,按 Esc 取消
settingV2.shortcut.unset = 未绑定
settingV2.shortcut.unbind = 取消绑定
settingV2.shortcut.unsupported = 仅开关设置项支持快捷键

settingV2.autoFill.category = 快速装填
settingV2.autoFill.cooldown.name = 操作冷却(ms)
Expand Down
12 changes: 11 additions & 1 deletion assets/bundles/bundle-mdtx_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ stat.ammo_capacity = Ammo Capacity
settings.category.settingV2 = [gold]MindustryX
settingV2.reset = [red]Reset to Default
settingV2.onlyModified = Only show modified settings
settingV2.shortcut = Configure Shortcut
settingV2.shortcut.current = Current shortcut: {0}
settingV2.shortcut.mode = Mode: {0}
settingV2.shortcut.mode.toggle = Toggle
settingV2.shortcut.mode.hold = Hold
settingV2.shortcut.rebind = Rebind
settingV2.shortcut.capture = Press any shortcut key to bind it, or Esc to cancel
settingV2.shortcut.unset = Unbound
settingV2.shortcut.unbind = Unbind
settingV2.shortcut.unsupported = Shortcuts are only supported for toggle settings

settingV2.autoFill.category = Quick Fill
settingV2.autoFill.cooldown.name = Operation Cooldown (ms)
Expand Down Expand Up @@ -294,4 +304,4 @@ unit.quell-missile.name = Quell Missile
unit.scathe-missile.name = Scathe Missile
team.neoplastic.name = Neoplastic

# 学术特色翻译(无需翻译其他语言)
# 学术特色翻译(无需翻译其他语言)
259 changes: 259 additions & 0 deletions patches/client/0074-FC-SettingsV2-shortcut-capture-integration.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wind-DeterMination-backup
<Wind-DeterMination-backup@users.noreply.github.com>
Date: Sun, 15 Mar 2026 02:02:55 +0800
Subject: [PATCH] FC: SettingsV2 shortcut capture integration

---
.../mindustry/ui/dialogs/KeybindDialog.java | 188 +++++++++++-------
1 file changed, 116 insertions(+), 72 deletions(-)

diff --git a/core/src/mindustry/ui/dialogs/KeybindDialog.java b/core/src/mindustry/ui/dialogs/KeybindDialog.java
index acdff149bc567c1b43d3130aecbcbddfe82ce265..f8f1378dee632932f46efb1378413c945ea2331c 100644
--- a/core/src/mindustry/ui/dialogs/KeybindDialog.java
+++ b/core/src/mindustry/ui/dialogs/KeybindDialog.java
@@ -17,11 +17,8 @@ import java.util.*;
import static arc.Core.*;

public class KeybindDialog extends Dialog{
- protected KeyBind rebindKey = null;
- protected boolean rebindAxis = false;
- protected boolean rebindMin = true;
- protected KeyCode minKey = null;
- protected Dialog rebindDialog;
+ private static int captureDialogs = 0;
+
protected Table bindsTable;
private String searchText = "";

@@ -59,6 +56,10 @@ public class KeybindDialog extends Dialog{
rebuildBinds();
}

+ public static boolean isCapturing(){
+ return captureDialogs > 0;
+ }
+
@Override
public void addCloseButton(){
buttons.button("@back", Icon.left, this::hide).size(210f, 64f);
@@ -85,10 +84,13 @@ public class KeybindDialog extends Dialog{
if(!searchText.isEmpty() && !bundle.get("keybind." + keybind.name + ".name", keybind.name).toLowerCase(Locale.ROOT).contains(searchText.toLowerCase(Locale.ROOT))){
continue;
}
+ if(mindustryX.features.SettingsV2.isHiddenSettingKeybind(keybind)){
+ continue;
+ }

if(lastCategory != keybind.category && keybind.category != null){
- table.add(bundle.get("category." + keybind.category + ".name", Strings.capitalize(keybind.category))).color(Color.gray).colspan(5).pad(10).padBottom(4).row();//MDTX: fix colspan for unbind
- table.image().color(Color.gray).fillX().height(3).pad(6).colspan(5).padTop(0).padBottom(10).row();//MDTX: fix colspan for unbind
+ table.add(bundle.get("category." + keybind.category + ".name", Strings.capitalize(keybind.category))).color(Color.gray).colspan(5).pad(10).padBottom(4).row();
+ table.image().color(Color.gray).fillX().height(3).pad(6).colspan(5).padTop(0).padBottom(10).row();
lastCategory = keybind.category;
}

@@ -100,11 +102,7 @@ public class KeybindDialog extends Dialog{
return axis.key != null ? axis.keyName() : axis.min.getName() + " [red]/[] " + axis.max.getName();
}).color(Pal.accent).left().minWidth(90).fillX().padRight(20);

- table.button("@settings.rebind", tstyle, () -> {
- rebindAxis = true;
- rebindMin = true;
- openDialog(keybind);
- }).size(bw, bh);
+ table.button("@settings.rebind", tstyle, () -> showRebindDialog(keybind, true)).size(bw, bh);
}else{
table.add(bundle.get("keybind." + keybind.name + ".name", Strings.capitalize(keybind.name)), Color.white).left().padRight(40).padLeft(8);
table.add(keybind.value.keyName()).update(l -> {
@@ -112,86 +110,130 @@ public class KeybindDialog extends Dialog{
l.setColor(keybind.value.key == KeyCode.unset ? Color.darkGray : Pal.accent);
}).color(Pal.accent).left().minWidth(90).padRight(20);

- table.button("@settings.rebind", tstyle, () -> {
- rebindAxis = false;
- rebindMin = false;
- openDialog(keybind);
- }).size(bw, bh);
+ table.button("@settings.rebind", tstyle, () -> showRebindDialog(keybind, false)).size(bw, bh);
}
- table.button("取消绑定", tstyle, () -> {
- keybind.value = new Axis(KeyCode.unset);
- keybind.save();
- }).size(bw, bh).pad(2f).padLeft(4f);
+
+ table.button("取消绑定", tstyle, () -> clearBind(keybind)).size(bw, bh).pad(2f).padLeft(4f);
table.button("@settings.resetKey", tstyle, keybind::resetToDefault).disabled(t -> keybind.isDefault()).size(bw, bh).pad(2f).padLeft(4f);
table.row();
}

- table.button("@settings.reset", Icon.refresh, tstyle, KeyBind::resetAll).minWidth(200f).colspan(5).padTop(4).margin(10f).height(50f).fill();//MDTX: fix colspan for unbind
+ table.button("@settings.reset", Icon.refresh, tstyle, KeybindDialog::resetVisibleBinds).minWidth(200f).colspan(5).padTop(4).margin(10f).height(50f).fill();
}

- void rebind(KeyBind bind, KeyCode newKey){
- if(rebindKey == null) return;
- rebindDialog.hide();
- boolean isAxis = bind.defaultValue instanceof Axis;
+ public static void clearBind(KeyBind keybind){
+ keybind.value = new Axis(KeyCode.unset);
+ keybind.save();
+ }

- if(isAxis){
- if(newKey.axis || !rebindMin){
- bind.value = newKey.axis ? new Axis(newKey) : new Axis(minKey, newKey);
- }
- }else{
- bind.value = new Axis(newKey, input.modifiers());
+ public static void clearConflictingBinds(KeyBind current, Axis candidate){
+ for(KeyBind keybind : KeyBind.all){
+ if(keybind == current) continue;
+ if(!keybind.value.equals(candidate)) continue;
+ clearBind(keybind);
}
- bind.save();
-
- if(rebindAxis && isAxis && rebindMin && !newKey.axis){
- rebindMin = false;
- minKey = newKey;
- openDialog(rebindKey);
- }else{
- rebindKey = null;
- rebindAxis = false;
+ }
+
+ public static void resetVisibleBinds(){
+ for(KeyBind keybind : KeyBind.all){
+ if(mindustryX.features.SettingsV2.isHiddenSettingKeybind(keybind)) continue;
+ keybind.resetToDefault();
}
}

- private void openDialog( KeyBind name){
- rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press"));
+ public static void showRebindDialog(KeyBind bind){
+ showRebindDialog(bind, false);
+ }

- rebindKey = name;
+ public static void showRebindDialog(KeyBind bind, boolean axis){
+ new RebindSession().begin(bind, axis);
+ }

- rebindDialog.titleTable.getCells().first().pad(4);
- rebindDialog.addListener(new InputListener(){
- private KeyCode pressedKey = null;
- @Override
- public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
- if(Core.app.isAndroid()) return false;
- rebind(name, button);
- return false;
- }
+ static class RebindSession{
+ protected KeyBind rebindKey;
+ protected boolean rebindAxis;
+ protected boolean rebindMin = true;
+ protected KeyCode minKey;
+ protected Dialog rebindDialog;
+
+ void begin(KeyBind bind, boolean axis){
+ rebindKey = bind;
+ rebindAxis = axis;
+ rebindMin = axis;
+ minKey = null;
+ openDialog(bind);
+ }
+
+ boolean rebind(KeyBind bind, KeyCode newKey){
Comment thread
Wind-DeterMination-backup marked this conversation as resolved.
+ if(rebindKey == null || !isBindable(newKey)) return false;

- @Override
- public boolean keyDown(InputEvent event, KeyCode keycode){
- pressedKey = keycode;
- return true;
+ rebindDialog.hide();
+ boolean isAxis = bind.defaultValue instanceof Axis;
+ Axis reboundValue = null;
+
+ if(isAxis){
+ if(newKey.axis || !rebindMin){
+ reboundValue = newKey.axis ? new Axis(newKey) : new Axis(minKey, newKey);
+ }
+ }else{
+ reboundValue = new Axis(newKey, input.modifiers());
}

- @Override
- public boolean keyUp(InputEvent event, KeyCode keycode){
- if(pressedKey == null || keycode != pressedKey) return false;
- rebindDialog.hide();
- rebind(name, keycode);
- return true;
+ if(reboundValue != null){
+ clearConflictingBinds(bind, reboundValue);
+ bind.value = reboundValue;
+ bind.save();
}

- @Override
- public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
- if(!rebindAxis) return false;
- rebindDialog.hide();
- rebind(name, KeyCode.scroll);
- return false;
+ if(rebindAxis && isAxis && rebindMin && !newKey.axis){
+ rebindMin = false;
+ minKey = newKey;
+ openDialog(rebindKey);
+ }else{
+ rebindKey = null;
+ rebindAxis = false;
}
- });
+ return true;
+ }
+
+ private boolean isBindable(KeyCode newKey){
+ return newKey != null && newKey != KeyCode.anyKey && newKey != KeyCode.unknown && newKey != KeyCode.unset;
Comment thread
Wind-DeterMination-backup marked this conversation as resolved.
+ }

- rebindDialog.show();
- Time.runTask(1f, () -> getScene().setScrollFocus(rebindDialog));
+ private void openDialog(KeyBind name){
+ rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press"));
+ captureDialogs++;
+ rebindDialog.hidden(() -> captureDialogs = Math.max(0, captureDialogs - 1));
+ rebindDialog.titleTable.getCells().first().pad(4);
+ rebindDialog.addListener(new InputListener(){
+ private KeyCode pressedKey = null;
+
+ @Override
+ public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
+ if(Core.app.isAndroid()) return false;
+ return rebind(name, button);
+ }
+
+ @Override
+ public boolean keyDown(InputEvent event, KeyCode keycode){
+ pressedKey = keycode;
+ return true;
+ }
+
+ @Override
+ public boolean keyUp(InputEvent event, KeyCode keycode){
+ if(pressedKey == null || keycode != pressedKey) return false;
+ return rebind(name, keycode);
+ }
+
+ @Override
+ public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
+ return rebindAxis && rebind(name, KeyCode.scroll);
+ }
+ });
+
+ rebindDialog.show();
+ Time.runTask(1f, () -> Core.scene.setScrollFocus(rebindDialog));
+ }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wind-DeterMination-backup
<Wind-DeterMination-backup@users.noreply.github.com>
Date: Sun, 15 Mar 2026 02:27:27 +0800
Subject: [PATCH] fix: reserve escape for key capture cancel

---
core/src/mindustry/ui/dialogs/KeybindDialog.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/src/mindustry/ui/dialogs/KeybindDialog.java b/core/src/mindustry/ui/dialogs/KeybindDialog.java
index f8f1378dee632932f46efb1378413c945ea2331c..78ae50701ad9ab1c45217116ea658e330f9f41d2 100644
--- a/core/src/mindustry/ui/dialogs/KeybindDialog.java
+++ b/core/src/mindustry/ui/dialogs/KeybindDialog.java
@@ -197,7 +197,7 @@ public class KeybindDialog extends Dialog{
}

private boolean isBindable(KeyCode newKey){
- return newKey != null && newKey != KeyCode.anyKey && newKey != KeyCode.unknown && newKey != KeyCode.unset;
+ return newKey != null && newKey != KeyCode.anyKey && newKey != KeyCode.unknown && newKey != KeyCode.unset && newKey != KeyCode.escape;
}

private void openDialog(KeyBind name){
65 changes: 65 additions & 0 deletions patches/client/0076-refactor-simplify-rebind-session-flow.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wind-DeterMination-backup
<Wind-DeterMination-backup@users.noreply.github.com>
Date: Sun, 15 Mar 2026 02:32:14 +0800
Subject: [PATCH] refactor: simplify rebind session flow

---
core/src/mindustry/ui/dialogs/KeybindDialog.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/core/src/mindustry/ui/dialogs/KeybindDialog.java b/core/src/mindustry/ui/dialogs/KeybindDialog.java
index 78ae50701ad9ab1c45217116ea658e330f9f41d2..9b337367bb8aec755e0cb813ebb50f6c7eac13c7 100644
--- a/core/src/mindustry/ui/dialogs/KeybindDialog.java
+++ b/core/src/mindustry/ui/dialogs/KeybindDialog.java
@@ -164,11 +164,11 @@ public class KeybindDialog extends Dialog{
openDialog(bind);
}

- boolean rebind(KeyBind bind, KeyCode newKey){
+ boolean rebind(KeyCode newKey){
if(rebindKey == null || !isBindable(newKey)) return false;

rebindDialog.hide();
- boolean isAxis = bind.defaultValue instanceof Axis;
+ boolean isAxis = rebindKey.defaultValue instanceof Axis;
Axis reboundValue = null;

if(isAxis){
@@ -180,9 +180,9 @@ public class KeybindDialog extends Dialog{
}

if(reboundValue != null){
- clearConflictingBinds(bind, reboundValue);
- bind.value = reboundValue;
- bind.save();
+ clearConflictingBinds(rebindKey, reboundValue);
+ rebindKey.value = reboundValue;
+ rebindKey.save();
}

if(rebindAxis && isAxis && rebindMin && !newKey.axis){
@@ -211,7 +211,7 @@ public class KeybindDialog extends Dialog{
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
if(Core.app.isAndroid()) return false;
- return rebind(name, button);
+ return rebind(button);
}

@Override
@@ -223,12 +223,12 @@ public class KeybindDialog extends Dialog{
@Override
public boolean keyUp(InputEvent event, KeyCode keycode){
if(pressedKey == null || keycode != pressedKey) return false;
- return rebind(name, keycode);
+ return rebind(keycode);
}

@Override
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
- return rebindAxis && rebind(name, KeyCode.scroll);
+ return rebindAxis && rebind(KeyCode.scroll);
}
});

1 change: 1 addition & 0 deletions src/mindustryX/Hooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void update(){
if(!Vars.headless){
updateTitle();
BindingExt.pollKeys();
SettingsV2.INSTANCE.pollShortcuts();
if(BindingExt.oreAdsorption.keyDown()) ArcOld.doOreAdsorption();
Vars.maxSchematicSize = VarsX.maxSchematicSize.get() > 256 ? Integer.MAX_VALUE : VarsX.maxSchematicSize.get();

Expand Down
Loading