New WIP custom map selection
This commit is contained in:
@@ -2,28 +2,18 @@ package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.ButtonGroup;
|
||||
import io.anuke.arc.scene.ui.ImageButton;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.TextButton;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.arc.util.Scaling;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.Gamemode;
|
||||
import io.anuke.mindustry.game.Rules;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class CustomGameDialog extends FloatingDialog{
|
||||
Difficulty difficulty = Difficulty.normal;
|
||||
CustomRulesDialog dialog = new CustomRulesDialog();
|
||||
Rules rules;
|
||||
Gamemode selectedGamemode;
|
||||
private MapPlayDialog dialog = new MapPlayDialog();
|
||||
|
||||
public CustomGameDialog(){
|
||||
super("$customgame");
|
||||
@@ -33,9 +23,9 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
selectedGamemode = Gamemode.survival;
|
||||
rules = selectedGamemode.get();
|
||||
|
||||
clearChildren();
|
||||
stack(cont, buttons).grow();
|
||||
buttons.bottom();
|
||||
cont.clear();
|
||||
|
||||
Table maps = new Table();
|
||||
@@ -44,64 +34,9 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
pane.setFadeScrollBars(false);
|
||||
|
||||
int maxwidth = (Core.graphics.isPortrait() ? 2 : 4);
|
||||
|
||||
Table selmode = new Table();
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
selmode.add("$level.mode").colspan(4);
|
||||
selmode.row();
|
||||
int i = 0;
|
||||
|
||||
Table modes = new Table();
|
||||
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
if(mode.hidden) continue;
|
||||
modes.addButton(mode.toString(), "toggle", () -> {
|
||||
selectedGamemode = mode;
|
||||
rules = mode.get();
|
||||
dialog.selectedGamemode = null;
|
||||
dialog.rules = null;
|
||||
}).update(b -> b.setChecked(selectedGamemode == mode)).group(group).size(140f, 54f);
|
||||
if(i++ % 2 == 1) modes.row();
|
||||
}
|
||||
selmode.add(modes);
|
||||
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
|
||||
|
||||
cont.add(selmode);
|
||||
cont.row();
|
||||
|
||||
Difficulty[] ds = Difficulty.values();
|
||||
|
||||
float s = 50f;
|
||||
|
||||
Table sdif = new Table();
|
||||
|
||||
sdif.add("$setting.difficulty.name").colspan(3);
|
||||
sdif.row();
|
||||
sdif.defaults().height(s + 4);
|
||||
sdif.addImageButton("icon-arrow-left", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() - 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
|
||||
sdif.addButton("", () -> {
|
||||
})
|
||||
.update(t -> {
|
||||
t.setText(difficulty.toString());
|
||||
t.touchable(Touchable.disabled);
|
||||
}).width(180f);
|
||||
|
||||
sdif.addImageButton("icon-arrow-right", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() + 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
sdif.addButton("$customize", () -> dialog.show(rules, selectedGamemode)).width(140).padLeft(10);
|
||||
|
||||
cont.add(sdif);
|
||||
cont.row();
|
||||
|
||||
float images = 146f;
|
||||
|
||||
i = 0;
|
||||
int i = 0;
|
||||
maps.defaults().width(170).fillY().top().pad(4f);
|
||||
for(Map map : world.maps.all()){
|
||||
|
||||
@@ -122,10 +57,7 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
border.setScaling(Scaling.fit);
|
||||
image.replaceImage(border);
|
||||
|
||||
image.clicked(() -> {
|
||||
hide();
|
||||
control.playMap(map, (dialog.rules == null) ? rules : dialog.rules);
|
||||
});
|
||||
image.clicked(() -> dialog.show(map));
|
||||
|
||||
maps.add(image);
|
||||
|
||||
@@ -138,23 +70,4 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
|
||||
cont.add(pane).uniformX();
|
||||
}
|
||||
|
||||
private void displayGameModeHelp(){
|
||||
FloatingDialog d = new FloatingDialog(Core.bundle.get("mode.help.title"));
|
||||
d.setFillParent(false);
|
||||
Table table = new Table();
|
||||
table.defaults().pad(1f);
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
pane.setFadeScrollBars(false);
|
||||
table.row();
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
if(mode.hidden) continue;
|
||||
table.labelWrap("[accent]" + mode.toString() + ":[] [lightgray]" + mode.description()).width(400f);
|
||||
table.row();
|
||||
}
|
||||
|
||||
d.cont.add(pane);
|
||||
d.buttons.addButton("$ok", d::hide).size(110, 50).pad(10f);
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.Gamemode;
|
||||
import io.anuke.mindustry.game.Rules;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
|
||||
@@ -14,7 +13,6 @@ import static io.anuke.mindustry.Vars.tilesize;
|
||||
public class CustomRulesDialog extends FloatingDialog{
|
||||
private Table main;
|
||||
public Rules rules;
|
||||
public Gamemode selectedGamemode;
|
||||
|
||||
public CustomRulesDialog(){
|
||||
super("$mode.custom");
|
||||
@@ -24,9 +22,9 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(Rules rules, Gamemode gamemode){
|
||||
public void show(Rules rules){
|
||||
this.rules = rules;
|
||||
this.selectedGamemode = gamemode;
|
||||
// this.selectedGamemode = gamemode;
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -35,7 +33,7 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
cont.pane(m -> main = m);
|
||||
main.margin(10f);
|
||||
main.addButton("$settings.reset", () -> {
|
||||
rules = selectedGamemode.get();
|
||||
//rules = selectedGamemode.get();
|
||||
setup();
|
||||
}).size(300f, 50f);
|
||||
main.left().defaults().fillX().left().pad(5);
|
||||
@@ -63,7 +61,7 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
number("$rules.playerhealthmultiplier", f -> rules.playerHealthMultiplier = f, () -> rules.playerHealthMultiplier);
|
||||
|
||||
title("$rules.title.unit");
|
||||
check("$rules.unitdrops", b -> rules.unitDrops = b, () -> rules.unitDrops, ()->true);
|
||||
check("$rules.unitdrops", b -> rules.unitDrops = b, () -> rules.unitDrops, () -> true);
|
||||
number("$rules.unitbuildspeedmultiplier", f -> rules.unitBuildSpeedMultiplier = f, () -> rules.unitBuildSpeedMultiplier);
|
||||
number("$rules.unithealthmultiplier", f -> rules.unitHealthMultiplier = f, () -> rules.unitHealthMultiplier);
|
||||
number("$rules.unitdamagemultiplier", f -> rules.unitDamageMultiplier = f, () -> rules.unitDamageMultiplier);
|
||||
|
||||
117
core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java
Normal file
117
core/src/io/anuke/mindustry/ui/dialogs/MapPlayDialog.java
Normal file
@@ -0,0 +1,117 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Scaling;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
public class MapPlayDialog extends FloatingDialog{
|
||||
Difficulty difficulty = Difficulty.normal;
|
||||
CustomRulesDialog dialog = new CustomRulesDialog();
|
||||
Rules rules;
|
||||
Gamemode selectedGamemode;
|
||||
|
||||
public MapPlayDialog(){
|
||||
super("");
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(Map map){
|
||||
title.setText(map.name());
|
||||
cont.clearChildren();
|
||||
|
||||
selectedGamemode = Gamemode.survival;
|
||||
rules = selectedGamemode.apply(new Rules());
|
||||
|
||||
Table selmode = new Table();
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
selmode.add("$level.mode").colspan(4);
|
||||
selmode.row();
|
||||
int i = 0;
|
||||
|
||||
Table modes = new Table();
|
||||
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
if(mode.hidden) continue;
|
||||
|
||||
if((mode == Gamemode.attack && !map.hasEnemyCore()) || (mode == Gamemode.pvp && !map.hasOtherCores())){
|
||||
continue;
|
||||
}
|
||||
|
||||
modes.addButton(mode.toString(), "toggle", () -> {
|
||||
selectedGamemode = mode;
|
||||
//rules = mode.get();
|
||||
//dialog.selectedGamemode = null;
|
||||
dialog.rules = null;
|
||||
}).update(b -> b.setChecked(selectedGamemode == mode)).group(group).size(140f, 54f);
|
||||
if(i++ % 2 == 1) modes.row();
|
||||
}
|
||||
selmode.add(modes);
|
||||
selmode.addButton("?", this::displayGameModeHelp).width(50f).fillY().padLeft(18f);
|
||||
|
||||
cont.add(selmode);
|
||||
cont.row();
|
||||
|
||||
Difficulty[] ds = Difficulty.values();
|
||||
|
||||
float s = 50f;
|
||||
|
||||
Table sdif = new Table();
|
||||
|
||||
sdif.add("$setting.difficulty.name").colspan(3);
|
||||
sdif.row();
|
||||
sdif.defaults().height(s + 4);
|
||||
sdif.addImageButton("icon-arrow-left", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() - 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
|
||||
sdif.addButton("", () -> {}).update(t -> {
|
||||
t.setText(difficulty.toString());
|
||||
t.touchable(Touchable.disabled);
|
||||
}).width(180f);
|
||||
|
||||
sdif.addImageButton("icon-arrow-right", 10 * 3, () -> {
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() + 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
sdif.addButton("$customize", () -> dialog.show(rules)).width(140).padLeft(10);
|
||||
|
||||
cont.add(sdif);
|
||||
cont.row();
|
||||
if(map.hasTag("description")){
|
||||
cont.add(map.description()).color(Color.LIGHT_GRAY);
|
||||
cont.row();
|
||||
}
|
||||
cont.add(new BorderImage(map.texture, 3f)).grow().get().setScaling(Scaling.fit);
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
private void displayGameModeHelp(){
|
||||
FloatingDialog d = new FloatingDialog(Core.bundle.get("mode.help.title"));
|
||||
d.setFillParent(false);
|
||||
Table table = new Table();
|
||||
table.defaults().pad(1f);
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
pane.setFadeScrollBars(false);
|
||||
table.row();
|
||||
for(Gamemode mode : Gamemode.values()){
|
||||
if(mode.hidden) continue;
|
||||
table.labelWrap("[accent]" + mode.toString() + ":[] [lightgray]" + mode.description()).width(400f);
|
||||
table.row();
|
||||
}
|
||||
|
||||
d.cont.add(pane);
|
||||
d.buttons.addButton("$ok", d::hide).size(110, 50).pad(10f);
|
||||
d.show();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user