New sector dialog done

This commit is contained in:
Anuken 2018-11-04 00:08:06 -04:00
parent 76a6a0cf75
commit 19d34779a0
12 changed files with 1045 additions and 972 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

View File

@ -54,7 +54,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 = Survive[accent] {0}/{1} []waves\nWave in {2}
text.mission.wave.enemies = Survive[accent] {0}/{1} []waves\n{2} Enemies 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.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.battle = Destroy the enemy core
text.mission.resource.menu = Obtain {0} x{1} text.mission.resource.menu = Obtain {0} x{1}
text.mission.resource = Obtain {0}\:\n[accent]{1}/{2}[] text.mission.resource = Obtain {0}\:\n[accent]{1}/{2}[]

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -5,7 +5,7 @@ page id=1 file="square2.png"
page id=2 file="square3.png" page id=2 file="square3.png"
chars count=11450 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=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=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=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 char id=36 x=7 y=0 width=23 height=31 xoffset=-1 yoffset=0 xadvance=24 page=0 chnl=0

View File

@ -441,14 +441,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
mid.table("button", t -> { mid.table("button", t -> {
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false); Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f])); 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.top();
t.add("$text.editor.brush"); t.add("$text.editor.brush");

View File

@ -1,49 +1,119 @@
package io.anuke.mindustry.ui.dialogs; package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.GridPoint2; import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Vector2; 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.Palette;
import io.anuke.mindustry.graphics.Shaders; import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.maps.Sector; import io.anuke.mindustry.maps.Sector;
import io.anuke.ucore.core.Graphics; import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.Element; 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.InputEvent;
import io.anuke.ucore.scene.event.InputListener; 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.ui.layout.Unit;
import io.anuke.ucore.scene.utils.Cursors; import io.anuke.ucore.scene.utils.Cursors;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Geometry; import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Log;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.world; import static io.anuke.mindustry.Vars.world;
public class SectorsDialog extends FloatingDialog{ public class SectorsDialog extends FloatingDialog{
private static final float sectorSize = Unit.dp.scl(32*5);
private Sector selected; private Sector selected;
private Table table;
private SectorView view;
public SectorsDialog(){ public SectorsDialog(){
super(""); 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); margin(0);
getTitleTable().clear(); getTitleTable().clear();
clear(); clear();
stack(content(), buttons()).grow(); stack(content(), buttons(), container).grow();
shown(this::setup); shown(this::setup);
} }
void setup(){ void setup(){
selected = null; selected = null;
table.clear();
content().clear(); content().clear();
buttons().clear(); buttons().clear();
buttons().bottom().margin(15); buttons().bottom().margin(15);
addCloseButton(); addCloseButton();
content().add(new SectorView()).grow(); content().add(view = new SectorView()).grow();
} }
void selectSector(Sector sector){ void selectSector(Sector sector){
Log.info((int)' ');
selected = sector; 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(){ public Sector getSelected(){
@ -52,7 +122,6 @@ public class SectorsDialog extends FloatingDialog{
class SectorView extends Element{ class SectorView extends Element{
float lastX, lastY; float lastX, lastY;
float sectorSize = Unit.dp.scl(32*5);
boolean clicked = false; boolean clicked = false;
float panX = 0, panY = -sectorSize/2f; float panX = 0, panY = -sectorSize/2f;
@ -61,7 +130,7 @@ public class SectorsDialog extends FloatingDialog{
@Override @Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button){ public boolean touchDown(InputEvent event, float x, float y, int pointer, int button){
if(pointer != 0) return false; if(pointer != 0) return false;
Cursors.setHand(); //Cursors.setHand();
lastX = x; lastX = x;
lastY = y; lastY = y;
return true; return true;
@ -91,13 +160,11 @@ public class SectorsDialog extends FloatingDialog{
public void draw(){ public void draw(){
Draw.alpha(alpha); Draw.alpha(alpha);
float padSectorSize = sectorSize; int shownSectorsX = (int)(width/sectorSize);
int shownSectorsY = (int)(height/sectorSize);
int shownSectorsX = (int)(width/padSectorSize); int offsetX = (int)(panX / sectorSize);
int shownSectorsY = (int)(height/padSectorSize); int offsetY = (int)(panY / sectorSize);
int offsetX = (int)(panX / padSectorSize);
int offsetY = (int)(panY / padSectorSize);
Vector2 mouse = Graphics.mouse(); Vector2 mouse = Graphics.mouse();
@ -106,20 +173,20 @@ public class SectorsDialog extends FloatingDialog{
int sectorX = offsetX + x; int sectorX = offsetX + x;
int sectorY = offsetY + y; int sectorY = offsetY + y;
float drawX = x + width/2f+ sectorX * (padSectorSize-2) - offsetX * padSectorSize - panX % padSectorSize + padSectorSize/2f; float drawX = x + width/2f+ sectorX * (sectorSize-2) - offsetX * sectorSize - panX % sectorSize + sectorSize/2f;
float drawY = y + height/2f + sectorY * (padSectorSize-2) - offsetY * padSectorSize - panY % padSectorSize + padSectorSize/2f; float drawY = y + height/2f + sectorY * (sectorSize-2) - offsetY * sectorSize - panY % sectorSize + sectorSize/2f;
Sector sector = world.sectors.get(sectorX, sectorY); Sector sector = world.sectors.get(sectorX, sectorY);
if(sector == null || sector.texture == null){ if(sector == null || sector.texture == null){
Draw.reset(); Draw.reset();
Draw.rect("empty-sector", drawX, drawY, sectorSize, sectorSize);
int i = 0; int i = 0;
for(GridPoint2 point : Geometry.d4){ for(GridPoint2 point : Geometry.d4){
Sector other = world.sectors.get(sectorX + point.x, sectorY + point.y); Sector other = world.sectors.get(sectorX + point.x, sectorY + point.y);
if(other != null){ if(other != null){
Draw.rect("sector-edge", drawX, drawY, padSectorSize, padSectorSize, i*90); Draw.rect("sector-edge", drawX, drawY, sectorSize, sectorSize, i*90);
} }
i ++; i ++;
@ -138,25 +205,31 @@ public class SectorsDialog extends FloatingDialog{
region = "icon-mission-done"; region = "icon-mission-done";
} }
Color iconColor; Color iconColor = Color.WHITE;
Color missionColor = Color.BLACK; Color backColor = Color.BLACK;
Color selectColor = Color.CLEAR;
if(sector == selected){ if(sector == selected){
iconColor = Palette.accent; selectColor = Palette.accent;
}else if(Mathf.inRect(mouse.x, mouse.y, drawX - padSectorSize / 2f, drawY - padSectorSize / 2f, }else if(Mathf.inRect(mouse.x, mouse.y, drawX - sectorSize / 2f, drawY - sectorSize / 2f,
drawX + padSectorSize / 2f, drawY + padSectorSize / 2f)){ drawX + sectorSize / 2f, drawY + sectorSize / 2f)){
if(clicked){ if(clicked){
selectSector(sector); selectSector(sector);
} }
iconColor = Color.WHITE; selectColor = Color.WHITE;
}else if(sector.complete){
iconColor = missionColor = Color.CLEAR;
}else{ }else{
iconColor = Color.GRAY; iconColor = Color.GRAY;
} }
Draw.color(missionColor); if(sector.complete){
Draw.alpha(0.75f * missionColor.a); 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)); Draw.rect("icon-mission-background", drawX, drawY, Unit.dp.scl(18f * 5), Unit.dp.scl(18f * 5));
float size = Unit.dp.scl(10f * 5); float size = Unit.dp.scl(10f * 5);

View File

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

View File

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

View File

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