New sector dialog done

This commit is contained in:
Anuken 2018-11-04 00:09:25 -04:00
commit 64f2ee67b2
39 changed files with 1221 additions and 1199 deletions

View file

@ -36,11 +36,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import static io.anuke.mindustry.Vars.*;
@ -55,17 +51,6 @@ public class AndroidLauncher extends PatchedAndroidApplication{
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
config.useImmersiveMode = true;
Platform.instance = new Platform(){
DateFormat format = SimpleDateFormat.getDateTimeInstance();
@Override
public String format(Date date){
return format.format(date);
}
@Override
public String format(int number){
return NumberFormat.getIntegerInstance().format(number);
}
@Override
public void addDialog(TextField field, int length){
@ -133,6 +118,7 @@ public class AndroidLauncher extends PatchedAndroidApplication{
return true;
}
};
try{
ProviderInstaller.installIfNeeded(this);
}catch(GooglePlayServicesRepairableException e){

View file

@ -25,7 +25,7 @@ allprojects {
appName = 'Mindustry'
gdxVersion = '1.9.8'
roboVMVersion = '2.3.0'
uCoreVersion = '7a77659cc5bb22c586d73cde6e21b854962e7f64'
uCoreVersion = 'f5ae8c0d58b6b7b42e95e57114220b11beb43fb3'
getVersionString = {
String buildVersion = getBuildVersion()

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 B

After

Width:  |  Height:  |  Size: 194 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

View file

@ -53,7 +53,7 @@ text.mission.complete.body = Sector {0},{1} has been conquered.
text.mission.wave = Survive[accent] {0}/{1} []waves\nWave in {2}
text.mission.wave.enemies = Survive[accent] {0}/{1} []waves\n{2} Enemies
text.mission.wave.enemy = Survive[accent] {0}/{1} []waves\n{2} Enemy
text.mission.wave.menu = Survive[accent] {0} []waves
text.mission.wave.menu = Survive[accent] {0}[] waves
text.mission.battle = Destroy the enemy core
text.mission.resource.menu = Obtain {0} x{1}
text.mission.resource = Obtain {0}\:\n[accent]{1}/{2}[]
@ -268,6 +268,7 @@ text.error.invalidaddress = Invalid address.
text.error.timedout = Timed out!\nMake sure the host has port forwarding set up, and that the address is correct!
text.error.mismatch = Packet error:\npossible client/server version mismatch.\nMake sure you and the host have the latest version of Mindustry!
text.error.alreadyconnected = Already connected.
text.error.mapnotfound = Map file not found!
text.error.any = Unkown network error.
text.settings.language = Language
@ -624,6 +625,7 @@ block.rtg-generator.name = RTG Generator
block.spectre.name = Spectre
block.meltdown.name = Meltdown
block.container.name = Container
block.core.description = The most important building in the game.
team.blue.name = blue
team.red.name = red
team.orange.name = orange
@ -668,7 +670,6 @@ tutorial.daggerfactory = Construct a[accent] dagger mech factory.[]\n\nThis will
tutorial.router = Factories need resources to function.\nCreate a router to split conveyor resources.
tutorial.dagger = Link power nodes to the factory.\nOnce requirements are met, a mech will be created.\n\nCreate more drills, generators and conveyors as necessary.
tutorial.battle = The[LIGHT_GRAY] enemy[] has revealed their core.\nDestroy it with your unit and dagger mechs.
block.core.description = The most important building in the game.
block.copper-wall.description = A cheap defensive block.\nUseful for protecting the core and turrets in the first few waves.
block.copper-wall-large.description = A cheap defensive block.\nUseful for protecting the core and turrets in the first few waves.\nSpans multiple tiles.
block.dense-alloy-wall.description = A standard defensive block.\nAdequate protection from enemies.

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Before After
Before After

View file

@ -5,7 +5,7 @@ page id=1 file="square2.png"
page id=2 file="square3.png"
chars count=11450
char id=10 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=0 page=0 chnl=0
char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=16 page=0 chnl=0
char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=10 page=0 chnl=0
char id=33 x=2039 y=147 width=7 height=23 xoffset=-1 yoffset=4 xadvance=8 page=0 chnl=0
char id=34 x=147 y=2032 width=15 height=11 xoffset=-1 yoffset=4 xadvance=16 page=0 chnl=0
char id=36 x=7 y=0 width=23 height=31 xoffset=-1 yoffset=0 xadvance=24 page=0 chnl=0

View file

@ -379,17 +379,12 @@ public class Control extends Module{
state.set(state.is(State.playing) ? State.paused : State.playing);
}
if(Inputs.keyTap("menu")){
if(state.is(State.paused)){
ui.paused.hide();
state.set(State.playing);
}else if(!ui.restart.isShown()){
if(ui.chatfrag.chatOpen()){
ui.chatfrag.hide();
}else{
ui.paused.show();
state.set(State.paused);
}
if(Inputs.keyTap("menu") && !ui.restart.isShown()){
if(ui.chatfrag.chatOpen()){
ui.chatfrag.hide();
}else if(!ui.paused.isShown() && !ui.hasDialog()){
ui.paused.show();
state.set(State.paused);
}
}

View file

@ -6,18 +6,12 @@ import io.anuke.ucore.core.Settings;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.scene.ui.TextField;
import java.util.Date;
import java.util.Random;
public abstract class Platform {
/**Each separate game platform should set this instance to their own implementation.*/
public static Platform instance = new Platform() {};
/**Format the date using the default date formatter.*/
public String format(Date date){return "invalid";}
/**Format a number by adding in commas or periods where needed.*/
public String format(int number){return "invalid";}
/**Add a text input dialog that should show up after the field is tapped.*/
public void addDialog(TextField field){
addDialog(field, 16);

View file

@ -87,22 +87,7 @@ public class UI extends SceneModule{
Dialog.closePadR = -1;
Dialog.closePadT = 5;
Colors.put("description", Palette.description);
Colors.put("turretinfo", Palette.turretinfo);
Colors.put("iteminfo", Palette.iteminfo);
Colors.put("powerinfo", Palette.powerinfo);
Colors.put("liquidinfo", Palette.liquidinfo);
Colors.put("craftinfo", Palette.craftinfo);
Colors.put("missingitems", Palette.missingitems);
Colors.put("health", Palette.health);
Colors.put("healthstats", Palette.healthstats);
Colors.put("interact", Palette.interact);
Colors.put("accent", Palette.accent);
Colors.put("place", Palette.place);
Colors.put("remove", Palette.remove);
Colors.put("placeRotate", Palette.placeRotate);
Colors.put("range", Palette.range);
Colors.put("power", Palette.power);
}
@Override

View file

@ -441,14 +441,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
mid.table("button", t -> {
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f]));
slider.update(() -> {
for(int j = 0; j < MapEditor.brushSizes.length; j++){
if(editor.getBrushSize() == j){
slider.setValue(j);
return;
}
}
});
t.top();
t.add("$text.editor.brush");

View file

@ -9,7 +9,6 @@ import com.badlogic.gdx.math.Bresenham2;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.editor.DrawOperation.TileOperation;
import io.anuke.mindustry.graphics.Palette;
@ -270,8 +269,7 @@ public class MapView extends Element implements GestureListener{
image.setImageSize(editor.getMap().width(), editor.getMap().height());
batch.flush();
boolean pop = ScissorStack.pushScissors(rect.set(x, y, width, height));
Graphics.beginClip(x, y, width, height);
Draw.color(Color.LIGHT_GRAY);
Lines.stroke(-2f);
@ -327,9 +325,7 @@ public class MapView extends Element implements GestureListener{
}
}
batch.flush();
if(pop) ScissorStack.popScissors();
Graphics.endClip();
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(3f));

View file

@ -33,8 +33,7 @@ import static io.anuke.mindustry.Vars.*;
public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
private static final IntMap<Fire> map = new IntMap<>();
private static final float baseLifetime = 1000f;
private static final float spreadChance = 0.05f, fireballChance = 0.07f;
private static final float baseLifetime = 1000f, spreadChance = 0.05f, fireballChance = 0.07f;
private int loadedPosition = -1;
private Tile tile;
@ -42,15 +41,10 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
private float baseFlammability = -1, puddleFlammability;
private float lifetime;
/**
* Deserialization use only!
*/
public Fire(){
}
/**Deserialization use only!*/
public Fire(){}
/**
* Start a fire on the tile. If there already is a file there, refreshes its lifetime.
*/
/**Start a fire on the tile. If there already is a file there, refreshes its lifetime.*/
public static void create(Tile tile){
if(Net.client() || tile == null) return; //not clientside.
@ -70,7 +64,11 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
}
public static boolean has(int x, int y){
return Structs.inBounds(x, y, world.width(), world.height()) && map.containsKey(x + y * world.width());
if(!Structs.inBounds(x, y, world.width(), world.height()) || !map.containsKey(x + y * world.width())){
return false;
}
Fire fire = map.get(x + y * world.width());
return fire.isAdded() && fire.fin() < 1f && fire.tile != null && fire.tile.x == x && fire.tile.y == y;
}
/**

View file

@ -20,7 +20,6 @@ import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.entities.EntityDraw;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.scene.utils.ScissorStack;
import java.nio.ByteBuffer;
@ -140,9 +139,7 @@ public class FogRenderer implements Disposable{
buffer.begin();
boolean pop = ScissorStack.pushScissors(rect.set((padding-shadowPadding), (padding-shadowPadding),
(world.width() + shadowPadding*2) ,
(world.height() + shadowPadding*2)));
Graphics.beginClip((padding-shadowPadding), (padding-shadowPadding), (world.width() + shadowPadding*2), (world.height() + shadowPadding*2));
Graphics.begin();
EntityDraw.setClip(false);
@ -172,7 +169,7 @@ public class FogRenderer implements Disposable{
Graphics.end();
buffer.end();
if(pop) ScissorStack.popScissors();
Graphics.endClip();
region.setTexture(buffer.getColorBufferTexture());
region.setRegion(u, v2, u2, v);

View file

@ -1,7 +1,6 @@
package io.anuke.mindustry.graphics;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
@ -20,7 +19,6 @@ import io.anuke.ucore.core.Events;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Pixmaps;
import io.anuke.ucore.scene.utils.ScissorStack;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.ThreadArray;
@ -34,8 +32,6 @@ public class MinimapRenderer implements Disposable{
private Texture texture;
private TextureRegion region;
private Rectangle rect = new Rectangle();
private Rectangle clipRect = new Rectangle();
private Color tmpColor = new Color();
private int zoom = 4;
public MinimapRenderer(){
@ -80,9 +76,7 @@ public class MinimapRenderer implements Disposable{
synchronized(units){
rect.set((dx - sz) * tilesize, (dy - sz) * tilesize, sz * 2 * tilesize, sz * 2 * tilesize);
Graphics.flush();
boolean clip = ScissorStack.pushScissors(clipRect.set(x, y, w, h));
Graphics.beginClip(x, y, w, h);
for(Unit unit : units){
float rx = (unit.x - rect.x) / rect.width * w, ry = (unit.y - rect.y) / rect.width * h;
@ -92,8 +86,7 @@ public class MinimapRenderer implements Disposable{
Draw.color();
Graphics.flush();
if(clip) ScissorStack.popScissors();
Graphics.endClip();
}
}

View file

@ -41,24 +41,8 @@ public class Palette{
portal = Color.valueOf("6344d7"),
portalDark = Color.valueOf("3f3dac"),
powerLaserFrom = Color.valueOf("e3e3e3"),
powerLaserTo = Color.valueOf("ffe7a8"),
heal = Color.valueOf("98ffa9"),
description = Color.WHITE,
turretinfo = Color.ORANGE,
iteminfo = Color.LIGHT_GRAY,
powerinfo = Color.YELLOW,
liquidinfo = Color.ROYAL,
craftinfo = Color.LIGHT_GRAY,
missingitems = Color.SCARLET,
health = Color.YELLOW,
ammo = Color.valueOf("32cf6d"),
healthstats = Color.SCARLET,
bar = Color.SLATE,
interact = Color.ORANGE,
accent = Color.valueOf("f4ba6e"),
accentBack = Color.valueOf("d58c4b"),
place = Color.valueOf("6335f8"),
@ -81,6 +65,5 @@ public class Palette{
redDust = Color.valueOf("ffa480"),
redderDust = Color.valueOf("ff7b69"),
plasticSmoke = Color.valueOf("f1e479"),
plasticBurn = Color.valueOf("e9ead3");
plasticSmoke = Color.valueOf("f1e479");
}

View file

@ -1,10 +1,10 @@
package io.anuke.mindustry.io;
import io.anuke.mindustry.core.Platform;
import io.anuke.mindustry.game.Difficulty;
import io.anuke.mindustry.game.GameMode;
import io.anuke.mindustry.maps.Map;
import java.text.SimpleDateFormat;
import java.util.Date;
import static io.anuke.mindustry.Vars.world;
@ -23,7 +23,7 @@ public class SaveMeta{
public SaveMeta(int version, long date, long timePlayed, int build, int sector, int mode, String map, int wave, Difficulty difficulty){
this.version = version;
this.build = build;
this.date = Platform.instance.format(new Date(date));
this.date = SimpleDateFormat.getDateTimeInstance().format(new Date(date));
this.timePlayed = timePlayed;
this.sector = sector;
this.mode = GameMode.values()[mode];

View file

@ -1,10 +1,12 @@
package io.anuke.mindustry.maps;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.async.AsyncExecutor;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.Difficulty;
@ -28,11 +30,12 @@ import io.anuke.ucore.util.*;
import static io.anuke.mindustry.Vars.*;
public class Sectors{
private static final int sectorImageSize = 32;
public static final int sectorImageSize = 32;
private final GridMap<Sector> grid = new GridMap<>();
private final SectorPresets presets = new SectorPresets();
private final Array<Item> allOres = Item.getAllOres();
private final AsyncExecutor executor = new AsyncExecutor(6);
public void playSector(Sector sector){
if(sector.hasSave() && SaveIO.breakingVersions.contains(sector.getSave().getBuild())){
@ -106,6 +109,7 @@ public class Sectors{
for(GridPoint2 g : Geometry.d4){
createSector(x + g.x, y + g.y);
Sector other = grid.get(x + g.x, y + g.y);
}
}
@ -125,6 +129,10 @@ public class Sectors{
if(sector.texture == null){
threads.runGraphics(() -> createTexture(sector));
}
if(sector.missions.size == 0){
completeSector(sector.x, sector.y);
}
}
public void abandonSector(Sector sector){
@ -217,6 +225,10 @@ public class Sectors{
/**Generates a mission for a sector. This is deterministic and the same for each client.*/
private void generate(Sector sector){
//empty sector
if(Mathf.randomSeed(sector.getSeed() + 213) < 0.2){
return;
}
//50% chance to get a wave mission
if(Mathf.randomSeed(sector.getSeed() + 6) < 0.5){
@ -228,11 +240,6 @@ public class Sectors{
sector.missions.add(new BattleMission());
}
//possibly another battle mission
if(Mathf.randomSeed(sector.getSeed() + 3) < 0.3){
sector.missions.add(new BattleMission());
}
//possibly add another recipe mission
addRecipeMission(sector, 11);
}
@ -264,24 +271,33 @@ public class Sectors{
sector.texture.dispose();
}
Pixmap pixmap = new Pixmap(sectorImageSize, sectorImageSize, Format.RGBA8888);
GenResult secResult = new GenResult();
executor.submit(() -> {
Pixmap pixmap = new Pixmap(sectorImageSize, sectorImageSize, Format.RGBA8888);
GenResult result = new GenResult();
GenResult secResult = new GenResult();
for(int x = 0; x < pixmap.getWidth(); x++){
for(int y = 0; y < pixmap.getHeight(); y++){
int toX = x * sectorSize / sectorImageSize;
int toY = y * sectorSize / sectorImageSize;
for(int x = 0; x < pixmap.getWidth(); x++){
for(int y = 0; y < pixmap.getHeight(); y++){
int toX = x * sectorSize / sectorImageSize;
int toY = y * sectorSize / sectorImageSize;
GenResult result = world.generator.generateTile(sector.x, sector.y, toX, toY, false);
world.generator.generateTile(secResult, sector.x, sector.y, toX, ((y+1) * sectorSize / sectorImageSize), false, null, null);
world.generator.generateTile(result, sector.x, sector.y, toX, toY, false, null, null);
world.generator.generateTile(secResult, sector.x, sector.y, toX, ((y+1) * sectorSize / sectorImageSize), false, null, null);
int color = ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation, secResult.elevation > result.elevation ? (byte)(1 << 6) : (byte)0);
pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, color);
int color = ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation, secResult.elevation > result.elevation ? (byte)(1 << 6) : (byte)0);
pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, color);
}
}
}
sector.texture = new Texture(pixmap);
pixmap.dispose();
Gdx.app.postRunnable(() -> {
sector.texture = new Texture(pixmap);
pixmap.dispose();
});
return null;
});
}

View file

@ -13,6 +13,11 @@ import static io.anuke.mindustry.Vars.*;
public class BattleMission extends Mission{
final int spacing = 30;
@Override
public String getIcon(){
return "icon-mission-battle";
}
@Override
public GameMode getMode(){
return GameMode.noWaves;
@ -25,7 +30,7 @@ public class BattleMission extends Mission{
@Override
public void generate(Generation gen){
super.generate(gen);
generateCoreAt(gen, 50, 50, defaultTeam);
if(state.teams.get(defaultTeam).cores.size == 0){
return;

View file

@ -17,7 +17,7 @@ import static io.anuke.mindustry.Vars.*;
public abstract class Mission{
private String extraMessage;
private boolean showComplete =true;
private boolean showComplete = true;
public abstract boolean isComplete();
@ -29,6 +29,10 @@ public abstract class Mission{
return displayString();
}
public String getIcon(){
return "icon-mission-defense";
}
public GameMode getMode(){
return GameMode.noWaves;
}
@ -95,9 +99,7 @@ public abstract class Mission{
return Array.with();
}
public void generate(Generation gen){
generateCoreAt(gen, 50, 50, defaultTeam);
}
public void generate(Generation gen){}
public void generateCoreAt(Generation gen, int coreX, int coreY, Team team){
gen.tiles[coreX][coreY].setBlock(StorageBlocks.core);

View file

@ -13,7 +13,6 @@ import io.anuke.ucore.scene.ui.Dialog;
import io.anuke.ucore.scene.ui.ScrollPane;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.ui;
public class FloatingDialog extends Dialog{
private boolean wasPaused;
@ -29,19 +28,16 @@ public class FloatingDialog extends Dialog{
hidden(() -> {
if(shouldPause && !state.is(State.menu)){
if(!wasPaused || Net.active())
if(!wasPaused || Net.active()){
state.set(State.playing);
}
}
});
shown(() -> {
if(shouldPause && !state.is(State.menu)){
wasPaused = state.is(State.paused);
if(ui.paused.getScene() != null){
wasPaused = ui.paused.wasPaused;
}
if(!Net.active()) state.set(State.paused);
ui.paused.hide();
state.set(State.paused);
}
});
@ -71,8 +67,9 @@ public class FloatingDialog extends Dialog{
buttons().addImageTextButton("$text.back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
keyDown(key -> {
if(key == Keys.ESCAPE || key == Keys.BACK)
hide();
if(key == Keys.ESCAPE || key == Keys.BACK) {
Gdx.app.postRunnable(this::hide);
}
});
}
}

View file

@ -177,8 +177,6 @@ public class JoinDialog extends FloatingDialog{
t.add("[lightgray]" + Bundles.format("text.save.map", host.mapname) + " / " + Bundles.format("text.save.wave", host.wave)).left();
}).expand().left().bottom().padLeft(12f).padBottom(8);
//server.content.add(versionString).top().expandY().top().expandX();
}, e -> {
server.content.clear();
server.content.add("$text.host.invalid");
@ -321,7 +319,6 @@ public class JoinDialog extends FloatingDialog{
public String ip;
public int port;
transient Host host;
transient Table content;
void setIP(String ip){

View file

@ -147,9 +147,14 @@ public class MapsDialog extends FloatingDialog{
table.row();
table.addImageTextButton("$text.editor.openin", "icon-load-map", "clear", 16 * 2, () -> {
Vars.ui.editor.beginEditMap(map.stream.get());
dialog.hide();
hide();
try{
Vars.ui.editor.beginEditMap(map.stream.get());
dialog.hide();
hide();
}catch(Exception e){
e.printStackTrace();
ui.showError("$text.error.mapnotfound");
}
}).fillX().height(50f).marginLeft(6);
table.addImageTextButton("$text.delete", "icon-trash-16", "clear", 16 * 2, () -> {

View file

@ -1,5 +1,6 @@
package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Input.Keys;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.net.Net;
import io.anuke.ucore.scene.ui.layout.Table;
@ -8,16 +9,22 @@ import io.anuke.ucore.util.Bundles;
import static io.anuke.mindustry.Vars.*;
public class PausedDialog extends FloatingDialog{
public boolean wasPaused = false;
private SaveDialog save = new SaveDialog();
private LoadDialog load = new LoadDialog();
private Table missionTable;
public PausedDialog(){
super("$text.menu");
shouldPause = true;
setup();
shown(this::rebuild);
keyDown(key -> {
if(key == Keys.ESCAPE || key == Keys.BACK) {
hide();
}
});
}
void rebuild(){
@ -40,11 +47,6 @@ public class PausedDialog extends FloatingDialog{
}
});
shown(() -> {
wasPaused = state.is(State.paused);
if(!Net.active()) state.set(State.paused);
});
content().table(t -> missionTable = t).colspan(mobile ? 3 : 1);
content().row();
@ -53,8 +55,6 @@ public class PausedDialog extends FloatingDialog{
content().addButton("$text.back", () -> {
hide();
if((!wasPaused || Net.active()) && !state.is(State.menu))
state.set(State.playing);
});
content().row();
@ -86,8 +86,6 @@ public class PausedDialog extends FloatingDialog{
content().addRowImageTextButton("$text.back", "icon-play-2", isize, () -> {
hide();
if(!wasPaused && !state.is(State.menu))
state.set(State.playing);
});
content().addRowImageTextButton("$text.settings", "icon-tools", isize, ui.settings::show);
content().addRowImageTextButton("$text.save", "icon-save", isize, save::show).disabled(b -> world.getSector() != null);

View file

@ -1,68 +1,119 @@
package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.maps.Sector;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.scene.Element;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.event.InputEvent;
import io.anuke.ucore.scene.event.InputListener;
import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.scene.utils.Cursors;
import io.anuke.ucore.scene.utils.ScissorStack;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Log;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.ui;
import static io.anuke.mindustry.Vars.world;
public class SectorsDialog extends FloatingDialog{
private Rectangle clip = new Rectangle();
private static final float sectorSize = Unit.dp.scl(32*5);
private Sector selected;
private Table table;
private SectorView view;
public SectorsDialog(){
super("$text.sectors");
super("");
table = new Table(){
@Override
public float getPrefWidth(){
return sectorSize*2f;
}
};
table.visible(() -> selected != null);
table.update(() -> {
if(selected != null){
int offsetX = (int)(view.panX / sectorSize);
int offsetY = (int)(view.panY / sectorSize);
float drawX = x + width/2f+ selected.x * (sectorSize-2) - offsetX * sectorSize - view.panX % sectorSize + sectorSize/2f;
float drawY = y + height/2f + selected.y * (sectorSize-2) - offsetY * sectorSize - view.panY % sectorSize + sectorSize/2f;
table.setPosition(drawX, drawY - sectorSize/2f + 1, Align.top);
}
});
Group container = new Group();
container.setTouchable(Touchable.childrenOnly);
container.addChild(table);
margin(0);
getTitleTable().clear();
clear();
stack(content(), buttons(), container).grow();
shown(this::setup);
}
void setup(){
selected = null;
table.clear();
content().clear();
buttons().clear();
buttons().bottom().margin(15);
addCloseButton();
content().label(() -> Bundles.format("text.sector", selected == null ? Bundles.get("text.none") :
(selected.x + ", " + selected.y + (!selected.complete && selected.saveID != -1 ? " " + Bundles.get("text.sector.locked") : ""))
+ (selected.saveID == -1 ? " " + Bundles.get("text.sector.unexplored") :
(selected.hasSave() ? " [accent]/[white] " + Bundles.format("text.sector.time", selected.getSave().getPlayTime()) : ""))));
content().row();
content().label(() -> Bundles.format("text.mission.main", selected == null || selected.completedMissions >= selected.missions.size
? Bundles.get("text.none") : selected.getDominantMission().menuDisplayString()));
content().row();
content().add(new SectorView()).grow();
content().row();
buttons().addImageTextButton("$text.sector.abandon", "icon-cancel", 16*2, () ->
ui.showConfirm("$text.confirm", "$text.sector.abandon.confirm", () -> world.sectors.abandonSector(selected)))
.size(200f, 64f).disabled(b -> selected == null || !selected.hasSave());
buttons().row();
buttons().addImageTextButton("$text.sector.deploy", "icon-play", 10*3, () -> {
hide();
ui.loadLogic(() -> world.sectors.playSector(selected));
}).disabled(b -> selected == null)
.fillX().height(64f).colspan(2).update(t -> t.setText(selected != null && selected.hasSave() ? "$text.sector.resume" : "$text.sector.deploy"));
content().add(view = new SectorView()).grow();
}
void selectSector(Sector sector){
Log.info((int)' ');
selected = sector;
table.clear();
table.background("button").margin(5);
table.defaults().pad(3);
table.add(Bundles.format("text.sector", sector.x + ", " + sector.y));
table.row();
if(selected.completedMissions < selected.missions.size && !selected.complete){
table.labelWrap(Bundles.format("text.mission", selected.getDominantMission().menuDisplayString())).growX();
table.row();
}
if(selected.hasSave()){
table.labelWrap(Bundles.format("text.sector.time", selected.getSave().getPlayTime())).growX();
table.row();
}
table.table(t -> {
t.addImageTextButton(sector.hasSave() ? "$text.sector.resume" : "$text.sector.deploy", "icon-play", 10*3, () -> {
hide();
Vars.ui.loadLogic(() -> world.sectors.playSector(selected));
}).height(60f).growX();
if(selected.hasSave()){
t.addImageTextButton("$text.sector.abandon", "icon-cancel", 16 * 2, () ->
Vars.ui.showConfirm("$text.confirm", "$text.sector.abandon.confirm", () -> world.sectors.abandonSector(selected))
).width(sectorSize).height(60f);
}
}).pad(-5).growX().padTop(0);
table.pack();
table.act(Gdx.graphics.getDeltaTime());
}
public Sector getSelected(){
@ -71,17 +122,15 @@ public class SectorsDialog extends FloatingDialog{
class SectorView extends Element{
float lastX, lastY;
float sectorSize = Unit.dp.scl(32*5);
float sectorPadding = Unit.dp.scl(14f);
boolean clicked = false;
float panX = -sectorPadding/2f, panY = -sectorSize/2f;
float panX = 0, panY = -sectorSize/2f;
SectorView(){
addListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button){
if(pointer != 0) return false;
Cursors.setHand();
//Cursors.setHand();
lastX = x;
lastY = y;
return true;
@ -111,16 +160,11 @@ public class SectorsDialog extends FloatingDialog{
public void draw(){
Draw.alpha(alpha);
float padSectorSize = sectorSize + sectorPadding;
int shownSectorsX = (int)(width/sectorSize);
int shownSectorsY = (int)(height/sectorSize);
int shownSectorsX = (int)(width/padSectorSize);
int shownSectorsY = (int)(height/padSectorSize);
clip.setSize(width, height).setCenter(x + width/2f, y + height/2f);
Graphics.flush();
boolean clipped = ScissorStack.pushScissors(clip);
int offsetX = (int)(panX / padSectorSize);
int offsetY = (int)(panY / padSectorSize);
int offsetX = (int)(panX / sectorSize);
int offsetY = (int)(panY / sectorSize);
Vector2 mouse = Graphics.mouse();
@ -129,58 +173,77 @@ public class SectorsDialog extends FloatingDialog{
int sectorX = offsetX + x;
int sectorY = offsetY + y;
float drawX = x + width/2f+ sectorX * padSectorSize - offsetX * padSectorSize - panX % padSectorSize;
float drawY = y + height/2f + sectorY * padSectorSize - offsetY * padSectorSize - panY % padSectorSize;
float drawX = x + width/2f+ sectorX * (sectorSize-2) - offsetX * sectorSize - panX % sectorSize + sectorSize/2f;
float drawY = y + height/2f + sectorY * (sectorSize-2) - offsetY * sectorSize - panY % sectorSize + sectorSize/2f;
Sector sector = world.sectors.get(sectorX, sectorY);
int width = 1;
int height = 1;
float paddingx = (width-1) * sectorPadding;
float paddingy = (height-1) * sectorPadding;
if(sector != null && (sector.x != sectorX || sector.y != sectorY)){
if(sector == null || sector.texture == null){
Draw.reset();
Draw.rect("empty-sector", drawX, drawY, sectorSize, sectorSize);
int i = 0;
for(GridPoint2 point : Geometry.d4){
Sector other = world.sectors.get(sectorX + point.x, sectorY + point.y);
if(other != null){
Draw.rect("sector-edge", drawX, drawY, sectorSize, sectorSize, i*90);
}
i ++;
}
continue;
}
drawX += (width-1)/2f*padSectorSize;
drawY += (height-1)/2f*padSectorSize;
Draw.colorl(!sector.complete ? 0.3f : 1f);
Draw.rect(sector.texture, drawX, drawY, sectorSize, sectorSize);
if(sector != null && sector.texture != null){
Draw.colorl(!sector.complete ? 0.3f : 1f);
Draw.rect(sector.texture, drawX, drawY, sectorSize * width + paddingx, sectorSize * height + paddingy);
if(sector.missions.size == 0) continue;
String region = sector.getDominantMission().getIcon();
if(sector.complete){
region = "icon-mission-done";
}
float stroke = 4f;
Color iconColor = Color.WHITE;
Color backColor = Color.BLACK;
Color selectColor = Color.CLEAR;
if(sector == null){
Draw.color(Color.DARK_GRAY);
}else if(sector == selected){
Draw.color(Palette.place);
stroke = 6f;
}else if(Mathf.inRect(mouse.x, mouse.y, drawX - padSectorSize/2f * width, drawY - padSectorSize/2f * height,
drawX + padSectorSize/2f * width, drawY + padSectorSize/2f * height)){
if(sector == selected){
selectColor = Palette.accent;
}else if(Mathf.inRect(mouse.x, mouse.y, drawX - sectorSize / 2f, drawY - sectorSize / 2f,
drawX + sectorSize / 2f, drawY + sectorSize / 2f)){
if(clicked){
selectSector(sector);
}
Draw.color(Palette.remove);
}else if (sector.complete){
Draw.color(Palette.accent);
selectColor = Color.WHITE;
}else{
Draw.color(Color.LIGHT_GRAY);
iconColor = Color.GRAY;
}
Lines.stroke(Unit.dp.scl(stroke));
Lines.crect(drawX, drawY, sectorSize * width + paddingx, sectorSize * height + paddingy, (int)stroke);
if(sector.complete){
iconColor = backColor = Color.CLEAR;
}
Draw.color(selectColor);
Draw.rect("sector-select", drawX, drawY, sectorSize, sectorSize);
Draw.color(backColor);
Draw.alpha(0.75f * backColor.a);
Draw.rect("icon-mission-background", drawX, drawY, Unit.dp.scl(18f * 5), Unit.dp.scl(18f * 5));
float size = Unit.dp.scl(10f * 5);
Draw.color(iconColor);
Shaders.outline.color = Color.BLACK;
Shaders.outline.region = Draw.region(region);
//Graphics.shader(Shaders.outline);
Draw.rect(region, drawX, drawY, size, size);
//Graphics.shader();
}
}
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(4f));
Lines.crect(x + width/2f, y + height/2f, width, height);
Draw.reset();
Graphics.flush();
if(clipped) ScissorStack.popScissors();
clicked = false;
}

View file

@ -50,11 +50,7 @@ public class SettingsMenuDialog extends SettingsDialog{
shown(() -> {
if(!state.is(State.menu)){
wasPaused = state.is(State.paused);
if(ui.paused.getScene() != null){
wasPaused = ui.paused.wasPaused;
}
if(!Net.active()) state.set(State.paused);
ui.paused.hide();
state.set(State.paused);
}
});

View file

@ -21,8 +21,8 @@ public class UnlocksDialog extends FloatingDialog{
public UnlocksDialog(){
super("$text.unlocks");
addCloseButton();
shouldPause = true;
addCloseButton();
shown(this::rebuild);
onResize(this::rebuild);
}
@ -36,7 +36,7 @@ public class UnlocksDialog extends FloatingDialog{
Array<Content>[] allContent = content.getContentMap();
for(int j =0; j< allContent.length; j ++){
for(int j = 0; j < allContent.length; j ++){
ContentType type = ContentType.values()[j];
Array<Content> array = allContent[j];

View file

@ -15,7 +15,7 @@ import static io.anuke.mindustry.Vars.*;
public class Junction extends Block{
protected float speed = 26; //frames taken to go through this junction
protected int capacity = 32;
protected int capacity = 6;
public Junction(String name){
super(name);

View file

@ -17,7 +17,7 @@ public class NumberValue implements StatValue{
this.unit = unit;
this.value = value;
if(unit.localized().contains("???")){
if(unit != StatUnit.none && unit.localized().contains("???")){
throw new RuntimeException("No bundle definition found for unit: '" + unit + "'");
}
}

View file

@ -18,9 +18,7 @@ import io.anuke.ucore.util.Strings;
import java.net.NetworkInterface;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import static io.anuke.mindustry.Vars.*;
@ -47,16 +45,6 @@ public class DesktopPlatform extends Platform{
new FileChooser(text, file -> file.extension().equalsIgnoreCase(filter), open, cons).show();
}
@Override
public String format(Date date){
return format.format(date);
}
@Override
public String format(int number){
return NumberFormat.getIntegerInstance().format(number);
}
@Override
public void updateRPC(){

View file

@ -19,11 +19,7 @@ import org.robovm.apple.foundation.NSURL;
import org.robovm.apple.uikit.*;
import java.io.IOException;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import static io.anuke.mindustry.Vars.*;
import static org.robovm.apple.foundation.NSPathUtilities.getDocumentsDirectory;
@ -43,17 +39,6 @@ public class IOSLauncher extends IOSApplication.Delegate {
}
Platform.instance = new Platform() {
DateFormat format = SimpleDateFormat.getDateTimeInstance();
@Override
public String format(Date date) {
return format.format(date);
}
@Override
public String format(int number) {
return NumberFormat.getIntegerInstance().format(number);
}
@Override
public void addDialog(TextField field) {

View file

@ -306,6 +306,7 @@ public class ServerControl extends Module{
}
info(" &ly{0} FPS.", (int) (60f / Timers.delta()));
info(" &ly{0} MB used.", Gdx.app.getJavaHeap() / 1024 / 1024);
if(playerGroup.size() > 0){
info(" &lyPlayers: {0}", playerGroup.size());