Add basic map editor, change map system
This commit is contained in:
@@ -16,7 +16,7 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.scene.utils.Elements;
|
||||
|
||||
public class LevelDialog extends FloatingDialog{
|
||||
private Map selectedMap = Map.maze;
|
||||
private Map selectedMap = Vars.world.maps().getMap(0);
|
||||
private TextureRegion region = new TextureRegion();
|
||||
|
||||
public LevelDialog(){
|
||||
@@ -49,8 +49,8 @@ public class LevelDialog extends FloatingDialog{
|
||||
content().add(selmode);
|
||||
content().row();
|
||||
|
||||
for(int i = 0; i < Map.values().length; i ++){
|
||||
Map map = Map.values()[i];
|
||||
int i = 0;
|
||||
for(Map map : Vars.world.maps().list()){
|
||||
|
||||
if(!map.visible && !Vars.debug) continue;
|
||||
|
||||
@@ -59,9 +59,9 @@ public class LevelDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
Table inset = new Table("pane-button");
|
||||
inset.add("[accent]"+map.name()).pad(3f).units(Unit.dp);
|
||||
inset.add("[accent]"+map.name).pad(3f).units(Unit.dp);
|
||||
inset.row();
|
||||
inset.add((StringSupplier)(()->"High Score: [accent]" + Settings.getInt("hiscore" + map.name())))
|
||||
inset.add((StringSupplier)(()->"High Score: [accent]" + Settings.getInt("hiscore" + map.name)))
|
||||
.pad(3f).units(Unit.dp);
|
||||
inset.pack();
|
||||
|
||||
@@ -72,7 +72,7 @@ public class LevelDialog extends FloatingDialog{
|
||||
Image back = new Image("white");
|
||||
back.setColor(map.backgroundColor);
|
||||
|
||||
ImageButton image = new ImageButton(new TextureRegion(Vars.world.getTexture(map)), "togglemap");
|
||||
ImageButton image = new ImageButton(new TextureRegion(map.texture), "togglemap");
|
||||
image.row();
|
||||
image.add(inset).width(images+6).units(Unit.dp);
|
||||
image.clicked(()->{
|
||||
@@ -88,6 +88,8 @@ public class LevelDialog extends FloatingDialog{
|
||||
maps.add(stack).width(170).pad(4f).units(Unit.dp);
|
||||
|
||||
maps.padRight(Unit.dp.inPixels(26));
|
||||
|
||||
i ++;
|
||||
}
|
||||
|
||||
content().add(pane).uniformX();
|
||||
|
||||
@@ -55,7 +55,9 @@ public class LoadDialog extends FloatingDialog{
|
||||
|
||||
button.row();
|
||||
|
||||
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", " + SaveIO.getMap(slot) + ", Wave " + SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i)));
|
||||
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", "
|
||||
+ SaveIO.getMap(slot).name + ", Wave " + SaveIO.getWave(slot)
|
||||
+ "\nLast Saved: " + SaveIO.getTimeString(i)));
|
||||
info.setAlignment(Align.center, Align.center);
|
||||
|
||||
button.add(info).padBottom(3).padTop(7);
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
public class MapEditor{
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
@@ -7,16 +9,10 @@ import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.ui.MenuButton;
|
||||
import io.anuke.mindustry.ui.PressGroup;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
import static io.anuke.mindustry.Vars.android;
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.gwt;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class MenuFragment implements Fragment{
|
||||
|
||||
public void build(){
|
||||
@@ -30,22 +26,25 @@ public class MenuFragment implements Fragment{
|
||||
float scale = 4f;
|
||||
defaults().size(100*scale, 21*scale).pad(-10f).units(Unit.dp);
|
||||
|
||||
add(new MenuButton("text-play", group, ()-> ui.showLevels()));
|
||||
add(new MenuButton("text-play", group, ui::showLevels));
|
||||
row();
|
||||
|
||||
add(new MenuButton("text-tutorial", group, ()-> control.playMap(Map.tutorial)));
|
||||
add(new MenuButton("text-tutorial", group, ()-> control.playMap(world.maps().getMap("tutorial"))));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("text-load", group, ()-> ui.showLoadGame()));
|
||||
add(new MenuButton("text-load", group, ui::showLoadGame));
|
||||
row();
|
||||
|
||||
add(new MenuButton("text-editor", group, ui::showEditor));
|
||||
row();
|
||||
}
|
||||
|
||||
add(new MenuButton("text-settings", group, ()-> ui.showPrefs()));
|
||||
add(new MenuButton("text-settings", group, ui::showPrefs));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("text-exit", group, ()-> Gdx.app.exit()));
|
||||
add(new MenuButton("text-exit", group, Gdx.app::exit));
|
||||
}
|
||||
get().pad(Unit.dp.inPixels(16));
|
||||
}}.end();
|
||||
@@ -60,9 +59,13 @@ public class MenuFragment implements Fragment{
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("Play").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tutorial", isize, ()-> control.playMap(Map.tutorial)).text("Tutorial").padTop(4f);
|
||||
new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getMap("tutorial"))).text("Tutorial").padTop(4f);
|
||||
|
||||
new imagebutton("icon-load", isize, () -> ui.showLoadGame()).text("Load").padTop(4f);
|
||||
|
||||
row();
|
||||
|
||||
new imagebutton("icon-terrain", isize, () -> ui.showEditor()).text("Editor").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("Settings").padTop(4f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user