Cleanup
This commit is contained in:
@@ -12,46 +12,34 @@ import mindustry.gen.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class BlockConfigFragment extends Fragment{
|
||||
public class BlockConfigFragment{
|
||||
Table table = new Table();
|
||||
Building configTile;
|
||||
Building selected;
|
||||
|
||||
@Override
|
||||
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.isMenu()){
|
||||
table.visible = false;
|
||||
configTile = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
Events.on(ResetEvent.class, e -> forceHide());
|
||||
}
|
||||
|
||||
Events.on(ResetEvent.class, e -> {
|
||||
table.visible = false;
|
||||
configTile = null;
|
||||
});
|
||||
public void forceHide(){
|
||||
table.visible = false;
|
||||
selected = null;
|
||||
}
|
||||
|
||||
public boolean isShown(){
|
||||
return table.visible && configTile != null;
|
||||
return table.visible && selected != null;
|
||||
}
|
||||
|
||||
public Building getSelectedTile(){
|
||||
return configTile;
|
||||
public Building getSelected(){
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void showConfig(Building tile){
|
||||
if(configTile != null) configTile.onConfigureClosed();
|
||||
if(selected != null) selected.onConfigureClosed();
|
||||
if(tile.configTapped()){
|
||||
configTile = tile;
|
||||
selected = tile;
|
||||
|
||||
table.visible = true;
|
||||
table.clear();
|
||||
@@ -62,16 +50,16 @@ public class BlockConfigFragment extends Fragment{
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interp.pow3Out));
|
||||
|
||||
table.update(() -> {
|
||||
if(configTile != null && configTile.shouldHideConfigure(player)){
|
||||
if(selected != null && selected.shouldHideConfigure(player)){
|
||||
hideConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
table.setOrigin(Align.center);
|
||||
if(configTile == null || configTile.block == Blocks.air || !configTile.isValid()){
|
||||
if(selected == null || selected.block == Blocks.air || !selected.isValid()){
|
||||
hideConfig();
|
||||
}else{
|
||||
configTile.updateTableAlign(table);
|
||||
selected.updateTableAlign(table);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -83,8 +71,8 @@ public class BlockConfigFragment extends Fragment{
|
||||
}
|
||||
|
||||
public void hideConfig(){
|
||||
if(configTile != null) configTile.onConfigureClosed();
|
||||
configTile = null;
|
||||
if(selected != null) selected.onConfigureClosed();
|
||||
selected = null;
|
||||
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interp.pow3Out), Actions.visible(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class BlockInventoryFragment extends Fragment{
|
||||
public class BlockInventoryFragment{
|
||||
private static final float holdWithdraw = 20f;
|
||||
private static final float holdShrink = 120f;
|
||||
|
||||
@@ -38,7 +38,6 @@ public class BlockInventoryFragment extends Fragment{
|
||||
Events.on(WorldLoadEvent.class, e -> hide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
table.name = "inventory";
|
||||
table.setTransform(true);
|
||||
|
||||
@@ -37,12 +37,6 @@ public class ChatFragment extends Table{
|
||||
private Seq<String> history = new Seq<>();
|
||||
private int historyPos = 0;
|
||||
private int scrollPos = 0;
|
||||
private Fragment container = new Fragment(){
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
scene.add(ChatFragment.this);
|
||||
}
|
||||
};
|
||||
|
||||
public ChatFragment(){
|
||||
super();
|
||||
@@ -89,8 +83,8 @@ public class ChatFragment extends Table{
|
||||
setup();
|
||||
}
|
||||
|
||||
public Fragment container(){
|
||||
return container;
|
||||
public void build(Group parent){
|
||||
scene.add(this);
|
||||
}
|
||||
|
||||
public void clearMessages(){
|
||||
|
||||
@@ -7,11 +7,10 @@ import arc.scene.*;
|
||||
import arc.scene.event.*;
|
||||
|
||||
/** Fades in a black overlay.*/
|
||||
public class FadeInFragment extends Fragment{
|
||||
public class FadeInFragment{
|
||||
private static final float duration = 40f;
|
||||
float time = 0f;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
parent.addChild(new Element(){
|
||||
{
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package mindustry.ui.fragments;
|
||||
|
||||
import arc.scene.*;
|
||||
|
||||
public abstract class Fragment{
|
||||
public abstract void build(Group parent);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class HintsFragment extends Fragment{
|
||||
public class HintsFragment{
|
||||
private static final Boolp isTutorial = () -> Vars.state.rules.sector == SectorPresets.groundZero.sector;
|
||||
private static final float foutTime = 0.6f;
|
||||
|
||||
@@ -35,7 +35,6 @@ public class HintsFragment extends Fragment{
|
||||
ObjectSet<Block> placedBlocks = new ObjectSet<>();
|
||||
Table last;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
group.setFillParent(true);
|
||||
group.touchable = Touchable.childrenOnly;
|
||||
|
||||
@@ -31,7 +31,7 @@ import mindustry.ui.*;
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.gen.Tex.*;
|
||||
|
||||
public class HudFragment extends Fragment{
|
||||
public class HudFragment{
|
||||
private static final float dsize = 65f, pauseHeight = 36f;
|
||||
|
||||
public final PlacementFragment blockfrag = new PlacementFragment();
|
||||
@@ -47,7 +47,6 @@ public class HudFragment extends Fragment{
|
||||
private Table lastUnlockLayout;
|
||||
private long lastToast;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
|
||||
//warn about guardian/boss waves
|
||||
|
||||
@@ -12,14 +12,13 @@ import arc.scene.ui.layout.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class LoadingFragment extends Fragment{
|
||||
public class LoadingFragment{
|
||||
private Table table;
|
||||
private TextButton button;
|
||||
private Bar bar;
|
||||
private Label nameLabel;
|
||||
private float progValue;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
parent.fill(t -> {
|
||||
//rect must fill screen completely.
|
||||
|
||||
@@ -21,12 +21,11 @@ import mindustry.ui.*;
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.gen.Tex.*;
|
||||
|
||||
public class MenuFragment extends Fragment{
|
||||
public class MenuFragment{
|
||||
private Table container, submenu;
|
||||
private Button currentMenu;
|
||||
private MenuRenderer renderer;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
renderer = new MenuRenderer();
|
||||
|
||||
|
||||
@@ -14,13 +14,12 @@ import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MinimapFragment extends Fragment{
|
||||
public class MinimapFragment{
|
||||
private boolean shown;
|
||||
float panx, pany, zoom = 1f, lastZoom = -1;
|
||||
private float baseSize = Scl.scl(5f);
|
||||
public Element elem;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
elem = parent.fill((x, y, w, h) -> {
|
||||
w = Core.graphics.getWidth();
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package mindustry.ui.fragments;
|
||||
|
||||
import arc.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import mindustry.*;
|
||||
|
||||
/** Fragment for displaying overlays such as block inventories. */
|
||||
public class OverlayFragment{
|
||||
public final BlockInventoryFragment inv;
|
||||
public final BlockConfigFragment config;
|
||||
|
||||
private WidgetGroup group = new WidgetGroup();
|
||||
|
||||
public OverlayFragment(){
|
||||
group.touchable = Touchable.childrenOnly;
|
||||
inv = new BlockInventoryFragment();
|
||||
config = new BlockConfigFragment();
|
||||
}
|
||||
|
||||
public void add(){
|
||||
group.setFillParent(true);
|
||||
Vars.ui.hudGroup.addChildBefore(Core.scene.find("overlaymarker"), group);
|
||||
|
||||
inv.build(group);
|
||||
config.build(group);
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
group.remove();
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import mindustry.world.blocks.ConstructBlock.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PlacementFragment extends Fragment{
|
||||
public class PlacementFragment{
|
||||
final int rowWidth = 4;
|
||||
|
||||
public Category currentCategory = Category.distribution;
|
||||
@@ -229,7 +229,6 @@ public class PlacementFragment extends Fragment{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
parent.fill(full -> {
|
||||
toggler = full;
|
||||
|
||||
@@ -18,14 +18,13 @@ import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PlayerListFragment extends Fragment{
|
||||
public class PlayerListFragment{
|
||||
public Table content = new Table().marginRight(13f).marginLeft(13f);
|
||||
private boolean visible = false;
|
||||
private Interval timer = new Interval();
|
||||
private TextField search;
|
||||
private Seq<Player> players = new Seq<>();
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
content.name = "players";
|
||||
parent.fill(cont -> {
|
||||
|
||||
@@ -32,12 +32,6 @@ public class ScriptConsoleFragment extends Table{
|
||||
private Seq<String> history = new Seq<>();
|
||||
private int historyPos = 0;
|
||||
private int scrollPos = 0;
|
||||
private Fragment container = new Fragment(){
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
scene.add(ScriptConsoleFragment.this);
|
||||
}
|
||||
};
|
||||
|
||||
public ScriptConsoleFragment(){
|
||||
setFillParent(true);
|
||||
@@ -82,8 +76,8 @@ public class ScriptConsoleFragment extends Table{
|
||||
setup();
|
||||
}
|
||||
|
||||
public Fragment container(){
|
||||
return container;
|
||||
public void build(Group parent){
|
||||
scene.add(this);
|
||||
}
|
||||
|
||||
public void clearMessages(){
|
||||
|
||||
Reference in New Issue
Block a user