Custom game loading

This commit is contained in:
Anuken
2019-01-26 10:52:16 -05:00
parent 0f26d62a0a
commit 83b5f6ef2d
2 changed files with 25 additions and 6 deletions

View File

@ -39,6 +39,7 @@ loadgame = Load Game
joingame = Join Game
addplayers = Add/Remove Players
customgame = Custom Game
newgame = New Game
none = <none>
close = Close
quit = Quit

View File

@ -11,6 +11,7 @@ import io.anuke.mindustry.game.EventType.ResizeEvent;
import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.ui.MenuButton;
import io.anuke.mindustry.ui.MobileButton;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import static io.anuke.mindustry.Vars.*;
@ -56,19 +57,19 @@ public class MenuFragment extends Fragment{
container.defaults().size(size).pad(5).padTop(4f);
MobileButton
play = new MobileButton("icon-play-2", isize, "$play", this::showPlaySelect),
play = new MobileButton("icon-play-2", isize, "$play", ui.deploy::show),
maps = new MobileButton("icon-map", isize, "$maps", ui.maps::show),
load = new MobileButton("icon-load", isize, "$load", ui.load::show),
custom = new MobileButton("icon-play-custom", isize, "customgame", this::showCustomSelect),
join = new MobileButton("icon-add", isize, "$joingame", ui.join::show),
editor = new MobileButton("icon-editor", isize, "$editor", () -> ui.loadAnd(ui.editor::show)),
tools = new MobileButton("icon-tools", isize, "$settings", ui.settings::show),
unlocks = new MobileButton("icon-unlocks", isize, "database", ui.database::show),
unlocks = new MobileButton("icon-unlocks", isize, "$database", ui.database::show),
donate = new MobileButton("icon-donate", isize, "$donate", Platform.instance::openDonations);
if(Core.graphics.getWidth() > Core.graphics.getHeight()){
container.add(play);
container.add(join);
container.add(load);
container.add(custom);
container.add(maps);
container.row();
@ -85,7 +86,7 @@ public class MenuFragment extends Fragment{
container.add(play);
container.add(maps);
container.row();
container.add(load);
container.add(custom);
container.add(join);
container.row();
container.add(editor);
@ -117,7 +118,7 @@ public class MenuFragment extends Fragment{
out.add(new MenuButton("icon-add", "$joingame", ui.join::show));
out.add(new MenuButton("icon-play-custom", "$customgame", ui.custom::show));
out.add(new MenuButton("icon-play-custom", "$customgame", this::showCustomSelect));
out.row();
@ -136,4 +137,21 @@ public class MenuFragment extends Fragment{
out.add(new MenuButton("icon-exit", "$quit", Core.app::exit)).width(bw).colspan(2);
});
}
private void showCustomSelect(){
FloatingDialog dialog = new FloatingDialog("$play");
dialog.setFillParent(false);
dialog.addCloseButton();
dialog.cont.defaults().size(230f, 64f);
dialog.cont.add(new MenuButton("icon-editor", "$newgame", () -> {
dialog.hide();
ui.custom.show();
}));
dialog.cont.row();
dialog.cont.add(new MenuButton("icon-load", "$loadgame", () -> {
ui.load.show();
dialog.hide();
}));
dialog.show();
}
}