UI cleanup

This commit is contained in:
Anuken
2020-07-23 17:37:45 -04:00
parent 69f6154894
commit 72fc103e16
28 changed files with 78 additions and 78 deletions

View File

@@ -182,10 +182,10 @@ public class UI implements ApplicationListener, Loadable{
Group group = Core.scene.root;
menuGroup.setFillParent(true);
menuGroup.touchable(Touchable.childrenOnly);
menuGroup.touchable = Touchable.childrenOnly;
menuGroup.visible(() -> state.isMenu());
hudGroup.setFillParent(true);
hudGroup.touchable(Touchable.childrenOnly);
hudGroup.touchable = Touchable.childrenOnly;
hudGroup.visible(() -> state.isGame());
Core.scene.add(menuGroup);
@@ -292,7 +292,7 @@ public class UI implements ApplicationListener, Loadable{
public void showInfoToast(String info, float duration){
Table table = new Table();
table.setFillParent(true);
table.touchable(Touchable.disabled);
table.touchable = Touchable.disabled;
table.update(() -> {
if(state.isMenu()) table.remove();
});
@@ -305,7 +305,7 @@ public class UI implements ApplicationListener, Loadable{
public void showInfoPopup(String info, float duration, int align, int top, int left, int bottom, int right){
Table table = new Table();
table.setFillParent(true);
table.touchable(Touchable.disabled);
table.touchable = Touchable.disabled;
table.update(() -> {
if(state.isMenu()) table.remove();
});
@@ -318,7 +318,7 @@ public class UI implements ApplicationListener, Loadable{
public void showLabel(String info, float duration, float worldx, float worldy){
Table table = new Table();
table.setFillParent(true);
table.touchable(Touchable.disabled);
table.touchable = Touchable.disabled;
table.update(() -> {
if(state.isMenu()) table.remove();
});

View File

@@ -475,7 +475,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
mode.setColor(Pal.remove);
mode.update(() -> mode.setText(tool.mode == -1 ? "" : "M" + (tool.mode + 1) + " "));
mode.setAlignment(Align.bottomRight, Align.bottomRight);
mode.touchable(Touchable.disabled);
mode.touchable = Touchable.disabled;
tools.stack(button, mode);
};

View File

@@ -214,7 +214,7 @@ public class MapGenerateDialog extends BaseDialog{
}
void rebuildFilters(){
int cols = Math.max((int)(Math.max(filterTable.getParent().getWidth(), Core.graphics.getWidth()/2f * 0.9f) / Scl.scl(290f)), 1);
int cols = Math.max((int)(Math.max(filterTable.parent.getWidth(), Core.graphics.getWidth()/2f * 0.9f) / Scl.scl(290f)), 1);
filterTable.clearChildren();
filterTable.top().left();
int i = 0;

View File

@@ -46,7 +46,7 @@ public class MapView extends Element implements GestureListener{
}
Core.input.getInputProcessors().insert(0, new GestureDetector(20, 0.5f, 2, 0.15f, this));
touchable(Touchable.enabled);
this.touchable = Touchable.enabled;
Point2 firstTouch = new Point2();

View File

@@ -93,7 +93,7 @@ public class WaveInfoDialog extends BaseDialog{
}).growX().height(70f);
}), new Label("$waves.none"){{
visible(() -> groups.isEmpty());
touchable(Touchable.disabled);
this.touchable = Touchable.disabled;
setWrap(true);
setAlignment(Align.center, Align.center);
}}).width(390f).growY();

View File

@@ -49,11 +49,11 @@ public class DesktopInput extends InputHandler{
group.fill(t -> {
t.bottom();
t.visible(() -> {
t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.builder().isBuilding() ? 1f : 0f, 0.15f);
t.color.a = Mathf.lerpDelta(t.color.a, player.builder().isBuilding() ? 1f : 0f, 0.15f);
return Core.settings.getBool("hints") && selectRequests.isEmpty() && t.getColor().a > 0.01f;
return Core.settings.getBool("hints") && selectRequests.isEmpty() && t.color.a > 0.01f;
});
t.touchable(() -> t.getColor().a < 0.1f ? Touchable.disabled : Touchable.childrenOnly);
t.touchable(() -> t.color.a < 0.1f ? Touchable.disabled : Touchable.childrenOnly);
t.table(Styles.black6, b -> {
b.defaults().left();
b.label(() -> Core.bundle.format(!isBuilding ? "resumebuilding" : "pausebuilding", Core.keybinds.get(Binding.pause_building).key.toString())).style(Styles.outlineLabel);

View File

@@ -890,7 +890,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
uiGroup = new WidgetGroup();
uiGroup.touchable(Touchable.childrenOnly);
uiGroup.touchable = Touchable.childrenOnly;
uiGroup.setFillParent(true);
ui.hudGroup.addChild(uiGroup);
buildUI(uiGroup);

View File

@@ -37,8 +37,8 @@ public class BorderImage extends Image{
public void draw(){
super.draw();
float scaleX = getScaleX();
float scaleY = getScaleY();
float scaleX = this.scaleX;
float scaleY = this.scaleY;
Draw.color(borderColor);
Draw.alpha(parentAlpha);

View File

@@ -15,7 +15,7 @@ public class Minimap extends Table{
public Minimap(){
background(Tex.pane);
float margin = 5f;
touchable(Touchable.enabled);
this.touchable = Touchable.enabled;
add(new Element(){
{

View File

@@ -19,14 +19,14 @@ public class MultiReqImage extends Stack{
time += Time.delta / 60f;
displays.each(req -> req.visible(false));
displays.each(req -> req.visible = false);
ReqImage valid = displays.find(ReqImage::valid);
if(valid != null){
valid.visible(true);
valid.visible = true;
}else{
if(displays.size > 0){
displays.get((int)(time) % displays.size).visible(true);
displays.get((int)time % displays.size).visible = true;
}
}
}

View File

@@ -62,7 +62,7 @@ public class DatabaseDialog extends BaseDialog{
image.addListener(listener);
if(!Vars.mobile && unlocked(unlock)){
image.addListener(new HandCursorListener());
image.update(() -> image.getColor().lerp(!listener.isOver() ? Color.lightGray : Color.white, 0.4f * Time.delta));
image.update(() -> image.color.lerp(!listener.isOver() ? Color.lightGray : Color.white, 0.4f * Time.delta));
}
if(unlocked(unlock)){

View File

@@ -76,7 +76,7 @@ public class FileChooser extends BaseDialog{
cancel.clicked(this::hide);
navigation = new TextField("");
navigation.touchable(Touchable.disabled);
navigation.touchable = Touchable.disabled;
files = new Table();
files.marginRight(10);

View File

@@ -286,12 +286,12 @@ public class JoinDialog extends BaseDialog{
pad = 6;
}
Cell cell = ((Table)pane.getParent()).getCell(button);
Cell cell = ((Table)pane.parent).getCell(button);
if(!Mathf.equal(cell.minWidth(), pw)){
cell.width(pw);
cell.padLeft(pad);
pane.getParent().invalidateHierarchy();
pane.parent.invalidateHierarchy();
}
});
}

View File

@@ -416,12 +416,12 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
stable.update(() -> {
if(selected != null){
if(launching){
stable.getColor().sub(0, 0, 0, 0.05f * Time.delta);
stable.color.sub(0, 0, 0, 0.05f * Time.delta);
}else{
//fade out UI when not facing selected sector
Tmp.v31.set(selected.tile.v).rotate(Vec3.Y, -planets.planet.getRotation()).scl(-1f).nor();
float dot = planets.cam.direction.dot(Tmp.v31);
stable.getColor().a = Math.max(dot, 0f)*2f;
stable.color.a = Math.max(dot, 0f)*2f;
if(dot*2f <= -0.1f){
stable.remove();
selected = null;

View File

@@ -64,7 +64,7 @@ public class ResearchDialog extends BaseDialog{
addListener(new InputListener(){
@Override
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
view.setScale(Mathf.clamp(view.getScaleX() - amountY / 10f * view.getScaleX(), 0.25f, 1f));
view.setScale(Mathf.clamp(view.scaleX - amountY / 10f * view.scaleX, 0.25f, 1f));
view.setOrigin(Align.center);
view.setTransform(true);
return true;
@@ -81,7 +81,7 @@ public class ResearchDialog extends BaseDialog{
@Override
public void zoom(InputEvent event, float initialDistance, float distance){
if(view.lastZoom < 0){
view.lastZoom = view.getScaleX();
view.lastZoom = view.scaleX;
}
view.setScale(Mathf.clamp(distance / initialDistance * view.lastZoom, 0.25f, 1f));
@@ -91,13 +91,13 @@ public class ResearchDialog extends BaseDialog{
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, KeyCode button){
view.lastZoom = view.getScaleX();
view.lastZoom = view.scaleX;
}
@Override
public void pan(InputEvent event, float x, float y, float deltaX, float deltaY){
view.panX += deltaX / view.getScaleX();
view.panY += deltaY / view.getScaleY();
view.panX += deltaX / view.scaleX;
view.panY += deltaY / view.scaleY;
view.moved = true;
view.clamp();
}
@@ -180,7 +180,7 @@ public class ResearchDialog extends BaseDialog{
Table table = new Table();
table.actions(Actions.fadeOut(0.5f, Interp.fade), Actions.remove());
table.top().add(info);
table.setName("toast");
table.name = "toast";
table.update(() -> {
table.toFront();
table.setPosition(Core.graphics.getWidth() / 2f, Core.graphics.getHeight() - 21, Align.top);
@@ -230,7 +230,7 @@ public class ResearchDialog extends BaseDialog{
Table infoTable = new Table();
{
infoTable.touchable(Touchable.enabled);
infoTable.touchable = Touchable.enabled;
for(TechTreeNode node : nodes){
ImageButton button = new ImageButton(node.node.content.icon(Cicon.medium), Styles.nodei);
@@ -273,7 +273,7 @@ public class ResearchDialog extends BaseDialog{
}
});
button.touchable(() -> !node.visible ? Touchable.disabled : Touchable.enabled);
button.setUserObject(node.node);
button.userObject = node.node;
button.setSize(nodeSize);
button.update(() -> {
float offset = (Core.graphics.getHeight() % 2) / 2f;
@@ -335,7 +335,7 @@ public class ResearchDialog extends BaseDialog{
if(button == null) return;
TechNode node = (TechNode)button.getUserObject();
TechNode node = (TechNode)button.userObject;
infoTable.exited(() -> {
if(hoverNode == button && !infoTable.hasMouse() && !hoverNode.hasMouse()){

View File

@@ -277,8 +277,8 @@ public class SchematicsDialog extends BaseDialog{
@Override
public void draw(){
boolean checked = getParent().getParent() instanceof Button
&& ((Button)getParent().getParent()).isOver();
boolean checked = parent.parent instanceof Button
&& ((Button)parent.parent).isOver();
boolean wasSet = set;
if(!set){

View File

@@ -17,7 +17,7 @@ public class BlockConfigFragment extends Fragment{
@Override
public void build(Group parent){
table.visible(false);
table.visible = false;
parent.addChild(table);
//hacky way to hide block config when in menu
@@ -27,7 +27,7 @@ public class BlockConfigFragment extends Fragment{
public void act(float delta){
super.act(delta);
if(state.isMenu()){
table.visible(false);
table.visible = false;
configTile = null;
}
}
@@ -35,7 +35,7 @@ public class BlockConfigFragment extends Fragment{
}
public boolean isShown(){
return table.isVisible() && configTile != null;
return table.visible && configTile != null;
}
public Building getSelectedTile(){
@@ -46,7 +46,7 @@ public class BlockConfigFragment extends Fragment{
if(tile.configTapped()){
configTile = tile;
table.visible(true);
table.visible = true;
table.clear();
tile.buildConfiguration(table);
table.pack();

View File

@@ -65,7 +65,7 @@ public class BlockInventoryFragment extends Fragment{
@Override
public void build(Group parent){
table.setName("inventory");
table.name = "inventory";
table.setTransform(true);
parent.setTransform(true);
parent.addChild(table);
@@ -90,7 +90,7 @@ public class BlockInventoryFragment extends Fragment{
table.clearListeners();
table.update(null);
}), Actions.visible(false));
table.touchable(Touchable.disabled);
table.touchable = Touchable.disabled;
tile = null;
}
@@ -103,7 +103,7 @@ public class BlockInventoryFragment extends Fragment{
table.clearChildren();
table.clearActions();
table.background(Tex.inventory);
table.touchable(Touchable.enabled);
table.touchable = Touchable.enabled;
table.update(() -> {
if(state.isMenu() || tile == null || !tile.isValid() || !tile.block().isAccessible() || emptyTime >= holdShrink){
@@ -209,7 +209,7 @@ public class BlockInventoryFragment extends Fragment{
updateTablePosition();
table.visible(true);
table.visible = true;
if(actions){
table.setScale(0f, 1f);

View File

@@ -131,8 +131,8 @@ public class ChatFragment extends Table{
float spacing = chatspace;
chatfield.visible(shown);
fieldlabel.visible(shown);
chatfield.visible = shown;
fieldlabel.visible = shown;
Draw.color(shadowColor);
Draw.alpha(shadowColor.a * opacity);

View File

@@ -16,7 +16,7 @@ public class FadeInFragment extends Fragment{
parent.addChild(new Element(){
{
setFillParent(true);
touchable(Touchable.disabled);
this.touchable = Touchable.disabled;
}
@Override

View File

@@ -69,14 +69,14 @@ public class HudFragment extends Fragment{
//paused table
parent.fill(t -> {
t.top().visible(() -> state.isPaused() && !state.isOutOfTime()).touchable(Touchable.disabled);
t.top().visible(() -> state.isPaused() && !state.isOutOfTime()).touchable = Touchable.disabled;
t.table(Styles.black5, top -> top.add("$paused").style(Styles.outlineLabel).pad(8f)).growX();
});
//TODO tear this all down
//menu at top left
parent.fill(cont -> {
cont.setName("overlaymarker");
cont.name = "overlaymarker";
cont.top().left();
if(mobile){
@@ -189,7 +189,7 @@ public class HudFragment extends Fragment{
//fps display
cont.table(info -> {
info.touchable(Touchable.disabled);
info.touchable = Touchable.disabled;
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps") && shown);
info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Scl.scl(dsize * 4 + 3), 0));
IntFormat fps = new IntFormat("fps");
@@ -221,7 +221,7 @@ public class HudFragment extends Fragment{
//spawner warning
parent.fill(t -> {
t.touchable(Touchable.disabled);
t.touchable = Touchable.disabled;
t.table(Styles.black, 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))
@@ -235,7 +235,7 @@ public class HudFragment extends Fragment{
//'core is under attack' table
parent.fill(t -> {
t.touchable(Touchable.disabled);
t.touchable = Touchable.disabled;
float notifDuration = 240f;
float[] coreAttackTime = {0};
float[] coreAttackOpacity = {0};
@@ -250,7 +250,7 @@ public class HudFragment extends Fragment{
return false;
}
t.getColor().a = coreAttackOpacity[0];
t.color.a = coreAttackOpacity[0];
if(coreAttackTime[0] > 0){
coreAttackOpacity[0] = Mathf.lerpDelta(coreAttackOpacity[0], 1f, 0.1f);
}else{
@@ -262,7 +262,7 @@ public class HudFragment extends Fragment{
return coreAttackOpacity[0] > 0;
});
t.table(Tex.button, top -> top.add("$coreattack").pad(2)
.update(label -> label.getColor().set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled);
.update(label -> label.color.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled);
});
//paused table for when the player is out of time
@@ -324,7 +324,7 @@ public class HudFragment extends Fragment{
showHudText = false;
}
});
p.touchable(Touchable.disabled);
p.touchable = Touchable.disabled;
});
//TODO DEBUG: rate table
@@ -519,7 +519,7 @@ public class HudFragment extends Fragment{
public void showLaunchDirect(){
Image image = new Image();
image.getColor().a = 0f;
image.color.a = 0f;
image.setFillParent(true);
image.actions(Actions.fadeIn(launchDuration / 60f, Interp.pow2In), Actions.delay(8f / 60f), Actions.remove());
Core.scene.add(image);
@@ -527,7 +527,7 @@ public class HudFragment extends Fragment{
public void showLaunch(){
Image image = new Image();
image.getColor().a = 0f;
image.color.a = 0f;
image.setFillParent(true);
image.actions(Actions.fadeIn(40f / 60f));
image.update(() -> {
@@ -540,8 +540,8 @@ public class HudFragment extends Fragment{
public void showLand(){
Image image = new Image();
image.getColor().a = 1f;
image.touchable(Touchable.disabled);
image.color.a = 1f;
image.touchable = Touchable.disabled;
image.setFillParent(true);
image.actions(Actions.fadeOut(0.8f), Actions.remove());
image.update(() -> {
@@ -614,11 +614,11 @@ public class HudFragment extends Fragment{
});
table.clearChildren();
table.touchable(Touchable.enabled);
table.touchable = Touchable.enabled;
StringBuilder builder = new StringBuilder();
table.setName("waves");
table.name = "waves";
table.labelWrap(() -> {
builder.setLength(0);
builder.append(wavef.get(state.wave));

View File

@@ -18,8 +18,8 @@ public class LoadingFragment extends Fragment{
@Override
public void build(Group parent){
parent.fill(Styles.black8, t -> {
t.visible(false);
t.touchable(Touchable.enabled);
t.visible = false;
t.touchable = Touchable.enabled;
t.add().height(133f).row();
t.add(new WarningBar()).growX().height(24f);
t.row();
@@ -37,12 +37,12 @@ public class LoadingFragment extends Fragment{
public void setProgress(Floatp progress){
bar.reset(0f);
bar.visible(true);
bar.visible = true;
bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent);
}
public void setButton(Runnable listener){
button.visible(true);
button.visible = true;
button.getListeners().remove(button.getListeners().size - 1);
button.clicked(listener);
}
@@ -58,19 +58,19 @@ public class LoadingFragment extends Fragment{
public void show(String text){
table.<Label>find("namelabel").setColor(Color.white);
bar.visible(false);
bar.visible = false;
table.clearActions();
table.touchable(Touchable.enabled);
table.touchable = Touchable.enabled;
table.<Label>find("namelabel").setText(text);
table.visible(true);
table.getColor().a = 1f;
table.visible = true;
table.color.a = 1f;
table.toFront();
}
public void hide(){
table.clearActions();
table.toFront();
table.touchable(Touchable.disabled);
table.touchable = Touchable.disabled;
table.actions(Actions.fadeOut(0.5f), Actions.visible(false));
}
}

View File

@@ -89,7 +89,7 @@ public class MenuFragment extends Fragment{
Fonts.def.setColor(Color.white);
Fonts.def.draw(versionText, fx, fy - logoh/2f, Align.center);
}).touchable(Touchable.disabled);
}).touchable = Touchable.disabled;
}
private void buildMobile(){
@@ -184,7 +184,7 @@ public class MenuFragment extends Fragment{
container.table(background, t -> {
submenu = t;
t.getColor().a = 0f;
t.color.a = 0f;
t.top();
t.defaults().width(width).height(70f);
t.visible(() -> !t.getChildren().isEmpty());

View File

@@ -54,7 +54,7 @@ public class MinimapFragment extends Fragment{
shown = false;
}
});
elem.touchable(Touchable.enabled);
elem.touchable = Touchable.enabled;
elem.addListener(new ElementGestureListener(){

View File

@@ -13,7 +13,7 @@ public class OverlayFragment{
private WidgetGroup group = new WidgetGroup();
public OverlayFragment(){
group.touchable(Touchable.childrenOnly);
group.touchable = Touchable.childrenOnly;
inv = new BlockInventoryFragment();
config = new BlockConfigFragment();
}

View File

@@ -80,7 +80,7 @@ public class PlacementFragment extends Fragment{
void rebuild(){
currentCategory = Category.turret;
Group group = toggler.getParent();
Group group = toggler.parent;
int index = toggler.getZIndex();
toggler.remove();
build(group);

View File

@@ -122,8 +122,8 @@ public class ScriptConsoleFragment extends Table{
float spacing = chatspace;
chatfield.visible(open);
fieldlabel.visible(open);
chatfield.visible = open;
fieldlabel.visible = open;
Draw.color(shadowColor);
Draw.alpha(shadowColor.a * opacity);