In-game editing (broken)
|
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B |
|
Before Width: | Height: | Size: 795 KiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 274 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 144 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 174 KiB |
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 240 KiB |
|
Before Width: | Height: | Size: 305 KiB After Width: | Height: | Size: 404 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 306 KiB |
|
Before Width: | Height: | Size: 598 KiB After Width: | Height: | Size: 685 KiB |
|
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 417 KiB |
@@ -40,6 +40,10 @@ public class GameState{
|
|||||||
state = astate;
|
state = astate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEditor(){
|
||||||
|
return rules.editor;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPaused(){
|
public boolean isPaused(){
|
||||||
return (is(State.paused) && !Net.active()) || (gameOver && !Net.active());
|
return (is(State.paused) && !Net.active()) || (gameOver && !Net.active());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class DrawOperation{
|
|||||||
public void undo(MapEditor editor){
|
public void undo(MapEditor editor){
|
||||||
for(int i = array.size - 1; i >= 0; i--){
|
for(int i = array.size - 1; i >= 0; i--){
|
||||||
long l = array.get(i);
|
long l = array.get(i);
|
||||||
array.set(i, TileOp.get(TileOp.x(l), TileOp.y(l), TileOp.type(l), get(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l))));
|
array.set(i, TileOp.get(TileOp.x(l), TileOp.y(l), TileOp.type(l), get(editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l))));
|
||||||
set(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.value(l));
|
set(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.value(l));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,12 +33,12 @@ public class DrawOperation{
|
|||||||
public void redo(MapEditor editor){
|
public void redo(MapEditor editor){
|
||||||
for(int i = 0; i < array.size; i++){
|
for(int i = 0; i < array.size; i++){
|
||||||
long l = array.get(i);
|
long l = array.get(i);
|
||||||
array.set(i, TileOp.get(TileOp.x(l), TileOp.y(l), TileOp.type(l), get(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l))));
|
array.set(i, TileOp.get(TileOp.x(l), TileOp.y(l), TileOp.type(l), get(editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l))));
|
||||||
set(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.value(l));
|
set(editor, editor.tile(TileOp.x(l), TileOp.y(l)), TileOp.type(l), TileOp.value(l));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short get(MapEditor editor, Tile tile, byte type){
|
short get(Tile tile, byte type){
|
||||||
if(type == OpType.floor.ordinal()){
|
if(type == OpType.floor.ordinal()){
|
||||||
return tile.floorID();
|
return tile.floorID();
|
||||||
}else if(type == OpType.block.ordinal()){
|
}else if(type == OpType.block.ordinal()){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.editor;
|
package io.anuke.mindustry.editor;
|
||||||
|
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.editor.DrawOperation.OpType;
|
import io.anuke.mindustry.editor.DrawOperation.OpType;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.gen.TileOp;
|
import io.anuke.mindustry.gen.TileOp;
|
||||||
@@ -9,6 +10,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.modules.*;
|
import io.anuke.mindustry.world.modules.*;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.state;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Vars.ui;
|
||||||
|
|
||||||
//TODO somehow remove or replace this class with a more flexible solution
|
//TODO somehow remove or replace this class with a more flexible solution
|
||||||
@@ -18,13 +20,13 @@ public class EditorTile extends Tile{
|
|||||||
super(x, y, floor, overlay, wall);
|
super(x, y, floor, overlay, wall);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Team getTeam(){
|
|
||||||
return Team.all[getTeamID()];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFloor(Floor type){
|
public void setFloor(Floor type){
|
||||||
|
if(state.is(State.playing)){
|
||||||
|
super.setFloor(type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(type instanceof OverlayFloor){
|
if(type instanceof OverlayFloor){
|
||||||
//don't place on liquids
|
//don't place on liquids
|
||||||
if(!floor.isLiquid){
|
if(!floor.isLiquid){
|
||||||
@@ -41,18 +43,37 @@ public class EditorTile extends Tile{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(Block type){
|
public void setBlock(Block type){
|
||||||
|
if(state.is(State.playing)){
|
||||||
|
super.setBlock(type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(block == type) return;
|
if(block == type) return;
|
||||||
op(OpType.block, block.id);
|
op(OpType.block, block.id);
|
||||||
|
if(rotation != 0) op(OpType.rotation, rotation);
|
||||||
|
if(team != 0) op(OpType.team, team);
|
||||||
super.setBlock(type);
|
super.setBlock(type);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO check if this line is necessary
|
@Override
|
||||||
//if(pteam != getTeamID()){
|
public void setBlock(Block type, Team team, int rotation){
|
||||||
// op((byte)OpType.team.ordinal(), pteam, getTeamID());
|
if(state.is(State.playing)){
|
||||||
//}
|
super.setBlock(type, team, rotation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setBlock(type);
|
||||||
|
setTeam(team);
|
||||||
|
rotation(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTeam(Team team){
|
public void setTeam(Team team){
|
||||||
|
if(state.is(State.playing)){
|
||||||
|
super.setTeam(team);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(getTeamID() == team.ordinal()) return;
|
if(getTeamID() == team.ordinal()) return;
|
||||||
op(OpType.team, getTeamID());
|
op(OpType.team, getTeamID());
|
||||||
super.setTeam(team);
|
super.setTeam(team);
|
||||||
@@ -60,6 +81,11 @@ public class EditorTile extends Tile{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rotation(int rotation){
|
public void rotation(int rotation){
|
||||||
|
if(state.is(State.playing)){
|
||||||
|
super.rotation(rotation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(rotation == rotation()) return;
|
if(rotation == rotation()) return;
|
||||||
op(OpType.rotation, rotation());
|
op(OpType.rotation, rotation());
|
||||||
super.rotation(rotation);
|
super.rotation(rotation);
|
||||||
@@ -67,6 +93,11 @@ public class EditorTile extends Tile{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOverlayID(short overlay){
|
public void setOverlayID(short overlay){
|
||||||
|
if(state.is(State.playing)){
|
||||||
|
super.setOverlayID(overlay);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(overlayID() == overlay) return;
|
if(overlayID() == overlay) return;
|
||||||
op(OpType.overlay, overlay);
|
op(OpType.overlay, overlay);
|
||||||
super.setOverlayID(overlay);
|
super.setOverlayID(overlay);
|
||||||
@@ -74,11 +105,21 @@ public class EditorTile extends Tile{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void preChanged(){
|
protected void preChanged(){
|
||||||
|
if(state.is(State.playing)){
|
||||||
|
super.preChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
super.setTeam(Team.none);
|
super.setTeam(Team.none);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void changed(){
|
protected void changed(){
|
||||||
|
if(state.is(State.playing)){
|
||||||
|
super.changed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
entity = null;
|
entity = null;
|
||||||
|
|
||||||
if(block == null){
|
if(block == null){
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.editor;
|
|||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
|
import io.anuke.arc.collection.StringMap;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.Consumer;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
@@ -18,6 +19,7 @@ import io.anuke.arc.scene.ui.layout.Unit;
|
|||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
|
import io.anuke.mindustry.game.Gamemode;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.io.MapIO;
|
import io.anuke.mindustry.io.MapIO;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.Map;
|
||||||
@@ -131,6 +133,10 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
menu.cont.row();
|
menu.cont.row();
|
||||||
|
|
||||||
|
menu.cont.addImageTextButton("$play", "icon-play", isize, this::playtest).padTop(-5).size(swidth * 2f + 10, 60f);
|
||||||
|
|
||||||
|
menu.cont.row();
|
||||||
|
|
||||||
menu.cont.addImageTextButton("$quit", "icon-back", isize, () -> {
|
menu.cont.addImageTextButton("$quit", "icon-back", isize, () -> {
|
||||||
tryExit();
|
tryExit();
|
||||||
menu.hide();
|
menu.hide();
|
||||||
@@ -203,6 +209,28 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
drawDefaultBackground(x, y);
|
drawDefaultBackground(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resumeEditing(){
|
||||||
|
shownWithMap = true;
|
||||||
|
show();
|
||||||
|
editor.renderer().updateAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playtest(){
|
||||||
|
menu.hide();
|
||||||
|
ui.loadAnd(() -> {
|
||||||
|
hide();
|
||||||
|
//logic.reset();
|
||||||
|
state.rules = Gamemode.editor.get();
|
||||||
|
world.setMap(new Map(StringMap.of(
|
||||||
|
"name", "Editor Playtesting",
|
||||||
|
"width", editor.width(),
|
||||||
|
"height", editor.height()
|
||||||
|
)));
|
||||||
|
world.endMapLoad();
|
||||||
|
logic.play();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void save(){
|
private void save(){
|
||||||
String name = editor.getTags().get("name", "").trim();
|
String name = editor.getTags().get("name", "").trim();
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,25 @@ public enum Gamemode{
|
|||||||
unitBuildSpeedMultiplier = 3f;
|
unitBuildSpeedMultiplier = 3f;
|
||||||
unitHealthMultiplier = 2f;
|
unitHealthMultiplier = 2f;
|
||||||
attackMode = true;
|
attackMode = true;
|
||||||
}});
|
}}),
|
||||||
|
editor(true, () -> new Rules(){{
|
||||||
|
infiniteResources = true;
|
||||||
|
editor = true;
|
||||||
|
waves = true;
|
||||||
|
waveTimer = false;
|
||||||
|
respawnTime = 0f;
|
||||||
|
}}),;
|
||||||
|
|
||||||
private final Supplier<Rules> rules;
|
private final Supplier<Rules> rules;
|
||||||
|
public final boolean hidden;
|
||||||
|
|
||||||
Gamemode(Supplier<Rules> rules){
|
Gamemode(Supplier<Rules> rules){
|
||||||
|
this(false, rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
Gamemode(boolean hidden, Supplier<Rules> rules){
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
|
this.hidden = hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rules get(){
|
public Rules get(){
|
||||||
|
|||||||
@@ -60,4 +60,6 @@ public class Rules{
|
|||||||
public boolean waitForWaveToEnd = false;
|
public boolean waitForWaveToEnd = false;
|
||||||
/** Determinates if gamemode is attack mode */
|
/** Determinates if gamemode is attack mode */
|
||||||
public boolean attackMode = false;
|
public boolean attackMode = false;
|
||||||
|
/** Whether this is the editor gamemode. */
|
||||||
|
public boolean editor = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
Table modes = new Table();
|
Table modes = new Table();
|
||||||
|
|
||||||
for(Gamemode mode : Gamemode.values()){
|
for(Gamemode mode : Gamemode.values()){
|
||||||
|
if(mode.hidden) continue;
|
||||||
modes.addButton(mode.toString(), "toggle", () -> {
|
modes.addButton(mode.toString(), "toggle", () -> {
|
||||||
selectedGamemode = mode;
|
selectedGamemode = mode;
|
||||||
rules = mode.get();
|
rules = mode.get();
|
||||||
@@ -147,6 +148,7 @@ public class CustomGameDialog extends FloatingDialog{
|
|||||||
pane.setFadeScrollBars(false);
|
pane.setFadeScrollBars(false);
|
||||||
table.row();
|
table.row();
|
||||||
for(Gamemode mode : Gamemode.values()){
|
for(Gamemode mode : Gamemode.values()){
|
||||||
|
if(mode.hidden) continue;
|
||||||
table.labelWrap("[accent]" + mode.toString() + ":[] [lightgray]" + mode.description()).width(400f);
|
table.labelWrap("[accent]" + mode.toString() + ":[] [lightgray]" + mode.description()).width(400f);
|
||||||
table.row();
|
table.row();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
cont.addButton("$settings", ui.settings::show);
|
cont.addButton("$settings", ui.settings::show);
|
||||||
|
|
||||||
if(!world.isZone()){
|
if(!world.isZone() && !state.isEditor()){
|
||||||
cont.row();
|
cont.row();
|
||||||
cont.addButton("$savegame", save::show);
|
cont.addButton("$savegame", save::show);
|
||||||
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
|
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
|
||||||
@@ -55,9 +55,10 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
|
|
||||||
cont.row();
|
cont.row();
|
||||||
|
|
||||||
cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f);
|
if(!state.isEditor()){
|
||||||
|
cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f);
|
||||||
cont.row();
|
cont.row();
|
||||||
|
}
|
||||||
|
|
||||||
cont.addButton("$quit", () -> {
|
cont.addButton("$quit", () -> {
|
||||||
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
||||||
@@ -74,7 +75,7 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
|
cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
|
||||||
cont.addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show);
|
cont.addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show);
|
||||||
|
|
||||||
if(!world.isZone()){
|
if(!world.isZone() && !state.isEditor()){
|
||||||
cont.addRowImageTextButton("$save", "icon-save", isize, save::show);
|
cont.addRowImageTextButton("$save", "icon-save", isize, save::show);
|
||||||
|
|
||||||
cont.row();
|
cont.row();
|
||||||
@@ -84,7 +85,9 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
cont.row();
|
cont.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
if(!state.isEditor()){
|
||||||
|
cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
||||||
|
}
|
||||||
cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> {
|
cont.addRowImageTextButton("$quit", "icon-quit", isize, () -> {
|
||||||
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
ui.showConfirm("$confirm", "$quit.confirm", () -> {
|
||||||
if(Net.client()) netClient.disconnectQuietly();
|
if(Net.client()) netClient.disconnectQuietly();
|
||||||
@@ -96,8 +99,12 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runExitSave(){
|
public void runExitSave(){
|
||||||
if(control.saves.getCurrent() == null ||
|
if(state.isEditor()){
|
||||||
!control.saves.getCurrent().isAutosave()){
|
ui.editor.resumeEditing();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(control.saves.getCurrent() == null || !control.saves.getCurrent().isAutosave()){
|
||||||
state.set(State.menu);
|
state.set(State.menu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ public class Tile implements Position, TargetTrait{
|
|||||||
protected Block block;
|
protected Block block;
|
||||||
protected Floor floor;
|
protected Floor floor;
|
||||||
/** Rotation, 0-3. Also used to store offload location, in which case it can be any number.*/
|
/** Rotation, 0-3. Also used to store offload location, in which case it can be any number.*/
|
||||||
private byte rotation;
|
protected byte rotation;
|
||||||
/** Team ordinal. */
|
/** Team ordinal. */
|
||||||
private byte team;
|
protected byte team;
|
||||||
/** Ore that is on top of this (floor) block. */
|
/** Ore that is on top of this (floor) block. */
|
||||||
private short overlay = 0;
|
protected short overlay = 0;
|
||||||
|
|
||||||
public Tile(int x, int y){
|
public Tile(int x, int y){
|
||||||
this.x = (short)x;
|
this.x = (short)x;
|
||||||
@@ -140,25 +140,12 @@ public class Tile implements Position, TargetTrait{
|
|||||||
preChanged();
|
preChanged();
|
||||||
this.block = type;
|
this.block = type;
|
||||||
this.team = (byte)team.ordinal();
|
this.team = (byte)team.ordinal();
|
||||||
this.rotation = 0;
|
|
||||||
this.rotation = (byte)Mathf.mod(rotation, 4);
|
|
||||||
changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlock(Block type, int rotation){
|
|
||||||
preChanged();
|
|
||||||
this.block = type;
|
|
||||||
this.rotation = 0;
|
|
||||||
this.rotation = (byte)Mathf.mod(rotation, 4);
|
this.rotation = (byte)Mathf.mod(rotation, 4);
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(Block type, Team team){
|
public void setBlock(Block type, Team team){
|
||||||
preChanged();
|
setBlock(type, team, 0);
|
||||||
this.block = type;
|
|
||||||
this.team = (byte)team.ordinal();
|
|
||||||
this.rotation = 0;
|
|
||||||
changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(Block type){
|
public void setBlock(Block type){
|
||||||
|
|||||||