Merge branch 'master' of https://github.com/Anuken/Mindustry into messages

# Conflicts:
#	core/assets/sprites/block_colors.png
#	core/assets/sprites/sprites.atlas
#	core/assets/sprites/sprites.png
#	core/assets/sprites/sprites2.png
#	core/assets/sprites/sprites5.png
This commit is contained in:
Anuken
2019-09-21 18:59:49 -04:00
267 changed files with 11249 additions and 6885 deletions

View File

@@ -1,15 +1,15 @@
package io.anuke.mindustry.ui;
import io.anuke.arc.Core;
import io.anuke.arc.function.FloatProvider;
import io.anuke.arc.function.Supplier;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.*;
import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.math.geom.Rectangle;
import io.anuke.arc.scene.Element;
import io.anuke.arc.scene.style.Drawable;
import io.anuke.arc.util.pooling.Pools;
import io.anuke.arc.math.*;
import io.anuke.arc.math.geom.*;
import io.anuke.arc.scene.*;
import io.anuke.arc.scene.style.*;
import io.anuke.arc.util.pooling.*;
import io.anuke.mindustry.gen.*;
public class Bar extends Element{
private static Rectangle scissor = new Rectangle();
@@ -37,6 +37,18 @@ public class Bar extends Element{
});
}
public Bar(){
}
public void set(Supplier<String> name, FloatProvider fraction, Color color){
this.fraction = fraction;
this.lastValue = fraction.get();
this.blinkColor.set(color);
setColor(color);
update(() -> this.name = name.get());
}
public Bar blink(Color color){
blinkColor.set(color);
return this;
@@ -44,6 +56,8 @@ public class Bar extends Element{
@Override
public void draw(){
if(fraction == null) return;
float computed = Mathf.clamp(fraction.get());
if(!Mathf.isEqual(lastValue, computed)){
blink = 1f;
@@ -53,11 +67,13 @@ public class Bar extends Element{
blink = Mathf.lerpDelta(blink, 0f, 0.2f);
value = Mathf.lerpDelta(value, computed, 0.15f);
Drawable bar = Tex.bar;
Draw.colorl(0.1f);
Draw.drawable("bar", x, y, width, height);
bar.draw(x, y, width, height);
Draw.color(color, blinkColor, blink);
Drawable top = Core.scene.skin.getDrawable("bar-top");
Drawable top = Tex.barTop;
float topWidth = width * value;
if(topWidth > Core.atlas.find("bar-top").getWidth()){
@@ -71,11 +87,11 @@ public class Bar extends Element{
Draw.color();
BitmapFont font = Core.scene.skin.getFont("default");
BitmapFont font = Fonts.outline;
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
lay.setText(font, name);
font.setColor(Color.WHITE);
font.setColor(Color.white);
font.draw(name, x + width / 2f - lay.width / 2f, y + height / 2f + lay.height / 2f + 1);
Pools.free(lay);

View File

@@ -3,7 +3,7 @@ package io.anuke.mindustry.ui;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.scene.ui.Image;
import io.anuke.arc.scene.ui.layout.UnitScl;
import io.anuke.arc.scene.ui.layout.Scl;
import io.anuke.mindustry.graphics.Pal;
public class BorderImage extends Image{
@@ -42,7 +42,7 @@ public class BorderImage extends Image{
Draw.color(borderColor);
Draw.alpha(parentAlpha);
Lines.stroke(UnitScl.dp.scl(thickness));
Lines.stroke(Scl.scl(thickness));
Lines.rect(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
Draw.reset();
}

View File

@@ -25,7 +25,7 @@ public class ContentDisplay{
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
@@ -33,7 +33,7 @@ public class ContentDisplay{
table.add(block.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(8).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(8).padLeft(0).padRight(0).fillX();
table.row();
}
@@ -73,7 +73,7 @@ public class ContentDisplay{
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
@@ -81,7 +81,7 @@ public class ContentDisplay{
table.add(item.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
@@ -104,7 +104,7 @@ public class ContentDisplay{
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
@@ -112,7 +112,7 @@ public class ContentDisplay{
table.add(liquid.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
@@ -139,7 +139,7 @@ public class ContentDisplay{
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
@@ -147,7 +147,7 @@ public class ContentDisplay{
table.add(mech.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}
@@ -186,7 +186,7 @@ public class ContentDisplay{
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
@@ -194,7 +194,7 @@ public class ContentDisplay{
table.add(unit.description).padLeft(5).padRight(5).width(400f).wrap().fillX();
table.row();
table.addImage("whiteui").height(3).color(Color.LIGHT_GRAY).pad(15).padLeft(0).padRight(0).fillX();
table.addImage().height(3).color(Color.lightGray).pad(15).padLeft(0).padRight(0).fillX();
table.row();
}

View File

@@ -0,0 +1,9 @@
package io.anuke.mindustry.ui;
import io.anuke.arc.graphics.g2d.*;
public class Fonts{
public static BitmapFont def;
public static BitmapFont outline;
public static BitmapFont chat;
}

View File

@@ -0,0 +1,14 @@
package io.anuke.mindustry.ui;
public enum IconSize{
def(48),
small(32),
smaller(30),
tiny(16);
public final int size;
IconSize(int size){
this.size = size;
}
}

View File

@@ -13,11 +13,15 @@ public class ItemDisplay extends Table{
this(item, 0);
}
public ItemDisplay(Item item, int amount){
add(new ItemImage(new ItemStack(item, amount))).size(8 * 4);
add(item.localizedName()).padLeft(4);
public ItemDisplay(Item item, int amount, boolean showName){
add(new ItemImage(new ItemStack(item, amount))).size(8 * 4).padRight(amount > 99 ? 12 : 0);
if(showName) add(item.localizedName()).padLeft(4 + amount > 99 ? 4 : 0);
this.item = item;
this.amount = amount;
}
public ItemDisplay(Item item, int amount){
this(item, amount, true);
}
}

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui;
import io.anuke.arc.collection.ObjectIntMap;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Item.Icon;
import io.anuke.mindustry.type.ItemType;
@@ -26,7 +27,7 @@ public class ItemsDisplay extends Table{
top().left();
margin(0);
table("button", t -> {
table(Tex.button,t -> {
t.margin(10).marginLeft(15).marginTop(15f);
t.add("$launcheditems").colspan(3).left().padBottom(5);
t.row();
@@ -35,7 +36,7 @@ public class ItemsDisplay extends Table{
if(item.type == ItemType.material && data.isUnlocked(item)){
t.label(() -> format.format(items.get(item, 0))).left();
t.addImage(item.icon(Icon.medium)).size(8 * 3).padLeft(4).padRight(4);
t.add(item.localizedName()).color(Color.LIGHT_GRAY).left();
t.add(item.localizedName()).color(Color.lightGray).left();
t.row();
}
}

View File

@@ -16,8 +16,7 @@ public class Links{
new LinkEntry("itch.io", "https://anuke.itch.io/mindustry", Color.valueOf("fa5c5c")),
new LinkEntry("google-play", "https://play.google.com/store/apps/details?id=io.anuke.mindustry", Color.valueOf("689f38")),
new LinkEntry("github", "https://github.com/Anuken/Mindustry/", Color.valueOf("24292e")),
new LinkEntry("dev-builds", "https://jenkins.hellomouse.net/job/mindustry/", Color.valueOf("fafbfc"))
new LinkEntry("dev-builds", "https://github.com/Anuken/MindustryBuilds", Color.valueOf("fafbfc"))
};
}

View File

@@ -27,10 +27,10 @@ public class LiquidDisplay extends Table{
t.add(Strings.autoFixed(amount, 1));
add(t);
}
}}).size(8 * 4).padRight(3);
}}).size(8 * 4).padRight(3 + (amount != 0 && Strings.autoFixed(amount, 1).length() > 2 ? 8 : 0));
if(perSecond){
add(StatUnit.perSecond.localized()).padLeft(2).padRight(5).color(Color.LIGHT_GRAY);
add(StatUnit.perSecond.localized()).padLeft(2).padRight(5).color(Color.lightGray);
}
add(liquid.localizedName());

View File

@@ -6,24 +6,25 @@ import io.anuke.arc.input.KeyCode;
import io.anuke.arc.scene.Element;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.gen.*;
import static io.anuke.mindustry.Vars.*;
public class Minimap extends Table{
public Minimap(){
background("pane");
background(Tex.pane);
float margin = 5f;
touchable(Touchable.enabled);
add(new Element(){
{
setSize(UnitScl.dp.scl(140f));
setSize(Scl.scl(140f));
}
@Override
public void act(float delta){
setPosition(UnitScl.dp.scl(margin), UnitScl.dp.scl(margin));
setPosition(Scl.scl(margin), Scl.scl(margin));
super.act(delta);
}
@@ -52,7 +53,7 @@ public class Minimap extends Table{
addListener(new ClickListener(){
{
tapSquareSize = UnitScl.dp.scl(11f);
tapSquareSize = Scl.scl(11f);
}
@Override

View File

@@ -1,13 +1,13 @@
package io.anuke.mindustry.ui;
import io.anuke.arc.scene.style.*;
import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.util.Align;
public class MobileButton extends ImageButton{
public MobileButton(String icon, float isize, String text, Runnable listener){
public MobileButton(Drawable icon, String text, Runnable listener){
super(icon);
resizeImage(isize);
clicked(listener);
row();
add(text).growX().wrap().center().get().setAlignment(Align.center, Align.center);

View File

@@ -5,7 +5,7 @@ import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.scene.Element;
import io.anuke.arc.scene.ui.Image;
import io.anuke.arc.scene.ui.layout.Stack;
import io.anuke.arc.scene.ui.layout.UnitScl;
import io.anuke.arc.scene.ui.layout.Scl;
import io.anuke.mindustry.graphics.Pal;
public class ReqImage extends Stack{
@@ -21,7 +21,7 @@ public class ReqImage extends Stack{
@Override
public void draw(){
Lines.stroke(UnitScl.dp.scl(2f), Pal.removeBack);
Lines.stroke(Scl.scl(2f), Pal.removeBack);
Lines.line(x, y - 2f + height, x + width, y - 2f);
Draw.color(Pal.remove);
Lines.line(x, y + height, x + width, y);

View File

@@ -0,0 +1,324 @@
package io.anuke.mindustry.ui;
import io.anuke.annotations.Annotations.*;
import io.anuke.arc.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.graphics.g2d.TextureAtlas.*;
import io.anuke.arc.scene.style.*;
import io.anuke.arc.scene.ui.Button.*;
import io.anuke.arc.scene.ui.CheckBox.*;
import io.anuke.arc.scene.ui.Dialog.*;
import io.anuke.arc.scene.ui.ImageButton.*;
import io.anuke.arc.scene.ui.KeybindDialog.*;
import io.anuke.arc.scene.ui.Label.*;
import io.anuke.arc.scene.ui.ScrollPane.*;
import io.anuke.arc.scene.ui.Slider.*;
import io.anuke.arc.scene.ui.TextButton.*;
import io.anuke.arc.scene.ui.TextField.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import static io.anuke.mindustry.gen.Tex.*;
@StyleDefaults
public class Styles{
public static Drawable black, black9, black8, black6, black3, none, flatDown, flatOver;
public static ButtonStyle defaultb, waveb;
public static TextButtonStyle defaultt, squaret, nodet, cleart, discordt, infot, clearPartialt, clearTogglet, clearToggleMenut, togglet;
public static ImageButtonStyle defaulti, nodei, righti, emptyi, emptytogglei, selecti, cleari, clearFulli, clearPartiali, clearPartial2i, clearTogglei, clearTransi, clearToggleTransi, clearTogglePartiali;
public static ScrollPaneStyle defaultPane, horizontalPane;
public static KeybindDialogStyle defaultKeybindDialog;
public static SliderStyle defaultSlider, vSlider;
public static LabelStyle defaultLabel, outlineLabel;
public static TextFieldStyle defaultField, areaField;
public static CheckBoxStyle defaultCheck;
public static DialogStyle defaultDialog, fullDialog;
public static void load(){
black = whiteui.tint(0f, 0f, 0f, 1f);
black9 = whiteui.tint(0f, 0f, 0f, 0.9f);
black8 = whiteui.tint(0f, 0f, 0f, 0.8f);
black6 = whiteui.tint(0f, 0f, 0f, 0.6f);
black3 = whiteui.tint(0f, 0f, 0f, 0.3f);
none = whiteui.tint(0f, 0f, 0f, 0f);
flatDown = createFlatDown();
flatOver = whiteui.tint(Color.valueOf("454545"));
defaultb = new ButtonStyle(){{
down = buttonDown;
up = button;
over = buttonOver;
disabled = buttonDisabled;
}};
waveb = new ButtonStyle(){{
up = buttonEdge4;
over = buttonEdgeOver4;
disabled = buttonEdge4;
}};
defaultt = new TextButtonStyle(){{
over = buttonOver;
disabled = buttonDisabled;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
down = buttonDown;
up = button;
}};
squaret = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
over = buttonSquareOver;
disabled = buttonDisabled;
down = buttonSquareDown;
up = buttonSquare;
}};
nodet = new TextButtonStyle(){{
disabled = button;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
up = buttonOver;
over = buttonDown;
}};
cleart = new TextButtonStyle(){{
over = flatOver;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
down = flatOver;
up = black;
}};
discordt = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
up = discordBanner;
}};
infot = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
up = infoBanner;
}};
clearPartialt = new TextButtonStyle(){{
down = whiteui;
up = pane;
over = flatDown;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
}};
clearTogglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = flatDown;
down = flatDown;
up = black;
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}};
clearToggleMenut = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = flatDown;
down = flatDown;
up = clear;
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}};
togglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
checked = buttonDown;
down = buttonDown;
up = button;
over = buttonOver;
disabled = buttonDisabled;
disabledFontColor = Color.gray;
}};
defaulti = new ImageButtonStyle(){{
down = buttonDown;
up = button;
over = buttonOver;
imageDisabledColor = Color.gray;
imageUpColor = Color.white;
disabled = buttonDisabled;
}};
nodei = new ImageButtonStyle(){{
up = buttonOver;
over = buttonDown;
}};
righti = new ImageButtonStyle(){{
over = buttonRightOver;
down = buttonRightDown;
up = buttonRight;
}};
emptyi = new ImageButtonStyle(){{
imageDownColor = Pal.accent;
imageUpColor = Color.white;
}};
emptytogglei = new ImageButtonStyle(){{
imageCheckedColor = Color.white;
imageDownColor = Color.white;
imageUpColor = Color.gray;
}};
selecti = new ImageButtonStyle(){{
checked = buttonSelect;
up = none;
}};
cleari = new ImageButtonStyle(){{
down = flatOver;
up = black;
over = flatOver;
}};
clearFulli = new ImageButtonStyle(){{
down = whiteui;
up = pane;
over = flatDown;
}};
clearPartiali = new ImageButtonStyle(){{
down = flatDown;
up = none;
over = flatOver;
}};
clearPartial2i = new ImageButtonStyle(){{
down = whiteui;
up = pane;
over = flatDown;
}};
clearTogglei = new ImageButtonStyle(){{
down = flatDown;
checked = flatDown;
up = black;
over = flatOver;
}};
clearTransi = new ImageButtonStyle(){{
down = flatDown;
up = black6;
over = flatOver;
}};
clearToggleTransi = new ImageButtonStyle(){{
down = flatDown;
checked = flatDown;
up = black6;
over = flatOver;
}};
clearTogglePartiali = new ImageButtonStyle(){{
down = flatDown;
checked = flatDown;
up = none;
over = flatOver;
}};
defaultPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
}};
horizontalPane = new ScrollPaneStyle(){{
vScroll = scroll;
vScrollKnob = scrollKnobVerticalBlack;
hScroll = scrollHorizontal;
hScrollKnob = scrollKnobHorizontalBlack;
}};
defaultKeybindDialog = new KeybindDialogStyle(){{
keyColor = Pal.accent;
keyNameColor = Color.white;
controllerColor = Color.lightGray;
}};
defaultSlider = new SliderStyle(){{
background = slider;
knob = sliderKnob;
knobOver = sliderKnobOver;
knobDown = sliderKnobDown;
}};
vSlider = new SliderStyle(){{
background = sliderVertical;
knob = sliderKnob;
knobOver = sliderKnobOver;
knobDown = sliderKnobDown;
}};
defaultLabel = new LabelStyle(){{
font = Fonts.def;
fontColor = Color.white;
}};
outlineLabel = new LabelStyle(){{
font = Fonts.outline;
fontColor = Color.white;
}};
defaultField = new TextFieldStyle(){{
font = Fonts.chat;
fontColor = Color.white;
disabledFontColor = Color.gray;
disabledBackground = underlineDisabled;
selection = Tex.selection;
background = underline;
invalidBackground = underlineRed;
cursor = Tex.cursor;
messageFont = Fonts.def;
messageFontColor = Color.gray;
}};
areaField = new TextFieldStyle(){{
font = Fonts.chat;
fontColor = Color.white;
disabledFontColor = Color.gray;
selection = Tex.selection;
background = underline;
cursor = Tex.cursor;
messageFont = Fonts.def;
messageFontColor = Color.gray;
}};
defaultCheck = new CheckBoxStyle(){{
checkboxOn = checkOn;
checkboxOff = checkOff;
checkboxOnOver = checkOnOver;
checkboxOver = checkOver;
checkboxOnDisabled = checkOnDisabled;
checkboxOffDisabled = checkDisabled;
font = Fonts.def;
fontColor = Color.white;
disabledFontColor = Color.gray;
}};
defaultDialog = new DialogStyle(){{
stageBackground = black9;
titleFont = Fonts.def;
background = windowEmpty;
titleFontColor = Pal.accent;
}};
fullDialog = new DialogStyle(){{
stageBackground = black;
titleFont = Fonts.def;
background = windowEmpty;
titleFontColor = Pal.accent;
}};
}
private static Drawable createFlatDown(){
AtlasRegion region = Core.atlas.find("flat-down-base");
int[] splits = region.splits;
ScaledNinePatchDrawable copy = new ScaledNinePatchDrawable(new NinePatch(region, splits[0], splits[1], splits[2], splits[3])){
public float getLeftWidth(){ return 0; }
public float getRightWidth(){ return 0; }
public float getTopHeight(){ return 0; }
public float getBottomHeight(){ return 0; }
};
copy.setMinWidth(0);
copy.setMinHeight(0);
copy.setTopHeight(0);
copy.setRightWidth(0);
copy.setBottomHeight(0);
copy.setLeftWidth(0);
return copy;
}
}

View File

@@ -1,20 +1,22 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.scene.ui.ScrollPane;
import io.anuke.arc.graphics.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.ui.Links;
import io.anuke.mindustry.ui.Links.LinkEntry;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.ui.Links.*;
import static io.anuke.mindustry.Vars.*;
public class AboutDialog extends FloatingDialog{
private Array<String> contributors = new Array<>();
private static ObjectSet<String> bannedItems = ObjectSet.with("google-play", "itch.io", "dev-builds", "trello");
private static ObjectSet<String> bannedItems = ObjectSet.with("google-play", "itch.io", "dev-builds");
public AboutDialog(){
super("$about.button");
@@ -39,32 +41,34 @@ public class AboutDialog extends FloatingDialog{
ScrollPane pane = new ScrollPane(in);
for(LinkEntry link : Links.getLinks()){
if((ios || OS.isMac) && bannedItems.contains(link.name)){ //because Apple doesn't like me mentioning things
if((ios || OS.isMac || steam) && bannedItems.contains(link.name)){
continue;
}
Table table = new Table("underline");
Table table = new Table(Tex.underline);
table.margin(0);
table.table(img -> {
img.addImage("whiteui").height(h - 5).width(40f).color(link.color);
img.addImage().height(h - 5).width(40f).color(link.color);
img.row();
img.addImage("whiteui").height(5).width(40f).color(link.color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
img.addImage().height(5).width(40f).color(link.color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
}).expandY();
table.table(i -> {
i.background("button-edge-3");
i.addImage("icon-" + link.name).size(iconsize);
i.background(Tex.buttonEdge3);
i.addImage(Core.atlas.drawable("icon-" + link.name));
}).size(h - 5, h);
table.table(inset -> {
inset.add("[accent]" + Strings.capitalize(link.name.replace("-", " "))).growX().left();
inset.row();
inset.labelWrap(link.description).width(w - 100f).color(Color.LIGHT_GRAY).growX();
inset.labelWrap(link.description).width(w - 100f).color(Color.lightGray).growX();
}).padLeft(8);
table.addImageButton("icon-link", iconsize, () -> {
table.addImageButton(Icon.link, () -> {
if(link.name.equals("wiki")) Events.fire(Trigger.openWiki);
if(!Core.net.openURI(link.link)){
ui.showError("$linkfail");
ui.showErrorMessage("$linkfail");
Core.app.setClipboardText(link.link);
}
}).size(h - 5, h);
@@ -94,7 +98,7 @@ public class AboutDialog extends FloatingDialog{
dialog.cont.add("$credits.text");
dialog.cont.row();
if(!contributors.isEmpty()){
dialog.cont.addImage("whiteui").color(Pal.accent).fillX().height(3f).pad(3f);
dialog.cont.addImage().color(Pal.accent).fillX().height(3f).pad(3f);
dialog.cont.row();
dialog.cont.add("$contributors");
dialog.cont.row();

View File

@@ -1,8 +1,9 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.scene.ui.ScrollPane;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.net.Administration.PlayerInfo;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.net.Administration.*;
import static io.anuke.mindustry.Vars.*;
@@ -32,12 +33,12 @@ public class AdminsDialog extends FloatingDialog{
}
for(PlayerInfo info : netServer.admins.getAdmins()){
Table res = new Table("button");
Table res = new Table(Tex.button);
res.margin(14f);
res.labelWrap("[LIGHT_GRAY]" + info.lastName).width(w - h - 24f);
res.add().growX();
res.addImageButton("icon-cancel", iconsize, () -> {
res.addImageButton(Icon.cancel, () -> {
ui.showConfirm("$confirm", "$confirmunadmin", () -> {
netServer.admins.unAdminPlayer(info.id);
playerGroup.all().each(player -> {

View File

@@ -1,8 +1,9 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.scene.ui.ScrollPane;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.net.Administration.PlayerInfo;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.net.Administration.*;
import static io.anuke.mindustry.Vars.*;
@@ -33,12 +34,12 @@ public class BansDialog extends FloatingDialog{
}
for(PlayerInfo info : netServer.admins.getBanned()){
Table res = new Table("button");
Table res = new Table(Tex.button);
res.margin(14f);
res.labelWrap("IP: [LIGHT_GRAY]" + info.lastIP + "\n[]Name: [LIGHT_GRAY]" + info.lastName).width(w - h - 24f);
res.add().growX();
res.addImageButton("icon-cancel", iconsize, () -> {
res.addImageButton(Icon.cancel, () -> {
ui.showConfirm("$confirm", "$confirmunban", () -> {
netServer.admins.unbanPlayerID(info.id);
setup();

View File

@@ -1,20 +1,20 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.function.Consumer;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.input.KeyCode;
import io.anuke.arc.scene.ui.Dialog;
import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.input.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.ui.*;
import static io.anuke.mindustry.Vars.player;
import static io.anuke.mindustry.Vars.playerColors;
import static io.anuke.mindustry.Vars.*;
public class ColorPickDialog extends Dialog{
private Consumer<Color> cons;
public ColorPickDialog(){
super("", "dialog");
super("");
build();
}
@@ -25,7 +25,7 @@ public class ColorPickDialog extends Dialog{
for(int i = 0; i < playerColors.length; i++){
Color color = playerColors[i];
ImageButton button = table.addImageButton("whiteui", "clear-toggle", 34, () -> {
ImageButton button = table.addImageButton(Tex.whiteui, Styles.clearTogglei, 34, () -> {
cons.accept(color);
hide();
}).size(48).get();

View File

@@ -1,32 +1,24 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.input.KeyCode;
import io.anuke.arc.input.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.util.Align;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
public class ControlsDialog extends KeybindDialog{
public ControlsDialog(){
setStyle(Core.scene.skin.get("dialog", WindowStyle.class));
setFillParent(true);
title.setAlignment(Align.center);
titleTable.row();
titleTable.add(new Image("whiteui"))
.growX().height(3f).pad(4f).get().setColor(Pal.accent);
if(Vars.mobile){
cont.row();
cont.add("$keybinds.mobile")
.center().growX().wrap().get().setAlignment(Align.center);
}
titleTable.add(new Image()).growX().height(3f).pad(4f).get().setColor(Pal.accent);
}
@Override
public void addCloseButton(){
buttons.addImageTextButton("$back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
buttons.addImageTextButton("$back", Icon.arrowLeftSmall, this::hide).size(230f, 64f);
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK)

View File

@@ -8,6 +8,7 @@ import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.maps.*;
import io.anuke.mindustry.ui.*;
@@ -36,7 +37,7 @@ public class CustomGameDialog extends FloatingDialog{
ScrollPane pane = new ScrollPane(maps);
pane.setFadeScrollBars(false);
int maxwidth = Mathf.clamp((int)(Core.graphics.getWidth() / UnitScl.dp.scl(200)), 1, 8);
int maxwidth = Mathf.clamp((int)(Core.graphics.getWidth() / Scl.scl(200)), 1, 8);
float images = 146f;
int i = 0;
@@ -47,7 +48,7 @@ public class CustomGameDialog extends FloatingDialog{
maps.row();
}
ImageButton image = new ImageButton(new TextureRegion(map.texture), "clear");
ImageButton image = new ImageButton(new TextureRegion(map.safeTexture()), Styles.cleari);
image.margin(5);
image.top();
@@ -59,19 +60,19 @@ public class CustomGameDialog extends FloatingDialog{
t.left();
for(Gamemode mode : Gamemode.all){
if(mode.valid(map) && Core.atlas.has("icon-mode-" + mode.name())){
t.addImage("icon-mode-" + mode.name()).size(16f).pad(4f);
t.addImage(Core.atlas.drawable("icon-mode-" + mode.name())).size(16f).pad(4f);
}
}
}).left();
image.row();
image.add(map.name()).pad(1f).growX().wrap().left().get().setEllipsis(true);
image.row();
image.addImage("whiteui", Pal.gray).growX().pad(3).height(4f);
image.addImage(Tex.whiteui, Pal.gray).growX().pad(3).height(4f);
image.row();
image.add(img).size(images);
BorderImage border = new BorderImage(map.texture, 3f);
BorderImage border = new BorderImage(map.safeTexture(), 3f);
border.setScaling(Scaling.fit);
image.replaceImage(border);

View File

@@ -101,7 +101,7 @@ public class CustomRulesDialog extends FloatingDialog{
main.table(t -> {
t.left();
t.add(text).left().padRight(5)
.update(a -> a.setColor(condition.get() ? Color.WHITE : Color.GRAY));
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
Vars.platform.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.accept(Strings.parseFloat(s)))
.padRight(100f)
.update(a -> a.setDisabled(!condition.get()))

View File

@@ -12,6 +12,7 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.type.ContentType;
@@ -43,7 +44,7 @@ public class DatabaseDialog extends FloatingDialog{
table.add("$content." + type.name() + ".name").growX().left().color(Pal.accent);
table.row();
table.addImage("whiteui").growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
table.addImage().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
table.row();
table.table(list -> {
list.left();
@@ -55,18 +56,18 @@ public class DatabaseDialog extends FloatingDialog{
for(int i = 0; i < array.size; i++){
UnlockableContent unlock = (UnlockableContent)array.get(i);
Image image = unlocked(unlock) ? new Image(unlock.getContentIcon()) : new Image("icon-locked", Pal.gray);
list.add(image).size(unlocked(unlock) ? 8*4 : Vars.iconsize).pad(3);
Image image = unlocked(unlock) ? new Image(unlock.getContentIcon()) : new Image(Icon.lockedSmall, Pal.gray);
list.add(image).size(8*4).pad(3);
ClickListener listener = new ClickListener();
image.addListener(listener);
if(!Vars.mobile && unlocked(unlock)){
image.addListener(new HandCursorListener());
image.update(() -> image.getColor().lerp(!listener.isOver() ? Color.LIGHT_GRAY : Color.WHITE, 0.4f * Time.delta()));
image.update(() -> image.getColor().lerp(!listener.isOver() ? Color.lightGray : Color.white, 0.4f * Time.delta()));
}
if(unlocked(unlock)){
image.clicked(() -> Vars.ui.content.show(unlock));
image.addListener(new Tooltip(t -> t.background("button").add(unlock.localizedName())));
image.addListener(new Tooltip(t -> t.background(Tex.button).add(unlock.localizedName())));
}
if((++count) % maxWidth == 0){

View File

@@ -17,36 +17,37 @@ import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.Saves.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.io.SaveIO.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.type.Zone.*;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.ui.Styles;
import io.anuke.mindustry.ui.TreeLayout.*;
import static io.anuke.mindustry.Vars.*;
public class DeployDialog extends FloatingDialog{
private final float nodeSize = UnitScl.dp.scl(230f);
private final float nodeSize = Scl.scl(230f);
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
private ZoneInfoDialog info = new ZoneInfoDialog();
private Rectangle bounds = new Rectangle();
public DeployDialog(){
super("", "fulldialog");
super("", Styles.fullDialog);
ZoneNode root = new ZoneNode(Zones.groundZero, null);
TreeLayout layout = new TreeLayout();
layout.gapBetweenLevels = layout.gapBetweenNodes = UnitScl.dp.scl(60f);
layout.gapBetweenNodes = UnitScl.dp.scl(120f);
layout.gapBetweenLevels = layout.gapBetweenNodes = Scl.scl(60f);
layout.gapBetweenNodes = Scl.scl(120f);
layout.layout(root);
bounds.set(layout.getBounds());
bounds.y += nodeSize*0.4f;
addCloseButton();
buttons.addImageTextButton("$techtree", "icon-tree", iconsize, () -> ui.tech.show()).size(230f, 64f);
buttons.addImageTextButton("$techtree", Icon.tree, () -> ui.tech.show()).size(230f, 64f);
shown(this::setup);
}
@@ -86,7 +87,7 @@ public class DeployDialog extends FloatingDialog{
Stack sub = new Stack();
if(slot.getZone() != null){
sub.add(new Table(f -> f.margin(4f).add(new Image("whiteui")).color(Color.fromGray(0.1f)).grow()));
sub.add(new Table(f -> f.margin(4f).add(new Image()).color(Color.fromGray(0.1f)).grow()));
sub.add(new Table(f -> f.margin(4f).add(new Image(slot.getZone().preview).setScaling(Scaling.fit)).update(img -> {
TextureRegionDrawable draw = (TextureRegionDrawable)img.getDrawable();
@@ -98,14 +99,14 @@ public class DeployDialog extends FloatingDialog{
if(draw.getRegion() == slot.getZone().preview && text != null){
draw.setRegion(new TextureRegion(text));
}
}).color(Color.DARK_GRAY).grow()));
}).color(Color.darkGray).grow()));
}
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), "square", () -> {
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> {
hide();
ui.loadAnd(() -> {
logic.reset();
Net.reset();
net.reset();
try{
control.saves.getZoneSlot().load();
state.set(State.playing);
@@ -169,20 +170,15 @@ public class DeployDialog extends FloatingDialog{
return false;
}
@Override
protected void drawBackground(float x, float y){
drawDefaultBackground(x, y);
}
void buildButton(Zone zone, Button button){
button.setDisabled(() -> hidden(zone));
button.clicked(() -> info.show(zone));
if(zone.unlocked() && !hidden(zone)){
button.labelWrap(zone.localizedName()).style("outline").width(140).growX().get().setAlignment(Align.center);
button.labelWrap(zone.localizedName()).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center);
}else{
Consumer<Element> flasher = zone.canUnlock() && !hidden(zone) ? e -> e.update(() -> e.getColor().set(Color.WHITE).lerp(Pal.accent, Mathf.absin(3f, 1f))) : e -> {};
flasher.accept(button.addImage("icon-locked").get());
Consumer<Element> flasher = zone.canUnlock() && !hidden(zone) ? e -> e.update(() -> e.getColor().set(Color.white).lerp(Pal.accent, Mathf.absin(3f, 1f))) : e -> {};
flasher.accept(button.addImage(Icon.locked).get());
button.row();
flasher.accept(button.add("$locked").get());
}
@@ -202,10 +198,10 @@ public class DeployDialog extends FloatingDialog{
}
stack.setSize(Tmp.v1.x, Tmp.v1.y);
stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.DARK_GRAY : Color.fromGray(0.2f)).grow()));
stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.fromGray(0.2f)).grow()));
stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center));
Button button = new Button("square");
Button button = new Button(Styles.squaret);
buildButton(node.zone, button);
stack.add(button);
addChild(stack);
@@ -237,7 +233,7 @@ public class DeployDialog extends FloatingDialog{
for(ZoneNode node : nodes){
for(ZoneNode child : node.allChildren){
Lines.stroke(UnitScl.dp.scl(4f), node.zone.locked() || child.zone.locked() ? Pal.gray : Pal.gray);
Lines.stroke(Scl.scl(4f), node.zone.locked() || child.zone.locked() ? Pal.gray : Pal.gray);
Draw.alpha(parentAlpha);
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
}

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.scene.ui.Dialog;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.Pal;
import static io.anuke.mindustry.Vars.*;
@@ -10,7 +11,7 @@ import static io.anuke.mindustry.Vars.*;
public class DiscordDialog extends Dialog{
public DiscordDialog(){
super("", "dialog");
super("");
float h = 70f;
@@ -19,17 +20,17 @@ public class DiscordDialog extends Dialog{
Color color = Color.valueOf("7289da");
cont.table(t -> {
t.background("button").margin(0);
t.background(Tex.button).margin(0);
t.table(img -> {
img.addImage("whiteui").height(h - 5).width(40f).color(color);
img.addImage().height(h - 5).width(40f).color(color);
img.row();
img.addImage("whiteui").height(5).width(40f).color(color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
img.addImage().height(5).width(40f).color(color.cpy().mul(0.8f, 0.8f, 0.8f, 1f));
}).expandY();
t.table(i -> {
i.background("button");
i.addImage("icon-discord").size(iconsize);
i.background(Tex.button);
i.addImage(Icon.discord);
}).size(h).left();
t.add("$discord").color(Pal.accent).growX().padLeft(10f);
@@ -43,7 +44,7 @@ public class DiscordDialog extends Dialog{
});
buttons.addButton("$openlink", () -> {
if(!Core.net.openURI(discordURL)){
ui.showError("$linkfail");
ui.showErrorMessage("$linkfail");
Core.app.setClipboardText(discordURL);
}
});

View File

@@ -1,21 +1,21 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.collection.Array;
import io.anuke.arc.files.FileHandle;
import io.anuke.arc.function.Consumer;
import io.anuke.arc.function.Predicate;
import io.anuke.arc.graphics.g2d.GlyphLayout;
import io.anuke.arc.scene.event.Touchable;
import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
import io.anuke.arc.function.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.scene.ui.layout.UnitScl;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.pooling.Pools;
import io.anuke.arc.util.pooling.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.ui.*;
import java.util.Arrays;
import java.util.*;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.platform;
public class FileChooser extends FloatingDialog{
private static final FileHandle homeDirectory = Core.files.absolute(OS.isMac ? OS.getProperty("user.home") + "/Downloads/" : Core.files.getExternalStoragePath());
@@ -31,13 +31,9 @@ public class FileChooser extends FloatingDialog{
private Consumer<FileHandle> selectListener;
private boolean open;
public static final Predicate<String> pngFiles = str -> str.equals("png");
public static final Predicate<String> anyMapFiles = str -> str.equals(oldMapExtension) || str.equals(mapExtension);
public static final Predicate<String> mapFiles = str -> str.equals(mapExtension);
public static final Predicate<String> saveFiles = str -> str.equals(saveExtension);
public FileChooser(String title, Predicate<FileHandle> filter, boolean open, Consumer<FileHandle> result){
super(title);
setFillParent(true);
this.open = open;
this.filter = filter;
this.selectListener = result;
@@ -88,11 +84,7 @@ public class FileChooser extends FloatingDialog{
files.marginRight(10);
files.marginLeft(3);
pane = new ScrollPane(files){
public float getPrefHeight(){
return Core.graphics.getHeight();
}
};
pane = new ScrollPane(files);
pane.setOverscroll(false, false);
pane.setFadeScrollBars(false);
@@ -100,10 +92,7 @@ public class FileChooser extends FloatingDialog{
Table icontable = new Table();
float isize = iconsize;
ImageButton up = new ImageButton("icon-folder-parent");
up.resizeImage(isize);
ImageButton up = new ImageButton(Icon.folderParent);
up.clicked(() -> {
directory = directory.parent();
updateFiles(true);
@@ -114,19 +103,15 @@ public class FileChooser extends FloatingDialog{
up.setDisabled(true);
}
ImageButton back = new ImageButton("icon-arrow-left");
back.resizeImage(isize);
ImageButton forward = new ImageButton("icon-arrow-right");
forward.resizeImage(isize);
ImageButton back = new ImageButton(Icon.arrowLeft);
ImageButton forward = new ImageButton(Icon.arrowRight);
forward.clicked(() -> stack.forward());
back.clicked(() -> stack.back());
forward.setDisabled(() -> !stack.canForward());
back.setDisabled(() -> !stack.canBack());
ImageButton home = new ImageButton("icon-home");
home.resizeImage(isize);
ImageButton home = new ImageButton(Icon.home);
home.clicked(() -> {
directory = homeDirectory;
lastDirectory = directory;
@@ -152,7 +137,7 @@ public class FileChooser extends FloatingDialog{
content.add(icontable).expandX().fillX();
content.row();
content.center().add(pane).width(Core.graphics.isPortrait() ? Core.graphics.getWidth() / UnitScl.dp.scl(1) : Core.graphics.getWidth() / UnitScl.dp.scl(2)).colspan(3).grow();
content.center().add(pane).colspan(3).grow();
content.row();
if(!open){
@@ -162,7 +147,7 @@ public class FileChooser extends FloatingDialog{
content.add(buttons).growX();
cont.add(content);
cont.add(content).grow();
}
private void updateFileFieldStatus(){
@@ -191,7 +176,7 @@ public class FileChooser extends FloatingDialog{
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
layout.setText(Core.scene.skin.getFont("default"), navigation.getText());
layout.setText(Fonts.def, navigation.getText());
if(layout.width < navigation.getWidth()){
navigation.setCursorPosition(0);
@@ -207,15 +192,15 @@ public class FileChooser extends FloatingDialog{
//macs are confined to the Downloads/ directory
if(!OS.isMac){
Image upimage = new Image("icon-folder-parent-small");
TextButton upbutton = new TextButton(".." + directory.toString(), "clear-toggle");
Image upimage = new Image(Icon.folderParentSmall);
TextButton upbutton = new TextButton(".." + directory.toString(), Styles.clearTogglet);
upbutton.clicked(() -> {
directory = directory.parent();
lastDirectory = directory;
updateFiles(true);
});
upbutton.left().add(upimage).padRight(4f).size(iconsizesmall).padLeft(4);
upbutton.left().add(upimage).padRight(4f).padLeft(4);
upbutton.getLabel().setAlignment(Align.left);
upbutton.getCells().reverse();
@@ -231,7 +216,7 @@ public class FileChooser extends FloatingDialog{
String filename = file.name();
TextButton button = new TextButton(shorten(filename), "clear-toggle");
TextButton button = new TextButton(shorten(filename), Styles.clearTogglet);
group.add(button);
button.clicked(() -> {
@@ -249,9 +234,9 @@ public class FileChooser extends FloatingDialog{
button.setChecked(filename.equals(filefield.getText()));
});
Image image = new Image(file.isDirectory() ? "icon-folder-small" : "icon-file-text-small");
Image image = new Image(file.isDirectory() ? Icon.folderSmall : Icon.fileTextSmall);
button.add(image).padRight(4f).padLeft(4).size(iconsizesmall);
button.add(image).padRight(4f).padLeft(4);
button.getCells().reverse();
files.top().left().add(button).align(Align.topLeft).fillX().expandX()
.height(50).pad(2).padTop(0).padBottom(0).colspan(2);

View File

@@ -8,7 +8,6 @@ import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.net.Net;
import static io.anuke.mindustry.Vars.*;
@@ -16,17 +15,17 @@ public class FloatingDialog extends Dialog{
private boolean wasPaused;
protected boolean shouldPause;
public FloatingDialog(String title, String style){
public FloatingDialog(String title, DialogStyle style){
super(title, style);
setFillParent(true);
this.title.setAlignment(Align.center);
titleTable.row();
titleTable.addImage("whiteui", Pal.accent)
titleTable.addImage(Tex.whiteui, Pal.accent)
.growX().height(3f).pad(4f);
hidden(() -> {
if(shouldPause && !state.is(State.menu)){
if(!wasPaused || Net.active()){
if(!wasPaused || net.active()){
state.set(State.playing);
}
}
@@ -42,7 +41,7 @@ public class FloatingDialog extends Dialog{
}
public FloatingDialog(String title){
this(title, "dialog");
this(title, Core.scene.getStyle(DialogStyle.class));
}
protected void onResize(Runnable run){
@@ -56,7 +55,7 @@ public class FloatingDialog extends Dialog{
@Override
public void addCloseButton(){
buttons.addImageTextButton("$back", "icon-arrow-left", iconsize, this::hide).size(210f, 64f);
buttons.addImageTextButton("$back", Icon.arrowLeft, this::hide).size(210f, 64f);
keyDown(key -> {
if(key == KeyCode.ESCAPE || key == KeyCode.BACK){

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.game.Stats.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.type.*;
@@ -21,6 +22,11 @@ public class GameOverDialog extends FloatingDialog{
public void show(Team winner){
this.winner = winner;
show();
if(winner == player.getTeam()){
Events.fire(new WinEvent());
}else{
Events.fire(new LoseEvent());
}
}
void rebuild(){

View File

@@ -1,17 +1,16 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.scene.ui.ImageButton;
import io.anuke.arc.util.Strings;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.net.Net;
import io.anuke.arc.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.ui.*;
import java.io.IOException;
import java.io.*;
import static io.anuke.mindustry.Vars.player;
import static io.anuke.mindustry.Vars.ui;
import static io.anuke.mindustry.Vars.*;
public class HostDialog extends FloatingDialog{
float w = 300;
@@ -30,7 +29,7 @@ public class HostDialog extends FloatingDialog{
ui.listfrag.rebuild();
}).grow().pad(8).get().setMaxLength(40);
ImageButton button = t.addImageButton("whiteui", "clear-full", 40, () -> {
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
new ColorPickDialog().show(color -> {
player.color.set(color);
Core.settings.put("color-0", Color.rgba8888(color));
@@ -50,23 +49,29 @@ public class HostDialog extends FloatingDialog{
return;
}
ui.loadfrag.show("$hosting");
Time.runTask(5f, () -> {
try{
Net.host(Vars.port);
player.isAdmin = true;
}catch(IOException e){
ui.showError(Core.bundle.format("server.error", Strings.parseException(e, true)));
}
ui.loadfrag.hide();
hide();
});
runHost();
}).width(w).height(70f);
cont.addButton("?", () -> ui.showInfo("$host.info")).size(65f, 70f).padLeft(6f);
shown(() -> {
Core.app.post(() -> Core.settings.getBoolOnce("hostinfo", () -> ui.showInfo("$host.info")));
if(!steam){
Core.app.post(() -> Core.settings.getBoolOnce("hostinfo", () -> ui.showInfo("$host.info")));
}
});
}
public void runHost(){
ui.loadfrag.show("$hosting");
Time.runTask(5f, () -> {
try{
net.host(Vars.port);
player.isAdmin = true;
}catch(IOException e){
ui.showException("$server.error", e);
}
ui.loadfrag.hide();
hide();
});
}
}

View File

@@ -4,16 +4,17 @@ import io.anuke.annotations.Annotations.*;
import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.input.*;
import io.anuke.arc.math.*;
import io.anuke.arc.scene.style.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.ui.*;
import static io.anuke.mindustry.Vars.*;
@@ -67,7 +68,7 @@ public class JoinDialog extends FloatingDialog{
refreshRemote();
}
add.hide();
}).disabled(b -> Core.settings.getString("ip").isEmpty() || Net.active());
}).disabled(b -> Core.settings.getString("ip").isEmpty() || net.active());
add.shown(() -> {
add.title.setText(renaming != null ? "$server.edit" : "$server.add");
@@ -76,6 +77,11 @@ public class JoinDialog extends FloatingDialog{
}
});
keyDown(KeyCode.F5, () -> {
refreshLocal();
refreshRemote();
});
shown(() -> {
setup();
refreshLocal();
@@ -93,7 +99,7 @@ public class JoinDialog extends FloatingDialog{
//why are java lambdas this bad
TextButton[] buttons = {null};
TextButton button = buttons[0] = remote.addButton("[accent]" + server.displayIP(), "clear", () -> {
TextButton button = buttons[0] = remote.addButton("[accent]" + server.displayIP(), Styles.cleart, () -> {
if(!buttons[0].childrenPressed()){
if(server.lastHost != null && server.lastHost.version != Version.build && Version.build != -1 && server.lastHost.version != -1){
ui.showInfo("[scarlet]" + (server.lastHost.version > Version.build ? KickReason.clientOutdated : KickReason.serverOutdated).toString() + "\n[]" +
@@ -112,7 +118,7 @@ public class JoinDialog extends FloatingDialog{
inner.add(button.getLabel()).growX();
inner.addImageButton("icon-arrow-up-small", "empty", iconsizesmall, () -> {
inner.addImageButton(Icon.arrowUpSmall, Styles.emptyi, () -> {
int index = servers.indexOf(server);
if(index > 0){
servers.remove(index);
@@ -131,16 +137,16 @@ public class JoinDialog extends FloatingDialog{
}).margin(3f).padTop(6f).top().right();
inner.addImageButton("icon-loading-small", "empty", iconsizesmall, () -> {
inner.addImageButton(Icon.loadingSmall, Styles.emptyi, () -> {
refreshServer(server);
}).margin(3f).padTop(6f).top().right();
inner.addImageButton("icon-pencil-small", "empty", iconsizesmall, () -> {
inner.addImageButton(Icon.pencilSmall, Styles.emptyi, () -> {
renaming = server;
add.show();
}).margin(3f).padTop(6f).top().right();
inner.addImageButton("icon-trash-16-small", "empty", iconsizesmall, () -> {
inner.addImageButton(Icon.trash16Small, Styles.emptyi, () -> {
ui.showConfirm("$confirm", "$server.delete", () -> {
servers.removeValue(server, true);
saveServers();
@@ -151,8 +157,7 @@ public class JoinDialog extends FloatingDialog{
button.row();
server.content = button.table(t -> {
}).grow().get();
server.content = button.table(t -> {}).grow().get();
remote.row();
}
@@ -168,7 +173,7 @@ public class JoinDialog extends FloatingDialog{
server.content.clear();
server.content.label(() -> Core.bundle.get("server.refreshing") + Strings.animated(Time.time(), 4, 11, "."));
Net.pingHost(server.ip, server.port, host -> setupServer(server, host), e -> {
net.pingHost(server.ip, server.port, host -> setupServer(server, host), e -> {
server.content.clear();
server.content.add("$host.invalid");
});
@@ -176,6 +181,11 @@ public class JoinDialog extends FloatingDialog{
void setupServer(Server server, Host host){
server.lastHost = host;
server.content.clear();
buildServer(host, server.content);
}
void buildServer(Host host, Table content){
String versionString;
if(host.version == -1){
@@ -192,14 +202,13 @@ public class JoinDialog extends FloatingDialog{
versionString = Core.bundle.format("server.version", host.version, host.versionType);
}
server.content.clear();
server.content.table(t -> {
content.table(t -> {
t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true);
t.row();
t.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players == 0 ? host.players : "[accent]" + host.players + "[lightgray]") : Core.bundle.format("players.single", "[accent]" + host.players + "[lightgray]"))).left();
t.add("[lightgray]" + (Core.bundle.format("players" + (host.players == 1 && host.playerLimit <= 0 ? ".single" : ""), (host.players == 0 ? "[lightgray]" : "[accent]") + host.players + (host.playerLimit > 0 ? "[lightgray]/[accent]" + host.playerLimit : "")+ "[lightgray]"))).left();
t.row();
t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + Core.bundle.format("save.wave", host.wave)).width(targetWidth() - 10f).left().get().setEllipsis(true);
t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + host.mode.toString()).width(targetWidth() - 10f).left().get().setEllipsis(true);
}).expand().left().bottom().padLeft(12f).padBottom(8);
}
@@ -222,13 +231,17 @@ public class JoinDialog extends FloatingDialog{
cont.clear();
cont.table(t -> {
t.add("$name").padRight(10);
t.addField(Core.settings.getString("name"), text -> {
player.name = text;
Core.settings.put("name", text);
Core.settings.save();
}).grow().pad(8).get().setMaxLength(maxNameLength);
if(!steam){
t.addField(Core.settings.getString("name"), text -> {
player.name = text;
Core.settings.put("name", text);
Core.settings.save();
}).grow().pad(8).get().setMaxLength(maxNameLength);
}else{
t.add(player.name).update(l -> l.setColor(player.color)).grow().pad(8);
}
ImageButton button = t.addImageButton("whiteui", "clear-full", 40, () -> {
ImageButton button = t.addImageButton(Tex.whiteui, Styles.clearFulli, 40, () -> {
new ColorPickDialog().show(color -> {
player.color.set(color);
Core.settings.put("color-0", Color.rgba8888(color));
@@ -240,7 +253,7 @@ public class JoinDialog extends FloatingDialog{
cont.row();
cont.add(pane).width(w + 38).pad(0);
cont.row();
cont.addCenteredImageTextButton("$server.add", "icon-add", iconsize, () -> {
cont.addCenteredImageTextButton("$server.add", Icon.add, () -> {
renaming = null;
add.show();
}).marginLeft(6).width(w).height(80f).update(button -> {
@@ -265,20 +278,23 @@ public class JoinDialog extends FloatingDialog{
totalHosts = 0;
local.clear();
local.background((Drawable)null);
local.table("button", t -> t.label(() -> "[accent]" + Core.bundle.get("hosts.discovering") + Strings.animated(Time.time(), 4, 10f, ".")).pad(10f)).growX();
Net.discoverServers(this::addLocalHost, this::finishLocalHosts);
local.background(null);
local.table(Tex.button, t -> t.label(() -> "[accent]" + Core.bundle.get("hosts.discovering.any") + Strings.animated(Time.time(), 4, 10f, ".")).pad(10f)).growX();
net.discoverServers(this::addLocalHost, this::finishLocalHosts);
for(String host : defaultServers){
net.pingHost(host, port, this::addLocalHost, e -> {});
}
}
void finishLocalHosts(){
if(totalHosts == 0){
local.clear();
local.background("button");
local.background(Tex.button);
local.add("$hosts.none").pad(10f);
local.add().growX();
local.addImageButton("icon-loading", iconsize, this::refreshLocal).pad(-12f).padLeft(0).size(70f);
local.addImageButton(Icon.loading, this::refreshLocal).pad(-12f).padLeft(0).size(70f);
}else{
local.background((Drawable)null);
local.background(null);
}
}
@@ -286,22 +302,20 @@ public class JoinDialog extends FloatingDialog{
if(totalHosts == 0){
local.clear();
}
local.background((Drawable)null);
local.background(null);
totalHosts++;
float w = targetWidth();
local.row();
TextButton button = local.addButton("[accent]" + host.name, "clear", () -> connect(host.address, port))
.width(w).height(80f).pad(4f).get();
button.left();
button.row();
button.add("[lightgray]" + (host.players != 1 ? Core.bundle.format("players", host.players) :
Core.bundle.format("players.single", host.players))).padBottom(5);
TextButton button = local.addButton("", Styles.cleart, () -> connect(host.address, port))
.width(w).pad(5f).get();
button.clearChildren();
buildServer(host, button);
}
void connect(String ip, int port){
if(Core.settings.getString("name").trim().isEmpty()){
public void connect(String ip, int port){
if(player.name.trim().isEmpty()){
ui.showInfo("$noname");
return;
}
@@ -315,9 +329,9 @@ public class JoinDialog extends FloatingDialog{
Time.runTask(2f, () -> {
logic.reset();
Net.reset();
net.reset();
Vars.netClient.beginConnecting();
Net.connect(ip, port, () -> {
net.connect(ip, port, () -> {
hide();
add.hide();
});

View File

@@ -5,6 +5,7 @@ import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.util.Log;
import io.anuke.arc.util.Strings;
import io.anuke.mindustry.ui.*;
import java.util.Locale;
@@ -29,7 +30,7 @@ public class LanguageDialog extends FloatingDialog{
ButtonGroup<TextButton> group = new ButtonGroup<>();
for(Locale loc : locales){
TextButton button = new TextButton(Strings.capitalize(loc.getDisplayName(loc)), "clear-toggle");
TextButton button = new TextButton(Strings.capitalize(loc.getDisplayName(loc)), Styles.clearTogglet);
button.clicked(() -> {
if(getLocale().equals(loc)) return;
Core.settings.put("locale", loc.toString());

View File

@@ -9,13 +9,13 @@ import io.anuke.arc.scene.style.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.Saves.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.io.*;
import io.anuke.mindustry.io.SaveIO.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.ui.Styles;
import java.io.*;
@@ -59,7 +59,7 @@ public class LoadDialog extends FloatingDialog{
for(SaveSlot slot : array){
if(slot.isHidden()) continue;
TextButton button = new TextButton("", "clear");
TextButton button = new TextButton("", Styles.cleart);
button.getLabel().remove();
button.clearChildren();
@@ -71,45 +71,44 @@ public class LoadDialog extends FloatingDialog{
title.table(t -> {
t.right();
t.addImageButton("icon-floppy", "emptytoggle", iconsize, () -> {
t.addImageButton(Icon.floppy, Styles.emptytogglei, () -> {
slot.setAutosave(!slot.isAutosave());
}).checked(slot.isAutosave()).right();
t.addImageButton("icon-trash", "empty", iconsize, () -> {
t.addImageButton(Icon.trash, Styles.emptyi, () -> {
ui.showConfirm("$confirm", "$save.delete.confirm", () -> {
slot.delete();
setup();
});
}).size(iconsize).right();
}).right();
t.addImageButton("icon-pencil", "empty", iconsize, () -> {
t.addImageButton(Icon.pencil, Styles.emptyi, () -> {
ui.showTextInput("$save.rename", "$save.rename.text", slot.getName(), text -> {
slot.setName(text);
setup();
});
}).size(iconsize).right();
}).right();
t.addImageButton("icon-save", "empty", iconsize, () -> {
if(!ios){
platform.showFileChooser(Core.bundle.get("save.export"), "Mindustry Save", file -> {
t.addImageButton(Icon.save, Styles.emptyi, () -> {
if(!ios){
platform.showFileChooser(false, saveExtension, file -> {
try{
slot.exportFile(file);
setup();
}catch(IOException e){
ui.showException("save.export.fail", e);
}
});
}else{
try{
FileHandle file = Core.files.local("save-" + slot.getName() + "." + saveExtension);
slot.exportFile(file);
setup();
}catch(IOException e){
ui.showError(Core.bundle.format("save.export.fail", Strings.parseException(e, true)));
platform.shareFile(file);
}catch(Exception e){
ui.showException("save.export.fail", e);
}
}, false, FileChooser.saveFiles);
}else{
try{
FileHandle file = Core.files.local("save-" + slot.getName() + "." + Vars.saveExtension);
slot.exportFile(file);
platform.shareFile(file);
}catch(Exception e){
ui.showError(Core.bundle.format("save.export.fail", Strings.parseException(e, true)));
}
}
}).size(iconsize).right();
}).right();
}).padRight(-10).growX();
}).growX().colspan(2);
@@ -137,13 +136,13 @@ public class LoadDialog extends FloatingDialog{
meta.row();
meta.labelWrap(Core.bundle.format("save.map", color + (slot.getMap() == null ? Core.bundle.get("unknown") : slot.getMap().name())));
meta.row();
meta.labelWrap(Core.bundle.format("save.wave", color + slot.getWave()));
meta.labelWrap(slot.mode().toString() + " /" + color + " " + Core.bundle.format("save.wave", color + slot.getWave()));
meta.row();
meta.labelWrap(() -> Core.bundle.format("save.autosave", color + Core.bundle.get(slot.isAutosave() ? "on" : "off")));
meta.row();
meta.labelWrap(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime()));
meta.row();
meta.labelWrap(Core.bundle.format("save.date", color + slot.getDate()));
meta.labelWrap(color + slot.getDate());
meta.row();
}).left().growX().width(250f);
@@ -171,20 +170,20 @@ public class LoadDialog extends FloatingDialog{
if(ios) return;
slots.addImageTextButton("$save.import", "icon-add", iconsize, () -> {
platform.showFileChooser(Core.bundle.get("save.import"), "Mindustry Save", file -> {
slots.addImageTextButton("$save.import", Icon.add, () -> {
platform.showFileChooser(true, saveExtension, file -> {
if(SaveIO.isSaveValid(file)){
try{
control.saves.importSave(file);
setup();
}catch(IOException e){
e.printStackTrace();
ui.showError(Core.bundle.format("save.import.fail", Strings.parseException(e, true)));
ui.showException("$save.import.fail", e);
}
}else{
ui.showError("$save.import.invalid");
ui.showErrorMessage("$save.import.invalid");
}
}, true, FileChooser.saveFiles);
});
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
}
@@ -194,14 +193,16 @@ public class LoadDialog extends FloatingDialog{
ui.loadAnd(() -> {
try{
Net.reset();
net.reset();
slot.load();
state.rules.editor = false;
state.rules.zone = null;
state.set(State.playing);
}catch(SaveException e){
Log.err(e);
state.set(State.menu);
logic.reset();
ui.showError("$save.corrupted");
ui.showErrorMessage("$save.corrupted");
}
});
}

View File

@@ -6,7 +6,10 @@ import io.anuke.arc.function.*;
import io.anuke.arc.input.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.*;
import static io.anuke.mindustry.Vars.*;
@@ -44,7 +47,7 @@ public class LoadoutDialog extends FloatingDialog{
FloatingDialog dialog = new FloatingDialog("");
dialog.setFillParent(false);
for(Item item : content.items().select(item -> filter.test(item) && item.type == ItemType.material && supplier.get().find(stack -> stack.item == item) == null)){
TextButton button = dialog.cont.addButton("", "clear", () -> {
TextButton button = dialog.cont.addButton("", Styles.cleart, () -> {
dialog.hide();
supplier.get().add(new ItemStack(item, 0));
updater.run();
@@ -67,7 +70,7 @@ public class LoadoutDialog extends FloatingDialog{
}).size(210f, 64f);
cont.row();
cont.addImageTextButton("$back", "icon-arrow-left", iconsize, this::hide).size(210f, 64f);
cont.addImageTextButton("$back", Icon.arrowLeft, this::hide).size(210f, 64f);
}
public void show(int capacity, Supplier<Array<ItemStack>> supplier, Runnable reseter, Runnable updater, Runnable hider, Predicate<Item> filter){
@@ -87,21 +90,34 @@ public class LoadoutDialog extends FloatingDialog{
int step = 50;
for(ItemStack stack : supplier.get()){
items.addButton("x", "clear-partial", () -> {
items.addButton("x", Styles.clearPartialt, () -> {
supplier.get().remove(stack);
updater.run();
setup();
}).size(bsize);
items.addButton("-", "clear-partial", () -> {
items.addButton("-", Styles.clearPartialt, () -> {
stack.amount = Math.max(stack.amount - step, 0);
updater.run();
}).size(bsize);
items.addButton("+", "clear-partial", () -> {
items.addButton("+", Styles.clearPartialt, () -> {
stack.amount = Math.min(stack.amount + step, capacity);
updater.run();
}).size(bsize);
items.addImageButton(Icon.pencilSmaller, Styles.clearPartial2i, () -> ui.showTextInput("$configure", stack.item.localizedName, 10, stack.amount + "", true, str -> {
if(Strings.canParsePostiveInt(str)){
int amount = Strings.parseInt(str);
if(amount >= 0 && amount <= capacity){
stack.amount = amount;
updater.run();
return;
}
}
ui.showInfo(Core.bundle.format("configure.invalid", capacity));
})).size(bsize);
items.addImage(stack.item.icon(Item.Icon.medium)).size(8 * 3).padRight(4).padLeft(4);
items.label(() -> stack.amount + "").left();

View File

@@ -6,6 +6,7 @@ import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.maps.*;
import io.anuke.mindustry.ui.*;
@@ -55,7 +56,7 @@ public class MapPlayDialog extends FloatingDialog{
for(Gamemode mode : Gamemode.values()){
if(mode.hidden) continue;
modes.addButton(mode.toString(), "toggle", () -> {
modes.addButton(mode.toString(), Styles.togglet, () -> {
selectedGamemode = mode;
rules = map.applyRules(mode);
}).update(b -> b.setChecked(selectedGamemode == mode)).size(140f, 54f).disabled(!mode.valid(map));
@@ -66,9 +67,9 @@ public class MapPlayDialog extends FloatingDialog{
cont.add(selmode);
cont.row();
cont.addImageTextButton("$customize", "icon-tools-small", iconsizesmall, () -> dialog.show(rules, () -> rules = map.applyRules(selectedGamemode))).width(230);
cont.addImageTextButton("$customize", Icon.toolsSmall, () -> dialog.show(rules, () -> rules = map.applyRules(selectedGamemode))).width(230);
cont.row();
cont.add(new BorderImage(map.texture, 3f)).size(mobile && !Core.graphics.isPortrait() ? 150f : 250f).get().setScaling(Scaling.fit);
cont.add(new BorderImage(map.safeTexture(), 3f)).size(mobile && !Core.graphics.isPortrait() ? 150f : 250f).get().setScaling(Scaling.fit);
//only maps with survival are valid for high scores
if(Gamemode.survival.valid(map)){
cont.row();
@@ -78,7 +79,7 @@ public class MapPlayDialog extends FloatingDialog{
buttons.clearChildren();
addCloseButton();
buttons.addImageTextButton("$play", "icon-play", iconsize, () -> {
buttons.addImageTextButton("$play", Icon.play, () -> {
control.playMap(map, rules);
hide();
ui.custom.hide();

View File

@@ -4,11 +4,12 @@ import io.anuke.arc.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.input.*;
import io.anuke.arc.math.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.io.*;
import io.anuke.mindustry.maps.*;
@@ -43,38 +44,41 @@ public class MapsDialog extends FloatingDialog{
buttons.clearChildren();
if(Core.graphics.isPortrait() && !ios){
buttons.addImageTextButton("$back", "icon-arrow-left", iconsize, this::hide).size(210f*2f, 64f).colspan(2);
buttons.addImageTextButton("$back", Icon.arrowLeft, this::hide).size(210f*2f, 64f).colspan(2);
buttons.row();
}else{
buttons.addImageTextButton("$back", "icon-arrow-left", iconsize, this::hide).size(210f, 64f);
buttons.addImageTextButton("$back", Icon.arrowLeft, this::hide).size(210f, 64f);
}
buttons.addImageTextButton("$editor.newmap", "icon-add", iconsize, () -> {
buttons.addImageTextButton("$editor.newmap", Icon.add, () -> {
ui.showTextInput("$editor.newmap", "$name", "", text -> {
ui.loadAnd(() -> {
Runnable show = () -> ui.loadAnd(() -> {
hide();
ui.editor.show();
ui.editor.editor.getTags().put("name", text);
Events.fire(new MapMakeEvent());
});
if(maps.byName(text) != null){
ui.showErrorMessage("$editor.exists");
}else{
show.run();
}
});
}).size(210f, 64f);
if(!ios){
buttons.addImageTextButton("$editor.importmap", "icon-load", iconsize, () -> {
platform.showFileChooser("$editor.importmap", "Map File", file -> {
buttons.addImageTextButton("$editor.importmap", Icon.load, () -> {
platform.showFileChooser(true, mapExtension, file -> {
ui.loadAnd(() -> {
maps.tryCatchMapError(() -> {
if(MapIO.isImage(file)){
ui.showError("$editor.errorimage");
ui.showErrorMessage("$editor.errorimage");
return;
}
Map map;
if(file.extension().equalsIgnoreCase(mapExtension)){
map = MapIO.createMap(file, true);
}else{
map = maps.makeLegacyMap(file);
}
Map map = MapIO.createMap(file, true);
//when you attempt to import a save, it will have no name, so generate one
String name = map.tags.getOr("name", () -> {
@@ -86,7 +90,7 @@ public class MapsDialog extends FloatingDialog{
//this will never actually get called, but it remains just in case
if(name == null){
ui.showError("$editor.errorname");
ui.showErrorMessage("$editor.errorname");
return;
}
@@ -109,7 +113,7 @@ public class MapsDialog extends FloatingDialog{
});
});
}, true, FileChooser.anyMapFiles);
});
}).size(210f, 64f);
}
@@ -121,7 +125,7 @@ public class MapsDialog extends FloatingDialog{
ScrollPane pane = new ScrollPane(maps);
pane.setFadeScrollBars(false);
int maxwidth = Mathf.clamp((int)(Core.graphics.getWidth() / UnitScl.dp.scl(230)), 1, 8);
int maxwidth = Mathf.clamp((int)(Core.graphics.getWidth() / Scl.scl(230)), 1, 8);
float mapsize = 200f;
int i = 0;
@@ -131,16 +135,16 @@ public class MapsDialog extends FloatingDialog{
maps.row();
}
TextButton button = maps.addButton("", "clear", () -> showMapInfo(map)).width(mapsize).pad(8).get();
TextButton button = maps.addButton("", Styles.cleart, () -> showMapInfo(map)).width(mapsize).pad(8).get();
button.clearChildren();
button.margin(9);
button.add(map.name()).width(mapsize - 18f).center().get().setEllipsis(true);
button.row();
button.addImage("whiteui").growX().pad(4).color(Pal.gray);
button.addImage().growX().pad(4).color(Pal.gray);
button.row();
button.stack(new Image(map.texture).setScaling(Scaling.fit), new BorderImage(map.texture).setScaling(Scaling.fit)).size(mapsize - 20f);
button.stack(new Image(map.safeTexture()).setScaling(Scaling.fit), new BorderImage(map.safeTexture()).setScaling(Scaling.fit)).size(mapsize - 20f);
button.row();
button.add(map.custom ? "$custom" : "$builtin").color(Color.GRAY).padTop(3);
button.add(map.custom ? "$custom" : map.workshop ? "$workshop" : "$builtin").color(Color.gray).padTop(3);
i++;
}
@@ -161,9 +165,9 @@ public class MapsDialog extends FloatingDialog{
float mapsize = Core.graphics.isPortrait() ? 160f : 300f;
Table table = dialog.cont;
table.stack(new Image(map.texture).setScaling(Scaling.fit), new BorderImage(map.texture).setScaling(Scaling.fit)).size(mapsize);
table.stack(new Image(map.safeTexture()).setScaling(Scaling.fit), new BorderImage(map.safeTexture()).setScaling(Scaling.fit)).size(mapsize);
table.table("flat", desc -> {
table.table(Styles.black, desc -> {
desc.top();
Table t = new Table();
t.margin(6);
@@ -174,39 +178,43 @@ public class MapsDialog extends FloatingDialog{
t.top();
t.defaults().padTop(10).left();
t.add("$editor.name").padRight(10).color(Color.GRAY).padTop(0);
t.add("$editor.name").padRight(10).color(Color.gray).padTop(0);
t.row();
t.add(map.name()).growX().wrap().padTop(2);
t.row();
t.add("$editor.author").padRight(10).color(Color.GRAY);
t.add("$editor.author").padRight(10).color(Color.gray);
t.row();
t.add(map.custom && map.author().isEmpty() ? "Anuke" : map.author()).growX().wrap().padTop(2);
t.row();
t.add("$editor.description").padRight(10).color(Color.GRAY).top();
t.add("$editor.description").padRight(10).color(Color.gray).top();
t.row();
t.add(map.description()).growX().wrap().padTop(2);
}).height(mapsize).width(mapsize);
table.row();
table.addImageTextButton("$editor.openin", "icon-load-map-small", iconsizesmall, () -> {
table.addImageTextButton("$editor.openin", Icon.loadMapSmall, () -> {
try{
Vars.ui.editor.beginEditMap(map.file);
dialog.hide();
hide();
}catch(Exception e){
e.printStackTrace();
ui.showError("$error.mapnotfound");
ui.showErrorMessage("$error.mapnotfound");
}
}).fillX().height(54f).marginLeft(10);
table.addImageTextButton("$delete", "icon-trash-16-small", iconsizesmall, () -> {
ui.showConfirm("$confirm", Core.bundle.format("map.delete", map.name()), () -> {
maps.removeMap(map);
dialog.hide();
setup();
});
}).fillX().height(54f).marginLeft(10).disabled(!map.custom).touchable(map.custom ? Touchable.enabled : Touchable.disabled);
table.addImageTextButton(map.workshop ? "$view.workshop" : "$delete", map.workshop ? Icon.linkSmall : Icon.trash16Small, () -> {
if(map.workshop){
platform.viewMapListing(map);
}else{
ui.showConfirm("$confirm", Core.bundle.format("map.delete", map.name()), () -> {
maps.removeMap(map);
dialog.hide();
setup();
});
}
}).fillX().height(54f).marginLeft(10).disabled(!map.workshop && !map.custom);
dialog.show();
}

View File

@@ -6,6 +6,7 @@ import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.input.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.gen.*;
import static io.anuke.mindustry.Vars.renderer;
@@ -23,17 +24,13 @@ public class MinimapDialog extends FloatingDialog{
onResize(this::setup);
}
public void drawBackground(float x, float y){
drawDefaultBackground(x, y);
}
void setup(){
cont.clearChildren();
cont.clear();
cont.table("pane", t -> {
cont.table(Tex.pane,t -> {
t.addRect((x, y, width, height) -> {
if(renderer.minimap.getRegion() == null) return;
Draw.color(Color.WHITE);
Draw.color(Color.white);
Draw.alpha(parentAlpha);
Draw.rect(renderer.minimap.getRegion(), x + width / 2f, y + height / 2f, width, height);
@@ -41,7 +38,7 @@ public class MinimapDialog extends FloatingDialog{
renderer.minimap.drawEntities(x, y, width, height);
}
}).grow();
}).size(Math.min(Core.graphics.getWidth() / 1.1f, Core.graphics.getHeight() / 1.3f) / UnitScl.dp.scl(1f)).padTop(-20f);
}).size(Math.min(Core.graphics.getWidth() / 1.1f, Core.graphics.getHeight() / 1.3f) / Scl.scl(1f)).padTop(-20f);
cont.addListener(new InputListener(){
@Override

View File

@@ -1,9 +1,9 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.input.KeyCode;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.net.Net;
import io.anuke.arc.*;
import io.anuke.arc.input.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.gen.*;
import static io.anuke.mindustry.Vars.*;
@@ -52,12 +52,22 @@ public class PausedDialog extends FloatingDialog{
if(!world.isZone() && !state.isEditor()){
cont.row();
cont.addButton("$savegame", save::show);
cont.addButton("$loadgame", load::show).disabled(b -> Net.active());
cont.addButton("$loadgame", load::show).disabled(b -> net.active());
}
cont.row();
cont.addButton("$hostserver", ui.host::show).disabled(b -> Net.active()).colspan(2).width(dw * 2 + 20f);
cont.addButton("$hostserver", () -> {
if(net.active() && steam){
platform.inviteFriends();
}else{
if(steam){
ui.host.runHost();
}else{
ui.host.show();
}
}
}).disabled(b -> net.active() && !steam).colspan(2).width(dw * 2 + 20f).update(e -> e.setText(net.active() && steam && net.server() ? "$invitefriends" : "$hostserver"));
}
cont.row();
@@ -66,24 +76,22 @@ public class PausedDialog extends FloatingDialog{
}else{
cont.defaults().size(120f).pad(5);
float isize = iconsize;
cont.addRowImageTextButton("$back", "icon-play-2", isize, this::hide);
cont.addRowImageTextButton("$settings", "icon-tools", isize, ui.settings::show);
cont.addRowImageTextButton("$back", Icon.play2, this::hide);
cont.addRowImageTextButton("$settings", Icon.tools, ui.settings::show);
if(!world.isZone() && !state.isEditor()){
cont.addRowImageTextButton("$save", "icon-save", isize, save::show);
cont.addRowImageTextButton("$save", Icon.save, save::show);
cont.row();
cont.addRowImageTextButton("$load", "icon-load", isize, load::show).disabled(b -> Net.active());
cont.addRowImageTextButton("$load", Icon.load, load::show).disabled(b -> net.active());
}else{
cont.row();
}
cont.addRowImageTextButton("$hostserver.mobile", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
cont.addRowImageTextButton("$hostserver.mobile", Icon.host, ui.host::show).disabled(b -> net.active());
cont.addRowImageTextButton("$quit", "icon-quit", isize, this::showQuitConfirm);
cont.addRowImageTextButton("$quit", Icon.quit, this::showQuitConfirm);
}
}
@@ -93,8 +101,8 @@ public class PausedDialog extends FloatingDialog{
Core.settings.put("playedtutorial", true);
Core.settings.save();
}
wasClient = Net.client();
if(Net.client()) netClient.disconnectQuietly();
wasClient = net.client();
if(net.client()) netClient.disconnectQuietly();
runExitSave();
hide();
});
@@ -117,7 +125,7 @@ public class PausedDialog extends FloatingDialog{
control.saves.getCurrent().save();
}catch(Throwable e){
e.printStackTrace();
ui.showError("[accent]" + Core.bundle.get("savefail"));
ui.showException("[accent]" + Core.bundle.get("savefail"), e);
}
state.set(State.menu);
logic.reset();

View File

@@ -5,6 +5,7 @@ import io.anuke.arc.scene.ui.TextButton;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.Saves.SaveSlot;
import io.anuke.mindustry.gen.*;
import static io.anuke.mindustry.Vars.*;
@@ -22,7 +23,7 @@ public class SaveDialog extends LoadDialog{
public void addSetup(){
slots.row();
slots.addImageTextButton("$save.new", "icon-add", 14 * 3, () ->
slots.addImageTextButton("$save.new", Icon.add, () ->
ui.showTextInput("$save", "$save.newslot", 30, "", text -> {
ui.loadAnd("$saving", () -> {
control.saves.addSave(text);
@@ -53,7 +54,7 @@ public class SaveDialog extends LoadDialog{
}catch(Throwable e){
e.printStackTrace();
ui.showError("[accent]" + Core.bundle.get("savefail"));
ui.showException("[accent]" + Core.bundle.get("savefail"), e);
}
});
}

View File

@@ -10,12 +10,15 @@ import io.anuke.arc.scene.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.SettingsDialog.SettingsTable.*;
import io.anuke.arc.scene.ui.TextButton.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.input.*;
import io.anuke.mindustry.ui.*;
import static io.anuke.arc.Core.bundle;
import static io.anuke.mindustry.Vars.*;
@@ -31,12 +34,10 @@ public class SettingsMenuDialog extends SettingsDialog{
private boolean wasPaused;
public SettingsMenuDialog(){
setStyle(Core.scene.skin.get("dialog", WindowStyle.class));
hidden(() -> {
Sounds.back.play();
if(!state.is(State.menu)){
if(!wasPaused || Net.active())
if(!wasPaused || net.active())
state.set(State.playing);
}
});
@@ -54,13 +55,13 @@ public class SettingsMenuDialog extends SettingsDialog{
setFillParent(true);
title.setAlignment(Align.center);
titleTable.row();
titleTable.add(new Image("whiteui")).growX().height(3f).pad(4f).get().setColor(Pal.accent);
titleTable.add(new Image()).growX().height(3f).pad(4f).get().setColor(Pal.accent);
cont.clearChildren();
cont.remove();
buttons.remove();
menu = new Table("button");
menu = new Table(Tex.button);
game = new SettingsTable();
graphics = new SettingsTable();
@@ -78,9 +79,9 @@ public class SettingsMenuDialog extends SettingsDialog{
dataDialog = new FloatingDialog("$settings.data");
dataDialog.addCloseButton();
dataDialog.cont.table("button", t -> {
dataDialog.cont.table(Tex.button, t -> {
t.defaults().size(240f, 60f).left();
String style = "clear";
TextButtonStyle style = Styles.cleart;
t.addButton("$settings.cleardata", style, () -> ui.showConfirm("$confirm", "$settings.clearall.confirm", () -> {
ObjectMap<String, Object> map = new ObjectMap<>();
@@ -102,56 +103,45 @@ public class SettingsMenuDialog extends SettingsDialog{
t.row();
if(android && (Core.files.local("mindustry-maps").exists() || Core.files.local("mindustry-saves").exists())){
t.addButton("$classic.export", style, () -> {
control.checkClassicData();
});
}
t.row();
t.addButton("$data.export", style, () -> {
if(ios){
FileHandle file = Core.files.local("mindustry-data-export.zip");
try{
data.exportData(file);
}catch(Exception e){
ui.showError(Strings.parseException(e, true));
ui.showException(e);
}
platform.shareFile(file);
}else{
platform.showFileChooser("$data.export", "Zip Files", file -> {
FileHandle ff = file;
if(!ff.extension().equals("zip")){
ff = ff.sibling(ff.nameWithoutExtension() + ".zip");
}
platform.showFileChooser(false, "zip", file -> {
try{
data.exportData(ff);
data.exportData(file);
ui.showInfo("$data.exported");
}catch(Exception e){
e.printStackTrace();
ui.showError(Strings.parseException(e, true));
ui.showException(e);
}
}, false, f -> false);
});
}
});
t.row();
//iOS doesn't have a file chooser.
if(!ios){
t.addButton("$data.import", style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser("$data.import", "Zip Files", file -> {
try{
data.importData(file);
Core.app.exit();
}catch(IllegalArgumentException e){
ui.showError("$data.invalid");
}catch(Exception e){
e.printStackTrace();
ui.showError(Strings.parseException(e, true));
t.addButton("$data.import", style, () -> ui.showConfirm("$confirm", "$data.import.confirm", () -> platform.showFileChooser(true, "zip", file -> {
try{
data.importData(file);
Core.app.exit();
}catch(IllegalArgumentException e){
ui.showErrorMessage("$data.invalid");
}catch(Exception e){
e.printStackTrace();
if(e.getMessage() == null || !e.getMessage().contains("too short")){
ui.showException(e);
}else{
ui.showErrorMessage("$data.invalid");
}
}, true, f -> f.equalsIgnoreCase("zip"))));
}
}
})));
});
ScrollPane pane = new ScrollPane(prefs);
@@ -186,7 +176,7 @@ public class SettingsMenuDialog extends SettingsDialog{
void rebuildMenu(){
menu.clearChildren();
String style = "clear";
TextButtonStyle style = Styles.cleart;
menu.defaults().size(300f, 60f);
menu.addButton("$settings.game", style, () -> visible(0));
@@ -213,8 +203,20 @@ public class SettingsMenuDialog extends SettingsDialog{
game.screenshakePref();
if(mobile){
game.checkPref("autotarget", true);
game.checkPref("keyboard", false);
game.checkPref("keyboard", false, val -> control.setInput(val ? new DesktopInput() : new MobileInput()));
if(Core.settings.getBool("keyboard")){
control.setInput(new DesktopInput());
}
}
//the issue with touchscreen support on desktop is that:
//1) I can't test it
//2) the SDL backend doesn't support multitouch
/*else{
game.checkPref("touchscreen", false, val -> control.setInput(!val ? new DesktopInput() : new MobileInput()));
if(Core.settings.getBool("touchscreen")){
control.setInput(new MobileInput());
}
}*/
game.sliderPref("saveinterval", 60, 10, 5 * 120, i -> Core.bundle.format("setting.seconds", i));
if(!mobile){
@@ -223,6 +225,12 @@ public class SettingsMenuDialog extends SettingsDialog{
game.checkPref("savecreate", true);
if(steam){
game.checkPref("publichost", false, i -> {
platform.updateLobby();
});
}
game.pref(new Setting(){
@Override
public void add(SettingsTable table){
@@ -290,7 +298,11 @@ public class SettingsMenuDialog extends SettingsDialog{
}
graphics.checkPref("bloom", false, val -> renderer.toggleBloom(val));
graphics.checkPref("lasers", true);
graphics.checkPref("pixelate", false);
graphics.checkPref("pixelate", false, val -> {
if(val){
Events.fire(Trigger.enablePixelation);
}
});
graphics.checkPref("linear", false, b -> {
for(Texture tex : Core.atlas.getTextures()){
@@ -320,7 +332,7 @@ public class SettingsMenuDialog extends SettingsDialog{
@Override
public void addCloseButton(){
buttons.addImageTextButton("$back", "icon-arrow-left", 30f, () -> {
buttons.addImageTextButton("$back", Icon.arrowLeftSmaller, () -> {
if(prefs.getChildren().first() != menu){
back();
}else{

View File

@@ -15,17 +15,19 @@ import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.content.TechTree.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.ui.Styles;
import io.anuke.mindustry.ui.TreeLayout.*;
import io.anuke.mindustry.world.Block.*;
import io.anuke.mindustry.world.*;
import static io.anuke.mindustry.Vars.*;
public class TechTreeDialog extends FloatingDialog{
private final float nodeSize = UnitScl.dp.scl(60f);
private final float nodeSize = Scl.scl(60f);
private ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
private TechTreeNode root = new TechTreeNode(TechTree.root, null);
private Rectangle bounds = new Rectangle();
@@ -47,21 +49,16 @@ public class TechTreeDialog extends FloatingDialog{
addCloseButton();
buttons.addImageTextButton("$database", "icon-database", iconsize, () -> {
buttons.addImageTextButton("$database", Icon.database, () -> {
hide();
ui.database.show();
}).size(210f, 64f);
}
@Override
protected void drawBackground(float x, float y){
drawDefaultBackground(x, y);
}
void treeLayout(){
TreeLayout layout = new TreeLayout();
layout.gapBetweenLevels = UnitScl.dp.scl(60f);
layout.gapBetweenNodes = UnitScl.dp.scl(40f);
layout.gapBetweenLevels = Scl.scl(60f);
layout.gapBetweenNodes = Scl.scl(40f);
LayoutNode node = new LayoutNode(root, null);
layout.layout(node);
bounds.set(layout.getBounds());
@@ -147,7 +144,7 @@ public class TechTreeDialog extends FloatingDialog{
infoTable.touchable(Touchable.enabled);
for(TechTreeNode node : nodes){
ImageButton button = new ImageButton(node.node.block.icon(Icon.medium), "node");
ImageButton button = new ImageButton(node.node.block.icon(Block.Icon.medium), Styles.nodei);
button.visible(() -> node.visible);
button.clicked(() -> {
if(mobile){
@@ -191,10 +188,10 @@ public class TechTreeDialog extends FloatingDialog{
button.update(() -> {
float offset = (Core.graphics.getHeight() % 2) / 2f;
button.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f + offset, Align.center);
button.getStyle().up = Core.scene.skin.getDrawable(!locked(node.node) ? "button-over" : !data.hasItems(node.node.requirements) ? "button-red" : "button");
button.getStyle().up = !locked(node.node) ? Tex.buttonOver : !data.hasItems(node.node.requirements) ? Tex.buttonRed : Tex.button;
((TextureRegionDrawable)button.getStyle().imageUp)
.setRegion(node.visible ? node.node.block.icon(Icon.medium) : Core.atlas.find("icon-locked"));
button.getImage().setColor(!locked(node.node) ? Color.WHITE : Color.GRAY);
.setRegion(node.visible ? node.node.block.icon(Block.Icon.medium) : Core.atlas.find("icon-locked"));
button.getImage().setColor(!locked(node.node) ? Color.white : Color.gray);
});
addChild(button);
}
@@ -239,6 +236,7 @@ public class TechTreeDialog extends FloatingDialog{
rebuild();
Core.scene.act();
Sounds.unlock.play();
Events.fire(new ResearchEvent(node.block));
}
void rebuild(){
@@ -262,12 +260,12 @@ public class TechTreeDialog extends FloatingDialog{
infoTable.update(() -> infoTable.setPosition(button.getX() + button.getWidth(), button.getY() + button.getHeight(), Align.topLeft));
infoTable.left();
infoTable.background("button").margin(8f);
infoTable.background(Tex.button).margin(8f);
infoTable.table(b -> {
b.margin(0).left().defaults().left();
b.addImageButton("icon-info-small", "clear", iconsizesmall, () -> ui.content.show(node.block)).growY().width(50f);
b.addImageButton(Icon.infoSmall, Styles.cleari, () -> ui.content.show(node.block)).growY().width(50f);
b.add().grow();
b.table(desc -> {
desc.left().defaults().left();
@@ -280,9 +278,9 @@ public class TechTreeDialog extends FloatingDialog{
t.table(list -> {
list.left();
list.addImage(req.item.icon(Item.Icon.medium)).size(8 * 3).padRight(3);
list.add(req.item.localizedName()).color(Color.LIGHT_GRAY);
list.add(req.item.localizedName()).color(Color.lightGray);
list.label(() -> " " + Math.min(data.getItem(req.item), req.amount) + " / " + req.amount)
.update(l -> l.setColor(data.has(req.item, req.amount) ? Color.LIGHT_GRAY : Color.SCARLET));
.update(l -> l.setColor(data.has(req.item, req.amount) ? Color.lightGray : Color.scarlet));
}).fillX().left();
t.row();
}
@@ -294,14 +292,14 @@ public class TechTreeDialog extends FloatingDialog{
if(mobile && locked(node)){
b.row();
b.addImageTextButton("$research", "icon-check-small", "node", iconsizesmall, () -> unlock(node))
b.addImageTextButton("$research", Icon.checkSmall, Styles.nodet, () -> unlock(node))
.disabled(i -> !data.hasItems(node.requirements)).growX().height(44f).colspan(3);
}
});
infoTable.row();
if(node.block.description != null){
infoTable.table(t -> t.margin(3f).left().labelWrap(node.block.description).color(Color.LIGHT_GRAY).growX()).fillX();
infoTable.table(t -> t.margin(3f).left().labelWrap(node.block.description).color(Color.lightGray).growX()).fillX();
}
@@ -320,7 +318,7 @@ public class TechTreeDialog extends FloatingDialog{
for(TechTreeNode child : node.children){
if(!child.visible) continue;
Lines.stroke(UnitScl.dp.scl(4f), locked(node.node) || locked(child.node) ? Pal.gray : Pal.accent);
Lines.stroke(Scl.scl(4f), locked(node.node) || locked(child.node) ? Pal.gray : Pal.accent);
Draw.alpha(parentAlpha);
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
}

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.net.Administration.TraceInfo;
public class TraceDialog extends FloatingDialog{
@@ -17,7 +18,7 @@ public class TraceDialog extends FloatingDialog{
public void show(Player player, TraceInfo info){
cont.clear();
Table table = new Table("clear");
Table table = new Table(Tex.clear);
table.margin(14);
table.defaults().pad(1);

View File

@@ -10,7 +10,6 @@ import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.type.Zone.*;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.Block.*;
import static io.anuke.mindustry.Vars.*;
@@ -24,11 +23,6 @@ public class ZoneInfoDialog extends FloatingDialog{
addCloseButton();
}
@Override
protected void drawBackground(float x, float y){
drawDefaultBackground(x, y);
}
public void show(Zone zone){
setup(zone);
show();
@@ -52,7 +46,7 @@ public class ZoneInfoDialog extends FloatingDialog{
iteminfo.row();
}
iteminfo.addImage(stack.item.icon(Item.Icon.medium)).size(8 * 3).padRight(1);
iteminfo.add(stack.amount + "").color(Color.LIGHT_GRAY).padRight(5);
iteminfo.add(stack.amount + "").color(Color.lightGray).padRight(5);
}
};
@@ -60,7 +54,7 @@ public class ZoneInfoDialog extends FloatingDialog{
cont.pane(cont -> {
if(zone.locked()){
cont.addImage("icon-locked");
cont.addImage(Icon.locked);
cont.row();
cont.add("$locked").padBottom(6);
cont.row();
@@ -73,9 +67,9 @@ public class ZoneInfoDialog extends FloatingDialog{
r.add("$complete").colspan(2).left();
r.row();
for(ZoneRequirement other : zone.zoneRequirements){
r.addImage("icon-terrain").padRight(4);
r.add(Core.bundle.format("zone.requirement", other.wave, other.zone.localizedName())).color(Color.LIGHT_GRAY);
r.addImage(other.zone.bestWave() >= other.wave ? "icon-check-small" : "icon-cancel-small", other.zone.bestWave() >= other.wave ? Color.LIGHT_GRAY : Color.SCARLET).padLeft(3);
r.addImage(Icon.terrain).padRight(4);
r.add(Core.bundle.format("zone.requirement", other.wave, other.zone.localizedName())).color(Color.lightGray);
r.addImage(other.zone.bestWave() >= other.wave ? Icon.checkSmall : Icon.cancelSmall, other.zone.bestWave() >= other.wave ? Color.lightGray : Color.scarlet).padLeft(3);
r.row();
}
});
@@ -88,9 +82,9 @@ public class ZoneInfoDialog extends FloatingDialog{
r.add("$research.list").colspan(2).left();
r.row();
for(Block block : zone.blockRequirements){
r.addImage(block.icon(Icon.small)).size(8 * 3).padRight(4);
r.add(block.localizedName).color(Color.LIGHT_GRAY);
r.addImage(data.isUnlocked(block) ? "icon-check-small" : "icon-cancel-small", data.isUnlocked(block) ? Color.LIGHT_GRAY : Color.SCARLET).padLeft(3);
r.addImage(block.icon(Block.Icon.small)).size(8 * 3).padRight(4);
r.add(block.localizedName).color(Color.lightGray);
r.addImage(data.isUnlocked(block) ? Icon.checkSmall : Icon.cancelSmall, data.isUnlocked(block) ? Color.lightGray : Color.scarlet).padLeft(3);
r.row();
}
@@ -101,7 +95,7 @@ public class ZoneInfoDialog extends FloatingDialog{
}else{
cont.add(zone.localizedName()).color(Pal.accent).growX().center();
cont.row();
cont.addImage("whiteui").color(Pal.accent).height(3).pad(6).growX();
cont.addImage().color(Pal.accent).height(3).pad(6).growX();
cont.row();
cont.table(desc -> {
desc.left().defaults().left().width(Core.graphics.isPortrait() ? 350f : 500f);

View File

@@ -22,7 +22,7 @@ import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Item.Icon;
import io.anuke.mindustry.world.Tile;
@@ -32,7 +32,7 @@ import static io.anuke.mindustry.Vars.*;
public class BlockInventoryFragment extends Fragment{
private final static float holdWithdraw = 20f;
private Table table;
private Table table = new Table();
private Tile tile;
private float holdTime = 0f;
private boolean holding;
@@ -40,7 +40,7 @@ public class BlockInventoryFragment extends Fragment{
@Remote(called = Loc.server, targets = Loc.both, forward = true)
public static void requestItem(Player player, Tile tile, Item item, int amount){
if(player == null || tile == null || !player.timer.get(Player.timerTransfer, 20)) return;
if(player == null || tile == null || !player.timer.get(Player.timerTransfer, 20) || !tile.interactable(player.getTeam())) return;
int removed = tile.block().removeStack(tile, item, amount);
@@ -52,7 +52,6 @@ public class BlockInventoryFragment extends Fragment{
@Override
public void build(Group parent){
table = new Table();
table.setName("inventory");
table.setTransform(true);
parent.setTransform(true);
@@ -71,6 +70,8 @@ public class BlockInventoryFragment extends Fragment{
}
public void hide(){
if(table == null) return;
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.run(() -> {
table.clearChildren();
table.clearListeners();
@@ -86,7 +87,7 @@ public class BlockInventoryFragment extends Fragment{
table.clearChildren();
table.clearActions();
table.background("inventory");
table.background(Tex.inventory);
table.touchable(Touchable.enabled);
table.update(() -> {

View File

@@ -1,28 +1,24 @@
package io.anuke.mindustry.ui.fragments;
import io.anuke.arc.Core;
import io.anuke.arc.Input.TextInput;
import io.anuke.arc.collection.Array;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.*;
import io.anuke.arc.Input.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.ui.Label;
import io.anuke.arc.scene.ui.Label.LabelStyle;
import io.anuke.arc.scene.ui.TextField;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.scene.ui.layout.UnitScl;
import io.anuke.arc.util.Align;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.input.Binding;
import io.anuke.mindustry.net.Net;
import io.anuke.arc.math.*;
import io.anuke.arc.scene.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.Label.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.input.*;
import io.anuke.mindustry.ui.*;
import static io.anuke.arc.Core.input;
import static io.anuke.arc.Core.scene;
import static io.anuke.mindustry.Vars.maxTextLength;
import static io.anuke.mindustry.Vars.mobile;
import static io.anuke.arc.Core.*;
import static io.anuke.mindustry.Vars.net;
import static io.anuke.mindustry.Vars.*;
public class ChatFragment extends Table{
private final static int messagesShown = 10;
@@ -33,9 +29,9 @@ public class ChatFragment extends Table{
private Label fieldlabel = new Label(">");
private BitmapFont font;
private GlyphLayout layout = new GlyphLayout();
private float offsetx = UnitScl.dp.scl(4), offsety = UnitScl.dp.scl(4), fontoffsetx = UnitScl.dp.scl(2), chatspace = UnitScl.dp.scl(50);
private float offsetx = Scl.scl(4), offsety = Scl.scl(4), fontoffsetx = Scl.scl(2), chatspace = Scl.scl(50);
private Color shadowColor = new Color(0, 0, 0, 0.4f);
private float textspacing = UnitScl.dp.scl(10);
private float textspacing = Scl.scl(10);
private Array<String> history = new Array<>();
private int historyPos = 0;
private int scrollPos = 0;
@@ -50,10 +46,10 @@ public class ChatFragment extends Table{
super();
setFillParent(true);
font = scene.skin.getFont("default");
font = Fonts.def;
visible(() -> {
if(!Net.active() && messages.size > 0){
if(!net.active() && messages.size > 0){
clearMessages();
if(chatOpen){
@@ -61,12 +57,12 @@ public class ChatFragment extends Table{
}
}
return Net.active();
return net.active();
});
update(() -> {
if(Net.active() && input.keyTap(Binding.chat)){
if(net.active() && input.keyTap(Binding.chat)){
toggle();
}
@@ -103,11 +99,11 @@ public class ChatFragment extends Table{
fieldlabel.getStyle().font = font;
fieldlabel.setStyle(fieldlabel.getStyle());
chatfield = new TextField("", new TextField.TextFieldStyle(scene.skin.get(TextField.TextFieldStyle.class)));
chatfield.setFilter((field, c) -> field.getText().length() < Vars.maxTextLength);
chatfield = new TextField("", new TextField.TextFieldStyle(scene.getStyle(TextField.TextFieldStyle.class)));
chatfield.setMaxLength(Vars.maxTextLength);
chatfield.getStyle().background = null;
chatfield.getStyle().font = scene.skin.getFont("chat");
chatfield.getStyle().fontColor = Color.WHITE;
chatfield.getStyle().font = Fonts.chat;
chatfield.getStyle().fontColor = Color.white;
chatfield.setStyle(chatfield.getStyle());
bottom().left().marginBottom(offsety).marginLeft(offsetx * 2).add(fieldlabel).padBottom(6f);
@@ -123,7 +119,7 @@ public class ChatFragment extends Table{
@Override
public void draw(){
float opacity = Core.settings.getInt("chatopacity") / 100f;
float textWidth = Math.min(Core.graphics.getWidth()/1.5f, UnitScl.dp.scl(700f));
float textWidth = Math.min(Core.graphics.getWidth()/1.5f, Scl.scl(700f));
Draw.color(shadowColor);
@@ -144,7 +140,7 @@ public class ChatFragment extends Table{
float theight = offsety + spacing + getMarginBottom();
for(int i = scrollPos; i < messages.size && i < messagesShown + scrollPos && (i < fadetime || chatOpen); i++){
layout.setText(font, messages.get(i).formattedMessage, Color.WHITE, textWidth, Align.bottomLeft, true);
layout.setText(font, messages.get(i).formattedMessage, Color.white, textWidth, Align.bottomLeft, true);
theight += layout.height + textspacing;
if(i - scrollPos == 0) theight -= textspacing + 1;
@@ -158,7 +154,7 @@ public class ChatFragment extends Table{
font.getCache().setAlphas(opacity);
}
Fill.crect(offsetx, theight - layout.height - 2, textWidth + UnitScl.dp.scl(4f), layout.height + textspacing);
Fill.crect(offsetx, theight - layout.height - 2, textWidth + Scl.scl(4f), layout.height + textspacing);
Draw.color(shadowColor);
Draw.alpha(opacity * shadowColor.a);

View File

@@ -13,6 +13,7 @@ import io.anuke.arc.scene.actions.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.style.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.ImageButton.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.*;
@@ -23,10 +24,10 @@ import io.anuke.mindustry.game.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.input.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.ui.Styles;
import io.anuke.mindustry.ui.dialogs.*;
import static io.anuke.mindustry.Vars.*;
@@ -60,28 +61,28 @@ public class HudFragment extends Fragment{
select.left();
select.defaults().size(dsize).left();
String style = "clear-trans";
ImageButtonStyle style = Styles.clearTransi;
select.addImageButton("icon-menu-large", style, iconsize, ui.paused::show);
flip = select.addImageButton("icon-arrow-up", style, iconsize, this::toggleMenus).get();
select.addImageButton(Icon.menuLarge, style, ui.paused::show);
flip = select.addImageButton(Icon.arrowUp, style, this::toggleMenus).get();
select.addImageButton("icon-pause", style, iconsize, () -> {
if(Net.active()){
select.addImageButton(Icon.pause, style, () -> {
if(net.active()){
ui.listfrag.toggle();
}else{
state.set(state.is(State.paused) ? State.playing : State.paused);
}
}).name("pause").update(i -> {
if(Net.active()){
i.getStyle().imageUp = Core.scene.skin.getDrawable("icon-players");
if(net.active()){
i.getStyle().imageUp = Icon.players;
}else{
i.setDisabled(false);
i.getStyle().imageUp = Core.scene.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
i.getStyle().imageUp = state.is(State.paused) ? Icon.play : Icon.pause;
}
}).get();
select.addImageButton("icon-settings", style, iconsize, () -> {
if(Net.active() && mobile){
select.addImageButton(Icon.settings, style,() -> {
if(net.active() && mobile){
if(ui.chatfrag.chatOpen()){
ui.chatfrag.hide();
}else{
@@ -93,16 +94,16 @@ public class HudFragment extends Fragment{
ui.database.show();
}
}).update(i -> {
if(Net.active() && mobile){
i.getStyle().imageUp = Core.scene.skin.getDrawable("icon-chat");
if(net.active() && mobile){
i.getStyle().imageUp = Icon.chat;
}else{
i.getStyle().imageUp = Core.scene.skin.getDrawable("icon-database");
i.getStyle().imageUp = Icon.database;
}
}).get();
select.addImage("whiteui").color(Pal.gray).width(4f).fillY();
select.addImage().color(Pal.gray).width(4f).fillY();
float size = UnitScl.dp.scl(dsize);
float size = Scl.scl(dsize);
Array<Element> children = new Array<>(select.getChildren());
//now, you may be wondering, why is this necessary? the answer is, I don't know, but it fixes layout issues somehow
@@ -114,7 +115,7 @@ public class HudFragment extends Fragment{
if(fi < 4){
elem.setSize(size);
}else{
elem.setSize(UnitScl.dp.scl(4f), size);
elem.setSize(Scl.scl(4f), size);
}
elem.setPosition(fi * size, Core.graphics.getHeight(), Align.topLeft);
return true;
@@ -125,7 +126,7 @@ public class HudFragment extends Fragment{
}
cont.row();
cont.addImage("whiteui").height(4f).color(Pal.gray).fillX();
cont.addImage().height(4f).color(Pal.gray).fillX();
cont.row();
}
@@ -143,7 +144,7 @@ public class HudFragment extends Fragment{
wavesMain.visible(() -> shown && !state.isEditor());
wavesMain.top().left();
Stack stack = new Stack();
Button waves = new Button("wave");
Button waves = new Button(Styles.waveb);
Table btable = new Table().margin(0);
stack.add(waves);
@@ -153,13 +154,13 @@ public class HudFragment extends Fragment{
addPlayButton(btable);
wavesMain.add(stack).width(dsize * 4 + 4f);
wavesMain.row();
wavesMain.table("button", t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.WHITE))
wavesMain.table(Tex.button, t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.white))
.grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get();
wavesMain.row();
}
{
editorMain.table("button-edge-4", t -> {
editorMain.table(Tex.buttonEdge4, t -> {
//t.margin(0f);
t.add("$editor.teams").growX().left();
t.row();
@@ -167,7 +168,7 @@ public class HudFragment extends Fragment{
teams.left();
int i = 0;
for(Team team : Team.all){
ImageButton button = teams.addImageButton("white", "clear-toggle-partial", 40f, () -> Call.setPlayerTeamEditor(player, team))
ImageButton button = teams.addImageButton(Tex.whiteui, Styles.clearTogglePartiali, 40f, () -> Call.setPlayerTeamEditor(player, team))
.size(50f).margin(6f).get();
button.getImageCell().grow();
button.getStyle().imageUpColor = team.color;
@@ -182,11 +183,11 @@ public class HudFragment extends Fragment{
if(enableUnitEditing){
t.row();
t.addImageTextButton("$editor.spawn", "icon-add", iconsize, () -> {
t.addImageTextButton("$editor.spawn", Icon.add, () -> {
FloatingDialog dialog = new FloatingDialog("$editor.spawn");
int i = 0;
for(UnitType type : content.<UnitType>getBy(ContentType.unit)){
dialog.cont.addImageButton("white", 48, () -> {
dialog.cont.addImageButton(Tex.whiteui, 48, () -> {
Call.spawnUnitEditor(player, type);
dialog.hide();
}).get().getStyle().imageUp = new TextureRegionDrawable(type.iconRegion);
@@ -201,7 +202,7 @@ public class HudFragment extends Fragment{
float[] position = {0, 0};
t.row();
t.addImageTextButton("$editor.removeunit", "icon-quit", "toggle", iconsize, () -> {}).fillX().update(b -> {
t.addImageTextButton("$editor.removeunit", Icon.quit, Styles.togglet, () -> {}).fillX().update(b -> {
boolean[] found = {false};
if(b.isChecked()){
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
@@ -222,7 +223,7 @@ public class HudFragment extends Fragment{
}
}
Draw.color(Pal.accent, Color.WHITE, Mathf.absin(Time.time(), 8f, 1f));
Draw.color(Pal.accent, Color.white, Mathf.absin(Time.time(), 8f, 1f));
Lines.poly(position[0], position[1], 4, size[0] / 2f);
Draw.reset();
@@ -238,13 +239,13 @@ public class HudFragment extends Fragment{
//fps display
cont.table(info -> {
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps"));
info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -UnitScl.dp.scl(dsize * 4 + 3), 0));
info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Scl.scl(dsize * 4 + 3), 0));
IntFormat fps = new IntFormat("fps");
IntFormat ping = new IntFormat("ping");
info.label(() -> fps.get(Core.graphics.getFramesPerSecond())).left().style("outline");
info.label(() -> fps.get(Core.graphics.getFramesPerSecond())).left().style(Styles.outlineLabel);
info.row();
info.label(() -> ping.get(Net.getPing())).visible(Net::client).left().style("outline");
info.label(() -> ping.get(netClient.getPing())).visible(net::client).left().style(Styles.outlineLabel);
}).top().left();
});
@@ -254,15 +255,15 @@ public class HudFragment extends Fragment{
//spawner warning
parent.fill(t -> {
t.touchable(Touchable.disabled);
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))))
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))
.margin(6).update(u -> u.color.a = Mathf.lerpDelta(u.color.a, Mathf.num(spawner.playerNear()), 0.1f)).get().color.a = 0f;
});
parent.fill(t -> {
t.visible(() -> netServer.isWaitingForPlayers());
t.table("button", c -> c.add("$waiting.players"));
t.table(Tex.button, c -> c.add("$waiting.players"));
});
//'core is under attack' table
@@ -308,8 +309,8 @@ public class HudFragment extends Fragment{
return coreAttackOpacity > 0;
});
t.table("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);
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);
});
//tutorial text
@@ -317,14 +318,14 @@ public class HudFragment extends Fragment{
Runnable resize = () -> {
t.clearChildren();
t.top().right().visible(() -> state.rules.tutorial);
t.stack(new Button("default"){{
t.stack(new Button(){{
marginLeft(48f);
labelWrap(() -> control.tutorial.stage.text() + (control.tutorial.canNext() ? "\n\n" + Core.bundle.get("tutorial.next") : "")).width(!Core.graphics.isPortrait() ? 400f : 160f).pad(2f);
clicked(() -> control.tutorial.nextSentence());
setDisabled(() -> !control.tutorial.canNext());
}},
new Table(f -> {
f.left().addImageButton("icon-arrow-left-small", "empty", iconsizesmall, () -> {
f.left().addImageButton(Icon.arrowLeftSmall, Styles.emptyi, () -> {
control.tutorial.prevSentence();
}).width(44f).growY().visible(() -> control.tutorial.canPrev());
}));
@@ -337,13 +338,13 @@ public class HudFragment extends Fragment{
//paused table
parent.fill(t -> {
t.top().visible(() -> state.isPaused()).touchable(Touchable.disabled);
t.table("button-trans", top -> top.add("$paused").pad(5f));
t.table(Tex.buttonTrans, top -> top.add("$paused").pad(5f));
});
//'saving' indicator
parent.fill(t -> {
t.bottom().visible(() -> control.saves.isSaving());
t.add("$saveload").style("outline");
t.add("$saveload").style(Styles.outlineLabel);
});
blockfrag.build(parent);
@@ -391,14 +392,14 @@ public class HudFragment extends Fragment{
scheduleToast(() -> {
Sounds.message.play();
Table table = new Table("button");
Table table = new Table(Tex.button);
table.update(() -> {
if(state.is(State.menu)){
table.remove();
}
});
table.margin(12);
table.addImage("icon-check").size(iconsize).pad(3);
table.addImage(Icon.check).pad(3);
table.add(text).wrap().width(280f).get().setAlignment(Align.center, Align.center);
table.pack();
@@ -427,7 +428,7 @@ public class HudFragment extends Fragment{
//if there's currently no unlock notification...
if(lastUnlockTable == null){
scheduleToast(() -> {
Table table = new Table("button");
Table table = new Table(Tex.button);
table.update(() -> {
if(state.is(State.menu)){
table.remove();
@@ -499,7 +500,7 @@ public class HudFragment extends Fragment{
lastUnlockLayout.add(image);
}else{ //else, add a specific icon to denote no more space
lastUnlockLayout.addImage("icon-add");
lastUnlockLayout.addImage(Icon.add);
}
lastUnlockLayout.pack();
@@ -507,7 +508,7 @@ public class HudFragment extends Fragment{
}
public void showLaunch(){
Image image = new Image("whiteui");
Image image = new Image();
image.getColor().a = 0f;
image.setFillParent(true);
image.actions(Actions.fadeIn(40f / 60f));
@@ -519,6 +520,21 @@ public class HudFragment extends Fragment{
Core.scene.add(image);
}
public void showLand(){
Image image = new Image();
image.getColor().a = 1f;
image.touchable(Touchable.disabled);
image.setFillParent(true);
image.actions(Actions.fadeOut(0.8f), Actions.remove());
image.update(() -> {
image.toFront();
if(state.is(State.menu)){
image.remove();
}
});
Core.scene.add(image);
}
private void showLaunchConfirm(){
FloatingDialog dialog = new FloatingDialog("$launch");
dialog.update(() -> {
@@ -542,7 +558,7 @@ public class HudFragment extends Fragment{
private boolean inLaunchWave(){
return world.isZone() &&
world.getZone().metCondition() &&
!Net.client() &&
!net.client() &&
state.wave % world.getZone().launchPeriod == 0 && !spawner.isSpawning();
}
@@ -552,13 +568,10 @@ public class HudFragment extends Fragment{
private void toggleMenus(){
if(flip != null){
flip.getStyle().imageUp = Core.scene.skin.getDrawable(shown ? "icon-arrow-down" : "icon-arrow-up");
flip.getStyle().imageUp = shown ? Icon.arrowDown : Icon.arrowUp;
}
shown = !shown;
if(flip != null){
flip.getParent().act(Core.graphics.getDeltaTime());
}
}
private void addWaveTable(Button table){
@@ -597,7 +610,7 @@ public class HudFragment extends Fragment{
if(inLaunchWave()){
builder.append("[#");
Tmp.c1.set(Color.WHITE).lerp(state.enemies() > 0 ? Color.WHITE : Color.SCARLET, Mathf.absin(Time.time(), 2f, 1f)).toString(builder);
Tmp.c1.set(Color.white).lerp(state.enemies() > 0 ? Color.white : Color.scarlet, Mathf.absin(Time.time(), 2f, 1f)).toString(builder);
builder.append("]");
if(!canLaunch()){
@@ -639,12 +652,12 @@ public class HudFragment extends Fragment{
}
private boolean canSkipWave(){
return state.rules.waves && ((Net.server() || player.isAdmin) || !Net.active()) && state.enemies() == 0 && !spawner.isSpawning() && !state.rules.tutorial;
return state.rules.waves && ((net.server() || player.isAdmin) || !net.active()) && state.enemies() == 0 && !spawner.isSpawning() && !state.rules.tutorial;
}
private void addPlayButton(Table table){
table.right().addImageButton("icon-play", "right", 30f, () -> {
if(Net.client() && player.isAdmin){
table.right().addImageButton(Icon.playSmaller, Styles.righti, 30f, () -> {
if(net.client() && player.isAdmin){
Call.onAdminRequest(player, AdminAction.wave);
}else if(inLaunchWave()){
ui.showConfirm("$confirm", "$launch.skip.confirm", () -> !canSkipWave(), () -> state.wavetime = 0f);

View File

@@ -1,5 +1,7 @@
package io.anuke.mindustry.ui.fragments;
import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.actions.*;
import io.anuke.arc.scene.event.Touchable;
@@ -7,42 +9,57 @@ import io.anuke.arc.scene.ui.Label;
import io.anuke.arc.scene.ui.TextButton;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.ui.*;
public class LoadingFragment extends Fragment{
private Table table;
private TextButton button;
private Bar bar;
@Override
public void build(Group parent){
parent.fill("loadDim", t -> {
parent.fill(Styles.black8, t -> {
t.visible(false);
t.touchable(Touchable.enabled);
t.add().height(70f).row();
t.add().height(133f).row();
t.addImage("whiteui").growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.addImage().growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.row();
t.add("$loading").name("namelabel").pad(10f);
t.row();
t.addImage("whiteui").growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.addImage().growX().height(3f).pad(4f).growX().get().setColor(Pal.accent);
t.row();
button = t.addButton("$cancel", () -> {
}).pad(20).size(250f, 70f).visible(false).get();
bar = t.add(new Bar()).pad(3).size(500f, 40f).visible(false).get();
t.row();
button = t.addButton("$cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
table = t;
});
}
public void setProgress(FloatProvider progress){
bar.visible(true);
bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent);
}
public void setButton(Runnable listener){
button.visible(true);
button.getListeners().remove(button.getListeners().size - 1);
button.clicked(listener);
}
public void setText(String text){
table.<Label>find("namelabel").setText(text);
table.<Label>find("namelabel").setColor(Pal.accent);
}
public void show(){
show("$loading");
}
public void show(String text){
table.<Label>find("namelabel").setColor(Color.white);
bar.visible(false);
table.clearActions();
table.touchable(Touchable.enabled);
table.<Label>find("namelabel").setText(text);

View File

@@ -1,22 +1,22 @@
package io.anuke.mindustry.ui.fragments;
import io.anuke.arc.Core;
import io.anuke.arc.Events;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.Texture;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.math.Interpolation;
import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.actions.Actions;
import io.anuke.arc.scene.event.Touchable;
import io.anuke.arc.scene.ui.Button;
import io.anuke.arc.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.*;
import io.anuke.arc.scene.*;
import io.anuke.arc.scene.actions.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.style.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.Align;
import io.anuke.mindustry.game.EventType.DisposeEvent;
import io.anuke.mindustry.game.EventType.ResizeEvent;
import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.graphics.MenuRenderer;
import io.anuke.mindustry.ui.MobileButton;
import io.anuke.arc.util.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.ui.Styles;
import static io.anuke.arc.Core.assets;
import static io.anuke.mindustry.Vars.*;
@@ -61,26 +61,26 @@ public class MenuFragment extends Fragment{
//info icon
if(mobile){
parent.fill(c -> c.bottom().left().addButton("", "info", ui.about::show).size(84, 45));
parent.fill(c -> c.bottom().right().addButton("", "discord", ui.discord::show).size(84, 45));
parent.fill(c -> c.bottom().left().addButton("", Styles.infot, ui.about::show).size(84, 45));
parent.fill(c -> c.bottom().right().addButton("", Styles.discordt, ui.discord::show).size(84, 45));
}
String versionText = "[#ffffffba]" + ((Version.build == -1) ? "[#fc8140aa]custom build" : (Version.type.equals("official") ? Version.modifier : Version.type) + " build " + Version.build);
parent.fill((x, y, w, h) -> {
Texture logo = Core.assets.get("sprites/logo.png");
float logoscl = UnitScl.dp.scl(1);
float logow = Math.min(logo.getWidth() * logoscl, Core.graphics.getWidth() - UnitScl.dp.scl(20));
float logoscl = Scl.scl(1);
float logow = Math.min(logo.getWidth() * logoscl, Core.graphics.getWidth() - Scl.scl(20));
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
float fx = (int)(Core.graphics.getWidth() / 2f);
float fy = (int)(Core.graphics.getHeight() - 6 - logoh) + logoh / 2 - (Core.graphics.isPortrait() ? UnitScl.dp.scl(30f) : 0f);
float fy = (int)(Core.graphics.getHeight() - 6 - logoh) + logoh / 2 - (Core.graphics.isPortrait() ? Scl.scl(30f) : 0f);
Draw.color();
Draw.rect(Draw.wrap(logo), fx, fy, logow, logoh);
Core.scene.skin.font().setColor(Color.WHITE);
Core.scene.skin.font().draw(versionText, fx, fy - logoh/2f, Align.center);
Fonts.def.setColor(Color.white);
Fonts.def.draw(versionText, fx, fy - logoh/2f, Align.center);
}).touchable(Touchable.disabled);
}
@@ -89,18 +89,17 @@ public class MenuFragment extends Fragment{
container.setSize(Core.graphics.getWidth(), Core.graphics.getHeight());
float size = 120f;
float isize = iconsize;
container.defaults().size(size).pad(5).padTop(4f);
MobileButton
play = new MobileButton("icon-play-2", isize, "$campaign", ui.deploy::show),
custom = new MobileButton("icon-play-custom", isize, "$customgame", ui.custom::show),
maps = new MobileButton("icon-load", isize, "$loadgame", ui.load::show),
join = new MobileButton("icon-add", isize, "$joingame", ui.join::show),
editor = new MobileButton("icon-editor", isize, "$editor", ui.maps::show),
tools = new MobileButton("icon-tools", isize, "$settings", ui.settings::show),
donate = new MobileButton("icon-link", isize, "$website", () -> Core.net.openURI("https://anuke.itch.io/mindustry")),
exit = new MobileButton("icon-exit", isize, "$quit", () -> Core.app.exit());
play = new MobileButton(Icon.play2, "$campaign", ui.deploy::show),
custom = new MobileButton(Icon.playCustom, "$customgame", ui.custom::show),
maps = new MobileButton(Icon.load, "$loadgame", ui.load::show),
join = new MobileButton(Icon.add, "$joingame", ui.join::show),
editor = new MobileButton(Icon.editor, "$editor", ui.maps::show),
tools = new MobileButton(Icon.tools, "$settings", ui.settings::show),
donate = new MobileButton(Icon.link, "$website", () -> Core.net.openURI("https://anuke.itch.io/mindustry")),
exit = new MobileButton(Icon.exit, "$quit", () -> Core.app.exit());
if(!Core.graphics.isPortrait()){
container.marginTop(60f);
@@ -147,7 +146,7 @@ public class MenuFragment extends Fragment{
float width = 230f;
String background = "flat-trans";
Drawable background = Styles.black6;
container.left();
container.add().width(Core.graphics.getWidth()/10f);
@@ -155,17 +154,18 @@ public class MenuFragment extends Fragment{
t.defaults().width(width).height(70f);
buttons(t,
new Buttoni("$play", "icon-play-2",
new Buttoni("$campaign", "icon-play-2", ui.deploy::show),
new Buttoni("$joingame", "icon-add", ui.join::show),
new Buttoni("$customgame", "icon-editor", ui.custom::show),
new Buttoni("$loadgame", "icon-load", ui.load::show),
new Buttoni("$tutorial", "icon-info", control::playTutorial)
new Buttoni("$play", Icon.play2Small,
new Buttoni("$campaign", Icon.play2Small, ui.deploy::show),
new Buttoni("$joingame", Icon.addSmall, ui.join::show),
new Buttoni("$customgame", Icon.editorSmall, ui.custom::show),
new Buttoni("$loadgame", Icon.loadSmall, ui.load::show),
new Buttoni("$tutorial", Icon.infoSmall, control::playTutorial)
),
new Buttoni("$editor", "icon-editor", ui.maps::show),
new Buttoni("$settings", "icon-tools", ui.settings::show),
new Buttoni("$about.button", "icon-info", ui.about::show),
new Buttoni("$quit", "icon-exit", Core.app::exit)
new Buttoni("$editor", Icon.editorSmall, ui.maps::show),
steam ? new Buttoni("$workshop", Icon.saveSmall, platform::openWorkshop) : null,
new Buttoni("$settings", Icon.toolsSmall, ui.settings::show),
new Buttoni("$about.button", Icon.infoSmall, ui.about::show),
new Buttoni("$quit", Icon.exitSmall, Core.app::exit)
);
}).width(width).growY();
@@ -197,9 +197,9 @@ public class MenuFragment extends Fragment{
private void buttons(Table t, Buttoni... buttons){
for(Buttoni b : buttons){
if(b == null) continue;
Button[] out = {null};
out[0] = t.addImageTextButton(b.text, b.icon + "-small", "clear-toggle-menu",
iconsizesmall, () -> {
out[0] = t.addImageTextButton(b.text, b.icon, Styles.clearToggleMenut, () -> {
if(currentMenu == out[0]){
currentMenu = null;
fadeOutMenu();
@@ -209,7 +209,7 @@ public class MenuFragment extends Fragment{
submenu.clearChildren();
fadeInMenu();
//correctly offset the button
submenu.add().height((Core.graphics.getHeight() - out[0].getY(Align.topLeft)) / UnitScl.dp.scl(1f));
submenu.add().height((Core.graphics.getHeight() - out[0].getY(Align.topLeft)) / Scl.scl(1f));
submenu.row();
buttons(submenu, b.submenu);
}else{
@@ -225,19 +225,19 @@ public class MenuFragment extends Fragment{
}
private class Buttoni{
final String icon;
final Drawable icon;
final String text;
final Runnable runnable;
final Buttoni[] submenu;
public Buttoni(String text, String icon, Runnable runnable){
public Buttoni(String text, Drawable icon, Runnable runnable){
this.icon = icon;
this.text = text;
this.runnable = runnable;
this.submenu = null;
}
public Buttoni(String text, String icon, Buttoni... buttons){
public Buttoni(String text, Drawable icon, Buttoni... buttons){
this.icon = icon;
this.text = text;
this.runnable = () -> {};

View File

@@ -12,11 +12,12 @@ import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.input.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.Styles;
import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.Block.*;
import static io.anuke.mindustry.Vars.*;
@@ -25,7 +26,7 @@ public class PlacementFragment extends Fragment{
Array<Block> returnArray = new Array<>();
Array<Category> returnCatArray = new Array<>();
boolean[] categoryEmpty = new boolean[Category.values().length];
boolean[] categoryEmpty = new boolean[Category.all.length];
Category currentCategory = Category.distribution;
Block hovered, lastDisplay;
Tile lastHover;
@@ -90,7 +91,7 @@ public class PlacementFragment extends Fragment{
int i = 0;
for(KeyCode key : inputCatGrid){
if(Core.input.keyDown(key)){
input.block = getByCategory(Category.values()[i]).first();
input.block = getByCategory(Category.all[i]).first();
currentCategory = input.block.buildCategory;
}
i++;
@@ -115,7 +116,6 @@ public class PlacementFragment extends Fragment{
full.bottom().right().visible(() -> ui.hudfrag.shown());
full.table(frame -> {
InputHandler input = control.input;
//rebuilds the category table with the correct recipes
Runnable rebuildCategory = () -> {
@@ -137,19 +137,19 @@ public class PlacementFragment extends Fragment{
continue;
}
ImageButton button = blockTable.addImageButton("icon-locked", "select", 8 * 4, () -> {
ImageButton button = blockTable.addImageButton(Icon.lockedSmall, Styles.selecti, () -> {
if(unlocked(block)){
input.block = input.block == block ? null : block;
control.input.block = control.input.block == block ? null : block;
}
}).size(46f).group(group).name("block-" + block.name).get();
button.getStyle().imageUp = new TextureRegionDrawable(block.icon(Icon.medium));
button.getStyle().imageUp = new TextureRegionDrawable(block.icon(Block.Icon.medium));
button.update(() -> { //color unplacable things gray
TileEntity core = player.getClosestCore();
Color color = state.rules.infiniteResources || (core != null && (core.items.has(block.buildRequirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.WHITE : Color.GRAY;
Color color = state.rules.infiniteResources || (core != null && (core.items.has(block.buildRequirements, state.rules.buildCostMultiplier) || state.rules.infiniteResources)) ? Color.white : Color.gray;
button.forEach(elem -> elem.setColor(color));
button.setChecked(input.block == block);
button.setChecked(control.input.block == block);
});
button.hovered(() -> hovered = block);
@@ -169,7 +169,7 @@ public class PlacementFragment extends Fragment{
};
//top table with hover info
frame.table("button-edge-2", top -> {
frame.table(Tex.buttonEdge2,top -> {
topTable = top;
top.add(new Table()).growX().update(topTable -> {
//don't refresh unnecessarily
@@ -189,12 +189,12 @@ public class PlacementFragment extends Fragment{
topTable.table(header -> {
header.left();
header.add(new Image(lastDisplay.icon(Icon.medium))).size(8 * 4);
header.add(new Image(lastDisplay.icon(Block.Icon.medium))).size(8 * 4);
header.labelWrap(() -> !unlocked(lastDisplay) ? Core.bundle.get("block.unknown") : lastDisplay.localizedName)
.left().width(190f).padLeft(5);
header.add().growX();
if(unlocked(lastDisplay)){
header.addButton("?", "clear-partial", () -> {
header.addButton("?", Styles.clearPartialt, () -> {
ui.content.show(lastDisplay);
Events.fire(new BlockInfoEvent());
}).size(8 * 5).padTop(-5).padRight(-5).right().grow().name("blockinfo");
@@ -209,7 +209,7 @@ public class PlacementFragment extends Fragment{
req.table(line -> {
line.left();
line.addImage(stack.item.icon(Item.Icon.small)).size(8 * 2);
line.add(stack.item.localizedName()).color(Color.LIGHT_GRAY).padLeft(2).left();
line.add(stack.item.localizedName()).color(Color.lightGray).padLeft(2).left();
line.labelWrap(() -> {
TileEntity core = player.getClosestCore();
if(core == null || state.rules.infiniteResources) return "*/*";
@@ -243,13 +243,13 @@ public class PlacementFragment extends Fragment{
});
}).colspan(3).fillX().visible(() -> getSelected() != null || tileDisplayBlock() != null).touchable(Touchable.enabled);
frame.row();
frame.addImage("whiteui").color(Pal.gray).colspan(3).height(4).growX();
frame.addImage().color(Pal.gray).colspan(3).height(4).growX();
frame.row();
frame.table("pane-2", blocksSelect -> {
frame.table(Tex.pane2, blocksSelect -> {
blocksSelect.margin(4).marginTop(0);
blocksSelect.table(blocks -> blockTable = blocks).grow();
blocksSelect.row();
blocksSelect.table(input::buildUI).growX();
blocksSelect.table(control.input::buildUI).name("inputTable").growX();
}).fillY().bottom().touchable(Touchable.enabled);
frame.table(categories -> {
categories.defaults().size(50f);
@@ -257,7 +257,7 @@ public class PlacementFragment extends Fragment{
ButtonGroup<ImageButton> group = new ButtonGroup<>();
//update category empty values
for(Category cat : Category.values()){
for(Category cat : Category.all){
Array<Block> blocks = getByCategory(cat);
categoryEmpty[cat.ordinal()] = blocks.isEmpty() || !unlocked(blocks.first());
}
@@ -267,11 +267,11 @@ public class PlacementFragment extends Fragment{
if(f++ % 2 == 0) categories.row();
if(categoryEmpty[cat.ordinal()]){
categories.addImage("flat-trans");
categories.addImage(Styles.black6);
continue;
}
categories.addImageButton("icon-" + cat.name() + "-med", "clear-toggle-trans", iconsizemed, () -> {
categories.addImageButton(Core.atlas.drawable("icon-" + cat.name() + "-smaller"), Styles.clearToggleTransi, () -> {
currentCategory = cat;
rebuildCategory.run();
}).group(group).update(i -> i.setChecked(currentCategory == cat)).name("category-" + cat.name());
@@ -280,7 +280,7 @@ public class PlacementFragment extends Fragment{
rebuildCategory.run();
frame.update(() -> {
if(gridUpdate(input)) rebuildCategory.run();
if(gridUpdate(control.input)) rebuildCategory.run();
});
});
});
@@ -288,7 +288,7 @@ public class PlacementFragment extends Fragment{
Array<Category> getCategories(){
returnCatArray.clear();
returnCatArray.addAll(Category.values());
returnCatArray.addAll(Category.all);
returnCatArray.sort((c1, c2) -> Boolean.compare(categoryEmpty[c1.ordinal()], categoryEmpty[c2.ordinal()]));
return returnCatArray;
}

View File

@@ -1,21 +1,18 @@
package io.anuke.mindustry.ui.fragments;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.event.Touchable;
import io.anuke.arc.scene.ui.Image;
import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.scene.ui.layout.UnitScl;
import io.anuke.arc.util.Interval;
import io.anuke.arc.util.Scaling;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetConnection;
import io.anuke.mindustry.net.Packets.AdminAction;
import io.anuke.arc.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.scene.*;
import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.net.*;
import io.anuke.mindustry.net.Packets.*;
import io.anuke.mindustry.ui.*;
import static io.anuke.mindustry.Vars.*;
@@ -29,7 +26,7 @@ public class PlayerListFragment extends Fragment{
parent.fill(cont -> {
cont.visible(() -> visible);
cont.update(() -> {
if(!(Net.active() && !state.is(State.menu))){
if(!(net.active() && !state.is(State.menu))){
visible = false;
return;
}
@@ -43,7 +40,7 @@ public class PlayerListFragment extends Fragment{
}
});
cont.table("button-trans", pane -> {
cont.table(Tex.buttonTrans, pane -> {
pane.label(() -> Core.bundle.format(playerGroup.size() == 1 ? "players.single" : "players", playerGroup.size()));
pane.row();
pane.pane(content).grow().get().setScrollingDisabled(true, false);
@@ -52,8 +49,8 @@ public class PlayerListFragment extends Fragment{
pane.table(menu -> {
menu.defaults().growX().height(50f).fillY();
menu.addButton("$server.bans", ui.bans::show).disabled(b -> Net.client());
menu.addButton("$server.admins", ui.admins::show).disabled(b -> Net.client());
menu.addButton("$server.bans", ui.bans::show).disabled(b -> net.client());
menu.addButton("$server.admins", ui.admins::show).disabled(b -> net.client());
menu.addButton("$close", this::toggle);
}).margin(0f).pad(10f).growX();
@@ -72,7 +69,7 @@ public class PlayerListFragment extends Fragment{
playerGroup.all().each(user -> {
NetConnection connection = user.con;
if(connection == null && Net.server() && !user.isLocal) return;
if(connection == null && net.server() && !user.isLocal) return;
Table button = new Table();
button.left();
@@ -84,7 +81,7 @@ public class PlayerListFragment extends Fragment{
super.draw();
Draw.color(Pal.gray);
Draw.alpha(parentAlpha);
Lines.stroke(UnitScl.dp.scl(4f));
Lines.stroke(Scl.scl(4f));
Lines.rect(x, y, width, height);
Draw.reset();
}
@@ -96,9 +93,9 @@ public class PlayerListFragment extends Fragment{
button.labelWrap("[#" + user.color.toString().toUpperCase() + "]" + user.name).width(170f).pad(10);
button.add().grow();
button.addImage("icon-admin").size(iconsize).visible(() -> user.isAdmin && !(!user.isLocal && Net.server())).padRight(5).get().updateVisibility();
button.addImage(Icon.admin).visible(() -> user.isAdmin && !(!user.isLocal && net.server())).padRight(5).get().updateVisibility();
if((Net.server() || player.isAdmin) && !user.isLocal && (!user.isAdmin || Net.server())){
if((net.server() || player.isAdmin) && !user.isLocal && (!user.isAdmin || net.server())){
button.add().growY();
float bs = (h) / 2f;
@@ -106,15 +103,15 @@ public class PlayerListFragment extends Fragment{
button.table(t -> {
t.defaults().size(bs);
t.addImageButton("icon-ban-small", "clear-partial", iconsizesmall,
t.addImageButton(Icon.banSmall, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", "$confirmban", () -> Call.onAdminRequest(user, AdminAction.ban)));
t.addImageButton("icon-cancel-small", "clear-partial", iconsizesmall,
t.addImageButton(Icon.cancelSmall, Styles.clearPartiali,
() -> ui.showConfirm("$confirm", "$confirmkick", () -> Call.onAdminRequest(user, AdminAction.kick)));
t.row();
t.addImageButton("icon-admin-small", "clear-toggle-partial", iconsizesmall, () -> {
if(Net.client()) return;
t.addImageButton(Icon.adminSmall, Styles.clearTogglePartiali, () -> {
if(net.client()) return;
String id = user.uuid;
@@ -125,18 +122,18 @@ public class PlayerListFragment extends Fragment{
}
})
.update(b -> b.setChecked(user.isAdmin))
.disabled(b -> Net.client())
.touchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled)
.disabled(b -> net.client())
.touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled)
.checked(user.isAdmin);
t.addImageButton("icon-zoom-small", "clear-partial", iconsizesmall, () -> Call.onAdminRequest(user, AdminAction.trace));
t.addImageButton(Icon.zoomSmall, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace));
}).padRight(12).size(bs + 10f, bs);
}
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14);
content.row();
content.addImage("whiteui").height(4f).color(state.rules.pvp ? user.getTeam().color : Pal.gray).growX();
content.addImage().height(4f).color(state.rules.pvp ? user.getTeam().color : Pal.gray).growX();
content.row();
});