mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-02 03:00:29 +03:00
Merge branch 'cardillan-pr/unbind-keys-2'
This commit is contained in:
@@ -1110,6 +1110,7 @@ settings.data = Game Data
|
|||||||
settings.reset = Reset to Defaults
|
settings.reset = Reset to Defaults
|
||||||
settings.rebind = Rebind
|
settings.rebind = Rebind
|
||||||
settings.resetKey = Reset
|
settings.resetKey = Reset
|
||||||
|
settings.unbindKey = Unbind
|
||||||
settings.controls = Controls
|
settings.controls = Controls
|
||||||
settings.game = Game
|
settings.game = Game
|
||||||
settings.sound = Sound
|
settings.sound = Sound
|
||||||
|
|||||||
@@ -149,24 +149,43 @@ public class KeybindDialog extends Dialog{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openDialog( KeyBind name){
|
private void openDialog(KeyBind keyBind){
|
||||||
rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press"));
|
InputListener blocker = new InputListener(){
|
||||||
|
@Override
|
||||||
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||||
|
event.cancel();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
rebindKey = name;
|
float bw = 210f, bh = 64f;
|
||||||
|
rebindDialog = new Dialog(bundle.get("keybind." + keyBind.name + ".name", Strings.capitalize(keyBind.name))){{
|
||||||
|
title.setAlignment(Align.center);
|
||||||
|
cont.add(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press")).pad(40f);
|
||||||
|
|
||||||
|
buttons.button("@settings.unbindKey", Icon.cancel, () -> {
|
||||||
|
keyBind.unset();
|
||||||
|
hide();
|
||||||
|
}).size(bw, bh).get().addListener(blocker);
|
||||||
|
|
||||||
|
buttons.button("@back", Icon.left, this::hide).size(bw, bh).get().addListener(blocker);
|
||||||
|
}};
|
||||||
|
|
||||||
|
rebindKey = keyBind;
|
||||||
|
|
||||||
rebindDialog.titleTable.getCells().first().pad(4);
|
rebindDialog.titleTable.getCells().first().pad(4);
|
||||||
rebindDialog.addListener(new InputListener(){
|
rebindDialog.addListener(new InputListener(){
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||||
if(Core.app.isAndroid()) return false;
|
if(Core.app.isAndroid()) return false;
|
||||||
rebind(name, button);
|
rebind(keyBind, button);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(InputEvent event, KeyCode keycode){
|
public boolean keyDown(InputEvent event, KeyCode keycode){
|
||||||
rebindDialog.hide();
|
rebindDialog.hide();
|
||||||
rebind(name, keycode);
|
rebind(keyBind, keycode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +193,7 @@ public class KeybindDialog extends Dialog{
|
|||||||
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
||||||
if(!rebindAxis) return false;
|
if(!rebindAxis) return false;
|
||||||
rebindDialog.hide();
|
rebindDialog.hide();
|
||||||
rebind(name, KeyCode.scroll);
|
rebind(keyBind, KeyCode.scroll);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user