From 65e65ba3088f385cb3546ca82361450c364b9000 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 11 Dec 2018 17:29:13 -0500 Subject: [PATCH] Formatting cleanup / Bugfix --- .../mindustry/input/DefaultKeybinds.java | 86 +++++++++---------- core/src/io/anuke/mindustry/ui/ItemImage.java | 4 +- .../mindustry/ui/fragments/HudFragment.java | 22 ++--- .../ui/fragments/PlacementFragment.java | 24 +++--- 4 files changed, 69 insertions(+), 67 deletions(-) diff --git a/core/src/io/anuke/mindustry/input/DefaultKeybinds.java b/core/src/io/anuke/mindustry/input/DefaultKeybinds.java index 5e9dcba515..69d993676e 100644 --- a/core/src/io/anuke/mindustry/input/DefaultKeybinds.java +++ b/core/src/io/anuke/mindustry/input/DefaultKeybinds.java @@ -16,52 +16,52 @@ public class DefaultKeybinds{ for(String section : sections){ KeyBinds.defaultSection(section, DeviceType.keyboard, - new Category("general"), - "move_x", new Axis(Input.A, Input.D), - "move_y", new Axis(Input.S, Input.W), - "select", Input.MOUSE_LEFT, - "deselect", Input.MOUSE_RIGHT, - "break", Input.MOUSE_RIGHT, - "rotate", new Axis(Input.SCROLL), - "dash", Input.SHIFT_LEFT, - "drop_unit", Input.SHIFT_LEFT, - "gridMode", Input.ALT_LEFT, - "gridModeShift", Input.SHIFT_LEFT, - new Category("view"), - "zoom_hold", Input.CONTROL_LEFT, - "zoom", new Axis(Input.SCROLL), - "zoom_minimap", new Axis(Input.MINUS, Input.PLUS), - "menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE, - "pause", Input.SPACE, - "toggle_menus", Input.C, - "screenshot", Input.P, - new Category("multiplayer"), - "player_list", Input.TAB, - "chat", Input.ENTER, - "chat_history_prev", Input.UP, - "chat_history_next", Input.DOWN, - "chat_scroll", new Axis(Input.SCROLL) + new Category("general"), + "move_x", new Axis(Input.A, Input.D), + "move_y", new Axis(Input.S, Input.W), + "select", Input.MOUSE_LEFT, + "deselect", Input.MOUSE_RIGHT, + "break", Input.MOUSE_RIGHT, + "rotate", new Axis(Input.SCROLL), + "dash", Input.SHIFT_LEFT, + "drop_unit", Input.SHIFT_LEFT, + "gridMode", Input.ALT_LEFT, + "gridModeShift", Input.SHIFT_LEFT, + new Category("view"), + "zoom_hold", Input.CONTROL_LEFT, + "zoom", new Axis(Input.SCROLL), + "zoom_minimap", new Axis(Input.MINUS, Input.PLUS), + "menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE, + "pause", Input.SPACE, + "toggle_menus", Input.C, + "screenshot", Input.P, + new Category("multiplayer"), + "player_list", Input.TAB, + "chat", Input.ENTER, + "chat_history_prev", Input.UP, + "chat_history_next", Input.DOWN, + "chat_scroll", new Axis(Input.SCROLL) ); KeyBinds.defaultSection(section, DeviceType.controller, - new Category("general"), - "move_x", new Axis(Input.CONTROLLER_L_STICK_HORIZONTAL_AXIS), - "move_y", new Axis(Input.CONTROLLER_L_STICK_VERTICAL_AXIS), - "cursor_x", new Axis(Input.CONTROLLER_R_STICK_HORIZONTAL_AXIS), - "cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS), - //"select", Input.CONTROLLER_R_BUMPER, - //"break", Input.CONTROLLER_L_BUMPER, - //"shoot", Input.CONTROLLER_R_TRIGGER, - "dash", Input.CONTROLLER_Y, - "rotate_alt", new Axis(Input.CONTROLLER_DPAD_RIGHT, Input.CONTROLLER_DPAD_LEFT), - "rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B), - new Category("view"), - "zoom_hold", Input.ANY_KEY, - "zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP), - "menu", Input.CONTROLLER_X, - "pause", Input.CONTROLLER_L_TRIGGER, - new Category("multiplayer"), - "player_list", Input.CONTROLLER_START + new Category("general"), + "move_x", new Axis(Input.CONTROLLER_L_STICK_HORIZONTAL_AXIS), + "move_y", new Axis(Input.CONTROLLER_L_STICK_VERTICAL_AXIS), + "cursor_x", new Axis(Input.CONTROLLER_R_STICK_HORIZONTAL_AXIS), + "cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS), + //"select", Input.CONTROLLER_R_BUMPER, + //"break", Input.CONTROLLER_L_BUMPER, + //"shoot", Input.CONTROLLER_R_TRIGGER, + "dash", Input.CONTROLLER_Y, + "rotate_alt", new Axis(Input.CONTROLLER_DPAD_RIGHT, Input.CONTROLLER_DPAD_LEFT), + "rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B), + new Category("view"), + "zoom_hold", Input.ANY_KEY, + "zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP), + "menu", Input.CONTROLLER_X, + "pause", Input.CONTROLLER_L_TRIGGER, + new Category("multiplayer"), + "player_list", Input.CONTROLLER_START ); } diff --git a/core/src/io/anuke/mindustry/ui/ItemImage.java b/core/src/io/anuke/mindustry/ui/ItemImage.java index 130916cb26..64007340af 100644 --- a/core/src/io/anuke/mindustry/ui/ItemImage.java +++ b/core/src/io/anuke/mindustry/ui/ItemImage.java @@ -11,7 +11,7 @@ public class ItemImage extends Stack{ public ItemImage(TextureRegion region, Supplier text){ Table t = new Table().left().bottom(); - t.label(text); + t.label(text).name("item-label"); add(new Image(region)); add(t); @@ -22,7 +22,7 @@ public class ItemImage extends Stack{ if(stack.amount != 0){ Table t = new Table().left().bottom(); - t.add(stack.amount + ""); + t.add(stack.amount + "").name("item-label"); add(t); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 9532564de0..9037574c38 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -198,7 +198,7 @@ public class HudFragment extends Fragment{ return coreAttackOpacity > 0; }); t.table("button", top -> top.add("$text.coreattack").pad(2) - .update(label -> label.setColor(Hue.mix(Color.ORANGE, Color.SCARLET, Mathf.absin(Timers.time(), 2f, 1f))))); + .update(label -> label.setColor(Hue.mix(Color.ORANGE, Color.SCARLET, Mathf.absin(Timers.time(), 2f, 1f))))); }); //'saving' indicator @@ -371,16 +371,16 @@ public class HudFragment extends Fragment{ table.setTouchable(Touchable.enabled); table.labelWrap(() -> - world.getSector() == null ? - (state.enemies() > 0 && state.mode.disableWaveTimer ? - wavef.get(state.wave) + "\n" + (state.enemies() == 1 ? - enemyf.get(state.enemies()) : - enemiesf.get(state.enemies())) : - wavef.get(state.wave) + "\n" + - (!state.mode.disableWaveTimer ? - Bundles.format("text.wave.waiting", (int) (state.wavetime / 60)) : - Bundles.get("text.waiting"))) : - Bundles.format("text.mission.display", world.getSector().currentMission().displayString())).growX().pad(8f); + world.getSector() == null ? + (state.enemies() > 0 && state.mode.disableWaveTimer ? + wavef.get(state.wave) + "\n" + (state.enemies() == 1 ? + enemyf.get(state.enemies()) : + enemiesf.get(state.enemies())) : + wavef.get(state.wave) + "\n" + + (!state.mode.disableWaveTimer ? + Bundles.format("text.wave.waiting", (int)(state.wavetime/60)) : + Bundles.get("text.waiting"))) : + Bundles.format("text.mission.display", world.getSector().currentMission().displayString())).growX().pad(8f); table.clicked(() -> { if(world.getSector() != null && world.getSector().currentMission().hasMessage()){ diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 7d07460b8a..ad37a2df83 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -42,15 +42,15 @@ public class PlacementFragment extends Fragment{ boolean lastGround; final Input[] inputGrid = { - Input.NUM_1, Input.NUM_2, Input.NUM_3, Input.NUM_4, - Input.Q, Input.W, Input.E, Input.R, - Input.A, Input.S, Input.D, Input.F, - Input.Z, Input.X, Input.C, Input.V + Input.NUM_1, Input.NUM_2, Input.NUM_3, Input.NUM_4, + Input.Q, Input.W, Input.E, Input.R, + Input.A, Input.S, Input.D, Input.F, + Input.Z, Input.X, Input.C, Input.V }, inputCatGrid = { - Input.NUM_1, Input.NUM_2, - Input.Q, Input.W, - Input.A, Input.S, - Input.Z, Input.X, Input.C, Input.V + Input.NUM_1, Input.NUM_2, + Input.Q, Input.W, + Input.A, Input.S, + Input.Z, Input.X, Input.C, Input.V }; public PlacementFragment(){ @@ -75,10 +75,12 @@ public class PlacementFragment extends Fragment{ } return true; }else if(Inputs.keyDown("select")){ // Mouse eyedropper select - Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y).target(); - if(tile.block() != null){ + Tile tile = world.tileWorld(Graphics.mouseWorld().x, Graphics.mouseWorld().y); + + if(tile != null){ + tile = tile.target(); Recipe tryRecipe = Recipe.getByResult(tile.block()); - if((tryRecipe != null) && control.unlocks.isUnlocked(tryRecipe)){ + if(tryRecipe != null && control.unlocks.isUnlocked(tryRecipe)){ input.recipe = tryRecipe; currentCategory = input.recipe.category; return true;