Added editor playtest button
This commit is contained in:
@@ -383,6 +383,7 @@ editor.waves = Waves:
|
|||||||
editor.rules = Rules:
|
editor.rules = Rules:
|
||||||
editor.generation = Generation:
|
editor.generation = Generation:
|
||||||
editor.ingame = Edit In-Game
|
editor.ingame = Edit In-Game
|
||||||
|
editor.playtest = Playtest
|
||||||
editor.publish.workshop = Publish On Workshop
|
editor.publish.workshop = Publish On Workshop
|
||||||
editor.newmap = New Map
|
editor.newmap = New Map
|
||||||
editor.center = Center
|
editor.center = Center
|
||||||
|
|||||||
@@ -295,17 +295,31 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void playMap(Map map, Rules rules){
|
public void playMap(Map map, Rules rules){
|
||||||
|
playMap(map, rules, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playMap(Map map, Rules rules, boolean playtest){
|
||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
logic.reset();
|
logic.reset();
|
||||||
world.loadMap(map, rules);
|
world.loadMap(map, rules);
|
||||||
state.rules = rules;
|
state.rules = rules;
|
||||||
|
if(playtest) state.playtestingMap = map;
|
||||||
state.rules.sector = null;
|
state.rules.sector = null;
|
||||||
state.rules.editor = false;
|
state.rules.editor = false;
|
||||||
logic.play();
|
logic.play();
|
||||||
if(settings.getBool("savecreate") && !world.isInvalidMap()){
|
if(settings.getBool("savecreate") && !world.isInvalidMap() && !playtest){
|
||||||
control.saves.addSave(map.name() + " " + new SimpleDateFormat("MMM dd h:mm", Locale.getDefault()).format(new Date()));
|
control.saves.addSave(map.name() + " " + new SimpleDateFormat("MMM dd h:mm", Locale.getDefault()).format(new Date()));
|
||||||
}
|
}
|
||||||
Events.fire(Trigger.newGame);
|
Events.fire(Trigger.newGame);
|
||||||
|
|
||||||
|
//booted out of map, resume editing
|
||||||
|
if(world.isInvalidMap() && playtest){
|
||||||
|
Dialog current = scene.getDialog();
|
||||||
|
ui.editor.resumeAfterPlaytest(map);
|
||||||
|
if(current != null){
|
||||||
|
current.update(current::toFront);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public class GameState{
|
|||||||
public Teams teams = new Teams();
|
public Teams teams = new Teams();
|
||||||
/** Number of enemies in the game; only used clientside in servers. */
|
/** Number of enemies in the game; only used clientside in servers. */
|
||||||
public int enemies;
|
public int enemies;
|
||||||
|
/** Map being playtested (not edited!) */
|
||||||
|
public @Nullable Map playtestingMap;
|
||||||
/** Current game state. */
|
/** Current game state. */
|
||||||
private State state = State.menu;
|
private State state = State.menu;
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
private MapResizeDialog resizeDialog;
|
private MapResizeDialog resizeDialog;
|
||||||
private MapGenerateDialog generateDialog;
|
private MapGenerateDialog generateDialog;
|
||||||
private SectorGenerateDialog sectorGenDialog;
|
private SectorGenerateDialog sectorGenDialog;
|
||||||
|
private MapPlayDialog playtestDialog;
|
||||||
private ScrollPane pane;
|
private ScrollPane pane;
|
||||||
private BaseDialog menu;
|
private BaseDialog menu;
|
||||||
private Table blockSelection;
|
private Table blockSelection;
|
||||||
@@ -56,6 +57,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
infoDialog = new MapInfoDialog();
|
infoDialog = new MapInfoDialog();
|
||||||
generateDialog = new MapGenerateDialog(true);
|
generateDialog = new MapGenerateDialog(true);
|
||||||
sectorGenDialog = new SectorGenerateDialog();
|
sectorGenDialog = new SectorGenerateDialog();
|
||||||
|
playtestDialog = new MapPlayDialog();
|
||||||
|
|
||||||
menu = new BaseDialog("@menu");
|
menu = new BaseDialog("@menu");
|
||||||
menu.addCloseButton();
|
menu.addCloseButton();
|
||||||
@@ -122,6 +124,12 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
file.writePng(out);
|
file.writePng(out);
|
||||||
out.dispose();
|
out.dispose();
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
t.row();
|
||||||
|
|
||||||
|
t.button("@editor.ingame", Icon.right, this::editInGame);
|
||||||
|
|
||||||
|
t.button("@editor.playtest", Icon.play, this::playtest);
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.cont.row();
|
menu.cont.row();
|
||||||
@@ -172,14 +180,12 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
menu.cont.row();
|
menu.cont.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.cont.button("@editor.ingame", Icon.right, this::playtest).padTop(!steam && !experimental ? -3 : 1).size(swidth * 2f + 10, 60f);
|
|
||||||
|
|
||||||
menu.cont.row();
|
menu.cont.row();
|
||||||
|
|
||||||
menu.cont.button("@quit", Icon.exit, () -> {
|
menu.cont.button("@quit", Icon.exit, () -> {
|
||||||
tryExit();
|
tryExit();
|
||||||
menu.hide();
|
menu.hide();
|
||||||
}).size(swidth * 2f + 10, 60f);
|
}).padTop(!steam && !experimental ? -3 : 1).size(swidth * 2f + 10, 60f);
|
||||||
|
|
||||||
resizeDialog = new MapResizeDialog((x, y) -> {
|
resizeDialog = new MapResizeDialog((x, y) -> {
|
||||||
if(!(editor.width() == x && editor.height() == y)){
|
if(!(editor.width() == x && editor.height() == y)){
|
||||||
@@ -249,7 +255,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
editor.renderer.updateAll();
|
editor.renderer.updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playtest(){
|
private void editInGame(){
|
||||||
menu.hide();
|
menu.hide();
|
||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
lastSavedRules = state.rules;
|
lastSavedRules = state.rules;
|
||||||
@@ -283,6 +289,33 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resumeAfterPlaytest(Map map){
|
||||||
|
beginEditMap(map.file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playtest(){
|
||||||
|
menu.hide();
|
||||||
|
Map map = save();
|
||||||
|
|
||||||
|
if(map != null){
|
||||||
|
//skip dialog, play with survival or attack when shift clicked
|
||||||
|
if(Core.input.shift()){
|
||||||
|
hide();
|
||||||
|
//auto pick best fit
|
||||||
|
control.playMap(map, map.applyRules(
|
||||||
|
Gamemode.survival.valid(map) ? Gamemode.survival :
|
||||||
|
Gamemode.attack.valid(map) ? Gamemode.attack :
|
||||||
|
Gamemode.sandbox), true
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
playtestDialog.playListener = this::hide;
|
||||||
|
//TODO skip dialog? or reuse
|
||||||
|
//TODO set playtesting map, do not create save.
|
||||||
|
playtestDialog.show(map, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable Map save(){
|
public @Nullable Map save(){
|
||||||
boolean isEditor = state.rules.editor;
|
boolean isEditor = state.rules.editor;
|
||||||
state.rules.editor = false;
|
state.rules.editor = false;
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import mindustry.ui.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MapPlayDialog extends BaseDialog{
|
public class MapPlayDialog extends BaseDialog{
|
||||||
|
public @Nullable Runnable playListener;
|
||||||
|
|
||||||
CustomRulesDialog dialog = new CustomRulesDialog();
|
CustomRulesDialog dialog = new CustomRulesDialog();
|
||||||
Rules rules;
|
Rules rules;
|
||||||
Gamemode selectedGamemode = Gamemode.survival;
|
Gamemode selectedGamemode = Gamemode.survival;
|
||||||
@@ -31,6 +33,10 @@ public class MapPlayDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void show(Map map){
|
public void show(Map map){
|
||||||
|
show(map, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(Map map, boolean playtesting){
|
||||||
this.lastMap = map;
|
this.lastMap = map;
|
||||||
title.setText(map.name());
|
title.setText(map.name());
|
||||||
cont.clearChildren();
|
cont.clearChildren();
|
||||||
@@ -79,7 +85,8 @@ public class MapPlayDialog extends BaseDialog{
|
|||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
buttons.button("@play", Icon.play, () -> {
|
buttons.button("@play", Icon.play, () -> {
|
||||||
control.playMap(map, rules);
|
if(playListener != null) playListener.run();
|
||||||
|
control.playMap(map, rules, playtesting);
|
||||||
hide();
|
hide();
|
||||||
ui.custom.hide();
|
ui.custom.hide();
|
||||||
}).size(210f, 64f);
|
}).size(210f, 64f);
|
||||||
|
|||||||
@@ -105,13 +105,18 @@ public class PausedDialog extends BaseDialog{
|
|||||||
}else{
|
}else{
|
||||||
quit.run();
|
quit.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runExitSave(){
|
public void runExitSave(){
|
||||||
if(state.isEditor() && !wasClient){
|
if(state.isEditor() && !wasClient){
|
||||||
ui.editor.resumeEditing();
|
ui.editor.resumeEditing();
|
||||||
return;
|
return;
|
||||||
|
}else if(state.playtestingMap != null){
|
||||||
|
//no exit save here
|
||||||
|
var testing = state.playtestingMap;
|
||||||
|
logic.reset();
|
||||||
|
ui.editor.resumeAfterPlaytest(testing);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(control.saves.getCurrent() == null || !control.saves.getCurrent().isAutosave() || wasClient){
|
if(control.saves.getCurrent() == null || !control.saves.getCurrent().isAutosave() || wasClient){
|
||||||
|
|||||||
Reference in New Issue
Block a user