Changed layout structure
This commit is contained in:
@@ -13,12 +13,13 @@ import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.math.Interpolation;
|
||||
import io.anuke.arc.scene.*;
|
||||
import io.anuke.arc.scene.actions.Actions;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.TextField.TextFieldFilter;
|
||||
import io.anuke.arc.scene.ui.Tooltip.Tooltips;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.editor.MapEditorDialog;
|
||||
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
@@ -38,6 +39,8 @@ public class UI implements ApplicationListener{
|
||||
public BackgroundFragment backfrag;
|
||||
public LoadingFragment loadfrag;
|
||||
|
||||
public WidgetGroup menuGroup, hudGroup;
|
||||
|
||||
public AboutDialog about;
|
||||
public GameOverDialog restart;
|
||||
public CustomGameDialog custom;
|
||||
@@ -128,6 +131,9 @@ public class UI implements ApplicationListener{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
menuGroup = new WidgetGroup();
|
||||
hudGroup = new WidgetGroup();
|
||||
|
||||
menufrag = new MenuFragment();
|
||||
hudfrag = new HudFragment();
|
||||
chatfrag = new ChatFragment();
|
||||
@@ -160,12 +166,22 @@ public class UI implements ApplicationListener{
|
||||
|
||||
Group group = Core.scene.root;
|
||||
|
||||
backfrag.build(group);
|
||||
control.input().getFrag().build(group);
|
||||
hudfrag.build(group);
|
||||
menufrag.build(group);
|
||||
chatfrag.container().build(group);
|
||||
listfrag.build(group);
|
||||
menuGroup.setFillParent(true);
|
||||
menuGroup.touchable(Touchable.childrenOnly);
|
||||
menuGroup.visible(() -> state.is(State.menu));
|
||||
hudGroup.setFillParent(true);
|
||||
hudGroup.touchable(Touchable.childrenOnly);
|
||||
hudGroup.visible(() -> !state.is(State.menu));
|
||||
|
||||
Core.scene.add(menuGroup);
|
||||
Core.scene.add(hudGroup);
|
||||
|
||||
// backfrag.build(group);
|
||||
control.input().getFrag().build(hudGroup);
|
||||
hudfrag.build(hudGroup);
|
||||
menufrag.build(menuGroup);
|
||||
chatfrag.container().build(hudGroup);
|
||||
listfrag.build(hudGroup);
|
||||
loadfrag.build(group);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
/** Distance on the back from where items originate. */
|
||||
final static float backTrns = 3f;
|
||||
|
||||
public final OverlayFragment frag = new OverlayFragment(this);
|
||||
public final OverlayFragment frag = new OverlayFragment();
|
||||
|
||||
public Block block;
|
||||
public int rotation;
|
||||
|
||||
@@ -24,6 +24,19 @@ public class BlockConfigFragment extends Fragment{
|
||||
public void build(Group parent){
|
||||
table.visible(false);
|
||||
parent.addChild(table);
|
||||
|
||||
//hacky way to hide block config when in menu
|
||||
//TODO remove?
|
||||
Core.scene.add(new Element(){
|
||||
@Override
|
||||
public void act(float delta){
|
||||
super.act(delta);
|
||||
if(state.is(State.menu)){
|
||||
table.visible(false);
|
||||
configTile = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isShown(){
|
||||
@@ -47,11 +60,6 @@ public class BlockConfigFragment extends Fragment{
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
|
||||
table.update(() -> {
|
||||
if(state.is(State.menu)){
|
||||
hideConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
if(configTile != null && configTile.block().shouldHideConfigure(configTile, player)){
|
||||
hideConfig();
|
||||
return;
|
||||
|
||||
@@ -52,7 +52,6 @@ public class BlockInventoryFragment extends Fragment{
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
table = new Table();
|
||||
table.visible(() -> !state.is(State.menu));
|
||||
table.setTransform(true);
|
||||
parent.setTransform(true);
|
||||
parent.addChild(table);
|
||||
|
||||
@@ -15,14 +15,14 @@ import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
|
||||
import static io.anuke.arc.Core.input;
|
||||
import static io.anuke.arc.Core.scene;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.maxTextLength;
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
|
||||
public class ChatFragment extends Table{
|
||||
private final static int messagesShown = 10;
|
||||
@@ -61,7 +61,7 @@ public class ChatFragment extends Table{
|
||||
}
|
||||
}
|
||||
|
||||
return !state.is(State.menu) && Net.active();
|
||||
return Net.active();
|
||||
});
|
||||
|
||||
update(() -> {
|
||||
|
||||
@@ -58,14 +58,13 @@ public class HudFragment extends Fragment{
|
||||
|
||||
//menu at top left
|
||||
parent.fill(cont -> {
|
||||
cont.top().left().visible(() -> !state.is(State.menu));
|
||||
cont.top().left();
|
||||
|
||||
if(mobile){
|
||||
|
||||
{
|
||||
Table select = new Table();
|
||||
|
||||
select.visible(() -> !state.is(State.menu));
|
||||
select.left();
|
||||
select.defaults().size(dsize).left();
|
||||
|
||||
@@ -124,7 +123,7 @@ public class HudFragment extends Fragment{
|
||||
elem.setSize(Unit.dp.scl(3f), size);
|
||||
}
|
||||
elem.setPosition(fi * size, Core.graphics.getHeight(), Align.topLeft);
|
||||
return !state.is(State.menu);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,12 +264,11 @@ public class HudFragment extends Fragment{
|
||||
});
|
||||
|
||||
//minimap
|
||||
parent.fill(t -> t.top().right().add(new Minimap()).visible(() -> !state.is(State.menu) && Core.settings.getBool("minimap")));
|
||||
parent.fill(t -> t.top().right().add(new Minimap()).visible(() -> Core.settings.getBool("minimap")));
|
||||
|
||||
//spawner warning
|
||||
parent.fill(t -> {
|
||||
t.touchable(Touchable.disabled);
|
||||
t.visible(() -> !state.is(State.menu));
|
||||
t.table("flat", c -> c.add("$nearpoint")
|
||||
.update(l -> l.setColor(Tmp.c1.set(Color.WHITE).lerp(Color.SCARLET, Mathf.absin(Time.time(), 10f, 1f))))
|
||||
.get().setAlignment(Align.center, Align.center))
|
||||
@@ -278,7 +276,7 @@ public class HudFragment extends Fragment{
|
||||
});
|
||||
|
||||
parent.fill(t -> {
|
||||
t.visible(() -> netServer.isWaitingForPlayers() && !state.is(State.menu));
|
||||
t.visible(() -> netServer.isWaitingForPlayers());
|
||||
t.table("button", c -> c.add("$waiting.players"));
|
||||
});
|
||||
|
||||
@@ -331,7 +329,7 @@ public class HudFragment extends Fragment{
|
||||
|
||||
//launch button
|
||||
parent.fill(t -> {
|
||||
t.top().right().visible(() -> !state.is(State.menu));
|
||||
t.top().right();
|
||||
TextButton[] testb = {null};
|
||||
TextButton button = Elements.newButton("$launch", () -> {
|
||||
FloatingDialog dialog = new FloatingDialog("$launch");
|
||||
@@ -390,7 +388,7 @@ public class HudFragment extends Fragment{
|
||||
|
||||
//'saving' indicator
|
||||
parent.fill(t -> {
|
||||
t.bottom().visible(() -> !state.is(State.menu) && control.saves.isSaving());
|
||||
t.bottom().visible(() -> control.saves.isSaving());
|
||||
t.add("$saveload");
|
||||
});
|
||||
|
||||
|
||||
@@ -4,13 +4,12 @@ import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.graphics.Texture;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.scene.*;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.Button;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||
import io.anuke.mindustry.graphics.MenuRenderer;
|
||||
@@ -30,13 +29,12 @@ public class MenuFragment extends Fragment{
|
||||
public void build(Group parent){
|
||||
renderer = new MenuRenderer();
|
||||
|
||||
Core.scene.table().addRect((a, b, w, h) -> {
|
||||
parent.fill((x, y, w, h) -> {
|
||||
renderer.render();
|
||||
});
|
||||
|
||||
parent.fill(c -> {
|
||||
container = c;
|
||||
container.visible(() -> state.is(State.menu));
|
||||
|
||||
if(!mobile){
|
||||
buildDesktop();
|
||||
@@ -62,19 +60,14 @@ public class MenuFragment extends Fragment{
|
||||
//(Version.build == -1 ? "custom build" : "build " + Version.build), Version.revision == 0 ? "" : "." + Version.revision)).color(Color.DARK_GRAY)
|
||||
//.visible(() -> state.is(State.menu)));
|
||||
|
||||
Core.scene.table().addRect((a, b, w, h) -> {
|
||||
//Draw.shader(Shaders.menu);
|
||||
// Fill.crect(0, 0, w, h);
|
||||
//Draw.shader();
|
||||
|
||||
boolean portrait = Core.graphics.getWidth() < Core.graphics.getHeight();
|
||||
parent.fill((x, y, w, h) -> {
|
||||
float logoscl = (int)Unit.dp.scl(1);
|
||||
float logow = Math.min(Math.min(logo.getWidth() * logoscl, 768), Core.graphics.getWidth() - 10);
|
||||
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(Draw.wrap(logo), (int)(w / 2), (int)(h - 10 - logoh) + logoh / 2, logow, logoh);
|
||||
}).visible(() -> state.is(State.menu)).grow().get().touchable(Touchable.disabled);
|
||||
Draw.rect(Draw.wrap(logo), (int)(Core.graphics.getWidth() / 2), (int)(Core.graphics.getHeight() - 10 - logoh) + logoh / 2, logow, logoh);
|
||||
}).touchable(Touchable.disabled);
|
||||
}
|
||||
|
||||
private void buildMobile(){
|
||||
@@ -157,16 +150,6 @@ public class MenuFragment extends Fragment{
|
||||
new Buttoni("$quit", "icon-exit", Core.app::exit)
|
||||
);
|
||||
|
||||
/*
|
||||
t.addImageTextButton("$play", "icon-play-2" + suffix, "clear", isize, ui.deploy::show).marginLeft(margin);
|
||||
t.row();
|
||||
|
||||
t.addImageTextButton("$joingame", "icon-add" + suffix, "clear", isize, ui.join::show).marginLeft(margin);
|
||||
t.row();
|
||||
|
||||
t.addImageTextButton("$customgame", "icon-play-custom" + suffix, "clear", isize, this::showCustomSelect).marginLeft(margin);
|
||||
t.row();*/
|
||||
|
||||
}).width(width).growY();
|
||||
|
||||
container.table(background, t -> {
|
||||
@@ -176,40 +159,6 @@ public class MenuFragment extends Fragment{
|
||||
t.visible(() -> !t.getChildren().isEmpty());
|
||||
|
||||
}).width(width).growY();
|
||||
|
||||
/*
|
||||
container.table(out -> {
|
||||
|
||||
float w = 200f;
|
||||
float bw = w * 2f + 10f;
|
||||
|
||||
out.margin(16);
|
||||
out.defaults().size(w, 66f).padTop(5).padRight(5);
|
||||
|
||||
out.add(new MenuButton("icon-play-2", "$play", ui.deploy::show)).width(bw).colspan(2);
|
||||
|
||||
out.row();
|
||||
|
||||
out.add(new MenuButton("icon-add", "$joingame", ui.join::show));
|
||||
|
||||
out.add(new MenuButton("icon-play-custom", "$customgame", this::showCustomSelect));
|
||||
|
||||
out.row();
|
||||
|
||||
out.add(new MenuButton("icon-editor", "$editor", () -> ui.loadAnd(ui.editor::show)));
|
||||
|
||||
out.add(new MenuButton("icon-map", "$maps", ui.maps::show));
|
||||
|
||||
out.row();
|
||||
|
||||
out.add(new MenuButton("icon-info", "$about.button", ui.about::show));
|
||||
|
||||
out.add(new MenuButton("icon-tools", "$settings", ui.settings::show));
|
||||
|
||||
out.row();
|
||||
|
||||
out.add(new MenuButton("icon-exit", "$quit", Core.app::exit)).width(bw).colspan(2);
|
||||
});*/
|
||||
}
|
||||
|
||||
private void buttons(Table t, Buttoni... buttons){
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.mindustry.input.InputHandler;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.layout.WidgetGroup;
|
||||
|
||||
/** Fragment for displaying overlays such as block inventories. */
|
||||
public class OverlayFragment extends Fragment{
|
||||
public final BlockInventoryFragment inv;
|
||||
public final BlockConfigFragment config;
|
||||
|
||||
private Group group = new Group();
|
||||
private WidgetGroup group = new WidgetGroup();
|
||||
|
||||
public OverlayFragment(InputHandler input){
|
||||
public OverlayFragment(){
|
||||
group.touchable(Touchable.childrenOnly);
|
||||
inv = new BlockInventoryFragment();
|
||||
config = new BlockConfigFragment();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user