+1
-1
@@ -21,7 +21,7 @@ allprojects {
|
||||
appName = "Mindustry"
|
||||
gdxVersion = '1.9.8'
|
||||
aiVersion = '1.8.1'
|
||||
uCoreVersion = 'b882f59';
|
||||
uCoreVersion = '5e4e43ed39';
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -14,15 +14,17 @@ text.joingame=Join Game
|
||||
text.quit=Quit
|
||||
text.about.button=About
|
||||
text.name=Name:
|
||||
text.public=Public
|
||||
text.players={0} players online
|
||||
text.players.single={0} player online
|
||||
text.server.kicked.kick=You have been kicked from the server!
|
||||
text.server.kicked.invalidPassword=Invalid password!
|
||||
text.server.connected=A player has joined.
|
||||
text.server.connected={0} has joined.
|
||||
text.server.disconnected={0} has disconnected.
|
||||
text.nohost=Can't host server on a custom map!
|
||||
text.hostserver=Host Server
|
||||
text.host=Host
|
||||
text.hosting=[accent]Opening server...
|
||||
text.hosts.refresh=Refresh
|
||||
text.hosts.discovering=Discovering LAN games
|
||||
text.hosts.none=[lightgray]No games found!
|
||||
|
||||
@@ -243,9 +243,9 @@ public class Control extends Module{
|
||||
for(Block block : Block.getAllBlocks()){
|
||||
block.onReset();
|
||||
}
|
||||
|
||||
ui.updateItems();
|
||||
ui.updateWeapons();
|
||||
|
||||
ui.hudfrag.updateItems();
|
||||
ui.weaponfrag.updateWeapons();
|
||||
}
|
||||
|
||||
public void play(){
|
||||
@@ -264,8 +264,8 @@ public class Control extends Module{
|
||||
if(mode.infiniteResources){
|
||||
Arrays.fill(items, 999999999);
|
||||
}
|
||||
|
||||
ui.updateItems();
|
||||
|
||||
ui.hudfrag.updateItems();
|
||||
|
||||
GameState.set(State.playing);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ public class Control extends Module{
|
||||
}
|
||||
|
||||
public void playMap(Map map){
|
||||
Vars.ui.showLoading();
|
||||
ui.loadfrag.show();
|
||||
saves.resetSave();
|
||||
|
||||
Timers.run(16, ()->{
|
||||
@@ -302,7 +302,7 @@ public class Control extends Module{
|
||||
play();
|
||||
});
|
||||
|
||||
Timers.run(18, ()-> ui.hideLoading());
|
||||
Timers.run(18, ()-> ui.loadfrag.hide());
|
||||
}
|
||||
|
||||
public GameMode getMode(){
|
||||
@@ -403,7 +403,7 @@ public class Control extends Module{
|
||||
}
|
||||
Effects.effect(Fx.coreexplosion, core.worldx(), core.worldy());
|
||||
|
||||
Timers.run(60, ()-> ui.showRestart());
|
||||
Timers.run(60, ()-> ui.restart.show());
|
||||
}
|
||||
|
||||
float waveSpacing(){
|
||||
@@ -602,23 +602,23 @@ public class Control extends Module{
|
||||
}
|
||||
|
||||
if(shouldUpdateItems && (Timers.get("updateItems", 8) || GameState.is(State.paused))){
|
||||
ui.updateItems();
|
||||
ui.hudfrag.updateItems();
|
||||
shouldUpdateItems = false;
|
||||
}
|
||||
|
||||
if(!GameState.is(State.menu)){
|
||||
input.update();
|
||||
|
||||
if(Inputs.keyTap("pause") && !ui.isGameOver() && !Net.active() && (GameState.is(State.paused) || GameState.is(State.playing))){
|
||||
if(Inputs.keyTap("pause") && !ui.restart.isShown() && !Net.active() && (GameState.is(State.paused) || GameState.is(State.playing))){
|
||||
GameState.set(GameState.is(State.playing) ? State.paused : State.playing);
|
||||
}
|
||||
|
||||
if(Inputs.keyTap("menu")){
|
||||
if(GameState.is(State.paused)){
|
||||
ui.hideMenu();
|
||||
ui.paused.hide();
|
||||
GameState.set(State.playing);
|
||||
}else if (!ui.isGameOver()){
|
||||
ui.showMenu();
|
||||
}else if (!ui.restart.isShown()){
|
||||
ui.paused.show();
|
||||
GameState.set(State.paused);
|
||||
}
|
||||
}
|
||||
@@ -634,7 +634,7 @@ public class Control extends Module{
|
||||
player.heal();
|
||||
player.add();
|
||||
Effects.sound("respawn");
|
||||
ui.fadeRespawn(false);
|
||||
ui.hudfrag.fadeRespawn(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,10 @@ public class NetClient extends Module {
|
||||
connecting = true;
|
||||
gotEntities = false;
|
||||
kicked = false;
|
||||
|
||||
Gdx.app.postRunnable(() -> {
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.showLoading("$text.connecting.data");
|
||||
Vars.ui.loadfrag.hide();
|
||||
Vars.ui.loadfrag.show("$text.connecting.data");
|
||||
});
|
||||
|
||||
ConnectPacket c = new ConnectPacket();
|
||||
@@ -59,7 +60,7 @@ public class NetClient extends Module {
|
||||
Timers.runTask(dataTimeout, () -> {
|
||||
if(!gotEntities){
|
||||
Gdx.app.error("Mindustry", "Failed to load data!");
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
Net.disconnect();
|
||||
}
|
||||
});
|
||||
@@ -69,9 +70,7 @@ public class NetClient extends Module {
|
||||
if(kicked) return;
|
||||
|
||||
Gdx.app.postRunnable(() -> {
|
||||
Timers.runFor(3f, () -> {
|
||||
Vars.ui.hideLoading();
|
||||
});
|
||||
Timers.runFor(3f, Vars.ui.loadfrag::hide);
|
||||
|
||||
GameState.set(State.menu);
|
||||
|
||||
@@ -96,8 +95,8 @@ public class NetClient extends Module {
|
||||
|
||||
GameState.set(State.playing);
|
||||
connecting = false;
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.hideJoinGame();
|
||||
Vars.ui.loadfrag.hide();
|
||||
Vars.ui.join.hide();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -170,9 +169,7 @@ public class NetClient extends Module {
|
||||
|
||||
Timers.resetTime(packet.time + (float)(TimeUtils.timeSinceMillis(packet.timestamp) / 1000.0 * 60.0));
|
||||
|
||||
Gdx.app.postRunnable(() -> {
|
||||
Vars.ui.updateItems();
|
||||
});
|
||||
Gdx.app.postRunnable(Vars.ui.hudfrag::updateItems);
|
||||
});
|
||||
|
||||
Net.handle(EnemySpawnPacket.class, spawn -> {
|
||||
@@ -199,7 +196,7 @@ public class NetClient extends Module {
|
||||
//TODO shoot effects for enemies, clientside as well as serverside
|
||||
BulletType type = (BulletType) BaseBulletType.getByID(packet.type);
|
||||
Entity owner = Vars.control.enemyGroup.getByID(packet.owner);
|
||||
Bullet bullet = new Bullet(type, owner, packet.x, packet.y, packet.angle).add();
|
||||
new Bullet(type, owner, packet.x, packet.y, packet.angle).add();
|
||||
});
|
||||
|
||||
Net.handle(BlockDestroyPacket.class, packet -> {
|
||||
@@ -217,7 +214,6 @@ public class NetClient extends Module {
|
||||
});
|
||||
|
||||
Net.handle(BlockSyncPacket.class, packet -> {
|
||||
//TODO implementation, load data...
|
||||
DataInputStream stream = new DataInputStream(packet.stream);
|
||||
|
||||
try{
|
||||
@@ -247,13 +243,9 @@ public class NetClient extends Module {
|
||||
}
|
||||
});
|
||||
|
||||
Net.handle(Player.class, player -> {
|
||||
player.add();
|
||||
});
|
||||
Net.handle(Player.class, Player::add);
|
||||
|
||||
Net.handle(ChatPacket.class, packet -> {
|
||||
Gdx.app.postRunnable(() -> Vars.ui.addChatMessage(packet.name, packet.text));
|
||||
});
|
||||
Net.handle(ChatPacket.class, packet -> Gdx.app.postRunnable(() -> Vars.ui.chatfrag.addMessage(packet.name, packet.text)));
|
||||
|
||||
Net.handle(KickPacket.class, packet -> {
|
||||
kicked = true;
|
||||
@@ -280,7 +272,7 @@ public class NetClient extends Module {
|
||||
Net.send(packet, SendMode.tcp);
|
||||
|
||||
if(Net.server()){
|
||||
Vars.ui.addChatMessage(Vars.player.name, packet.text);
|
||||
Vars.ui.chatfrag.addMessage(packet.text, Vars.player.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +306,7 @@ public class NetClient extends Module {
|
||||
if(Timers.get("syncPlayer", playerSyncTime)){
|
||||
PositionPacket packet = new PositionPacket();
|
||||
packet.data = Vars.player.getInterpolator().type.write(Vars.player);
|
||||
Net.send(packet, SendMode.udp); //TODO udp instead?
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
@@ -22,7 +21,6 @@ import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.modules.Module;
|
||||
@@ -42,9 +40,7 @@ public class NetServer extends Module{
|
||||
|
||||
public NetServer(){
|
||||
|
||||
Net.handleServer(Connect.class, connect -> {
|
||||
UCore.log("Connection found: " + connect.addressTCP);
|
||||
});
|
||||
Net.handleServer(Connect.class, connect -> UCore.log("Connection found: " + connect.addressTCP));
|
||||
|
||||
Net.handleServer(ConnectPacket.class, packet -> {
|
||||
int id = Net.getLastConnection();
|
||||
@@ -68,14 +64,11 @@ public class NetServer extends Module{
|
||||
|
||||
UCore.log("Packed " + outc.size() + " COMPRESSED bytes of data.");
|
||||
|
||||
//TODO compress and uncompress when sending
|
||||
data.stream = new ByteArrayInputStream(outc.toByteArray());
|
||||
|
||||
Net.sendStream(id, data);
|
||||
|
||||
Gdx.app.postRunnable(() -> {
|
||||
Vars.ui.showInfo("$text.server.connected");
|
||||
|
||||
EntityDataPacket dp = new EntityDataPacket();
|
||||
|
||||
Player player = new Player();
|
||||
@@ -94,6 +87,8 @@ public class NetServer extends Module{
|
||||
Net.sendExcept(id, player, SendMode.tcp);
|
||||
|
||||
Net.sendTo(id, dp, SendMode.tcp);
|
||||
|
||||
Vars.ui.showInfo(Bundles.format("text.server.connected", packet.name));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -162,17 +157,6 @@ public class NetServer extends Module{
|
||||
});
|
||||
}
|
||||
|
||||
//TODO decide whether to use effects
|
||||
public void sendEffect(Effect effect, Color color, float x, float y, float rotation){
|
||||
EffectPacket packet = new EffectPacket();
|
||||
packet.id = effect.id;
|
||||
packet.color = Color.rgba8888(color);
|
||||
packet.x = x;
|
||||
packet.y = y;
|
||||
packet.rotation = rotation;
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
|
||||
public void handleBullet(BulletType type, Entity owner, float x, float y, float angle, short damage){
|
||||
BulletPacket packet = new BulletPacket();
|
||||
packet.x = x;
|
||||
@@ -281,8 +265,6 @@ public class NetServer extends Module{
|
||||
int h = 12;
|
||||
sendBlockSync(id, x, y, w, h);
|
||||
}
|
||||
|
||||
//TODO sync to each player entity
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,8 +304,6 @@ public class NetServer extends Module{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
//TODO finish
|
||||
|
||||
packet.stream = new ByteArrayInputStream(bs.toByteArray());
|
||||
|
||||
Net.sendStream(client, packet);
|
||||
|
||||
@@ -38,7 +38,6 @@ import static io.anuke.ucore.core.Core.batch;
|
||||
import static io.anuke.ucore.core.Core.camera;
|
||||
|
||||
public class Renderer extends RendererModule{
|
||||
private final static int chunksize = 32;
|
||||
private final static float shieldHitDuration = 18f;
|
||||
|
||||
public Surface shadowSurface, shieldSurface, indicatorSurface;
|
||||
@@ -101,7 +100,7 @@ public class Renderer extends RendererModule{
|
||||
|
||||
//TODO identify the source of this bug
|
||||
if(control.core == null){
|
||||
ui.showGameError();
|
||||
ui.showError("$text.error.crashmessage");
|
||||
GameState.set(State.menu);
|
||||
return;
|
||||
}
|
||||
@@ -218,7 +217,7 @@ public class Renderer extends RendererModule{
|
||||
Draw.tscl(0.25f/2);
|
||||
for(Player player : Vars.control.playerGroup.all()){
|
||||
if(!player.isLocal){
|
||||
Draw.text(player.name, player.x, player.y + 6);
|
||||
Draw.text(player.name, player.x, player.y + 7);
|
||||
}
|
||||
}
|
||||
Draw.tscl(Vars.fontscale);
|
||||
@@ -352,13 +351,13 @@ public class Renderer extends RendererModule{
|
||||
if(input.breakMode == PlaceMode.holdDelete)
|
||||
input.breakMode.draw(tilex, tiley, 0, 0);
|
||||
|
||||
}else if(input.breakMode.delete && control.input.drawPlace() && input.recipe == null){ //TODO test!
|
||||
}else if(input.breakMode.delete && control.input.drawPlace() && input.recipe == null){
|
||||
input.breakMode.draw(control.input.getBlockX(), control.input.getBlockY(),
|
||||
control.input.getBlockEndX(), control.input.getBlockEndY());
|
||||
}
|
||||
|
||||
if(Vars.ui.getTools().confirming){
|
||||
ToolFragment t = Vars.ui.getTools();
|
||||
if(Vars.ui.toolfrag.confirming){
|
||||
ToolFragment t = Vars.ui.toolfrag;
|
||||
PlaceMode.areaDelete.draw(t.px, t.py, t.px2, t.py2);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,7 @@ public class Tutorial{
|
||||
}
|
||||
|
||||
public void buildUI(table table){
|
||||
|
||||
//TODO maybe align it to the bottom?
|
||||
|
||||
table.atop();
|
||||
|
||||
new table("pane"){{
|
||||
@@ -395,7 +394,7 @@ public class Tutorial{
|
||||
void onSwitch(){
|
||||
if(!Vars.control.getWeapons().contains(Weapon.multigun, true)){
|
||||
Vars.control.getWeapons().add(Weapon.multigun);
|
||||
Vars.ui.updateWeapons();
|
||||
Vars.ui.weaponfrag.updateWeapons();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,65 +3,53 @@ package io.anuke.mindustry.core;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.mapeditor.MapEditor;
|
||||
import io.anuke.mindustry.mapeditor.MapEditorDialog;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import io.anuke.mindustry.ui.fragments.*;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Listenable;
|
||||
import io.anuke.ucore.modules.SceneModule;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Skin;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.build;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.scene.ui.TextField;
|
||||
import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
|
||||
import io.anuke.ucore.scene.ui.TextField.TextFieldFilter.DigitsOnlyFilter;
|
||||
import io.anuke.ucore.scene.ui.Window.WindowStyle;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.TooltipManager;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.ucore.scene.actions.Actions.*;
|
||||
|
||||
public class UI extends SceneModule{
|
||||
Table loadingtable, configtable;
|
||||
MindustrySettingsDialog prefs;
|
||||
MindustryKeybindDialog keys;
|
||||
MapEditorDialog editorDialog;
|
||||
Dialog about, restart, levels, upgrades, load, settingserror, gameerror, discord, join;
|
||||
MenuDialog menu;
|
||||
Tooltip tooltip;
|
||||
Tile configTile;
|
||||
MapEditor editor;
|
||||
boolean wasPaused = false;
|
||||
|
||||
private Fragment menufrag = new MenuFragment(),
|
||||
toolfrag = new ToolFragment(),
|
||||
hudfrag = new HudFragment(),
|
||||
placefrag = new PlacementFragment(),
|
||||
weaponfrag = new WeaponFragment(),
|
||||
chatfrag = new ChatFragment(),
|
||||
listfrag = new PlayerListFragment();
|
||||
public AboutDialog about;
|
||||
public RestartDialog restart;
|
||||
public LevelDialog levels;
|
||||
public LoadDialog load;
|
||||
public DiscordDialog discord;
|
||||
public JoinDialog join;
|
||||
public HostDialog host;
|
||||
public PausedDialog paused;
|
||||
public SettingsMenuDialog settings;
|
||||
public ControlsDialog controls;
|
||||
public MapEditorDialog editor;
|
||||
public UpgradeDialog upgrades;
|
||||
|
||||
public final MenuFragment menufrag = new MenuFragment();
|
||||
public final ToolFragment toolfrag = new ToolFragment();
|
||||
public final HudFragment hudfrag = new HudFragment();
|
||||
public final PlacementFragment placefrag = new PlacementFragment();
|
||||
public final WeaponFragment weaponfrag = new WeaponFragment();
|
||||
public final ChatFragment chatfrag = new ChatFragment();
|
||||
public final PlayerListFragment listfrag = new PlayerListFragment();
|
||||
public final BackgroundFragment backfrag = new BackgroundFragment();
|
||||
public final LoadingFragment loadfrag = new LoadingFragment();
|
||||
public final BlockConfigFragment configfrag = new BlockConfigFragment();
|
||||
|
||||
public UI() {
|
||||
Dialog.setShowAction(()-> sequence(
|
||||
@@ -89,7 +77,7 @@ public class UI extends SceneModule{
|
||||
|
||||
TooltipManager.getInstance().animations = false;
|
||||
|
||||
Settings.setErrorHandler(()-> Timers.run(1f, ()-> settingserror.show()));
|
||||
Settings.setErrorHandler(()-> Timers.run(1f, ()-> showError("[crimson]Failed to access local storage.\nSettings will not be saved.")));
|
||||
|
||||
Settings.defaults("pixelate", true);
|
||||
|
||||
@@ -114,261 +102,65 @@ public class UI extends SceneModule{
|
||||
Colors.put("breakStart", Color.YELLOW);
|
||||
Colors.put("breakInvalid", Color.RED);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void loadSkin(){
|
||||
skin = new Skin(Gdx.files.internal("ui/uiskin.json"), Core.atlas);
|
||||
}
|
||||
|
||||
void drawBackground(){
|
||||
int w = (int)screen.x;
|
||||
int h = (int)screen.y;
|
||||
|
||||
Draw.color();
|
||||
|
||||
TextureRegion back = Draw.region("background");
|
||||
float backscl = Unit.dp.scl(5f);
|
||||
|
||||
Draw.alpha(0.7f);
|
||||
Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2 +240f, h/2 - back.getRegionHeight()*backscl/2 + 250f,
|
||||
back.getRegionWidth()*backscl, back.getRegionHeight()*backscl);
|
||||
|
||||
float logoscl = (int)Unit.dp.scl(7);
|
||||
TextureRegion logo = skin.getRegion("logotext");
|
||||
float logow = logo.getRegionWidth()*logoscl;
|
||||
float logoh = logo.getRegionHeight()*logoscl;
|
||||
|
||||
|
||||
Draw.color();
|
||||
Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15, logow, logoh);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(Vars.debug && !Vars.showUI) return;
|
||||
|
||||
if(GameState.is(State.menu)){
|
||||
scene.getBatch().getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
scene.getBatch().begin();
|
||||
|
||||
drawBackground();
|
||||
|
||||
scene.getBatch().end();
|
||||
}
|
||||
|
||||
scene.act();
|
||||
scene.draw();
|
||||
|
||||
if(control.showCursor()) {
|
||||
Draw.color();
|
||||
|
||||
float scl = Unit.dp.scl(3f);
|
||||
scene.getBatch().begin();
|
||||
Draw.rect("controller-cursor", Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 16*scl, 16*scl);
|
||||
scene.getBatch().end();
|
||||
|
||||
Graphics.begin();
|
||||
Draw.rect("controller-cursor", Graphics.mouse().x, Graphics.mouse().y, 16*scl, 16*scl);
|
||||
Graphics.end();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
|
||||
configtable = new Table();
|
||||
scene.add(configtable);
|
||||
|
||||
if(!Vars.gwt){
|
||||
editor = new MapEditor();
|
||||
editorDialog = new MapEditorDialog(editor);
|
||||
}
|
||||
|
||||
settingserror = new Dialog("Warning", "dialog");
|
||||
settingserror.content().add("[crimson]Failed to access local storage.\nSettings will not be saved.");
|
||||
settingserror.content().margin(10f);
|
||||
settingserror.getButtonTable().addButton("OK", settingserror::hide).size(80f, 55f).pad(4);
|
||||
|
||||
gameerror = new Dialog("$text.error.crashtitle", "dialog");
|
||||
gameerror.content().labelWrap("$text.error.crashmessage").width(600f).pad(10f);
|
||||
gameerror.buttons().addButton("#text.ok", gameerror::hide).size(200f, 50);
|
||||
|
||||
editor = new MapEditorDialog();
|
||||
controls = new ControlsDialog();
|
||||
restart = new RestartDialog();
|
||||
join = new JoinDialog();
|
||||
|
||||
discord = new Dialog("Discord", "dialog");
|
||||
discord.content().margin(12f);
|
||||
discord.content().add("$text.discord");
|
||||
discord.content().row();
|
||||
discord.content().add("[orange]"+Vars.discordURL);
|
||||
discord.buttons().defaults().size(200f, 50);
|
||||
discord.buttons().addButton("$text.openlink", () -> Mindustry.platforms.openLink(Vars.discordURL));
|
||||
discord.buttons().addButton("$text.back", discord::hide);
|
||||
|
||||
discord = new DiscordDialog();
|
||||
load = new LoadDialog();
|
||||
|
||||
upgrades = new UpgradeDialog();
|
||||
|
||||
levels = new LevelDialog();
|
||||
|
||||
prefs = new MindustrySettingsDialog();
|
||||
prefs.setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
menu = new MenuDialog();
|
||||
|
||||
prefs.sound.volumePrefs();
|
||||
|
||||
prefs.game.sliderPref("difficulty", 1, 0, 2, i -> Bundles.get("setting.difficulty." + (i == 0 ? "easy" : i == 1 ? "normal" : "hard")));
|
||||
prefs.game.screenshakePref();
|
||||
prefs.game.checkPref("smoothcam", true);
|
||||
prefs.game.checkPref("indicators", true);
|
||||
prefs.game.checkPref("effects", true);
|
||||
prefs.game.sliderPref("sensitivity", 100, 10, 300, i -> i + "%");
|
||||
prefs.game.sliderPref("saveinterval", 90, 15, 5*120, i -> Bundles.format("setting.seconds", i));
|
||||
|
||||
prefs.graphics.checkPref("fps", false);
|
||||
prefs.graphics.checkPref("vsync", true, b -> Gdx.graphics.setVSync(b));
|
||||
prefs.graphics.checkPref("lasers", true);
|
||||
prefs.graphics.checkPref("healthbars", true);
|
||||
prefs.graphics.checkPref("pixelate", true, b->{
|
||||
if(b){
|
||||
Vars.renderer.pixelSurface.setScale(Core.cameraScale);
|
||||
Vars.renderer.shadowSurface.setScale(Core.cameraScale);
|
||||
Vars.renderer.shieldSurface.setScale(Core.cameraScale);
|
||||
}else{
|
||||
Vars.renderer.shadowSurface.setScale(1);
|
||||
Vars.renderer.shieldSurface.setScale(1);
|
||||
}
|
||||
renderer.setPixelate(b);
|
||||
});
|
||||
|
||||
Gdx.graphics.setVSync(Settings.getBool("vsync"));
|
||||
|
||||
prefs.hidden(()->{
|
||||
if(!GameState.is(State.menu)){
|
||||
if(!wasPaused || Net.active())
|
||||
GameState.set(State.playing);
|
||||
}
|
||||
});
|
||||
|
||||
prefs.shown(()->{
|
||||
if(!GameState.is(State.menu)){
|
||||
wasPaused = GameState.is(State.paused);
|
||||
if(menu.getScene() != null){
|
||||
wasPaused = menu.wasPaused;
|
||||
}
|
||||
if(!Net.active()) GameState.set(State.paused);
|
||||
menu.hide();
|
||||
}
|
||||
});
|
||||
|
||||
keys = new MindustryKeybindDialog();
|
||||
|
||||
about = new FloatingDialog("About");
|
||||
about.addCloseButton();
|
||||
for(String text : aboutText){
|
||||
about.content().add(text).left();
|
||||
about.content().row();
|
||||
}
|
||||
|
||||
restart = new Dialog("$text.gameover", "dialog");
|
||||
|
||||
restart.shown(()->{
|
||||
restart.content().clearChildren();
|
||||
if(control.isHighScore()){
|
||||
restart.content().add("$text.highscore").pad(6);
|
||||
restart.content().row();
|
||||
}
|
||||
restart.content().add("$text.lasted").pad(12).get();
|
||||
restart.content().add("[GREEN]" + control.getWave());
|
||||
restart.pack();
|
||||
});
|
||||
|
||||
restart.getButtonTable().addButton("$text.menu", ()->{
|
||||
restart.hide();
|
||||
GameState.set(State.menu);
|
||||
control.reset();
|
||||
}).size(200, 50).pad(3);
|
||||
settings = new SettingsMenuDialog();
|
||||
paused = new PausedDialog();
|
||||
about = new AboutDialog();
|
||||
host = new HostDialog();
|
||||
|
||||
build.begin(scene);
|
||||
|
||||
|
||||
backfrag.build();
|
||||
weaponfrag.build();
|
||||
|
||||
hudfrag.build();
|
||||
|
||||
configfrag.build();
|
||||
menufrag.build();
|
||||
|
||||
placefrag.build();
|
||||
|
||||
loadingtable = new table("loadDim"){{
|
||||
touchable(Touchable.enabled);
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
|
||||
row();
|
||||
new label("$text.loading"){{
|
||||
get().setName("namelabel");
|
||||
}}.pad(10);
|
||||
row();
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
|
||||
}}.end().get();
|
||||
|
||||
loadingtable.setVisible(false);
|
||||
|
||||
toolfrag.build();
|
||||
|
||||
chatfrag.build();
|
||||
|
||||
listfrag.build();
|
||||
|
||||
updateItems();
|
||||
loadfrag.build();
|
||||
|
||||
build.end();
|
||||
}
|
||||
|
||||
public void addChatMessage(String sender, String message){
|
||||
((ChatFragment)chatfrag).addMessage(message, sender);
|
||||
}
|
||||
|
||||
public void showGameError(){
|
||||
gameerror.show();
|
||||
}
|
||||
|
||||
public void updateWeapons(){
|
||||
((WeaponFragment)weaponfrag).updateWeapons();
|
||||
}
|
||||
|
||||
public void fadeRespawn(boolean in){
|
||||
((HudFragment)hudfrag).fadeRespawn(in);
|
||||
}
|
||||
|
||||
public void showConfig(Tile tile){
|
||||
configTile = tile;
|
||||
|
||||
configtable.clear();
|
||||
((Configurable)tile.block()).buildTable(tile, configtable);
|
||||
configtable.pack();
|
||||
configtable.setTransform(true);
|
||||
configtable.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
|
||||
configtable.update(()->{
|
||||
configtable.setOrigin(Align.center);
|
||||
Vector2 pos = Graphics.screen(tile.worldx(), tile.worldy());
|
||||
configtable.setPosition(pos.x, pos.y, Align.center);
|
||||
if(configTile == null || configTile.block() == Blocks.air){
|
||||
hideConfig();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean hasConfigMouse(){
|
||||
Element e = scene.hit(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), true);
|
||||
return e != null && (e == configtable || e.isDescendantOf(configtable));
|
||||
}
|
||||
|
||||
public void hideConfig(){
|
||||
configtable.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.visible(false));
|
||||
}
|
||||
|
||||
public void showTextInput(String title, String text, String def, TextFieldFilter filter, Consumer<String> confirmed){
|
||||
new Dialog(title, "dialog"){{
|
||||
content().margin(30);
|
||||
content().add(text).padRight(6f);
|
||||
content().margin(30).add(text).padRight(6f);
|
||||
TextField field = content().addField(def, t->{}).size(170f, 50f).get();
|
||||
field.setTextFieldFilter((f, c) -> field.getText().length() < 12 && filter.acceptChar(f, c));
|
||||
Mindustry.platforms.addDialog(field);
|
||||
@@ -385,152 +177,17 @@ public class UI extends SceneModule{
|
||||
showTextInput(title, text, def, (field, c) -> true, confirmed);
|
||||
}
|
||||
|
||||
public void showInfo(String info){
|
||||
scene.table().add("[accent]" + info).padBottom(Gdx.graphics.getHeight()/2+100f).get().getParent().actions(Actions.fadeOut(4f), Actions.removeActor());
|
||||
}
|
||||
|
||||
public void showError(String text){
|
||||
new Dialog("$text.error.title", "dialog"){{
|
||||
content().margin(15);
|
||||
content().add(text);
|
||||
content().margin(15).add(text);
|
||||
buttons().addButton("$text.ok", this::hide).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showErrorClose(String text){
|
||||
new Dialog("$text.error.title", "dialog"){{
|
||||
content().margin(15);
|
||||
content().add(text);
|
||||
buttons().addButton("$text.quit", Gdx.app::exit).size(90, 50).pad(4);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showLoading(){
|
||||
showLoading("$text.loading");
|
||||
}
|
||||
|
||||
public void showLoading(String text){
|
||||
loadingtable.<Label>find("namelabel").setText(text);
|
||||
loadingtable.setVisible(true);
|
||||
loadingtable.toFront();
|
||||
}
|
||||
|
||||
public void hideLoading(){
|
||||
loadingtable.setVisible(false);
|
||||
}
|
||||
|
||||
public void showPrefs(){
|
||||
prefs.show();
|
||||
}
|
||||
|
||||
public void showControls(){
|
||||
keys.show();
|
||||
}
|
||||
|
||||
public void showLevels(){
|
||||
levels.show();
|
||||
}
|
||||
|
||||
public void showLoadGame(){
|
||||
load.show();
|
||||
}
|
||||
|
||||
public void showJoinGame(){
|
||||
join.show();
|
||||
}
|
||||
|
||||
public void hideJoinGame(){
|
||||
join.hide();
|
||||
}
|
||||
|
||||
public void showMenu(){
|
||||
menu.show();
|
||||
}
|
||||
|
||||
public void hideMenu(){
|
||||
menu.hide();
|
||||
|
||||
if(scene.getKeyboardFocus() != null && scene.getKeyboardFocus() instanceof Dialog){
|
||||
((Dialog)scene.getKeyboardFocus()).hide();
|
||||
}
|
||||
}
|
||||
|
||||
public void showRestart(){
|
||||
restart.show();
|
||||
}
|
||||
|
||||
public void hideTooltip(){
|
||||
if(tooltip != null)
|
||||
tooltip.hide();
|
||||
}
|
||||
|
||||
public void showInfo(String info){
|
||||
scene.table().add(info).get().getParent().actions(Actions.fadeOut(4f), Actions.removeActor());
|
||||
}
|
||||
|
||||
public void showHostServer(){
|
||||
showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> {
|
||||
int result = Strings.parseInt(text);
|
||||
if(result == Integer.MIN_VALUE || result >= 65535){
|
||||
Vars.ui.showError("$text.server.invalidport");
|
||||
}else{
|
||||
try{
|
||||
Net.host(result);
|
||||
}catch (IOException e){
|
||||
Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showAbout(){
|
||||
about.show();
|
||||
}
|
||||
|
||||
public boolean onDialog(){
|
||||
return scene.getKeyboardFocus() instanceof Dialog;
|
||||
}
|
||||
|
||||
public boolean isGameOver(){
|
||||
return restart.getScene() != null;
|
||||
}
|
||||
|
||||
public void showUpgrades(){
|
||||
upgrades.show();
|
||||
}
|
||||
|
||||
public void showDiscord(){
|
||||
discord.show();
|
||||
}
|
||||
|
||||
public void showEditor(){
|
||||
editorDialog.show();
|
||||
}
|
||||
|
||||
public MapEditorDialog getEditorDialog(){
|
||||
return editorDialog;
|
||||
}
|
||||
|
||||
public ToolFragment getTools(){
|
||||
return (ToolFragment)toolfrag;
|
||||
}
|
||||
|
||||
public MapEditor getEditor(){
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void reloadLevels(){
|
||||
((LevelDialog)levels).reload();
|
||||
}
|
||||
|
||||
public boolean isEditing(){
|
||||
return editorDialog.getScene() != null;
|
||||
}
|
||||
|
||||
public void updateItems(){
|
||||
((HudFragment)hudfrag).updateItems();
|
||||
}
|
||||
|
||||
public MindustrySettingsDialog getPrefs() {
|
||||
return prefs;
|
||||
}
|
||||
|
||||
public void showConfirm(String title, String text, Listenable confirmed){
|
||||
FloatingDialog dialog = new FloatingDialog(title);
|
||||
dialog.content().add(text).pad(4f);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class World extends Module{
|
||||
|
||||
public Tile tile(int x, int y){
|
||||
if(tiles == null){
|
||||
ui.showGameError();
|
||||
ui.showError("$text.error.crashmessage");
|
||||
GameState.set(State.menu);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Player extends DestructibleEntity implements Syncable{
|
||||
//TODO respawning doesn't work for multiplayer
|
||||
if(isLocal) {
|
||||
Vars.control.setRespawnTime(respawnduration);
|
||||
ui.fadeRespawn(true);
|
||||
ui.hudfrag.fadeRespawn(true);
|
||||
}else{
|
||||
Timers.run(respawnduration, () -> {
|
||||
heal();
|
||||
|
||||
@@ -11,7 +11,6 @@ import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
@@ -58,8 +57,7 @@ public class AndroidInput extends InputHandler{
|
||||
@Override
|
||||
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||
if(ui.hasMouse()) return false;
|
||||
|
||||
ui.hideTooltip();
|
||||
|
||||
lmousex = screenX;
|
||||
lmousey = screenY;
|
||||
|
||||
@@ -77,9 +75,9 @@ public class AndroidInput extends InputHandler{
|
||||
if(cursor != null && !ui.hasMouse(screenX, screenY)){
|
||||
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
||||
if(linked != null && linked.block() instanceof Configurable){
|
||||
ui.showConfig(linked);
|
||||
}else if(!ui.hasConfigMouse()){
|
||||
ui.hideConfig();
|
||||
ui.configfrag.showConfig(linked);
|
||||
}else if(!ui.configfrag.hasConfigMouse()){
|
||||
ui.configfrag.hideConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +115,6 @@ public class AndroidInput extends InputHandler{
|
||||
public void update(){
|
||||
enableHold = breakMode == PlaceMode.holdDelete;
|
||||
|
||||
float scl = Settings.getInt("sensitivity")/100f * Unit.dp.scl(1f);
|
||||
float xa = Inputs.getAxis("move_x");
|
||||
float ya = Inputs.getAxis("move_y");
|
||||
if(Math.abs(xa) < Vars.controllerMin) xa = 0;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DesktopInput extends InputHandler{
|
||||
endx = Gdx.input.getX();
|
||||
endy = Gdx.input.getY();
|
||||
|
||||
if(Inputs.getAxisActive("zoom") && Inputs.keyDown("zoom_hold") && !GameState.is(State.menu) && !ui.onDialog()){
|
||||
if(Inputs.getAxisActive("zoom") && Inputs.keyDown("zoom_hold") && !GameState.is(State.menu) && !ui.hasDialog()){
|
||||
renderer.scaleCamera((int)Inputs.getAxis("zoom"));
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class DesktopInput extends InputHandler{
|
||||
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
|
||||
if(Inputs.keyTap("weapon_" + i)){
|
||||
player.weapon = control.getWeapons().get(i - 1);
|
||||
ui.updateWeapons();
|
||||
ui.weaponfrag.updateWeapons();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,14 +90,14 @@ public class DesktopInput extends InputHandler{
|
||||
if(Inputs.keyTap("select") && cursor != null && !ui.hasMouse()){
|
||||
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
||||
if(linked != null && linked.block() instanceof Configurable){
|
||||
ui.showConfig(linked);
|
||||
}else if(!ui.hasConfigMouse()){
|
||||
ui.hideConfig();
|
||||
ui.configfrag.showConfig(linked);
|
||||
}else if(!ui.configfrag.hasConfigMouse()){
|
||||
ui.configfrag.hideConfig();
|
||||
}
|
||||
}
|
||||
|
||||
if(Inputs.keyTap("break")){
|
||||
ui.hideConfig();
|
||||
ui.configfrag.hideConfig();
|
||||
}
|
||||
|
||||
if(Inputs.keyRelease("break")){
|
||||
|
||||
@@ -183,7 +183,7 @@ public enum PlaceMode{
|
||||
endx = this.endx; endy = this.endy;
|
||||
|
||||
if(Vars.android){
|
||||
ToolFragment t = Vars.ui.getTools();
|
||||
ToolFragment t = Vars.ui.toolfrag;
|
||||
if(!t.confirming || t.px != tilex || t.py != tiley || t.px2 != endx || t.py2 != endy) {
|
||||
t.confirming = true;
|
||||
t.px = tilex;
|
||||
|
||||
@@ -14,9 +14,7 @@ import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.ucore.core.Inputs.DeviceType;
|
||||
import io.anuke.ucore.core.KeyBinds;
|
||||
import io.anuke.ucore.core.KeyBinds.Keybind;
|
||||
import io.anuke.ucore.scene.ui.SettingsDialog.SettingsTable.Setting;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class BundleGen {
|
||||
private static FileHandle file;
|
||||
@@ -27,12 +25,12 @@ public class BundleGen {
|
||||
file.writeString("", false);
|
||||
write("about.text=" + join(Vars.aboutText));
|
||||
write("discord.text=Join the mindustry discord!\n[orange]");
|
||||
|
||||
/*
|
||||
Mathf.each(table -> {
|
||||
for(Setting setting : table.getSettings()){
|
||||
write("setting." + setting.name + ".name=" + setting.title);
|
||||
}
|
||||
}, Vars.ui.getPrefs().game, Vars.ui.getPrefs().graphics, Vars.ui.getPrefs().sound);
|
||||
}, Vars.ui.getPrefs().game, Vars.ui.getPrefs().graphics, Vars.ui.getPrefs().sound);*/
|
||||
|
||||
for(Map map : Vars.world.maps().list()){
|
||||
write("map." + map.name + ".name=" + map.name);
|
||||
|
||||
@@ -90,8 +90,9 @@ public class Maps implements Disposable{
|
||||
}
|
||||
|
||||
saveCustomMap(map);
|
||||
Vars.ui.reloadLevels();
|
||||
Vars.ui.levels.reload();
|
||||
//TODO reload map dialog
|
||||
|
||||
}
|
||||
|
||||
public void saveMaps(Array<Map> array, FileHandle file){
|
||||
|
||||
@@ -183,7 +183,7 @@ public class NetworkIO {
|
||||
Vars.control.getItems()[i] = stream.readInt();
|
||||
}
|
||||
|
||||
Vars.ui.updateItems();
|
||||
Vars.ui.hudfrag.updateItems();
|
||||
|
||||
//enemies
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Save12 extends SaveFileVersion {
|
||||
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
||||
}
|
||||
|
||||
Vars.ui.updateWeapons();
|
||||
Vars.ui.weaponfrag.updateWeapons();
|
||||
|
||||
//inventory
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Save12 extends SaveFileVersion {
|
||||
Vars.control.getItems()[item.id] = amount;
|
||||
}
|
||||
|
||||
Vars.ui.updateItems();
|
||||
Vars.ui.hudfrag.updateItems();
|
||||
|
||||
//enemies
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Save13 extends SaveFileVersion {
|
||||
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
||||
}
|
||||
|
||||
Vars.ui.updateWeapons();
|
||||
Vars.ui.weaponfrag.updateWeapons();
|
||||
|
||||
//inventory
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Save13 extends SaveFileVersion {
|
||||
Vars.control.getItems()[item.id] = amount;
|
||||
}
|
||||
|
||||
Vars.ui.updateItems();
|
||||
Vars.ui.hudfrag.updateItems();
|
||||
|
||||
//enemies
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Save14 extends SaveFileVersion{
|
||||
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
||||
}
|
||||
|
||||
Vars.ui.updateWeapons();
|
||||
Vars.ui.weaponfrag.updateWeapons();
|
||||
|
||||
//inventory
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Save14 extends SaveFileVersion{
|
||||
Vars.control.getItems()[item.id] = amount;
|
||||
}
|
||||
|
||||
Vars.ui.updateItems();
|
||||
Vars.ui.hudfrag.updateItems();
|
||||
|
||||
//enemies
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package io.anuke.mindustry.mapeditor;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.IntSet;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.ColorMapper.BlockPair;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
public enum EditorTool{
|
||||
pick{
|
||||
public void touched(MapEditor editor, int x, int y){
|
||||
@@ -18,7 +17,7 @@ public enum EditorTool{
|
||||
if(pair == null) return;
|
||||
Block block = pair.dominant();
|
||||
editor.setDrawBlock(block);
|
||||
Vars.ui.getEditorDialog().updateSelectedBlock();
|
||||
Vars.ui.editor.updateSelectedBlock();
|
||||
}
|
||||
},
|
||||
pencil{
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package io.anuke.mindustry.mapeditor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.ui.FileChooser;
|
||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.ColorMapper.BlockPair;
|
||||
@@ -19,12 +16,17 @@ import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Pixmaps;
|
||||
import io.anuke.ucore.scene.builders.*;
|
||||
import io.anuke.ucore.scene.builders.build;
|
||||
import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MapEditorDialog extends Dialog{
|
||||
private MapEditor editor;
|
||||
private MapView view;
|
||||
@@ -37,14 +39,16 @@ public class MapEditorDialog extends Dialog{
|
||||
|
||||
private ButtonGroup<ImageButton> blockgroup;
|
||||
|
||||
public MapEditorDialog(MapEditor editor){
|
||||
public MapEditorDialog(){
|
||||
super("$text.mapeditor", "dialog");
|
||||
this.editor = editor;
|
||||
if(Vars.gwt) return;
|
||||
|
||||
editor = new MapEditor();
|
||||
dialog = new MapGenerateDialog(editor);
|
||||
view = new MapView(editor);
|
||||
|
||||
openFile = new FileChooser("$text.loadimage", FileChooser.pngFilter, true, file -> {
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
Timers.run(3f, () -> {
|
||||
try{
|
||||
Pixmap pixmap = new Pixmap(file);
|
||||
@@ -58,7 +62,7 @@ public class MapEditorDialog extends Dialog{
|
||||
Vars.ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
||||
e.printStackTrace();
|
||||
}
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -67,7 +71,7 @@ public class MapEditorDialog extends Dialog{
|
||||
file = file.parent().child(file.nameWithoutExtension() + ".png");
|
||||
}
|
||||
FileHandle result = file;
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
Timers.run(3f, () -> {
|
||||
try{
|
||||
Pixmaps.write(editor.pixmap(), result);
|
||||
@@ -75,13 +79,13 @@ public class MapEditorDialog extends Dialog{
|
||||
Vars.ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||
if(!Vars.android) e.printStackTrace();
|
||||
}
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
});
|
||||
});
|
||||
|
||||
loadDialog = new MapLoadDialog(map -> {
|
||||
saveDialog.setFieldText(map.name);
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
|
||||
Timers.run(3f, () -> {
|
||||
Map copy = new Map();
|
||||
@@ -90,7 +94,7 @@ public class MapEditorDialog extends Dialog{
|
||||
copy.pixmap = Pixmaps.copy(map.pixmap);
|
||||
copy.texture = new Texture(copy.pixmap);
|
||||
editor.beginEdit(copy);
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
view.clearStack();
|
||||
});
|
||||
});
|
||||
@@ -98,28 +102,28 @@ public class MapEditorDialog extends Dialog{
|
||||
resizeDialog = new MapResizeDialog(editor, (x, y) -> {
|
||||
Pixmap pix = editor.pixmap();
|
||||
if(!(pix.getWidth() == x && pix.getHeight() == y)){
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
Timers.run(10f, ()->{
|
||||
editor.resize(x, y);
|
||||
view.clearStack();
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
saveDialog = new MapSaveDialog(name -> {
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
if(verifyMap()){
|
||||
saved = true;
|
||||
editor.getMap().name = name;
|
||||
Timers.run(10f, () -> {
|
||||
Vars.world.maps().saveAndReload(editor.getMap(), editor.pixmap());
|
||||
loadDialog.rebuild();
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
view.clearStack();
|
||||
});
|
||||
}else{
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.badlogic.gdx.utils.Scaling;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.mapeditor.MapFilter.GenPref;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.mindustry.ui.FloatingDialog;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Pixmaps;
|
||||
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||
@@ -71,14 +71,14 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
});
|
||||
buttons().addButton("$text.update", this::apply);
|
||||
buttons().addButton("$text.apply", () ->{
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
|
||||
Timers.run(3f, () ->{
|
||||
Pixmap copy = Pixmaps.copy(editor.pixmap());
|
||||
editor.applyFilter();
|
||||
Vars.ui.getEditorDialog().getView().push(copy, Pixmaps.copy(editor.pixmap()));
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.getEditorDialog().resetSaved();
|
||||
Vars.ui.editor.getView().push(copy, Pixmaps.copy(editor.pixmap()));
|
||||
Vars.ui.loadfrag.hide();
|
||||
Vars.ui.editor.resetSaved();
|
||||
hide();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.mapeditor;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
import io.anuke.mindustry.ui.FloatingDialog;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.anuke.mindustry.mapeditor;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import io.anuke.mindustry.ui.FloatingDialog;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.function.BiConsumer;
|
||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.mapeditor;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.ui.FloatingDialog;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.mapeditor;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
@@ -12,12 +11,13 @@ import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.ui.GridImage;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.graphics.Pixmaps;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
@@ -115,7 +115,7 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
if(tool.edit){
|
||||
updated = true;
|
||||
Vars.ui.getEditorDialog().resetSaved();
|
||||
Vars.ui.editor.resetSaved();
|
||||
}
|
||||
|
||||
op = new DrawOperation(editor.pixmap());
|
||||
@@ -131,7 +131,7 @@ public class MapView extends Element implements GestureListener{
|
||||
GridPoint2 p = project(x, y);
|
||||
|
||||
if(tool == EditorTool.line){
|
||||
Vars.ui.getEditorDialog().resetSaved();
|
||||
Vars.ui.editor.resetSaved();
|
||||
Array<GridPoint2> points = br.line(startx, starty, p.x, p.y);
|
||||
for(GridPoint2 point : points){
|
||||
editor.draw(point.x, point.y);
|
||||
@@ -154,7 +154,7 @@ public class MapView extends Element implements GestureListener{
|
||||
GridPoint2 p = project(x, y);
|
||||
|
||||
if(drawing && tool == EditorTool.pencil){
|
||||
Vars.ui.getEditorDialog().resetSaved();
|
||||
Vars.ui.editor.resetSaved();
|
||||
Array<GridPoint2> points = br.line(lastx, lasty, p.x, p.y);
|
||||
for(GridPoint2 point : points){
|
||||
editor.draw(point.x, point.y);
|
||||
@@ -255,8 +255,8 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
private boolean active(){
|
||||
return Core.scene.getKeyboardFocus() != null
|
||||
&& Core.scene.getKeyboardFocus().isDescendantOf(Vars.ui.getEditorDialog())
|
||||
&& Vars.ui.isEditing() && tool == EditorTool.zoom &&
|
||||
&& Core.scene.getKeyboardFocus().isDescendantOf(Vars.ui.editor)
|
||||
&& Vars.ui.editor.isShown() && tool == EditorTool.zoom &&
|
||||
Core.scene.hit(Graphics.mouse().x, Graphics.mouse().y, true) == this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.ucore.UCore;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Listenable;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class MindustrySettingsDialog extends SettingsDialog{
|
||||
public SettingsTable graphics;
|
||||
public SettingsTable game;
|
||||
public SettingsTable sound;
|
||||
|
||||
private Table prefs;
|
||||
private Table menu;
|
||||
private boolean built = false;
|
||||
|
||||
public MindustrySettingsDialog(){
|
||||
setFillParent(true);
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().add(new Image("white"))
|
||||
.growX().height(3f).pad(4f).get().setColor(Colors.get("accent"));
|
||||
|
||||
content().clearChildren();
|
||||
content().remove();
|
||||
buttons().remove();
|
||||
|
||||
menu = new Table();
|
||||
|
||||
Consumer<SettingsTable> s = table -> {
|
||||
table.row();
|
||||
table.addImageTextButton("$text.back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f);
|
||||
};
|
||||
|
||||
game = new SettingsTable(s);
|
||||
graphics = new SettingsTable(s);
|
||||
sound = new SettingsTable(s);
|
||||
|
||||
prefs = new Table();
|
||||
prefs.top();
|
||||
prefs.margin(14f);
|
||||
|
||||
menu.defaults().size(300f, 60f).pad(3f);
|
||||
menu.addButton("$text.settings.game", () -> visible(0));
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.graphics", () -> visible(1));
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.sound", () -> visible(2));
|
||||
|
||||
if(!Vars.android) {
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.controls", () -> Vars.ui.showControls());
|
||||
}
|
||||
|
||||
prefs.clearChildren();
|
||||
prefs.add(menu);
|
||||
|
||||
ScrollPane pane = new ScrollPane(prefs, "clear");
|
||||
pane.setFadeScrollBars(false);
|
||||
|
||||
row();
|
||||
add(pane).grow().top();
|
||||
row();
|
||||
add(buttons()).fillX();
|
||||
|
||||
hidden(this::back);
|
||||
}
|
||||
|
||||
private void back(){
|
||||
prefs.clearChildren();
|
||||
prefs.add(menu);
|
||||
}
|
||||
|
||||
private void visible(int index){
|
||||
prefs.clearChildren();
|
||||
Table table = Mathf.select(index, game, graphics, sound);
|
||||
prefs.add(table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("$text.menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
|
||||
keyDown(key->{
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import static io.anuke.mindustry.Vars.aboutText;
|
||||
|
||||
public class AboutDialog extends FloatingDialog {
|
||||
|
||||
public AboutDialog(){
|
||||
super("$text.about");
|
||||
|
||||
addCloseButton();
|
||||
|
||||
for(String text : aboutText){
|
||||
content().add(text).left();
|
||||
content().row();
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
@@ -7,9 +7,9 @@ import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.KeybindDialog;
|
||||
|
||||
public class MindustryKeybindDialog extends KeybindDialog{
|
||||
public class ControlsDialog extends KeybindDialog{
|
||||
|
||||
public MindustryKeybindDialog(){
|
||||
public ControlsDialog(){
|
||||
setDialog();
|
||||
|
||||
setFillParent(true);
|
||||
@@ -0,0 +1,19 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
|
||||
public class DiscordDialog extends Dialog {
|
||||
|
||||
public DiscordDialog(){
|
||||
super("Discord", "dialog");
|
||||
content().margin(12f);
|
||||
content().add("$text.discord");
|
||||
content().row();
|
||||
content().add("[orange]"+ Vars.discordURL);
|
||||
buttons().defaults().size(200f, 50);
|
||||
buttons().addButton("$text.openlink", () -> Mindustry.platforms.openLink(Vars.discordURL));
|
||||
buttons().addButton("$text.back", this::hide);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
@@ -17,7 +17,7 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FileChooser extends FloatingDialog{
|
||||
public class FileChooser extends FloatingDialog {
|
||||
private Table files;
|
||||
private FileHandle homeDirectory = Gdx.files.absolute(Gdx.files.getExternalStoragePath());
|
||||
private FileHandle directory = homeDirectory;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
@@ -0,0 +1,60 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//TODO
|
||||
public class HostDialog extends Dialog{
|
||||
float w = 300;
|
||||
|
||||
public HostDialog(){
|
||||
super("$text.hostserver", "dialog");
|
||||
|
||||
content().table(t -> {
|
||||
t.add("$text.name").padRight(10);
|
||||
t.addField(Settings.getString("name"), text -> {
|
||||
if(text.isEmpty()) return;
|
||||
Vars.player.name = text;
|
||||
Settings.put("name", text);
|
||||
Settings.save();
|
||||
}).grow().pad(8);
|
||||
}).width(w).height(70f).pad(4);
|
||||
|
||||
content().row();
|
||||
|
||||
content().addButton("Host", () -> {
|
||||
Vars.ui.loadfrag.show("$text.hosting");
|
||||
Timers.runTask(5f, () -> {
|
||||
try{
|
||||
Net.host(Vars.port);
|
||||
}catch (IOException e){
|
||||
Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||
}
|
||||
Vars.ui.loadfrag.hide();
|
||||
hide();
|
||||
});
|
||||
}).width(w).height(70f);
|
||||
}
|
||||
|
||||
/*
|
||||
showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> {
|
||||
int result = Strings.parseInt(text);
|
||||
if(result == Integer.MIN_VALUE || result >= 65535){
|
||||
Vars.ui.showError("$text.server.invalidport");
|
||||
}else{
|
||||
try{
|
||||
Net.host(result);
|
||||
}catch (IOException e){
|
||||
Vars.ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
+6
-4
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
@@ -45,7 +45,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
join.buttons().addButton("$text.cancel", join::hide);
|
||||
join.buttons().addButton("$text.ok", () ->
|
||||
connect(Settings.getString("ip"), Strings.parseInt(Settings.getString("port")))
|
||||
).disabled(b -> Settings.getString("ip").isEmpty() || Strings.parseInt(Settings.getString("port")) == Integer.MIN_VALUE);
|
||||
).disabled(b -> Settings.getString("ip").isEmpty() || Strings.parseInt(Settings.getString("port")) == Integer.MIN_VALUE || Net.active());
|
||||
|
||||
setup();
|
||||
|
||||
@@ -105,11 +105,13 @@ public class JoinDialog extends FloatingDialog {
|
||||
}
|
||||
|
||||
void connect(String ip, int port){
|
||||
Vars.ui.showLoading("$text.connecting");
|
||||
Vars.ui.loadfrag.show("$text.connecting");
|
||||
|
||||
Timers.runTask(2f, () -> {
|
||||
try{
|
||||
Net.connect(ip, port);
|
||||
hide();
|
||||
join.hide();
|
||||
}catch (Exception e) {
|
||||
Throwable t = e;
|
||||
while(t.getCause() != null){
|
||||
@@ -128,7 +130,7 @@ public class JoinDialog extends FloatingDialog {
|
||||
error = Strings.parseException(e, false);
|
||||
}
|
||||
Vars.ui.showError(Bundles.format("text.connectfail", error));
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
@@ -161,18 +161,18 @@ public class LoadDialog extends FloatingDialog{
|
||||
public void modifyButton(TextButton button, SaveSlot slot){
|
||||
button.clicked(() -> {
|
||||
if(!button.childrenPressed()){
|
||||
Vars.ui.showLoading();
|
||||
Vars.ui.loadfrag.show();
|
||||
|
||||
Timers.runTask(3f, () -> {
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
hide();
|
||||
try{
|
||||
slot.load();
|
||||
GameState.set(State.playing);
|
||||
Vars.ui.hideMenu();
|
||||
Vars.ui.paused.hide();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
Vars.ui.hideMenu();
|
||||
Vars.ui.paused.hide();
|
||||
GameState.set(State.menu);
|
||||
Vars.control.reset();
|
||||
Vars.ui.showError("$text.save.corrupted");
|
||||
+12
-14
@@ -1,10 +1,11 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.ui.PressGroup;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.builders.build;
|
||||
@@ -14,12 +15,12 @@ import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class MenuDialog extends FloatingDialog{
|
||||
public class PausedDialog extends FloatingDialog{
|
||||
private SaveDialog save = new SaveDialog();
|
||||
private LoadDialog load = new LoadDialog();
|
||||
public boolean wasPaused = false;
|
||||
|
||||
public MenuDialog() {
|
||||
public PausedDialog() {
|
||||
super("$text.menu");
|
||||
setup();
|
||||
}
|
||||
@@ -40,9 +41,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
});
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.settings", () -> {
|
||||
ui.showPrefs();
|
||||
});
|
||||
content().addButton("$text.settings", ui.settings::show);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.savegame", () -> {
|
||||
@@ -60,7 +59,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
if(Vars.world.getMap().custom){
|
||||
ui.showError("$text.nohost");
|
||||
}else {
|
||||
ui.showHostServer();
|
||||
ui.host.show();
|
||||
}
|
||||
}).disabled(b -> Net.active());
|
||||
|
||||
@@ -88,19 +87,19 @@ public class MenuDialog extends FloatingDialog{
|
||||
GameState.set(State.playing);
|
||||
}).text("$text.back").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
|
||||
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
|
||||
|
||||
new imagebutton("icon-save", isize, ()-> save.show()).text("$text.save").padTop(4f);
|
||||
new imagebutton("icon-save", isize, save::show).text("$text.save").padTop(4f);
|
||||
|
||||
content().row();
|
||||
|
||||
new imagebutton("icon-load", isize, () -> load.show()).text("$text.load").padTop(4f).disabled(Net.active());
|
||||
new imagebutton("icon-load", isize, load::show).text("$text.load").padTop(4f).disabled(Net.active());
|
||||
|
||||
new imagebutton("icon-host", isize, () -> {
|
||||
if(Vars.world.getMap().custom){
|
||||
ui.showError("$text.nohost");
|
||||
}else {
|
||||
ui.showHostServer();
|
||||
ui.host.show();
|
||||
}
|
||||
}).text("$text.host")
|
||||
.disabled(b -> Net.active()).padTop(4f);
|
||||
@@ -127,15 +126,14 @@ public class MenuDialog extends FloatingDialog{
|
||||
if(Vars.control.getSaves().getCurrent() == null ||
|
||||
!Vars.control.getSaves().getCurrent().isAutosave()) return;
|
||||
|
||||
Vars.ui.showLoading("$text.saveload");
|
||||
Vars.ui.loadfrag.show("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
try{
|
||||
Vars.control.getSaves().getCurrent().save();
|
||||
}catch(Throwable e){
|
||||
e = (e.getCause() == null ? e : e.getCause());
|
||||
|
||||
Vars.ui.showError("[orange]"+ Bundles.get("text.savefail")+"\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
|
||||
public class RestartDialog extends Dialog {
|
||||
|
||||
public RestartDialog(){
|
||||
super("$text.gameover", "dialog");
|
||||
|
||||
shown(()->{
|
||||
content().clearChildren();
|
||||
if(control.isHighScore()){
|
||||
content().add("$text.highscore").pad(6);
|
||||
content().row();
|
||||
}
|
||||
content().add("$text.lasted").pad(12).get();
|
||||
content().add("[GREEN]" + control.getWave());
|
||||
pack();
|
||||
});
|
||||
|
||||
getButtonTable().addButton("$text.menu", ()-> {
|
||||
hide();
|
||||
GameState.set(State.menu);
|
||||
control.reset();
|
||||
});
|
||||
}
|
||||
}
|
||||
+7
-15
@@ -1,17 +1,11 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.io.Saves;
|
||||
import io.anuke.mindustry.io.Saves.SaveSlot;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.builders.button;
|
||||
import io.anuke.ucore.scene.ui.ConfirmDialog;
|
||||
import io.anuke.ucore.scene.ui.Dialog;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class SaveDialog extends LoadDialog{
|
||||
@@ -26,12 +20,12 @@ public class SaveDialog extends LoadDialog{
|
||||
}
|
||||
|
||||
slots.row();
|
||||
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14*3, () -> {
|
||||
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14*3, () ->
|
||||
Vars.ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {
|
||||
Vars.control.getSaves().addSave(text);
|
||||
setup();
|
||||
});
|
||||
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||
})
|
||||
).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,19 +33,17 @@ public class SaveDialog extends LoadDialog{
|
||||
button.clicked(() -> {
|
||||
if(button.childrenPressed()) return;
|
||||
|
||||
Vars.ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> {
|
||||
save(slot);
|
||||
});
|
||||
Vars.ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> save(slot));
|
||||
});
|
||||
}
|
||||
|
||||
void save(SaveSlot slot){
|
||||
|
||||
Vars.ui.showLoading("$text.saveload");
|
||||
Vars.ui.loadfrag.show("$text.saveload");
|
||||
|
||||
Timers.runTask(5f, () -> {
|
||||
hide();
|
||||
Vars.ui.hideLoading();
|
||||
Vars.ui.loadfrag.hide();
|
||||
try{
|
||||
slot.save();
|
||||
}catch(Throwable e){
|
||||
@@ -0,0 +1,158 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||
import io.anuke.ucore.scene.ui.SettingsDialog;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class SettingsMenuDialog extends SettingsDialog{
|
||||
public SettingsTable graphics;
|
||||
public SettingsTable game;
|
||||
public SettingsTable sound;
|
||||
|
||||
private Table prefs;
|
||||
private Table menu;
|
||||
private boolean built = false;
|
||||
private boolean wasPaused;
|
||||
|
||||
public SettingsMenuDialog(){
|
||||
setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
hidden(()->{
|
||||
if(!GameState.is(State.menu)){
|
||||
if(!wasPaused || Net.active())
|
||||
GameState.set(State.playing);
|
||||
}
|
||||
});
|
||||
|
||||
shown(()->{
|
||||
if(!GameState.is(State.menu)){
|
||||
wasPaused = GameState.is(State.paused);
|
||||
if(menu.getScene() != null){
|
||||
wasPaused = ((PausedDialog)menu).wasPaused;
|
||||
}
|
||||
if(!Net.active()) GameState.set(State.paused);
|
||||
//TODO hide menu
|
||||
Vars.ui.paused.hide();
|
||||
}
|
||||
});
|
||||
|
||||
setFillParent(true);
|
||||
title().setAlignment(Align.center);
|
||||
getTitleTable().row();
|
||||
getTitleTable().add(new Image("white"))
|
||||
.growX().height(3f).pad(4f).get().setColor(Colors.get("accent"));
|
||||
|
||||
content().clearChildren();
|
||||
content().remove();
|
||||
buttons().remove();
|
||||
|
||||
menu = new Table();
|
||||
|
||||
Consumer<SettingsTable> s = table -> {
|
||||
table.row();
|
||||
table.addImageTextButton("$text.back", "icon-arrow-left", 10*3, this::back).size(240f, 60f).colspan(2).padTop(15f);
|
||||
};
|
||||
|
||||
game = new SettingsTable(s);
|
||||
graphics = new SettingsTable(s);
|
||||
sound = new SettingsTable(s);
|
||||
|
||||
prefs = new Table();
|
||||
prefs.top();
|
||||
prefs.margin(14f);
|
||||
|
||||
menu.defaults().size(300f, 60f).pad(3f);
|
||||
menu.addButton("$text.settings.game", () -> visible(0));
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.graphics", () -> visible(1));
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.sound", () -> visible(2));
|
||||
|
||||
if(!Vars.android) {
|
||||
menu.row();
|
||||
menu.addButton("$text.settings.controls", Vars.ui.controls::show);
|
||||
}
|
||||
|
||||
prefs.clearChildren();
|
||||
prefs.add(menu);
|
||||
|
||||
ScrollPane pane = new ScrollPane(prefs, "clear");
|
||||
pane.setFadeScrollBars(false);
|
||||
|
||||
row();
|
||||
add(pane).grow().top();
|
||||
row();
|
||||
add(buttons()).fillX();
|
||||
|
||||
hidden(this::back);
|
||||
|
||||
addSettings();
|
||||
}
|
||||
|
||||
void addSettings(){
|
||||
sound.volumePrefs();
|
||||
|
||||
game.sliderPref("difficulty", 1, 0, 2, i -> Bundles.get("setting.difficulty." + (i == 0 ? "easy" : i == 1 ? "normal" : "hard")));
|
||||
game.screenshakePref();
|
||||
game.checkPref("smoothcam", true);
|
||||
game.checkPref("indicators", true);
|
||||
game.checkPref("effects", true);
|
||||
game.sliderPref("sensitivity", 100, 10, 300, i -> i + "%");
|
||||
game.sliderPref("saveinterval", 90, 15, 5*120, i -> Bundles.format("setting.seconds", i));
|
||||
|
||||
graphics.checkPref("fps", false);
|
||||
graphics.checkPref("vsync", true, b -> Gdx.graphics.setVSync(b));
|
||||
graphics.checkPref("lasers", true);
|
||||
graphics.checkPref("healthbars", true);
|
||||
graphics.checkPref("pixelate", true, b->{
|
||||
if(b){
|
||||
Vars.renderer.pixelSurface.setScale(Core.cameraScale);
|
||||
Vars.renderer.shadowSurface.setScale(Core.cameraScale);
|
||||
Vars.renderer.shieldSurface.setScale(Core.cameraScale);
|
||||
}else{
|
||||
Vars.renderer.shadowSurface.setScale(1);
|
||||
Vars.renderer.shieldSurface.setScale(1);
|
||||
}
|
||||
renderer.setPixelate(b);
|
||||
});
|
||||
|
||||
Gdx.graphics.setVSync(Settings.getBool("vsync"));
|
||||
}
|
||||
|
||||
private void back(){
|
||||
prefs.clearChildren();
|
||||
prefs.add(menu);
|
||||
}
|
||||
|
||||
private void visible(int index){
|
||||
prefs.clearChildren();
|
||||
Table table = Mathf.select(index, game, graphics, sound);
|
||||
prefs.add(table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCloseButton(){
|
||||
buttons().addImageTextButton("$text.menu", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||
|
||||
keyDown(key->{
|
||||
if(key == Keys.ESCAPE || key == Keys.BACK)
|
||||
hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -1,10 +1,7 @@
|
||||
package io.anuke.mindustry.ui;
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
@@ -17,6 +14,9 @@ import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class UpgradeDialog extends FloatingDialog{
|
||||
boolean wasPaused = false;
|
||||
|
||||
@@ -58,7 +58,7 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
if(control.hasWeapon(weapon)){
|
||||
button.setDisabled(true);
|
||||
button.setColor(Color.GRAY);
|
||||
}else if(!Vars.control.hasItems(weapon.requirements)){
|
||||
}else if(!control.hasItems(weapon.requirements)){
|
||||
button.setDisabled(true);
|
||||
}else{
|
||||
button.setDisabled(false);
|
||||
@@ -92,7 +92,7 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
ItemStack[] req = weapon.requirements;
|
||||
for(ItemStack s : req){
|
||||
|
||||
int amount = Math.min(Vars.control.getAmount(s.item), s.amount);
|
||||
int amount = Math.min(control.getAmount(s.item), s.amount);
|
||||
reqtable.addImage(Draw.region("icon-" + s.item.name)).padRight(3).size(8*2);
|
||||
reqtable.add(
|
||||
(amount >= s.amount ? "" : "[RED]")
|
||||
@@ -114,7 +114,7 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
|
||||
run.listen();
|
||||
|
||||
Tooltip tip = new Tooltip(tiptable, run);
|
||||
Tooltip<Table> tip = new Tooltip<>(tiptable, run);
|
||||
|
||||
tip.setInstant(true);
|
||||
|
||||
@@ -123,9 +123,9 @@ public class UpgradeDialog extends FloatingDialog{
|
||||
button.clicked(()->{
|
||||
if(button.isDisabled()) return;
|
||||
|
||||
Vars.control.removeItems(weapon.requirements);
|
||||
control.removeItems(weapon.requirements);
|
||||
control.addWeapon(weapon);
|
||||
ui.updateWeapons();
|
||||
ui.weaponfrag.updateWeapons();
|
||||
run.listen();
|
||||
Effects.sound("purchase");
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class BackgroundFragment implements Fragment {
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
|
||||
Core.scene.table().addRect((a, b, w, h) -> {
|
||||
Draw.color();
|
||||
|
||||
TextureRegion back = Draw.region("background");
|
||||
float backscl = Unit.dp.scl(5f);
|
||||
|
||||
Draw.alpha(0.7f);
|
||||
Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2 +240f, h/2 - back.getRegionHeight()*backscl/2 + 250f,
|
||||
back.getRegionWidth()*backscl, back.getRegionHeight()*backscl);
|
||||
|
||||
float logoscl = (int)Unit.dp.scl(7);
|
||||
TextureRegion logo = Core.skin.getRegion("logotext");
|
||||
float logow = logo.getRegionWidth()*logoscl;
|
||||
float logoh = logo.getRegionHeight()*logoscl;
|
||||
|
||||
Draw.color();
|
||||
Core.batch.draw(logo, w/2 - logow/2, h - logoh + 15, logow, logoh);
|
||||
}).visible(() -> GameState.is(State.menu)).grow();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class BlockConfigFragment implements Fragment {
|
||||
private Table table;
|
||||
private Tile configTile;
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
table = new Table();
|
||||
Core.scene.add(table);
|
||||
}
|
||||
|
||||
public void showConfig(Tile tile){
|
||||
configTile = tile;
|
||||
|
||||
table.clear();
|
||||
((Configurable)tile.block()).buildTable(tile, table);
|
||||
table.pack();
|
||||
table.setTransform(true);
|
||||
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
|
||||
table.update(()->{
|
||||
table.setOrigin(Align.center);
|
||||
Vector2 pos = Graphics.screen(tile.worldx(), tile.worldy());
|
||||
table.setPosition(pos.x, pos.y, Align.center);
|
||||
if(configTile == null || configTile.block() == Blocks.air){
|
||||
hideConfig();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean hasConfigMouse(){
|
||||
Element e = Core.scene.hit(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), true);
|
||||
return e != null && (e == table || e.isDescendantOf(table));
|
||||
}
|
||||
|
||||
public void hideConfig(){
|
||||
table.actions(Actions.scaleTo(0f, 1f, 0.06f, Interpolation.pow3Out), Actions.visible(false));
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.mindustry.resource.Recipe;
|
||||
import io.anuke.mindustry.resource.Section;
|
||||
import io.anuke.mindustry.ui.FloatingDialog;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
|
||||
@@ -41,9 +41,7 @@ public class HudFragment implements Fragment{
|
||||
defaults().size(dsize).left();
|
||||
float isize = 40;
|
||||
|
||||
menu = new imagebutton("icon-menu", isize, ()->{
|
||||
ui.showMenu();
|
||||
}).get();
|
||||
menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
|
||||
|
||||
flip = new imagebutton("icon-arrow-up", isize, ()->{
|
||||
if(wavetable.getActions().size != 0) return;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.graphics.Colors;
|
||||
import io.anuke.ucore.scene.builders.label;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.event.Touchable;
|
||||
import io.anuke.ucore.scene.ui.Label;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
public class LoadingFragment implements Fragment {
|
||||
private Table table;
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
|
||||
table = new table("loadDim"){{
|
||||
touchable(Touchable.enabled);
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
|
||||
row();
|
||||
new label("$text.loading"){{
|
||||
get().setName("namelabel");
|
||||
}}.pad(10);
|
||||
row();
|
||||
get().addImage("white").growX()
|
||||
.height(3f).pad(4f).growX().get().setColor(Colors.get("accent"));
|
||||
}}.end().get();
|
||||
|
||||
table.setVisible(false);
|
||||
}
|
||||
|
||||
public void show(){
|
||||
show("$text.loading");
|
||||
}
|
||||
|
||||
public void show(String text){
|
||||
table.<Label>find("namelabel").setText(text);
|
||||
table.setVisible(true);
|
||||
table.toFront();
|
||||
}
|
||||
|
||||
public void hide(){
|
||||
table.setVisible(false);
|
||||
}
|
||||
}
|
||||
@@ -25,26 +25,26 @@ public class MenuFragment implements Fragment{
|
||||
float scale = 4f;
|
||||
defaults().size(100*scale, 21*scale).pad(-10f);
|
||||
|
||||
add(new MenuButton("$text.play", group, ui::showLevels));
|
||||
add(new MenuButton("$text.play", group, ui.levels::show));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("$text.joingame", group, ui::showJoinGame));
|
||||
add(new MenuButton("$text.joingame", group, ui.join::show));
|
||||
row();
|
||||
}
|
||||
|
||||
add(new MenuButton("$text.tutorial", group, ()-> control.playMap(world.maps().getMap("tutorial"))));
|
||||
row();
|
||||
|
||||
add(new MenuButton("$text.loadgame", group, ui::showLoadGame));
|
||||
add(new MenuButton("$text.loadgame", group, ui.load::show));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
add(new MenuButton("$text.editor", group, ui::showEditor));
|
||||
add(new MenuButton("$text.editor", group, ui.editor::show));
|
||||
row();
|
||||
}
|
||||
|
||||
add(new MenuButton("$text.settings", group, ui::showPrefs));
|
||||
add(new MenuButton("$text.settings", group, ui.settings::show));
|
||||
row();
|
||||
|
||||
if(!gwt){
|
||||
@@ -61,25 +61,23 @@ public class MenuFragment implements Fragment{
|
||||
defaults().size(120f).pad(5);
|
||||
float isize = 14f*4;
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("$text.play").padTop(4f);
|
||||
new imagebutton("icon-play-2", isize, ui.levels::show).text("$text.play").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tutorial", isize, () -> control.playMap(world.maps().getMap("tutorial"))).text("$text.tutorial").padTop(4f);
|
||||
|
||||
new imagebutton("icon-load", isize, () -> ui.showLoadGame()).text("$text.load").padTop(4f);
|
||||
new imagebutton("icon-load", isize, ui.load::show).text("$text.load").padTop(4f);
|
||||
|
||||
new imagebutton("icon-add", isize, () -> ui.showJoinGame()).text("$text.joingame").padTop(4f);
|
||||
new imagebutton("icon-add", isize, ui.join::show).text("$text.joingame").padTop(4f);
|
||||
|
||||
row();
|
||||
|
||||
new imagebutton("icon-editor", isize, () -> ui.showEditor()).text("$text.editor").padTop(4f);
|
||||
new imagebutton("icon-editor", isize, ui.editor::show).text("$text.editor").padTop(4f);
|
||||
|
||||
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
|
||||
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
|
||||
|
||||
new imagebutton("icon-info", isize, () -> ui.showAbout()).text("$text.about.button").padTop(4f);
|
||||
new imagebutton("icon-info", isize, ui.about::show).text("$text.about.button").padTop(4f);
|
||||
|
||||
new imagebutton("icon-donate", isize, () -> {
|
||||
Mindustry.platforms.openDonations();
|
||||
}).text("$text.donate").padTop(4f);
|
||||
new imagebutton("icon-donate", isize, Mindustry.platforms::openDonations).text("$text.donate").padTop(4f);
|
||||
|
||||
visible(()->GameState.is(State.menu));
|
||||
}}.end();
|
||||
@@ -90,14 +88,10 @@ public class MenuFragment implements Fragment{
|
||||
new table(){{
|
||||
atop().aright();
|
||||
if(Mindustry.hasDiscord){
|
||||
new imagebutton("icon-discord", 30f, ()->{
|
||||
ui.showDiscord();
|
||||
}).margin(14);
|
||||
new imagebutton("icon-discord", 30f, ui.discord::show).margin(14);
|
||||
}
|
||||
if(!Vars.android) {
|
||||
new imagebutton("icon-info", 30f, () -> {
|
||||
ui.showAbout();
|
||||
}).margin(14);
|
||||
new imagebutton("icon-info", 30f, ui.about::show).margin(14);
|
||||
}
|
||||
}}.end().visible(()->GameState.is(State.menu));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PlayerListFragment implements Fragment{
|
||||
}
|
||||
});
|
||||
|
||||
visible(() -> Inputs.keyDown("player_list") && Net.active() && !GameState.is(State.menu)); //TODO move elsewhere?
|
||||
visible(() -> Inputs.keyDown("player_list") && Net.active() && !GameState.is(State.menu));
|
||||
}}.end();
|
||||
|
||||
rebuild();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import io.anuke.mindustry.core.GameState;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
@@ -12,6 +10,8 @@ import io.anuke.ucore.scene.ui.ImageButton;
|
||||
import io.anuke.ucore.scene.ui.Tooltip;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class WeaponFragment implements Fragment{
|
||||
Table weapontable;
|
||||
|
||||
@@ -64,11 +64,8 @@ public class WeaponFragment implements Fragment{
|
||||
tip.setInstant(true);
|
||||
|
||||
button.addListener(tip);
|
||||
|
||||
}
|
||||
|
||||
weapontable.addImageButton("icon-menu", 8*4, ()->{
|
||||
ui.showUpgrades();
|
||||
});
|
||||
weapontable.addImageButton("icon-menu", 8*4, ui.weaponfrag::updateWeapons);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.production.Generator;
|
||||
|
||||
public class PowerLaser extends Generator{
|
||||
public float powerAmount = 0.03f;
|
||||
public Color color = Color.valueOf("e54135");
|
||||
|
||||
public PowerLaser(String name) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Generator extends PowerBlock{
|
||||
|
||||
if(hasLasers){
|
||||
list.add("[powerinfo]Laser tile range: " + laserRange);
|
||||
list.add("[powerinfo]Max power transfer/second: " + Strings.toFixed(powerSpeed * 2, 2));
|
||||
list.add("[powerinfo]Max power transfer/second: " + Strings.toFixed(powerSpeed * 60, 2));
|
||||
}
|
||||
|
||||
if(explosive){
|
||||
|
||||
Reference in New Issue
Block a user