Partial conversion done
This commit is contained in:
@@ -18,7 +18,7 @@ text.players={0} players online
|
|||||||
text.players.single={0} player online
|
text.players.single={0} player online
|
||||||
text.server.kicked.kick=You have been kicked from the server!
|
text.server.kicked.kick=You have been kicked from the server!
|
||||||
text.server.kicked.invalidPassword=Invalid password!
|
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.server.disconnected={0} has disconnected.
|
||||||
text.nohost=Can't host server on a custom map!
|
text.nohost=Can't host server on a custom map!
|
||||||
text.hostserver=Host Server
|
text.hostserver=Host Server
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ public class Control extends Module{
|
|||||||
block.onReset();
|
block.onReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.updateItems();
|
ui.hudfrag.updateItems();
|
||||||
ui.updateWeapons();
|
ui.weaponfrag.updateWeapons();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play(){
|
public void play(){
|
||||||
@@ -265,7 +265,7 @@ public class Control extends Module{
|
|||||||
Arrays.fill(items, 999999999);
|
Arrays.fill(items, 999999999);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.updateItems();
|
ui.hudfrag.updateItems();
|
||||||
|
|
||||||
GameState.set(State.playing);
|
GameState.set(State.playing);
|
||||||
}
|
}
|
||||||
@@ -293,7 +293,7 @@ public class Control extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void playMap(Map map){
|
public void playMap(Map map){
|
||||||
Vars.ui.showLoading();
|
ui.loadfrag.show();
|
||||||
saves.resetSave();
|
saves.resetSave();
|
||||||
|
|
||||||
Timers.run(16, ()->{
|
Timers.run(16, ()->{
|
||||||
@@ -302,7 +302,7 @@ public class Control extends Module{
|
|||||||
play();
|
play();
|
||||||
});
|
});
|
||||||
|
|
||||||
Timers.run(18, ()-> ui.hideLoading());
|
Timers.run(18, ()-> ui.loadfrag.hide());
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameMode getMode(){
|
public GameMode getMode(){
|
||||||
@@ -403,7 +403,7 @@ public class Control extends Module{
|
|||||||
}
|
}
|
||||||
Effects.effect(Fx.coreexplosion, core.worldx(), core.worldy());
|
Effects.effect(Fx.coreexplosion, core.worldx(), core.worldy());
|
||||||
|
|
||||||
Timers.run(60, ()-> ui.showRestart());
|
Timers.run(60, ()-> ui.restart.show());
|
||||||
}
|
}
|
||||||
|
|
||||||
float waveSpacing(){
|
float waveSpacing(){
|
||||||
@@ -602,23 +602,23 @@ public class Control extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(shouldUpdateItems && (Timers.get("updateItems", 8) || GameState.is(State.paused))){
|
if(shouldUpdateItems && (Timers.get("updateItems", 8) || GameState.is(State.paused))){
|
||||||
ui.updateItems();
|
ui.hudfrag.updateItems();
|
||||||
shouldUpdateItems = false;
|
shouldUpdateItems = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GameState.is(State.menu)){
|
if(!GameState.is(State.menu)){
|
||||||
input.update();
|
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);
|
GameState.set(GameState.is(State.playing) ? State.paused : State.playing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.keyTap("menu")){
|
if(Inputs.keyTap("menu")){
|
||||||
if(GameState.is(State.paused)){
|
if(GameState.is(State.paused)){
|
||||||
ui.hideMenu();
|
ui.menu.hide();
|
||||||
GameState.set(State.playing);
|
GameState.set(State.playing);
|
||||||
}else if (!ui.isGameOver()){
|
}else if (!ui.restart.isShown()){
|
||||||
ui.showMenu();
|
ui.menu.show();
|
||||||
GameState.set(State.paused);
|
GameState.set(State.paused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -634,7 +634,7 @@ public class Control extends Module{
|
|||||||
player.heal();
|
player.heal();
|
||||||
player.add();
|
player.add();
|
||||||
Effects.sound("respawn");
|
Effects.sound("respawn");
|
||||||
ui.fadeRespawn(false);
|
ui.hudfrag.fadeRespawn(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ public class NetClient extends Module {
|
|||||||
connecting = true;
|
connecting = true;
|
||||||
gotEntities = false;
|
gotEntities = false;
|
||||||
kicked = false;
|
kicked = false;
|
||||||
|
|
||||||
Gdx.app.postRunnable(() -> {
|
Gdx.app.postRunnable(() -> {
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
Vars.ui.showLoading("$text.connecting.data");
|
Vars.ui.loadfrag.show("$text.connecting.data");
|
||||||
});
|
});
|
||||||
|
|
||||||
ConnectPacket c = new ConnectPacket();
|
ConnectPacket c = new ConnectPacket();
|
||||||
@@ -59,7 +60,7 @@ public class NetClient extends Module {
|
|||||||
Timers.runTask(dataTimeout, () -> {
|
Timers.runTask(dataTimeout, () -> {
|
||||||
if(!gotEntities){
|
if(!gotEntities){
|
||||||
Gdx.app.error("Mindustry", "Failed to load data!");
|
Gdx.app.error("Mindustry", "Failed to load data!");
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
Net.disconnect();
|
Net.disconnect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -69,9 +70,7 @@ public class NetClient extends Module {
|
|||||||
if(kicked) return;
|
if(kicked) return;
|
||||||
|
|
||||||
Gdx.app.postRunnable(() -> {
|
Gdx.app.postRunnable(() -> {
|
||||||
Timers.runFor(3f, () -> {
|
Timers.runFor(3f, Vars.ui.loadfrag::hide);
|
||||||
Vars.ui.hideLoading();
|
|
||||||
});
|
|
||||||
|
|
||||||
GameState.set(State.menu);
|
GameState.set(State.menu);
|
||||||
|
|
||||||
@@ -96,8 +95,8 @@ public class NetClient extends Module {
|
|||||||
|
|
||||||
GameState.set(State.playing);
|
GameState.set(State.playing);
|
||||||
connecting = false;
|
connecting = false;
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
Vars.ui.hideJoinGame();
|
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));
|
Timers.resetTime(packet.time + (float)(TimeUtils.timeSinceMillis(packet.timestamp) / 1000.0 * 60.0));
|
||||||
|
|
||||||
Gdx.app.postRunnable(() -> {
|
Gdx.app.postRunnable(Vars.ui.hudfrag::updateItems);
|
||||||
Vars.ui.updateItems();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Net.handle(EnemySpawnPacket.class, spawn -> {
|
Net.handle(EnemySpawnPacket.class, spawn -> {
|
||||||
@@ -199,7 +196,7 @@ public class NetClient extends Module {
|
|||||||
//TODO shoot effects for enemies, clientside as well as serverside
|
//TODO shoot effects for enemies, clientside as well as serverside
|
||||||
BulletType type = (BulletType) BaseBulletType.getByID(packet.type);
|
BulletType type = (BulletType) BaseBulletType.getByID(packet.type);
|
||||||
Entity owner = Vars.control.enemyGroup.getByID(packet.owner);
|
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 -> {
|
Net.handle(BlockDestroyPacket.class, packet -> {
|
||||||
@@ -217,7 +214,6 @@ public class NetClient extends Module {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Net.handle(BlockSyncPacket.class, packet -> {
|
Net.handle(BlockSyncPacket.class, packet -> {
|
||||||
//TODO implementation, load data...
|
|
||||||
DataInputStream stream = new DataInputStream(packet.stream);
|
DataInputStream stream = new DataInputStream(packet.stream);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -247,13 +243,9 @@ public class NetClient extends Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Net.handle(Player.class, player -> {
|
Net.handle(Player.class, Player::add);
|
||||||
player.add();
|
|
||||||
});
|
|
||||||
|
|
||||||
Net.handle(ChatPacket.class, packet -> {
|
Net.handle(ChatPacket.class, packet -> Gdx.app.postRunnable(() -> Vars.ui.chatfrag.addMessage(packet.name, packet.text)));
|
||||||
Gdx.app.postRunnable(() -> Vars.ui.addChatMessage(packet.name, packet.text));
|
|
||||||
});
|
|
||||||
|
|
||||||
Net.handle(KickPacket.class, packet -> {
|
Net.handle(KickPacket.class, packet -> {
|
||||||
kicked = true;
|
kicked = true;
|
||||||
@@ -280,7 +272,7 @@ public class NetClient extends Module {
|
|||||||
Net.send(packet, SendMode.tcp);
|
Net.send(packet, SendMode.tcp);
|
||||||
|
|
||||||
if(Net.server()){
|
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)){
|
if(Timers.get("syncPlayer", playerSyncTime)){
|
||||||
PositionPacket packet = new PositionPacket();
|
PositionPacket packet = new PositionPacket();
|
||||||
packet.data = Vars.player.getInterpolator().type.write(Vars.player);
|
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;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.utils.IntArray;
|
import com.badlogic.gdx.utils.IntArray;
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
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.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.UCore;
|
import io.anuke.ucore.UCore;
|
||||||
import io.anuke.ucore.core.Effects.Effect;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.entities.Entity;
|
import io.anuke.ucore.entities.Entity;
|
||||||
import io.anuke.ucore.modules.Module;
|
import io.anuke.ucore.modules.Module;
|
||||||
@@ -42,9 +40,7 @@ public class NetServer extends Module{
|
|||||||
|
|
||||||
public NetServer(){
|
public NetServer(){
|
||||||
|
|
||||||
Net.handleServer(Connect.class, connect -> {
|
Net.handleServer(Connect.class, connect -> UCore.log("Connection found: " + connect.addressTCP));
|
||||||
UCore.log("Connection found: " + connect.addressTCP);
|
|
||||||
});
|
|
||||||
|
|
||||||
Net.handleServer(ConnectPacket.class, packet -> {
|
Net.handleServer(ConnectPacket.class, packet -> {
|
||||||
int id = Net.getLastConnection();
|
int id = Net.getLastConnection();
|
||||||
@@ -68,14 +64,11 @@ public class NetServer extends Module{
|
|||||||
|
|
||||||
UCore.log("Packed " + outc.size() + " COMPRESSED bytes of data.");
|
UCore.log("Packed " + outc.size() + " COMPRESSED bytes of data.");
|
||||||
|
|
||||||
//TODO compress and uncompress when sending
|
|
||||||
data.stream = new ByteArrayInputStream(outc.toByteArray());
|
data.stream = new ByteArrayInputStream(outc.toByteArray());
|
||||||
|
|
||||||
Net.sendStream(id, data);
|
Net.sendStream(id, data);
|
||||||
|
|
||||||
Gdx.app.postRunnable(() -> {
|
Gdx.app.postRunnable(() -> {
|
||||||
Vars.ui.showInfo("$text.server.connected");
|
|
||||||
|
|
||||||
EntityDataPacket dp = new EntityDataPacket();
|
EntityDataPacket dp = new EntityDataPacket();
|
||||||
|
|
||||||
Player player = new Player();
|
Player player = new Player();
|
||||||
@@ -94,6 +87,8 @@ public class NetServer extends Module{
|
|||||||
Net.sendExcept(id, player, SendMode.tcp);
|
Net.sendExcept(id, player, SendMode.tcp);
|
||||||
|
|
||||||
Net.sendTo(id, dp, 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){
|
public void handleBullet(BulletType type, Entity owner, float x, float y, float angle, short damage){
|
||||||
BulletPacket packet = new BulletPacket();
|
BulletPacket packet = new BulletPacket();
|
||||||
packet.x = x;
|
packet.x = x;
|
||||||
@@ -281,8 +265,6 @@ public class NetServer extends Module{
|
|||||||
int h = 12;
|
int h = 12;
|
||||||
sendBlockSync(id, x, y, w, h);
|
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);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO finish
|
|
||||||
|
|
||||||
packet.stream = new ByteArrayInputStream(bs.toByteArray());
|
packet.stream = new ByteArrayInputStream(bs.toByteArray());
|
||||||
|
|
||||||
Net.sendStream(client, packet);
|
Net.sendStream(client, packet);
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import static io.anuke.ucore.core.Core.batch;
|
|||||||
import static io.anuke.ucore.core.Core.camera;
|
import static io.anuke.ucore.core.Core.camera;
|
||||||
|
|
||||||
public class Renderer extends RendererModule{
|
public class Renderer extends RendererModule{
|
||||||
private final static int chunksize = 32;
|
|
||||||
private final static float shieldHitDuration = 18f;
|
private final static float shieldHitDuration = 18f;
|
||||||
|
|
||||||
public Surface shadowSurface, shieldSurface, indicatorSurface;
|
public Surface shadowSurface, shieldSurface, indicatorSurface;
|
||||||
@@ -101,7 +100,7 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
//TODO identify the source of this bug
|
//TODO identify the source of this bug
|
||||||
if(control.core == null){
|
if(control.core == null){
|
||||||
ui.showGameError();
|
ui.showError("$text.error.crashmessage");
|
||||||
GameState.set(State.menu);
|
GameState.set(State.menu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -352,13 +351,13 @@ public class Renderer extends RendererModule{
|
|||||||
if(input.breakMode == PlaceMode.holdDelete)
|
if(input.breakMode == PlaceMode.holdDelete)
|
||||||
input.breakMode.draw(tilex, tiley, 0, 0);
|
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(),
|
input.breakMode.draw(control.input.getBlockX(), control.input.getBlockY(),
|
||||||
control.input.getBlockEndX(), control.input.getBlockEndY());
|
control.input.getBlockEndX(), control.input.getBlockEndY());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Vars.ui.getTools().confirming){
|
if(Vars.ui.toolfrag.confirming){
|
||||||
ToolFragment t = Vars.ui.getTools();
|
ToolFragment t = Vars.ui.toolfrag;
|
||||||
PlaceMode.areaDelete.draw(t.px, t.py, t.px2, t.py2);
|
PlaceMode.areaDelete.draw(t.px, t.py, t.px2, t.py2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class Tutorial{
|
|||||||
|
|
||||||
public void buildUI(table table){
|
public void buildUI(table table){
|
||||||
|
|
||||||
//TODO maybe align it to the bottom?
|
|
||||||
table.atop();
|
table.atop();
|
||||||
|
|
||||||
new table("pane"){{
|
new table("pane"){{
|
||||||
@@ -395,7 +394,7 @@ public class Tutorial{
|
|||||||
void onSwitch(){
|
void onSwitch(){
|
||||||
if(!Vars.control.getWeapons().contains(Weapon.multigun, true)){
|
if(!Vars.control.getWeapons().contains(Weapon.multigun, true)){
|
||||||
Vars.control.getWeapons().add(Weapon.multigun);
|
Vars.control.getWeapons().add(Weapon.multigun);
|
||||||
Vars.ui.updateWeapons();
|
Vars.ui.weaponfrag.updateWeapons();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import io.anuke.ucore.function.Consumer;
|
|||||||
import io.anuke.ucore.function.Listenable;
|
import io.anuke.ucore.function.Listenable;
|
||||||
import io.anuke.ucore.modules.SceneModule;
|
import io.anuke.ucore.modules.SceneModule;
|
||||||
import io.anuke.ucore.scene.Skin;
|
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.build;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
import io.anuke.ucore.scene.ui.TextField;
|
import io.anuke.ucore.scene.ui.TextField;
|
||||||
@@ -26,7 +27,7 @@ import static io.anuke.mindustry.Vars.control;
|
|||||||
import static io.anuke.ucore.scene.actions.Actions.*;
|
import static io.anuke.ucore.scene.actions.Actions.*;
|
||||||
|
|
||||||
public class UI extends SceneModule{
|
public class UI extends SceneModule{
|
||||||
public Dialog about, restart, levels, upgrades, load, discord, join, menu, prefs, keys, editor;
|
public Dialog about, restart, levels, upgrades, load, discord, join, menu, prefs, keys, editor, host;
|
||||||
|
|
||||||
public final MenuFragment menufrag = new MenuFragment();
|
public final MenuFragment menufrag = new MenuFragment();
|
||||||
public final ToolFragment toolfrag = new ToolFragment();
|
public final ToolFragment toolfrag = new ToolFragment();
|
||||||
@@ -37,6 +38,7 @@ public class UI extends SceneModule{
|
|||||||
public final PlayerListFragment listfrag = new PlayerListFragment();
|
public final PlayerListFragment listfrag = new PlayerListFragment();
|
||||||
public final BackgroundFragment backfrag = new BackgroundFragment();
|
public final BackgroundFragment backfrag = new BackgroundFragment();
|
||||||
public final LoadingFragment loadfrag = new LoadingFragment();
|
public final LoadingFragment loadfrag = new LoadingFragment();
|
||||||
|
public final BlockConfigFragment configfrag = new BlockConfigFragment();
|
||||||
|
|
||||||
public UI() {
|
public UI() {
|
||||||
Dialog.setShowAction(()-> sequence(
|
Dialog.setShowAction(()-> sequence(
|
||||||
@@ -126,16 +128,18 @@ public class UI extends SceneModule{
|
|||||||
load = new LoadDialog();
|
load = new LoadDialog();
|
||||||
upgrades = new UpgradeDialog();
|
upgrades = new UpgradeDialog();
|
||||||
levels = new LevelDialog();
|
levels = new LevelDialog();
|
||||||
prefs = new MindustrySettingsDialog();
|
prefs = new SettingsMenuDialog();
|
||||||
menu = new MenuDialog();
|
menu = new MenuDialog();
|
||||||
keys = new MindustryKeybindDialog();
|
keys = new ControlsDialog();
|
||||||
about = new AboutDialog();
|
about = new AboutDialog();
|
||||||
|
host = new HostDialog();
|
||||||
|
|
||||||
build.begin(scene);
|
build.begin(scene);
|
||||||
|
|
||||||
backfrag.build();
|
backfrag.build();
|
||||||
weaponfrag.build();
|
weaponfrag.build();
|
||||||
hudfrag.build();
|
hudfrag.build();
|
||||||
|
configfrag.build();
|
||||||
menufrag.build();
|
menufrag.build();
|
||||||
placefrag.build();
|
placefrag.build();
|
||||||
toolfrag.build();
|
toolfrag.build();
|
||||||
@@ -165,6 +169,10 @@ public class UI extends SceneModule{
|
|||||||
showTextInput(title, text, def, (field, c) -> true, confirmed);
|
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){
|
public void showError(String text){
|
||||||
new Dialog("$text.error.title", "dialog"){{
|
new Dialog("$text.error.title", "dialog"){{
|
||||||
content().margin(15).add(text);
|
content().margin(15).add(text);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class World extends Module{
|
|||||||
|
|
||||||
public Tile tile(int x, int y){
|
public Tile tile(int x, int y){
|
||||||
if(tiles == null){
|
if(tiles == null){
|
||||||
ui.showGameError();
|
ui.showError("$text.error.crashmessage");
|
||||||
GameState.set(State.menu);
|
GameState.set(State.menu);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class Player extends DestructibleEntity implements Syncable{
|
|||||||
//TODO respawning doesn't work for multiplayer
|
//TODO respawning doesn't work for multiplayer
|
||||||
if(isLocal) {
|
if(isLocal) {
|
||||||
Vars.control.setRespawnTime(respawnduration);
|
Vars.control.setRespawnTime(respawnduration);
|
||||||
ui.fadeRespawn(true);
|
ui.hudfrag.fadeRespawn(true);
|
||||||
}else{
|
}else{
|
||||||
Timers.run(respawnduration, () -> {
|
Timers.run(respawnduration, () -> {
|
||||||
heal();
|
heal();
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.core.Inputs;
|
import io.anuke.ucore.core.Inputs;
|
||||||
import io.anuke.ucore.core.Settings;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
@@ -59,7 +58,6 @@ public class AndroidInput extends InputHandler{
|
|||||||
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||||
if(ui.hasMouse()) return false;
|
if(ui.hasMouse()) return false;
|
||||||
|
|
||||||
ui.hideTooltip();
|
|
||||||
lmousex = screenX;
|
lmousex = screenX;
|
||||||
lmousey = screenY;
|
lmousey = screenY;
|
||||||
|
|
||||||
@@ -77,9 +75,9 @@ public class AndroidInput extends InputHandler{
|
|||||||
if(cursor != null && !ui.hasMouse(screenX, screenY)){
|
if(cursor != null && !ui.hasMouse(screenX, screenY)){
|
||||||
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
||||||
if(linked != null && linked.block() instanceof Configurable){
|
if(linked != null && linked.block() instanceof Configurable){
|
||||||
ui.showConfig(linked);
|
ui.configfrag.showConfig(linked);
|
||||||
}else if(!ui.hasConfigMouse()){
|
}else if(!ui.configfrag.hasConfigMouse()){
|
||||||
ui.hideConfig();
|
ui.configfrag.hideConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +115,6 @@ public class AndroidInput extends InputHandler{
|
|||||||
public void update(){
|
public void update(){
|
||||||
enableHold = breakMode == PlaceMode.holdDelete;
|
enableHold = breakMode == PlaceMode.holdDelete;
|
||||||
|
|
||||||
float scl = Settings.getInt("sensitivity")/100f * Unit.dp.scl(1f);
|
|
||||||
float xa = Inputs.getAxis("move_x");
|
float xa = Inputs.getAxis("move_x");
|
||||||
float ya = Inputs.getAxis("move_y");
|
float ya = Inputs.getAxis("move_y");
|
||||||
if(Math.abs(xa) < Vars.controllerMin) xa = 0;
|
if(Math.abs(xa) < Vars.controllerMin) xa = 0;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
|
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
|
||||||
if(Inputs.keyTap("weapon_" + i)){
|
if(Inputs.keyTap("weapon_" + i)){
|
||||||
player.weapon = control.getWeapons().get(i - 1);
|
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()){
|
if(Inputs.keyTap("select") && cursor != null && !ui.hasMouse()){
|
||||||
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
||||||
if(linked != null && linked.block() instanceof Configurable){
|
if(linked != null && linked.block() instanceof Configurable){
|
||||||
ui.showConfig(linked);
|
ui.configfrag.showConfig(linked);
|
||||||
}else if(!ui.hasConfigMouse()){
|
}else if(!ui.configfrag.hasConfigMouse()){
|
||||||
ui.hideConfig();
|
ui.configfrag.hideConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.keyTap("break")){
|
if(Inputs.keyTap("break")){
|
||||||
ui.hideConfig();
|
ui.configfrag.hideConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.keyRelease("break")){
|
if(Inputs.keyRelease("break")){
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ public class Maps implements Disposable{
|
|||||||
saveCustomMap(map);
|
saveCustomMap(map);
|
||||||
Vars.ui.reloadLevels();
|
Vars.ui.reloadLevels();
|
||||||
//TODO reload map dialog
|
//TODO reload map dialog
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveMaps(Array<Map> array, FileHandle file){
|
public void saveMaps(Array<Map> array, FileHandle file){
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class Save13 extends SaveFileVersion {
|
|||||||
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
Vars.control.addWeapon(Weapon.values()[stream.readByte()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vars.ui.updateWeapons();
|
Vars.ui.weaponfrag.updateWeapons();
|
||||||
|
|
||||||
//inventory
|
//inventory
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ public class Save13 extends SaveFileVersion {
|
|||||||
Vars.control.getItems()[item.id] = amount;
|
Vars.control.getItems()[item.id] = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vars.ui.updateItems();
|
Vars.ui.hudfrag.updateItems();
|
||||||
|
|
||||||
//enemies
|
//enemies
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package io.anuke.mindustry.mapeditor;
|
package io.anuke.mindustry.mapeditor;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
import io.anuke.mindustry.ui.dialogs.FileChooser;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
@@ -19,12 +16,17 @@ import io.anuke.ucore.core.Core;
|
|||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Pixmaps;
|
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.*;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class MapEditorDialog extends Dialog{
|
public class MapEditorDialog extends Dialog{
|
||||||
private MapEditor editor;
|
private MapEditor editor;
|
||||||
private MapView view;
|
private MapView view;
|
||||||
@@ -39,11 +41,12 @@ public class MapEditorDialog extends Dialog{
|
|||||||
|
|
||||||
public MapEditorDialog(){
|
public MapEditorDialog(){
|
||||||
super("$text.mapeditor", "dialog");
|
super("$text.mapeditor", "dialog");
|
||||||
|
editor = new MapEditor();
|
||||||
dialog = new MapGenerateDialog(editor);
|
dialog = new MapGenerateDialog(editor);
|
||||||
view = new MapView(editor);
|
view = new MapView(editor);
|
||||||
|
|
||||||
openFile = new FileChooser("$text.loadimage", FileChooser.pngFilter, true, file -> {
|
openFile = new FileChooser("$text.loadimage", FileChooser.pngFilter, true, file -> {
|
||||||
Vars.ui.showLoading();
|
Vars.ui.loadfrag.show();
|
||||||
Timers.run(3f, () -> {
|
Timers.run(3f, () -> {
|
||||||
try{
|
try{
|
||||||
Pixmap pixmap = new Pixmap(file);
|
Pixmap pixmap = new Pixmap(file);
|
||||||
@@ -57,7 +60,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
Vars.ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
Vars.ui.showError(Bundles.format("text.editor.errorimageload", Strings.parseException(e, false)));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,7 +69,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
file = file.parent().child(file.nameWithoutExtension() + ".png");
|
file = file.parent().child(file.nameWithoutExtension() + ".png");
|
||||||
}
|
}
|
||||||
FileHandle result = file;
|
FileHandle result = file;
|
||||||
Vars.ui.showLoading();
|
Vars.ui.loadfrag.show();
|
||||||
Timers.run(3f, () -> {
|
Timers.run(3f, () -> {
|
||||||
try{
|
try{
|
||||||
Pixmaps.write(editor.pixmap(), result);
|
Pixmaps.write(editor.pixmap(), result);
|
||||||
@@ -74,13 +77,13 @@ public class MapEditorDialog extends Dialog{
|
|||||||
Vars.ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
Vars.ui.showError(Bundles.format("text.editor.errorimagesave", Strings.parseException(e, false)));
|
||||||
if(!Vars.android) e.printStackTrace();
|
if(!Vars.android) e.printStackTrace();
|
||||||
}
|
}
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
loadDialog = new MapLoadDialog(map -> {
|
loadDialog = new MapLoadDialog(map -> {
|
||||||
saveDialog.setFieldText(map.name);
|
saveDialog.setFieldText(map.name);
|
||||||
Vars.ui.showLoading();
|
Vars.ui.loadfrag.show();
|
||||||
|
|
||||||
Timers.run(3f, () -> {
|
Timers.run(3f, () -> {
|
||||||
Map copy = new Map();
|
Map copy = new Map();
|
||||||
@@ -89,7 +92,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
copy.pixmap = Pixmaps.copy(map.pixmap);
|
copy.pixmap = Pixmaps.copy(map.pixmap);
|
||||||
copy.texture = new Texture(copy.pixmap);
|
copy.texture = new Texture(copy.pixmap);
|
||||||
editor.beginEdit(copy);
|
editor.beginEdit(copy);
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -97,28 +100,28 @@ public class MapEditorDialog extends Dialog{
|
|||||||
resizeDialog = new MapResizeDialog(editor, (x, y) -> {
|
resizeDialog = new MapResizeDialog(editor, (x, y) -> {
|
||||||
Pixmap pix = editor.pixmap();
|
Pixmap pix = editor.pixmap();
|
||||||
if(!(pix.getWidth() == x && pix.getHeight() == y)){
|
if(!(pix.getWidth() == x && pix.getHeight() == y)){
|
||||||
Vars.ui.showLoading();
|
Vars.ui.loadfrag.show();
|
||||||
Timers.run(10f, ()->{
|
Timers.run(10f, ()->{
|
||||||
editor.resize(x, y);
|
editor.resize(x, y);
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
saveDialog = new MapSaveDialog(name -> {
|
saveDialog = new MapSaveDialog(name -> {
|
||||||
Vars.ui.showLoading();
|
Vars.ui.loadfrag.show();
|
||||||
if(verifyMap()){
|
if(verifyMap()){
|
||||||
saved = true;
|
saved = true;
|
||||||
editor.getMap().name = name;
|
editor.getMap().name = name;
|
||||||
Timers.run(10f, () -> {
|
Timers.run(10f, () -> {
|
||||||
Vars.world.maps().saveAndReload(editor.getMap(), editor.pixmap());
|
Vars.world.maps().saveAndReload(editor.getMap(), editor.pixmap());
|
||||||
loadDialog.rebuild();
|
loadDialog.rebuild();
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import com.badlogic.gdx.utils.Align;
|
|||||||
import io.anuke.ucore.scene.ui.Image;
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
import io.anuke.ucore.scene.ui.KeybindDialog;
|
import io.anuke.ucore.scene.ui.KeybindDialog;
|
||||||
|
|
||||||
public class MindustryKeybindDialog extends KeybindDialog{
|
public class ControlsDialog extends KeybindDialog{
|
||||||
|
|
||||||
public MindustryKeybindDialog(){
|
public ControlsDialog(){
|
||||||
setDialog();
|
setDialog();
|
||||||
|
|
||||||
setFillParent(true);
|
setFillParent(true);
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
public class HostDialog {
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
public class HostDialog extends Dialog{
|
||||||
|
|
||||||
|
public HostDialog(){
|
||||||
|
super("$text.hostserver", "dialog");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> {
|
showTextInput("$text.hostserver", "$text.server.port", Vars.port + "", new DigitsOnlyFilter(), text -> {
|
||||||
int result = Strings.parseInt(text);
|
int result = Strings.parseInt(text);
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void connect(String ip, int port){
|
void connect(String ip, int port){
|
||||||
Vars.ui.showLoading("$text.connecting");
|
Vars.ui.loadfrag.show("$text.connecting");
|
||||||
|
|
||||||
Timers.runTask(2f, () -> {
|
Timers.runTask(2f, () -> {
|
||||||
try{
|
try{
|
||||||
@@ -128,7 +128,7 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
error = Strings.parseException(e, false);
|
error = Strings.parseException(e, false);
|
||||||
}
|
}
|
||||||
Vars.ui.showError(Bundles.format("text.connectfail", error));
|
Vars.ui.showError(Bundles.format("text.connectfail", error));
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,18 +161,18 @@ public class LoadDialog extends FloatingDialog{
|
|||||||
public void modifyButton(TextButton button, SaveSlot slot){
|
public void modifyButton(TextButton button, SaveSlot slot){
|
||||||
button.clicked(() -> {
|
button.clicked(() -> {
|
||||||
if(!button.childrenPressed()){
|
if(!button.childrenPressed()){
|
||||||
Vars.ui.showLoading();
|
Vars.ui.loadfrag.show();
|
||||||
|
|
||||||
Timers.runTask(3f, () -> {
|
Timers.runTask(3f, () -> {
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
hide();
|
hide();
|
||||||
try{
|
try{
|
||||||
slot.load();
|
slot.load();
|
||||||
GameState.set(State.playing);
|
GameState.set(State.playing);
|
||||||
Vars.ui.hideMenu();
|
Vars.ui.menu.hide();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Vars.ui.hideMenu();
|
Vars.ui.menu.hide();
|
||||||
GameState.set(State.menu);
|
GameState.set(State.menu);
|
||||||
Vars.control.reset();
|
Vars.control.reset();
|
||||||
Vars.ui.showError("$text.save.corrupted");
|
Vars.ui.showError("$text.save.corrupted");
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ public class MenuDialog extends FloatingDialog{
|
|||||||
});
|
});
|
||||||
|
|
||||||
content().row();
|
content().row();
|
||||||
content().addButton("$text.settings", () -> {
|
content().addButton("$text.settings", ui.prefs::show);
|
||||||
ui.showPrefs();
|
|
||||||
});
|
|
||||||
|
|
||||||
content().row();
|
content().row();
|
||||||
content().addButton("$text.savegame", () -> {
|
content().addButton("$text.savegame", () -> {
|
||||||
@@ -61,7 +59,7 @@ public class MenuDialog extends FloatingDialog{
|
|||||||
if(Vars.world.getMap().custom){
|
if(Vars.world.getMap().custom){
|
||||||
ui.showError("$text.nohost");
|
ui.showError("$text.nohost");
|
||||||
}else {
|
}else {
|
||||||
ui.showHostServer();
|
ui.host.show();
|
||||||
}
|
}
|
||||||
}).disabled(b -> Net.active());
|
}).disabled(b -> Net.active());
|
||||||
|
|
||||||
@@ -89,19 +87,19 @@ public class MenuDialog extends FloatingDialog{
|
|||||||
GameState.set(State.playing);
|
GameState.set(State.playing);
|
||||||
}).text("$text.back").padTop(4f);
|
}).text("$text.back").padTop(4f);
|
||||||
|
|
||||||
new imagebutton("icon-tools", isize, () -> ui.showPrefs()).text("$text.settings").padTop(4f);
|
new imagebutton("icon-tools", isize, ui.prefs::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();
|
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, () -> {
|
new imagebutton("icon-host", isize, () -> {
|
||||||
if(Vars.world.getMap().custom){
|
if(Vars.world.getMap().custom){
|
||||||
ui.showError("$text.nohost");
|
ui.showError("$text.nohost");
|
||||||
}else {
|
}else {
|
||||||
ui.showHostServer();
|
ui.host.show();
|
||||||
}
|
}
|
||||||
}).text("$text.host")
|
}).text("$text.host")
|
||||||
.disabled(b -> Net.active()).padTop(4f);
|
.disabled(b -> Net.active()).padTop(4f);
|
||||||
@@ -128,15 +126,14 @@ public class MenuDialog extends FloatingDialog{
|
|||||||
if(Vars.control.getSaves().getCurrent() == null ||
|
if(Vars.control.getSaves().getCurrent() == null ||
|
||||||
!Vars.control.getSaves().getCurrent().isAutosave()) return;
|
!Vars.control.getSaves().getCurrent().isAutosave()) return;
|
||||||
|
|
||||||
Vars.ui.showLoading("$text.saveload");
|
Vars.ui.loadfrag.show("$text.saveload");
|
||||||
|
|
||||||
Timers.runTask(5f, () -> {
|
Timers.runTask(5f, () -> {
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
try{
|
try{
|
||||||
Vars.control.getSaves().getCurrent().save();
|
Vars.control.getSaves().getCurrent().save();
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
e = (e.getCause() == null ? e : e.getCause());
|
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());
|
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());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ public class SaveDialog extends LoadDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
slots.row();
|
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.ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {
|
||||||
Vars.control.getSaves().addSave(text);
|
Vars.control.getSaves().addSave(text);
|
||||||
setup();
|
setup();
|
||||||
});
|
})
|
||||||
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -33,19 +33,17 @@ public class SaveDialog extends LoadDialog{
|
|||||||
button.clicked(() -> {
|
button.clicked(() -> {
|
||||||
if(button.childrenPressed()) return;
|
if(button.childrenPressed()) return;
|
||||||
|
|
||||||
Vars.ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> {
|
Vars.ui.showConfirm("$text.overwrite", "$text.save.overwrite", () -> save(slot));
|
||||||
save(slot);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void save(SaveSlot slot){
|
void save(SaveSlot slot){
|
||||||
|
|
||||||
Vars.ui.showLoading("$text.saveload");
|
Vars.ui.loadfrag.show("$text.saveload");
|
||||||
|
|
||||||
Timers.runTask(5f, () -> {
|
Timers.runTask(5f, () -> {
|
||||||
hide();
|
hide();
|
||||||
Vars.ui.hideLoading();
|
Vars.ui.loadfrag.hide();
|
||||||
try{
|
try{
|
||||||
slot.save();
|
slot.save();
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.renderer;
|
import static io.anuke.mindustry.Vars.renderer;
|
||||||
|
|
||||||
public class MindustrySettingsDialog extends SettingsDialog{
|
public class SettingsMenuDialog extends SettingsDialog{
|
||||||
public SettingsTable graphics;
|
public SettingsTable graphics;
|
||||||
public SettingsTable game;
|
public SettingsTable game;
|
||||||
public SettingsTable sound;
|
public SettingsTable sound;
|
||||||
@@ -30,7 +30,7 @@ public class MindustrySettingsDialog extends SettingsDialog{
|
|||||||
private boolean built = false;
|
private boolean built = false;
|
||||||
private boolean wasPaused;
|
private boolean wasPaused;
|
||||||
|
|
||||||
public MindustrySettingsDialog(){
|
public SettingsMenuDialog(){
|
||||||
setStyle(Core.skin.get("dialog", WindowStyle.class));
|
setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||||
|
|
||||||
hidden(()->{
|
hidden(()->{
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
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.Tooltip;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
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{
|
public class UpgradeDialog extends FloatingDialog{
|
||||||
boolean wasPaused = false;
|
boolean wasPaused = false;
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
if(control.hasWeapon(weapon)){
|
if(control.hasWeapon(weapon)){
|
||||||
button.setDisabled(true);
|
button.setDisabled(true);
|
||||||
button.setColor(Color.GRAY);
|
button.setColor(Color.GRAY);
|
||||||
}else if(!Vars.control.hasItems(weapon.requirements)){
|
}else if(!control.hasItems(weapon.requirements)){
|
||||||
button.setDisabled(true);
|
button.setDisabled(true);
|
||||||
}else{
|
}else{
|
||||||
button.setDisabled(false);
|
button.setDisabled(false);
|
||||||
@@ -92,7 +92,7 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
ItemStack[] req = weapon.requirements;
|
ItemStack[] req = weapon.requirements;
|
||||||
for(ItemStack s : req){
|
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.addImage(Draw.region("icon-" + s.item.name)).padRight(3).size(8*2);
|
||||||
reqtable.add(
|
reqtable.add(
|
||||||
(amount >= s.amount ? "" : "[RED]")
|
(amount >= s.amount ? "" : "[RED]")
|
||||||
@@ -114,7 +114,7 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
|
|
||||||
run.listen();
|
run.listen();
|
||||||
|
|
||||||
Tooltip tip = new Tooltip(tiptable, run);
|
Tooltip<Table> tip = new Tooltip<>(tiptable, run);
|
||||||
|
|
||||||
tip.setInstant(true);
|
tip.setInstant(true);
|
||||||
|
|
||||||
@@ -123,9 +123,9 @@ public class UpgradeDialog extends FloatingDialog{
|
|||||||
button.clicked(()->{
|
button.clicked(()->{
|
||||||
if(button.isDisabled()) return;
|
if(button.isDisabled()) return;
|
||||||
|
|
||||||
Vars.control.removeItems(weapon.requirements);
|
control.removeItems(weapon.requirements);
|
||||||
control.addWeapon(weapon);
|
control.addWeapon(weapon);
|
||||||
ui.updateWeapons();
|
ui.weaponfrag.updateWeapons();
|
||||||
run.listen();
|
run.listen();
|
||||||
Effects.sound("purchase");
|
Effects.sound("purchase");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ public class HudFragment implements Fragment{
|
|||||||
defaults().size(dsize).left();
|
defaults().size(dsize).left();
|
||||||
float isize = 40;
|
float isize = 40;
|
||||||
|
|
||||||
menu = new imagebutton("icon-menu", isize, ()->{
|
menu = new imagebutton("icon-menu", isize, ui.menu::show).get();
|
||||||
ui.showMenu();
|
|
||||||
}).get();
|
|
||||||
|
|
||||||
flip = new imagebutton("icon-arrow-up", isize, ()->{
|
flip = new imagebutton("icon-arrow-up", isize, ()->{
|
||||||
if(wavetable.getActions().size != 0) return;
|
if(wavetable.getActions().size != 0) return;
|
||||||
|
|||||||
@@ -25,26 +25,26 @@ public class MenuFragment implements Fragment{
|
|||||||
float scale = 4f;
|
float scale = 4f;
|
||||||
defaults().size(100*scale, 21*scale).pad(-10f);
|
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();
|
row();
|
||||||
|
|
||||||
if(!gwt){
|
if(!gwt){
|
||||||
add(new MenuButton("$text.joingame", group, ui::showJoinGame));
|
add(new MenuButton("$text.joingame", group, ui.join::show));
|
||||||
row();
|
row();
|
||||||
}
|
}
|
||||||
|
|
||||||
add(new MenuButton("$text.tutorial", group, ()-> control.playMap(world.maps().getMap("tutorial"))));
|
add(new MenuButton("$text.tutorial", group, ()-> control.playMap(world.maps().getMap("tutorial"))));
|
||||||
row();
|
row();
|
||||||
|
|
||||||
add(new MenuButton("$text.loadgame", group, ui::showLoadGame));
|
add(new MenuButton("$text.loadgame", group, ui.load::show));
|
||||||
row();
|
row();
|
||||||
|
|
||||||
if(!gwt){
|
if(!gwt){
|
||||||
add(new MenuButton("$text.editor", group, ui::showEditor));
|
add(new MenuButton("$text.editor", group, ui.editor::show));
|
||||||
row();
|
row();
|
||||||
}
|
}
|
||||||
|
|
||||||
add(new MenuButton("$text.settings", group, ui::showPrefs));
|
add(new MenuButton("$text.settings", group, ui.prefs::show));
|
||||||
row();
|
row();
|
||||||
|
|
||||||
if(!gwt){
|
if(!gwt){
|
||||||
@@ -61,25 +61,23 @@ public class MenuFragment implements Fragment{
|
|||||||
defaults().size(120f).pad(5);
|
defaults().size(120f).pad(5);
|
||||||
float isize = 14f*4;
|
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-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();
|
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.prefs::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, () -> {
|
new imagebutton("icon-donate", isize, Mindustry.platforms::openDonations).text("$text.donate").padTop(4f);
|
||||||
Mindustry.platforms.openDonations();
|
|
||||||
}).text("$text.donate").padTop(4f);
|
|
||||||
|
|
||||||
visible(()->GameState.is(State.menu));
|
visible(()->GameState.is(State.menu));
|
||||||
}}.end();
|
}}.end();
|
||||||
@@ -90,14 +88,10 @@ public class MenuFragment implements Fragment{
|
|||||||
new table(){{
|
new table(){{
|
||||||
atop().aright();
|
atop().aright();
|
||||||
if(Mindustry.hasDiscord){
|
if(Mindustry.hasDiscord){
|
||||||
new imagebutton("icon-discord", 30f, ()->{
|
new imagebutton("icon-discord", 30f, ui.discord::show).margin(14);
|
||||||
ui.showDiscord();
|
|
||||||
}).margin(14);
|
|
||||||
}
|
}
|
||||||
if(!Vars.android) {
|
if(!Vars.android) {
|
||||||
new imagebutton("icon-info", 30f, () -> {
|
new imagebutton("icon-info", 30f, ui.about::show).margin(14);
|
||||||
ui.showAbout();
|
|
||||||
}).margin(14);
|
|
||||||
}
|
}
|
||||||
}}.end().visible(()->GameState.is(State.menu));
|
}}.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();
|
}}.end();
|
||||||
|
|
||||||
rebuild();
|
rebuild();
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
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.Tooltip;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class WeaponFragment implements Fragment{
|
public class WeaponFragment implements Fragment{
|
||||||
Table weapontable;
|
Table weapontable;
|
||||||
|
|
||||||
@@ -64,11 +64,8 @@ public class WeaponFragment implements Fragment{
|
|||||||
tip.setInstant(true);
|
tip.setInstant(true);
|
||||||
|
|
||||||
button.addListener(tip);
|
button.addListener(tip);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
weapontable.addImageButton("icon-menu", 8*4, ()->{
|
weapontable.addImageButton("icon-menu", 8*4, ui.weaponfrag::updateWeapons);
|
||||||
ui.showUpgrades();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.production.Generator;
|
import io.anuke.mindustry.world.blocks.types.production.Generator;
|
||||||
|
|
||||||
public class PowerLaser extends Generator{
|
public class PowerLaser extends Generator{
|
||||||
public float powerAmount = 0.03f;
|
|
||||||
public Color color = Color.valueOf("e54135");
|
public Color color = Color.valueOf("e54135");
|
||||||
|
|
||||||
public PowerLaser(String name) {
|
public PowerLaser(String name) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class Generator extends PowerBlock{
|
|||||||
|
|
||||||
if(hasLasers){
|
if(hasLasers){
|
||||||
list.add("[powerinfo]Laser tile range: " + laserRange);
|
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){
|
if(explosive){
|
||||||
|
|||||||
Reference in New Issue
Block a user