From 0b71dcecc02ece75feec19281c4341fffa44e86e Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 9 Jan 2018 23:10:41 -0500 Subject: [PATCH] Prepared for 3.3 beta release --- core/assets/bundles/bundle.properties | 13 +- .../src/io/anuke/mindustry/core/Tutorial.java | 5 +- .../anuke/mindustry/input/InputHandler.java | 1 + .../io/anuke/mindustry/input/PlaceMode.java | 6 + .../mindustry/ui/fragments/ChatFragment.java | 12 +- .../ui/fragments/PlacementFragment.java | 183 +++++++++++------- 6 files changed, 139 insertions(+), 81 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 7b4b8ca9d2..619eea289d 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -130,6 +130,15 @@ text.respawn=Respawning in text.error.title=[crimson]An error has occured text.error.crashmessage=[SCARLET]An unexpected error has occured, which would have caused a crash. []Please report the exact circumstances under which this error occured to the developer: \n[ORANGE]anukendev@gmail.com[] text.error.crashtitle=An error has occured +text.mode.break=Break mode: {0} +text.mode.place=Place mode: {0} +placemode.hold.name=line +placemode.areadelete.name=area +placemode.touchdelete.name=touch +placemode.holddelete.name=hold +placemode.none.name=none +placemode.touch.name=touch +placemode.cursor.name=cursor text.blocks.extrainfo=[accent]extra block info: text.blocks.blockinfo=Block Info text.blocks.powercapacity=Power Capacity @@ -211,7 +220,7 @@ map.spiral.name=spiral map.tutorial.name=tutorial tutorial.intro.text=[yellow]Welcome to the tutorial.[] To begin, press 'next'. tutorial.moveDesktop.text=To move, use the [orange][[WASD][] keys. Hold [orange]shift[] to boost. Hold [orange]CTRL[] while using the [orange]scrollwheel[] to zoom in or out. -tutorial.shoot.text=Use your mouse to aim, hold [orange]left mouse button[] to shootInternal. Try practicing on the [yellow]target[]. +tutorial.shoot.text=Use your mouse to aim, hold [orange]left mouse button[] to shoot. Try practicing on the [yellow]target[]. tutorial.moveAndroid.text=To pan the view, drag one finger across the screen. Pinch and drag to zoom in or out. tutorial.placeSelect.text=Try selecting a [yellow]conveyor[] from the block menu in the bottom right. tutorial.placeConveyorDesktop.text=Use the [orange][[scrollwheel][] to rotate the conveyor to face [orange]forwards[], then place it in the [yellow]marked location[] using the [orange][[left mouse button][]. @@ -250,7 +259,7 @@ tutorial.laserMore.text=You can check how much power a block has by hovering ove tutorial.healingTurret.text=This laser can be used to power a [lime]repair turret[]. Place one here. tutorial.healingTurretExplain.text=As long as it has power, this turret will [lime]repair nearby blocks.[] When playing, make sure you get one in your base as quickly as possible! tutorial.smeltery.text=Many blocks require [orange]steel[] to make, which requires a [orange]smelter[] to craft. Place one here. -tutorial.smelterySetup.text=This smelter will now produce [orange]steel[] from the input coal and iron. +tutorial.smelterySetup.text=This smelter will now produce [orange]steel[] from the input iron, using coal as fuel. tutorial.end.text=And that concludes the tutorial! Good luck! keybind.move_x.name=move_x keybind.move_y.name=move_y diff --git a/core/src/io/anuke/mindustry/core/Tutorial.java b/core/src/io/anuke/mindustry/core/Tutorial.java index acaf23cb39..99db58f233 100644 --- a/core/src/io/anuke/mindustry/core/Tutorial.java +++ b/core/src/io/anuke/mindustry/core/Tutorial.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.math.GridPoint2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.Item; -import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.*; @@ -374,6 +373,8 @@ public class Tutorial{ androidOnly = true; } }, + //TODO re-add tutorial on weapons + /* purchaseWeapons{ { desktopOnly = true; @@ -397,7 +398,7 @@ public class Tutorial{ Vars.ui.hudfrag.updateWeapons(); } } - }, + },*/ spawnWave{ float warmup = 0f; { diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 2b2e19f715..8de0abe0ea 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -35,6 +35,7 @@ public abstract class InputHandler extends InputAdapter{ public int rotation; public PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold; public PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete; + public PlaceMode lastPlaceMode = placeMode; public abstract void update(); public abstract float getCursorX(); diff --git a/core/src/io/anuke/mindustry/input/PlaceMode.java b/core/src/io/anuke/mindustry/input/PlaceMode.java index 6b5a5f8f6a..6c58a3b6ac 100644 --- a/core/src/io/anuke/mindustry/input/PlaceMode.java +++ b/core/src/io/anuke/mindustry/input/PlaceMode.java @@ -14,6 +14,7 @@ import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.utils.Cursors; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; @@ -393,4 +394,9 @@ public enum PlaceMode{ public void tapped(int x, int y){ } + + @Override + public String toString(){ + return Bundles.get("placemode."+name().toLowerCase()+".name"); + } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java index f1b7b1937f..98d40e9c4c 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java @@ -1,6 +1,5 @@ package io.anuke.mindustry.ui.fragments; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; @@ -81,7 +80,12 @@ public class ChatFragment extends Table implements Fragment{ add(chatfield).padBottom(offsety).padLeft(offsetx).growX().padRight(offsetx).height(28); if(Vars.android) { - addImageButton("icon-arrow-right", 14 * 2, this::toggle).size(50f, 55f).visible(() -> chatOpen); + marginBottom(110f); + marginRight(240f); + } + + if(Vars.android) { + addImageButton("icon-arrow-right", 14 * 2, this::toggle).size(46f, 51f).visible(() -> chatOpen).pad(2f); } } @@ -91,7 +95,7 @@ public class ChatFragment extends Table implements Fragment{ batch.setColor(shadowColor); if(chatOpen) - batch.draw(skin.getRegion("white"), offsetx, chatfield.getY(), Gdx.graphics.getWidth()-offsetx*2, chatfield.getHeight()-1); + batch.draw(skin.getRegion("white"), offsetx, chatfield.getY(), chatfield.getWidth() + 15f, chatfield.getHeight()-1); //font.getData().down = Unit.dp.scl(-21.5f); //font.getData().lineHeight = 22f; @@ -106,7 +110,7 @@ public class ChatFragment extends Table implements Fragment{ batch.setColor(shadowColor); - float theight = offsety + spacing; + float theight = offsety + spacing + getMarginBottom(); for(int i = 0; i < messagesShown && i < messages.size && i < fadetime; i ++){ layout.setText(font, messages.get(i).formattedMessage, Color.WHITE, textWidth, Align.bottomLeft, true); diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 5de804e180..e0f226f238 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -11,18 +11,22 @@ import io.anuke.mindustry.input.PlaceMode; import io.anuke.ucore.core.Core; import io.anuke.ucore.scene.actions.Actions; import io.anuke.ucore.scene.builders.imagebutton; +import io.anuke.ucore.scene.builders.label; import io.anuke.ucore.scene.builders.table; import io.anuke.ucore.scene.event.Touchable; import io.anuke.ucore.scene.ui.ButtonGroup; import io.anuke.ucore.scene.ui.ImageButton; +import io.anuke.ucore.scene.ui.Label; import io.anuke.ucore.scene.ui.layout.Table; +import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Mathf; import static io.anuke.mindustry.Vars.control; public class PlacementFragment implements Fragment{ - boolean shown = false; - Table breaktable, next; + boolean shown = false, placing = false; + Table breaktable, next, container; + Label modelabel; public void build(){ if(!Vars.android) return; @@ -30,6 +34,7 @@ public class PlacementFragment implements Fragment{ InputHandler input = control.getInput(); float s = 50f; + float translation = 54f; new table(){{ visible(() -> !GameState.is(State.menu)); @@ -41,6 +46,20 @@ public class PlacementFragment implements Fragment{ ButtonGroup breakGroup = new ButtonGroup<>(); update(t -> { + if((input.recipe == null) == placing){ + float i = 0.1f; + Interpolation n = Interpolation.pow3Out; + if(input.recipe == null){ + placing = false; + container.clearActions(); + container.actions(Actions.translateBy(0, -(container.getTranslation().y + translation), i, n)); + }else{ + placing = true; + container.clearActions(); + container.actions(Actions.translateBy(0, -(container.getTranslation().y), i, n)); + input.placeMode = input.lastPlaceMode; + } + } if(!input.placeMode.delete){ placeGroup.setMinCheckCount(1); @@ -72,95 +91,113 @@ public class PlacementFragment implements Fragment{ } }); - new table(){{ - visible(() -> input.recipe != null); - touchable(Touchable.enabled); + container = new table(){{ + modelabel = new label("").get(); - aleft(); + row(); - new table("pane"){{ - margin(5f); + new table() {{ + abottom(); aleft(); - defaults().size(s, s + 4).padBottom(-5.5f); + height(s + 5 + 4); - Color color = Color.GRAY; - - new imagebutton("icon-cancel", 14*3, ()->{ - input.recipe = null; - }).imageColor(color) - .visible(()->input.recipe != null); - - for(PlaceMode mode : PlaceMode.values()){ - if(!mode.shown || mode.delete) continue; - - new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{ - control.getInput().resetCursor(); - input.placeMode = mode; - }).group(placeGroup).get().setName(mode.name()); - } - - new imagebutton("icon-arrow", 14*3, ()->{ - input.rotation = Mathf.mod(input.rotation + 1, 4); - }).imageColor(color).visible(() -> input.recipe != null).update(image ->{ - image.getImage().setRotation(input.rotation *90); - image.getImage().setOrigin(Align.center); - }); - - }}.padBottom(-5).left().end(); - }}.left().end(); - - row(); - - new table(){{ - abottom(); - aleft(); - - height(s+5+4); - - next = new table("pane"){{ - margin(5f); - - defaults().padBottom(-5.5f); - - new imagebutton("icon-arrow-right", 10 * 3, () -> { - toggle(!shown); - }).update(l -> l.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-left" : "icon-" + input.breakMode.name())).size(s, s+4); - - }}.end().get(); - - breaktable = new table("pane"){{ - visible(() -> shown); - margin(5f); - marginLeft(0f); - touchable(Touchable.enabled); - aleft(); - - defaults().size(s, s+4); - - for(PlaceMode mode : PlaceMode.values()){ - if(!mode.shown || !mode.delete) continue; + next = new table("pane") {{ + margin(5f); defaults().padBottom(-5.5f); - new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{ - control.getInput().resetCursor(); - input.breakMode = mode; - if(!mode.both) input.placeMode = mode; - }).group(breakGroup).get().setName(mode.name()); - } + new imagebutton("icon-arrow-right", 10 * 3, () -> { + toggle(!shown); + }).update(l -> l.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-left" : "icon-" + input.breakMode.name())).size(s, s + 4); + + }}.end().get(); + + breaktable = new table("pane") {{ + visible(() -> shown); + margin(5f); + marginLeft(0f); + touchable(Touchable.enabled); + aleft(); + + defaults().size(s, s + 4); + + for (PlaceMode mode : PlaceMode.values()) { + if (!mode.shown || !mode.delete) continue; + + defaults().padBottom(-5.5f); + + new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> { + control.getInput().resetCursor(); + input.breakMode = mode; + if (!mode.both) input.placeMode = mode; + modeText(Bundles.format("text.mode.break", mode.toString())); + }).group(breakGroup).get().setName(mode.name()); + } + + }}.end().get(); + + breaktable.getParent().swapActor(breaktable, next); + + breaktable.getTranslation().set(-breaktable.getPrefWidth(), 0); }}.end().get(); - breaktable.getParent().swapActor(breaktable, next); + row(); - breaktable.getTranslation().set(-breaktable.getPrefWidth(), 0); + new table() {{ + touchable(Touchable.enabled); + + aleft(); + + new table("pane") {{ + margin(5f); + aleft(); + + defaults().size(s, s + 4).padBottom(-5.5f); + + Color color = Color.GRAY; + + new imagebutton("icon-cancel", 14 * 3, () -> { + input.recipe = null; + }).imageColor(color) + .visible(() -> input.recipe != null); + + for (PlaceMode mode : PlaceMode.values()) { + if (!mode.shown || mode.delete) continue; + + new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> { + control.getInput().resetCursor(); + input.placeMode = mode; + input.lastPlaceMode = mode; + modeText(Bundles.format("text.mode.place", mode.toString())); + }).group(placeGroup).get().setName(mode.name()); + } + + new imagebutton("icon-arrow", 14 * 3, () -> { + input.rotation = Mathf.mod(input.rotation + 1, 4); + }).imageColor(color).visible(() -> input.recipe != null).update(image -> { + image.getImage().setRotation(input.rotation * 90); + image.getImage().setOrigin(Align.center); + }); + + }}.left().end(); + }}.left().end(); }}.end().get(); + container.setTranslation(0, -translation); + }}.end(); } + private void modeText(String text){ + modelabel.setText(text); + modelabel.clearActions(); + modelabel.setColor(Color.WHITE); + modelabel.actions(Actions.fadeOut(5f, Interpolation.fade)); + } + private void toggle(boolean show){ float dur = 0.3f; Interpolation in = Interpolation.pow3Out;