Partial conversion done
This commit is contained in:
@@ -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.menu.hide();
|
||||
GameState.set(State.playing);
|
||||
}else if (!ui.isGameOver()){
|
||||
ui.showMenu();
|
||||
}else if (!ui.restart.isShown()){
|
||||
ui.menu.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;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.function.Listenable;
|
||||
import io.anuke.ucore.modules.SceneModule;
|
||||
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.ui.Dialog;
|
||||
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.*;
|
||||
|
||||
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 ToolFragment toolfrag = new ToolFragment();
|
||||
@@ -37,6 +38,7 @@ public class UI extends SceneModule{
|
||||
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(
|
||||
@@ -126,16 +128,18 @@ public class UI extends SceneModule{
|
||||
load = new LoadDialog();
|
||||
upgrades = new UpgradeDialog();
|
||||
levels = new LevelDialog();
|
||||
prefs = new MindustrySettingsDialog();
|
||||
prefs = new SettingsMenuDialog();
|
||||
menu = new MenuDialog();
|
||||
keys = new MindustryKeybindDialog();
|
||||
keys = new ControlsDialog();
|
||||
about = new AboutDialog();
|
||||
host = new HostDialog();
|
||||
|
||||
build.begin(scene);
|
||||
|
||||
backfrag.build();
|
||||
weaponfrag.build();
|
||||
hudfrag.build();
|
||||
configfrag.build();
|
||||
menufrag.build();
|
||||
placefrag.build();
|
||||
toolfrag.build();
|
||||
@@ -165,6 +169,10 @@ 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).add(text);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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")){
|
||||
|
||||
@@ -92,6 +92,7 @@ public class Maps implements Disposable{
|
||||
saveCustomMap(map);
|
||||
Vars.ui.reloadLevels();
|
||||
//TODO reload map dialog
|
||||
|
||||
}
|
||||
|
||||
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.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
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
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.dialogs.FileChooser;
|
||||
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.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;
|
||||
@@ -39,11 +41,12 @@ public class MapEditorDialog extends Dialog{
|
||||
|
||||
public MapEditorDialog(){
|
||||
super("$text.mapeditor", "dialog");
|
||||
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);
|
||||
@@ -57,7 +60,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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -66,7 +69,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);
|
||||
@@ -74,13 +77,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();
|
||||
@@ -89,7 +92,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();
|
||||
});
|
||||
});
|
||||
@@ -97,28 +100,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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -1,6 +1,14 @@
|
||||
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 -> {
|
||||
int result = Strings.parseInt(text);
|
||||
|
||||
@@ -105,7 +105,7 @@ 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{
|
||||
@@ -128,7 +128,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();
|
||||
}
|
||||
|
||||
@@ -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.menu.hide();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
Vars.ui.hideMenu();
|
||||
Vars.ui.menu.hide();
|
||||
GameState.set(State.menu);
|
||||
Vars.control.reset();
|
||||
Vars.ui.showError("$text.save.corrupted");
|
||||
|
||||
@@ -41,9 +41,7 @@ public class MenuDialog extends FloatingDialog{
|
||||
});
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.settings", () -> {
|
||||
ui.showPrefs();
|
||||
});
|
||||
content().addButton("$text.settings", ui.prefs::show);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.savegame", () -> {
|
||||
@@ -61,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());
|
||||
|
||||
@@ -89,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.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();
|
||||
|
||||
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);
|
||||
@@ -128,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());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,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
|
||||
@@ -33,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){
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.renderer;
|
||||
|
||||
public class MindustrySettingsDialog extends SettingsDialog{
|
||||
public class SettingsMenuDialog extends SettingsDialog{
|
||||
public SettingsTable graphics;
|
||||
public SettingsTable game;
|
||||
public SettingsTable sound;
|
||||
@@ -30,7 +30,7 @@ public class MindustrySettingsDialog extends SettingsDialog{
|
||||
private boolean built = false;
|
||||
private boolean wasPaused;
|
||||
|
||||
public MindustrySettingsDialog(){
|
||||
public SettingsMenuDialog(){
|
||||
setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
hidden(()->{
|
||||
@@ -1,10 +1,7 @@
|
||||
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");
|
||||
});
|
||||
|
||||
@@ -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.menu::show).get();
|
||||
|
||||
flip = new imagebutton("icon-arrow-up", isize, ()->{
|
||||
if(wavetable.getActions().size != 0) return;
|
||||
|
||||
@@ -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.prefs::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.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, () -> {
|
||||
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