Moved launch controls to wave button
BIN
core/assets-raw/sprites/ui/button-edge-over-4.9.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
@@ -323,7 +323,7 @@ bestwave = [lightgray]Best Wave: {0}
|
|||||||
launch = < LAUNCH >
|
launch = < LAUNCH >
|
||||||
launch.title = Launch Successful
|
launch.title = Launch Successful
|
||||||
launch.next = [lightgray]next opportunity at wave {0}
|
launch.next = [lightgray]next opportunity at wave {0}
|
||||||
launch.unable = [scarlet]Unable to LAUNCH.[] {0} Enemies.
|
launch.unable2 = [scarlet]Unable to LAUNCH.[]
|
||||||
launch.confirm = This will launch all resources in your core.\nYou will not be able to return to this base.
|
launch.confirm = This will launch all resources in your core.\nYou will not be able to return to this base.
|
||||||
uncover = Uncover
|
uncover = Uncover
|
||||||
configure = Configure Loadout
|
configure = Configure Loadout
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 278 KiB After Width: | Height: | Size: 278 KiB |
|
Before Width: | Height: | Size: 464 KiB After Width: | Height: | Size: 461 KiB |
@@ -64,7 +64,12 @@
|
|||||||
checked: button-down,
|
checked: button-down,
|
||||||
down: button-down,
|
down: button-down,
|
||||||
up: button
|
up: button
|
||||||
}
|
},
|
||||||
|
wave: {
|
||||||
|
up: button-edge-4,
|
||||||
|
over: button-edge-over-4,
|
||||||
|
disabled: button-edge-4
|
||||||
|
},
|
||||||
},
|
},
|
||||||
TextButtonStyle: {
|
TextButtonStyle: {
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -1,42 +1,34 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.*;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.Events;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.input.*;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.input.KeyCode;
|
import io.anuke.arc.scene.*;
|
||||||
import io.anuke.arc.math.Interpolation;
|
import io.anuke.arc.scene.actions.*;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.scene.event.*;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.scene.style.*;
|
||||||
import io.anuke.arc.scene.Element;
|
|
||||||
import io.anuke.arc.scene.Group;
|
|
||||||
import io.anuke.arc.scene.actions.Actions;
|
|
||||||
import io.anuke.arc.scene.event.Touchable;
|
|
||||||
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
|
||||||
import io.anuke.arc.scene.ui.*;
|
import io.anuke.arc.scene.ui.*;
|
||||||
|
import io.anuke.arc.scene.ui.layout.Unit;
|
||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.scene.utils.Elements;
|
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.*;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.game.UnlockableContent;
|
import io.anuke.mindustry.graphics.*;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.input.*;
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
|
||||||
import io.anuke.mindustry.input.Binding;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Packets.AdminAction;
|
import io.anuke.mindustry.net.Packets.*;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.type.UnitType;
|
|
||||||
import io.anuke.mindustry.ui.*;
|
import io.anuke.mindustry.ui.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -144,21 +136,14 @@ public class HudFragment extends Fragment{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Table wavesMain, editorMain;
|
Table wavesMain, editorMain;
|
||||||
boolean[] prev = {false};
|
|
||||||
|
|
||||||
cont.stack(wavesMain = new Table(), editorMain = new Table()).height(wavesMain.getPrefHeight()).update(s -> {
|
cont.stack(wavesMain = new Table(), editorMain = new Table()).height(wavesMain.getPrefHeight());
|
||||||
((Table)s.getParent()).getCell(s).height((wavesMain.isVisible() ? wavesMain.getPrefHeight() : editorMain.getPrefHeight()) / Unit.dp.scl(1f));
|
|
||||||
if(prev[0] != wavesMain.isVisible()){
|
|
||||||
s.getParent().pack();
|
|
||||||
prev[0] = wavesMain.isVisible();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
{
|
{
|
||||||
wavesMain.visible(() -> shown && !state.isEditor());
|
wavesMain.visible(() -> shown && !state.isEditor());
|
||||||
wavesMain.left();
|
wavesMain.top().left();
|
||||||
Stack stack = new Stack();
|
Stack stack = new Stack();
|
||||||
TextButton waves = new TextButton("", "wave");
|
Button waves = new Button("wave");
|
||||||
Table btable = new Table().margin(0);
|
Table btable = new Table().margin(0);
|
||||||
|
|
||||||
stack.add(waves);
|
stack.add(waves);
|
||||||
@@ -327,59 +312,6 @@ public class HudFragment extends Fragment{
|
|||||||
.update(label -> label.getColor().set(Color.ORANGE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled);
|
.update(label -> label.getColor().set(Color.ORANGE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled);
|
||||||
});
|
});
|
||||||
|
|
||||||
//launch button
|
|
||||||
parent.fill(t -> {
|
|
||||||
t.top().right();
|
|
||||||
TextButton[] testb = {null};
|
|
||||||
TextButton button = Elements.newButton("$launch", () -> {
|
|
||||||
FloatingDialog dialog = new FloatingDialog("$launch");
|
|
||||||
dialog.update(() -> {
|
|
||||||
if(!testb[0].isVisible()){
|
|
||||||
dialog.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.cont.add("$launch.confirm").width(500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
|
||||||
dialog.buttons.defaults().size(200f, 54f).pad(2f);
|
|
||||||
dialog.setFillParent(false);
|
|
||||||
dialog.buttons.addButton("$cancel", dialog::hide);
|
|
||||||
dialog.buttons.addButton("$ok", () -> {
|
|
||||||
dialog.hide();
|
|
||||||
Call.launchZone();
|
|
||||||
});
|
|
||||||
dialog.keyDown(KeyCode.ESCAPE, dialog::hide);
|
|
||||||
dialog.keyDown(KeyCode.BACK, dialog::hide);
|
|
||||||
dialog.show();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
testb[0] = button;
|
|
||||||
|
|
||||||
button.getStyle().disabledFontColor = Color.WHITE;
|
|
||||||
button.margin(16f);
|
|
||||||
button.visible(() ->
|
|
||||||
world.isZone() &&
|
|
||||||
world.getZone().metCondition() &&
|
|
||||||
!Net.client() &&
|
|
||||||
state.wave % world.getZone().launchPeriod == 0 && !world.spawner.isSpawning());
|
|
||||||
|
|
||||||
button.update(() -> {
|
|
||||||
if(world.getZone() == null){
|
|
||||||
button.setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
button.setText(state.enemies() > 0 ? Core.bundle.format("launch.unable", state.enemies()) : Core.bundle.get("launch") + "\n" +
|
|
||||||
Core.bundle.format("launch.next", state.wave + world.getZone().launchPeriod));
|
|
||||||
|
|
||||||
button.getLabel().setColor(Tmp.c1.set(Color.WHITE).lerp(state.enemies() > 0 ? Color.WHITE : Color.SCARLET,
|
|
||||||
Mathf.absin(Time.time(), 2f, 1f)));
|
|
||||||
});
|
|
||||||
|
|
||||||
button.setDisabled(() -> state.enemies() > 0);
|
|
||||||
button.getLabelCell().left().get().setAlignment(Align.left, Align.left);
|
|
||||||
t.add(button).size(250f, 80f);
|
|
||||||
});
|
|
||||||
|
|
||||||
//paused table
|
//paused table
|
||||||
parent.fill(t -> {
|
parent.fill(t -> {
|
||||||
t.top().visible(() -> state.isPaused());
|
t.top().visible(() -> state.isPaused());
|
||||||
@@ -542,6 +474,37 @@ public class HudFragment extends Fragment{
|
|||||||
Core.scene.add(image);
|
Core.scene.add(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showLaunchConfirm(){
|
||||||
|
FloatingDialog dialog = new FloatingDialog("$launch");
|
||||||
|
dialog.update(() -> {
|
||||||
|
if(!inLaunchWave()){
|
||||||
|
dialog.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.cont.add("$launch.confirm").width(500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
||||||
|
dialog.buttons.defaults().size(200f, 54f).pad(2f);
|
||||||
|
dialog.setFillParent(false);
|
||||||
|
dialog.buttons.addButton("$cancel", dialog::hide);
|
||||||
|
dialog.buttons.addButton("$ok", () -> {
|
||||||
|
dialog.hide();
|
||||||
|
Call.launchZone();
|
||||||
|
});
|
||||||
|
dialog.keyDown(KeyCode.ESCAPE, dialog::hide);
|
||||||
|
dialog.keyDown(KeyCode.BACK, dialog::hide);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean inLaunchWave(){
|
||||||
|
return world.isZone() &&
|
||||||
|
world.getZone().metCondition() &&
|
||||||
|
!Net.client() &&
|
||||||
|
state.wave % world.getZone().launchPeriod == 0 && !world.spawner.isSpawning();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canLaunch(){
|
||||||
|
return inLaunchWave() && state.enemies() <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void toggleMenus(){
|
private void toggleMenus(){
|
||||||
if(flip != null){
|
if(flip != null){
|
||||||
flip.getStyle().imageUp = Core.scene.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
|
flip.getStyle().imageUp = Core.scene.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
|
||||||
@@ -553,7 +516,7 @@ public class HudFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addWaveTable(TextButton table){
|
private void addWaveTable(Button table){
|
||||||
StringBuilder ibuild = new StringBuilder();
|
StringBuilder ibuild = new StringBuilder();
|
||||||
|
|
||||||
IntFormat wavef = new IntFormat("wave");
|
IntFormat wavef = new IntFormat("wave");
|
||||||
@@ -586,6 +549,22 @@ public class HudFragment extends Fragment{
|
|||||||
builder.append(wavef.get(state.wave));
|
builder.append(wavef.get(state.wave));
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
|
|
||||||
|
if(inLaunchWave()){
|
||||||
|
builder.append("[#");
|
||||||
|
Tmp.c1.set(Color.WHITE).lerp(state.enemies() > 0 ? Color.WHITE : Color.SCARLET, Mathf.absin(Time.time(), 2f, 1f)).toString(builder);
|
||||||
|
builder.append("]");
|
||||||
|
|
||||||
|
if(!canLaunch()){
|
||||||
|
builder.append(Core.bundle.get("launch.unable2"));
|
||||||
|
}else{
|
||||||
|
builder.append(Core.bundle.get("launch"));
|
||||||
|
builder.append("\n");
|
||||||
|
builder.append(Core.bundle.format("launch.next", state.wave + world.getZone().launchPeriod));
|
||||||
|
builder.append("\n");
|
||||||
|
}
|
||||||
|
builder.append("[]\n");
|
||||||
|
}
|
||||||
|
|
||||||
if(state.enemies() > 0){
|
if(state.enemies() > 0){
|
||||||
if(state.enemies() == 1){
|
if(state.enemies() == 1){
|
||||||
builder.append(enemyf.get(state.enemies()));
|
builder.append(enemyf.get(state.enemies()));
|
||||||
@@ -604,8 +583,13 @@ public class HudFragment extends Fragment{
|
|||||||
return builder;
|
return builder;
|
||||||
}).growX().pad(8f);
|
}).growX().pad(8f);
|
||||||
|
|
||||||
table.setDisabled(true);
|
table.setDisabled(() -> !canLaunch());
|
||||||
table.visible(() -> state.rules.waves);
|
table.visible(() -> state.rules.waves);
|
||||||
|
table.clicked(() -> {
|
||||||
|
if(canLaunch()){
|
||||||
|
showLaunchConfirm();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayButton(Table table){
|
private void addPlayButton(Table table){
|
||||||
@@ -616,7 +600,6 @@ public class HudFragment extends Fragment{
|
|||||||
state.wavetime = 0f;
|
state.wavetime = 0f;
|
||||||
}
|
}
|
||||||
}).growY().fillX().right().width(40f)
|
}).growY().fillX().right().width(40f)
|
||||||
.visible(() -> state.rules.waves && ((Net.server() || player.isAdmin) || !Net.active()) && state.enemies() == 0
|
.visible(() -> state.rules.waves && ((Net.server() || player.isAdmin) || !Net.active()) && state.enemies() == 0 && !world.spawner.isSpawning() && !inLaunchWave());
|
||||||
&& !world.spawner.isSpawning());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||