Keybind search bar + modding support
This commit is contained in:
@@ -24,7 +24,7 @@ import static mindustry.gen.Tex.*;
|
||||
@StyleDefaults
|
||||
public class Styles{
|
||||
//TODO all these names are inconsistent and not descriptive
|
||||
public static Drawable black, black9, black8, black6, black3, black5, grayPanel, none, flatDown, flatOver, accentDrawable;
|
||||
public static Drawable black, black9, black8, black6, black3, black5, grayPanel, grayPanelDark, none, flatDown, flatOver, accentDrawable;
|
||||
|
||||
public static ButtonStyle defaultb, underlineb;
|
||||
|
||||
@@ -109,6 +109,7 @@ public class Styles{
|
||||
black3 = whiteui.tint(0f, 0f, 0f, 0.3f);
|
||||
none = whiteui.tint(0f, 0f, 0f, 0f);
|
||||
grayPanel = whiteui.tint(Pal.darkestGray);
|
||||
grayPanelDark = whiteui.tint(Pal.darkestestGray);
|
||||
flatDown = createFlatDown();
|
||||
flatOver = whiteui.tint(Color.valueOf("454545"));
|
||||
accentDrawable = whiteui.tint(Pal.accent);
|
||||
@@ -155,7 +156,8 @@ public class Styles{
|
||||
over = flatOver;
|
||||
font = Fonts.def;
|
||||
fontColor = Color.white;
|
||||
disabledFontColor = Color.lightGray;
|
||||
disabledFontColor = Color.gray;
|
||||
disabled = grayPanelDark;
|
||||
down = flatOver;
|
||||
up = grayPanel;
|
||||
}};
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ContentInfoDialog extends BaseDialog{
|
||||
addCloseButton();
|
||||
|
||||
keyDown(key -> {
|
||||
if(key == keybinds.get(Binding.block_info).key){
|
||||
if(key == Binding.blockInfo.value.key){
|
||||
Core.app.post(this::hide);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,39 +1,62 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.KeyBinds.*;
|
||||
import arc.graphics.*;
|
||||
import arc.input.*;
|
||||
import arc.input.InputDevice.*;
|
||||
import arc.input.KeyBind.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
|
||||
public class KeybindDialog extends Dialog{
|
||||
protected Section section;
|
||||
protected KeyBind rebindKey = null;
|
||||
protected boolean rebindAxis = false;
|
||||
protected boolean rebindMin = true;
|
||||
protected KeyCode minKey = null;
|
||||
protected Dialog rebindDialog;
|
||||
protected float scroll;
|
||||
protected ObjectIntMap<Section> sectionControls = new ObjectIntMap<>();
|
||||
protected Table bindsTable;
|
||||
private String searchText = "";
|
||||
|
||||
public KeybindDialog(){
|
||||
super(bundle.get("keybind.title"));
|
||||
setup();
|
||||
addCloseButton();
|
||||
setFillParent(true);
|
||||
title.setAlignment(Align.center);
|
||||
titleTable.row();
|
||||
titleTable.add(new Image()).growX().height(3f).pad(4f).get().setColor(Pal.accent);
|
||||
bindsTable = new Table();
|
||||
ScrollPane pane = new ScrollPane(bindsTable);
|
||||
pane.setFadeScrollBars(false);
|
||||
|
||||
top();
|
||||
|
||||
cont.table(table -> {
|
||||
table.left();
|
||||
table.image(Icon.zoom);
|
||||
var field = table.field(searchText, res -> {
|
||||
searchText = res;
|
||||
rebuildBinds();
|
||||
}).growX().get();
|
||||
|
||||
shown(() -> {
|
||||
field.setText(searchText = "");
|
||||
rebuildBinds();
|
||||
app.post(field::requestKeyboard);
|
||||
});
|
||||
}).fillX().padBottom(4).top();
|
||||
|
||||
cont.row();
|
||||
cont.add(pane).grow();
|
||||
|
||||
rebuildBinds();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,187 +68,114 @@ public class KeybindDialog extends Dialog{
|
||||
});
|
||||
}
|
||||
|
||||
private void setup(){
|
||||
cont.clear();
|
||||
private void rebuildBinds(){
|
||||
|
||||
Section[] sections = Core.keybinds.getSections();
|
||||
Table table = bindsTable;
|
||||
bindsTable.clear();
|
||||
|
||||
Stack stack = new Stack();
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
ScrollPane pane = new ScrollPane(stack);
|
||||
pane.setFadeScrollBars(false);
|
||||
pane.update(() -> scroll = pane.getScrollY());
|
||||
this.section = sections[0];
|
||||
table.add().height(10);
|
||||
table.row();
|
||||
|
||||
for(Section section : sections){
|
||||
if(!sectionControls.containsKey(section))
|
||||
sectionControls.put(section, input.getDevices().indexOf(section.device, true));
|
||||
String lastCategory = null;
|
||||
var tstyle = Styles.grayt;
|
||||
|
||||
if(sectionControls.get(section, 0) >= input.getDevices().size){
|
||||
sectionControls.put(section, 0);
|
||||
section.device = input.getDevices().get(0);
|
||||
float bw = 140f, bh = 40f;
|
||||
|
||||
for(KeyBind keybind : KeyBind.all){
|
||||
if(!searchText.isEmpty() && !bundle.get("keybind." + keybind.name + ".name", keybind.name).toLowerCase(Locale.ROOT).contains(searchText.toLowerCase(Locale.ROOT))){
|
||||
continue;
|
||||
}
|
||||
|
||||
if(sections.length != 1){
|
||||
TextButton button = new TextButton(bundle.get("section." + section.name + ".name", Strings.capitalize(section.name)));
|
||||
if(section.equals(this.section))
|
||||
button.toggle();
|
||||
|
||||
button.clicked(() -> this.section = section);
|
||||
|
||||
group.add(button);
|
||||
cont.add(button).fill();
|
||||
if(lastCategory != keybind.category && keybind.category != null){
|
||||
table.add(bundle.get("category." + keybind.category + ".name", Strings.capitalize(keybind.category))).color(Color.gray).colspan(4).pad(10).padBottom(4).row();
|
||||
table.image().color(Color.gray).fillX().height(3).pad(6).colspan(4).padTop(0).padBottom(10).row();
|
||||
lastCategory = keybind.category;
|
||||
}
|
||||
|
||||
Table table = new Table();
|
||||
if(keybind.defaultValue instanceof Axis){
|
||||
table.add(bundle.get("keybind." + keybind.name + ".name", Strings.capitalize(keybind.name)), Color.white).left().padRight(40).padLeft(8);
|
||||
|
||||
Label device = new Label("Keyboard");
|
||||
//device.setColor(style.controllerColor);
|
||||
device.setAlignment(Align.center);
|
||||
table.labelWrap(() -> {
|
||||
Axis axis = keybind.value;
|
||||
return axis.key != null ? axis.key.toString() : axis.min + " [red]/[] " + axis.max;
|
||||
}).color(Pal.accent).left().minWidth(90).fillX().padRight(20);
|
||||
|
||||
Seq<InputDevice> devices = input.getDevices();
|
||||
table.button("@settings.rebind", tstyle, () -> {
|
||||
rebindAxis = true;
|
||||
rebindMin = true;
|
||||
openDialog(keybind);
|
||||
}).size(bw, bh);
|
||||
}else{
|
||||
table.add(bundle.get("keybind." + keybind.name + ".name", Strings.capitalize(keybind.name)), Color.white).left().padRight(40).padLeft(8);
|
||||
table.label(() -> keybind.value.key.toString()).color(Pal.accent).left().minWidth(90).padRight(20);
|
||||
|
||||
Table stable = new Table();
|
||||
|
||||
stable.button("<", () -> {
|
||||
int i = sectionControls.get(section, 0);
|
||||
if(i - 1 >= 0){
|
||||
sectionControls.put(section, i - 1);
|
||||
section.device = devices.get(i - 1);
|
||||
setup();
|
||||
}
|
||||
}).disabled(sectionControls.get(section, 0) - 1 < 0).size(40);
|
||||
|
||||
stable.add(device).minWidth(device.getMinWidth() + 60);
|
||||
|
||||
device.setText(input.getDevices().get(sectionControls.get(section, 0)).name());
|
||||
|
||||
stable.button(">", () -> {
|
||||
int i = sectionControls.get(section, 0);
|
||||
|
||||
if(i + 1 < devices.size){
|
||||
sectionControls.put(section, i + 1);
|
||||
section.device = devices.get(i + 1);
|
||||
setup();
|
||||
}
|
||||
}).disabled(sectionControls.get(section, 0) + 1 >= devices.size).size(40);
|
||||
|
||||
//no alternate devices until further notice
|
||||
//table.add(stable).colspan(4).row();
|
||||
|
||||
table.add().height(10);
|
||||
table.button("@settings.rebind", tstyle, () -> {
|
||||
rebindAxis = false;
|
||||
rebindMin = false;
|
||||
openDialog(keybind);
|
||||
}).size(bw, bh);
|
||||
}
|
||||
table.button("@settings.resetKey", tstyle, keybind::resetToDefault).disabled(t -> keybind.isDefault()).size(bw, bh).pad(2f).padLeft(4f);
|
||||
table.row();
|
||||
if(section.device.type() == DeviceType.controller){
|
||||
table.table(info -> info.add("Controller Type: [lightGray]" +
|
||||
Strings.capitalize(section.device.name())).left());
|
||||
}
|
||||
table.row();
|
||||
|
||||
String lastCategory = null;
|
||||
var tstyle = Styles.defaultt;
|
||||
|
||||
for(KeyBind keybind : keybinds.getKeybinds()){
|
||||
if(lastCategory != keybind.category() && keybind.category() != null){
|
||||
table.add(bundle.get("category." + keybind.category() + ".name", Strings.capitalize(keybind.category()))).color(Color.gray).colspan(4).pad(10).padBottom(4).row();
|
||||
table.image().color(Color.gray).fillX().height(3).pad(6).colspan(4).padTop(0).padBottom(10).row();
|
||||
lastCategory = keybind.category();
|
||||
}
|
||||
|
||||
if(keybind.defaultValue(section.device.type()) instanceof Axis){
|
||||
table.add(bundle.get("keybind." + keybind.name() + ".name", Strings.capitalize(keybind.name())), Color.white).left().padRight(40).padLeft(8);
|
||||
|
||||
table.labelWrap(() -> {
|
||||
Axis axis = keybinds.get(section, keybind);
|
||||
return axis.key != null ? axis.key.toString() : axis.min + " [red]/[] " + axis.max;
|
||||
}).color(Pal.accent).left().minWidth(90).fillX().padRight(20);
|
||||
|
||||
table.button("@settings.rebind", tstyle, () -> {
|
||||
rebindAxis = true;
|
||||
rebindMin = true;
|
||||
openDialog(section, keybind);
|
||||
}).width(130f);
|
||||
}else{
|
||||
table.add(bundle.get("keybind." + keybind.name() + ".name", Strings.capitalize(keybind.name())), Color.white).left().padRight(40).padLeft(8);
|
||||
table.label(() -> keybinds.get(section, keybind).key.toString()).color(Pal.accent).left().minWidth(90).padRight(20);
|
||||
|
||||
table.button("@settings.rebind", tstyle, () -> {
|
||||
rebindAxis = false;
|
||||
rebindMin = false;
|
||||
openDialog(section, keybind);
|
||||
}).width(130f);
|
||||
}
|
||||
table.button("@settings.resetKey", tstyle, () -> keybinds.resetToDefault(section, keybind)).width(130f).pad(2f).padLeft(4f);
|
||||
table.row();
|
||||
}
|
||||
|
||||
table.visible(() -> this.section.equals(section));
|
||||
|
||||
table.button("@settings.reset", () -> keybinds.resetToDefaults()).colspan(4).padTop(4).fill();
|
||||
|
||||
stack.add(table);
|
||||
}
|
||||
|
||||
cont.row();
|
||||
cont.add(pane).growX().colspan(sections.length);
|
||||
|
||||
table.button("@settings.reset", Icon.refresh, tstyle, KeyBind::resetAll).minWidth(200f).colspan(4).padTop(4).margin(10f).height(50f).fill();
|
||||
}
|
||||
|
||||
void rebind(Section section, KeyBind bind, KeyCode newKey){
|
||||
void rebind(KeyBind bind, KeyCode newKey){
|
||||
if(rebindKey == null) return;
|
||||
rebindDialog.hide();
|
||||
boolean isAxis = bind.defaultValue(section.device.type()) instanceof Axis;
|
||||
boolean isAxis = bind.defaultValue instanceof Axis;
|
||||
|
||||
if(isAxis){
|
||||
if(newKey.axis || !rebindMin){
|
||||
section.binds.get(section.device.type(), OrderedMap::new).put(rebindKey, newKey.axis ? new Axis(newKey) : new Axis(minKey, newKey));
|
||||
bind.value = newKey.axis ? new Axis(newKey) : new Axis(minKey, newKey);
|
||||
}
|
||||
}else{
|
||||
section.binds.get(section.device.type(), OrderedMap::new).put(rebindKey, new Axis(newKey));
|
||||
bind.value = new Axis(newKey);
|
||||
}
|
||||
bind.save();
|
||||
|
||||
if(rebindAxis && isAxis && rebindMin && !newKey.axis){
|
||||
rebindMin = false;
|
||||
minKey = newKey;
|
||||
openDialog(section, rebindKey);
|
||||
openDialog(rebindKey);
|
||||
}else{
|
||||
rebindKey = null;
|
||||
rebindAxis = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void openDialog(Section section, KeyBind name){
|
||||
private void openDialog( KeyBind name){
|
||||
rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press"));
|
||||
|
||||
rebindKey = name;
|
||||
|
||||
rebindDialog.titleTable.getCells().first().pad(4);
|
||||
|
||||
if(section.device.type() == DeviceType.keyboard){
|
||||
rebindDialog.addListener(new InputListener(){
|
||||
@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;
|
||||
}
|
||||
|
||||
rebindDialog.addListener(new InputListener(){
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
if(Core.app.isAndroid()) return false;
|
||||
rebind(section, name, button);
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean keyDown(InputEvent event, KeyCode keycode){
|
||||
rebindDialog.hide();
|
||||
rebind(name, keycode);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyDown(InputEvent event, KeyCode keycode){
|
||||
rebindDialog.hide();
|
||||
rebind(section, name, keycode);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
||||
if(!rebindAxis) return false;
|
||||
rebindDialog.hide();
|
||||
rebind(section, name, KeyCode.scroll);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@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;
|
||||
}
|
||||
});
|
||||
|
||||
rebindDialog.show();
|
||||
Time.runTask(1f, () -> getScene().setScrollFocus(rebindDialog));
|
||||
|
||||
@@ -84,7 +84,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
addListener(new InputListener(){
|
||||
@Override
|
||||
public boolean keyDown(InputEvent event, KeyCode key){
|
||||
if(event.targetActor == PlanetDialog.this && (key == KeyCode.escape || key == KeyCode.back || key == Core.keybinds.get(Binding.planet_map).key)){
|
||||
if(event.targetActor == PlanetDialog.this && (key == KeyCode.escape || key == KeyCode.back || key == Binding.planetMap.value.key)){
|
||||
if(showing() && newPresets.size > 1){
|
||||
//clear all except first, which is the last sector.
|
||||
newPresets.truncate(1);
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ResearchDialog extends BaseDialog{
|
||||
addCloseButton();
|
||||
|
||||
keyDown(key -> {
|
||||
if(key == Core.keybinds.get(Binding.research).key){
|
||||
if(key == Binding.research.value.key){
|
||||
Core.app.post(this::hide);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -65,19 +65,19 @@ public class ChatFragment extends Table{
|
||||
}
|
||||
|
||||
if(shown){
|
||||
if(input.keyTap(Binding.chat_history_prev) && historyPos < history.size - 1){
|
||||
if(input.keyTap(Binding.chatHistoryPrev) && historyPos < history.size - 1){
|
||||
if(historyPos == 0) history.set(0, chatfield.getText());
|
||||
historyPos++;
|
||||
updateChat();
|
||||
}
|
||||
if(input.keyTap(Binding.chat_history_next) && historyPos > 0){
|
||||
if(input.keyTap(Binding.chatHistoryNext) && historyPos > 0){
|
||||
historyPos--;
|
||||
updateChat();
|
||||
}
|
||||
if(input.keyTap(Binding.chat_mode)){
|
||||
if(input.keyTap(Binding.chatMode)){
|
||||
nextMode();
|
||||
}
|
||||
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chat_scroll), 0, Math.max(0, messages.size - messagesShown));
|
||||
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chatScroll), 0, Math.max(0, messages.size - messagesShown));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -62,18 +62,18 @@ public class ConsoleFragment extends Table{
|
||||
}
|
||||
|
||||
if(open){
|
||||
if(input.keyTap(Binding.chat_history_prev) && historyPos < history.size - 1){
|
||||
if(input.keyTap(Binding.chatHistoryPrev) && historyPos < history.size - 1){
|
||||
if(historyPos == 0) history.set(0, chatfield.getText());
|
||||
historyPos++;
|
||||
updateChat();
|
||||
}
|
||||
if(input.keyTap(Binding.chat_history_next) && historyPos > 0){
|
||||
if(input.keyTap(Binding.chatHistoryNext) && historyPos > 0){
|
||||
historyPos--;
|
||||
updateChat();
|
||||
}
|
||||
}
|
||||
|
||||
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chat_scroll), 0, Math.max(0, messages.size));
|
||||
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chatScroll), 0, Math.max(0, messages.size));
|
||||
});
|
||||
|
||||
history.insert(0, "");
|
||||
|
||||
@@ -164,7 +164,7 @@ public class HintsFragment{
|
||||
}
|
||||
|
||||
public enum DefaultHint implements Hint{
|
||||
desktopMove(visibleDesktop, () -> Core.input.axis(Binding.move_x) != 0 || Core.input.axis(Binding.move_y) != 0),
|
||||
desktopMove(visibleDesktop, () -> Core.input.axis(Binding.moveX) != 0 || Core.input.axis(Binding.moveY) != 0),
|
||||
zoom(visibleDesktop, () -> Core.input.axis(KeyCode.scroll) != 0),
|
||||
breaking(() -> isTutorial.get() && state.rules.defaultTeam.data().getCount(Blocks.conveyor) > 5, () -> ui.hints.events.contains("break")),
|
||||
desktopShoot(visibleDesktop, () -> isSerpulo() && Vars.state.enemies > 0, () -> player.shooting),
|
||||
@@ -175,8 +175,8 @@ public class HintsFragment{
|
||||
() -> control.input.commandMode && control.input.selectedUnits.size > 0 && control.input.selectedUnits.first().controller() instanceof CommandAI ai && ai.targetPos != null),
|
||||
respawn(visibleMobile, () -> !player.dead() && !player.unit().spawnedByCore, () -> !player.dead() && player.unit().spawnedByCore),
|
||||
launch(() -> (isTutorial.get() || Vars.state.rules.sector == SectorPresets.onset.sector) && state.rules.sector.isCaptured(), () -> ui.planet.isShown()),
|
||||
schematicSelect(visibleDesktop, () -> ui.hints.placedBlocks.contains(Blocks.router) || ui.hints.placedBlocks.contains(Blocks.ductRouter), () -> Core.input.keyRelease(Binding.schematic_select) || Core.input.keyTap(Binding.pick)),
|
||||
conveyorPathfind(() -> control.input.block == Blocks.titaniumConveyor, () -> Core.input.keyRelease(Binding.diagonal_placement) || (mobile && Core.settings.getBool("swapdiagonal"))),
|
||||
schematicSelect(visibleDesktop, () -> ui.hints.placedBlocks.contains(Blocks.router) || ui.hints.placedBlocks.contains(Blocks.ductRouter), () -> Core.input.keyRelease(Binding.schematicSelect) || Core.input.keyTap(Binding.pick)),
|
||||
conveyorPathfind(() -> control.input.block == Blocks.titaniumConveyor, () -> Core.input.keyRelease(Binding.diagonalPlacement) || (mobile && Core.settings.getBool("swapdiagonal"))),
|
||||
boost(visibleDesktop, () -> !player.dead() && player.unit().type.canBoost, () -> Core.input.keyDown(Binding.boost)),
|
||||
blockInfo(() -> control.input.block == Blocks.graphitePress, () -> ui.content.isShown()),
|
||||
derelict(() -> ui.hints.events.contains("derelictmouse") && !isTutorial.get(), () -> ui.hints.events.contains("derelictbreak")),
|
||||
|
||||
@@ -278,14 +278,14 @@ public class HudFragment{
|
||||
}
|
||||
|
||||
cont.update(() -> {
|
||||
if(Core.input.keyTap(Binding.toggle_menus) && !ui.chatfrag.shown() && !Core.scene.hasDialog() && !Core.scene.hasField()){
|
||||
if(Core.input.keyTap(Binding.toggleMenus) && !ui.chatfrag.shown() && !Core.scene.hasDialog() && !Core.scene.hasField()){
|
||||
Core.settings.getBoolOnce("ui-hidden", () -> {
|
||||
ui.announce(Core.bundle.format("showui", Core.keybinds.get(Binding.toggle_menus).key.toString(), 11));
|
||||
ui.announce(Core.bundle.format("showui", Binding.toggleMenus.value.key.toString(), 11));
|
||||
});
|
||||
toggleMenus();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.skip_wave) && canSkipWave()){
|
||||
if(Core.input.keyTap(Binding.skipWave) && canSkipWave()){
|
||||
if(net.client() && player.admin){
|
||||
Call.adminRequest(player, AdminAction.wave, null);
|
||||
}else{
|
||||
|
||||
@@ -54,21 +54,21 @@ public class PlacementFragment{
|
||||
boolean blockSelectEnd, wasCommandMode;
|
||||
int blockSelectSeq;
|
||||
long blockSelectSeqMillis;
|
||||
Binding[] blockSelect = {
|
||||
Binding.block_select_01,
|
||||
Binding.block_select_02,
|
||||
Binding.block_select_03,
|
||||
Binding.block_select_04,
|
||||
Binding.block_select_05,
|
||||
Binding.block_select_06,
|
||||
Binding.block_select_07,
|
||||
Binding.block_select_08,
|
||||
Binding.block_select_09,
|
||||
Binding.block_select_10,
|
||||
Binding.block_select_left,
|
||||
Binding.block_select_right,
|
||||
Binding.block_select_up,
|
||||
Binding.block_select_down
|
||||
KeyBind[] blockSelect = {
|
||||
Binding.blockSelect01,
|
||||
Binding.blockSelect02,
|
||||
Binding.blockSelect03,
|
||||
Binding.blockSelect04,
|
||||
Binding.blockSelect05,
|
||||
Binding.blockSelect06,
|
||||
Binding.blockSelect07,
|
||||
Binding.blockSelect08,
|
||||
Binding.blockSelect09,
|
||||
Binding.blockSelect10,
|
||||
Binding.blockSelectLeft,
|
||||
Binding.blockSelectRight,
|
||||
Binding.blockSelectUp,
|
||||
Binding.blockSelectDown
|
||||
};
|
||||
|
||||
public PlacementFragment(){
|
||||
@@ -230,7 +230,7 @@ public class PlacementFragment{
|
||||
}
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.category_prev)){
|
||||
if(Core.input.keyTap(Binding.categoryPrev)){
|
||||
int i = 0;
|
||||
do{
|
||||
currentCategory = currentCategory.prev();
|
||||
@@ -240,7 +240,7 @@ public class PlacementFragment{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.category_next)){
|
||||
if(Core.input.keyTap(Binding.categoryNext)){
|
||||
int i = 0;
|
||||
do{
|
||||
currentCategory = currentCategory.next();
|
||||
@@ -250,7 +250,7 @@ public class PlacementFragment{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.block_info)){
|
||||
if(Core.input.keyTap(Binding.blockInfo)){
|
||||
var build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
Block hovering = build == null ? null : build instanceof ConstructBuild c ? c.current : build.block;
|
||||
Block displayBlock = menuHoverBlock != null ? menuHoverBlock : input.block != null ? input.block : hovering;
|
||||
@@ -363,9 +363,9 @@ public class PlacementFragment{
|
||||
Seq<Block> blocks = getByCategory(currentCategory);
|
||||
for(int i = 0; i < blocks.size; i++){
|
||||
if(blocks.get(i) == displayBlock && (i + 1) / 10 - 1 < blockSelect.length){
|
||||
keyCombo = Core.bundle.format("placement.blockselectkeys", Core.keybinds.get(blockSelect[currentCategory.ordinal()]).key.toString())
|
||||
+ (i < 10 ? "" : Core.keybinds.get(blockSelect[(i + 1) / 10 - 1]).key.toString() + ",")
|
||||
+ Core.keybinds.get(blockSelect[i % 10]).key.toString() + "]";
|
||||
keyCombo = Core.bundle.format("placement.blockselectkeys", blockSelect[currentCategory.ordinal()].value.key.toString())
|
||||
+ (i < 10 ? "" : blockSelect[(i + 1) / 10 - 1].value.key.toString() + ",")
|
||||
+ blockSelect[i % 10].value.key.toString() + "]";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user