Merge branch 'continuous-sectors' of https://github.com/Anuken/Mindustry

# Conflicts:
#	core/assets/bundles/bundle.properties
This commit is contained in:
Anuken
2018-09-24 22:57:49 -04:00
62 changed files with 1218 additions and 263 deletions

View File

@@ -4,9 +4,12 @@ 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.utils.Array;
import com.badlogic.gdx.utils.async.AsyncExecutor;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.ColorMapper;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.Element;
@@ -20,6 +23,7 @@ import static io.anuke.mindustry.Vars.sectorSize;
import static io.anuke.mindustry.Vars.world;
public class GenViewDialog extends FloatingDialog{
Array<Item> ores = Array.with(Items.copper, Items.lead, Items.coal);
public GenViewDialog(){
super("generate view");
@@ -81,7 +85,7 @@ public class GenViewDialog extends FloatingDialog{
Pixmap pixmap = new Pixmap(sectorSize, sectorSize, Format.RGBA8888);
for(int i = 0; i < sectorSize; i++){
for(int j = 0; j < sectorSize; j++){
world.generator().generateTile(result, wx, wy, i, j, true, null);
world.generator().generateTile(result, wx, wy, i, j, true, null, ores);
pixmap.drawPixel(i, sectorSize - 1 - j, ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation, (byte)0));
}
}

View File

@@ -24,7 +24,7 @@ public class SaveDialog extends LoadDialog{
slots.row();
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14 * 3, () ->
ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {
ui.loadAnd("$text.saving", () -> {
ui.loadGraphics("$text.saving", () -> {
control.getSaves().addSave(text);
threads.runGraphics(() -> threads.run(() -> threads.runGraphics(this::setup)));
});

View File

@@ -43,8 +43,8 @@ public class SectorsDialog extends FloatingDialog{
(selected.hasSave() ? " [accent]/[white] " + Bundles.format("text.sector.time", selected.getSave().getPlayTime()) : ""))));
content().row();
content().label(() -> Bundles.format("text.mission", selected == null || selected.completedMissions >= selected.missions.size
? Bundles.get("text.none") : selected.missions.get(selected.completedMissions).displayString())
+ "[WHITE] " + (selected == null ? "" : Bundles.format("text.save.difficulty", "[LIGHT_GRAY]" + selected.getDifficulty().toString())));
? Bundles.get("text.none") : selected.missions.get(selected.completedMissions).menuDisplayString())
+ "[WHITE] " /*+ (selected == null ? "" : Bundles.format("text.save.difficulty", "[LIGHT_GRAY]" + selected.getDifficulty().toString()))*/);
content().row();
content().add(new SectorView()).grow();
content().row();
@@ -113,9 +113,9 @@ public class SectorsDialog extends FloatingDialog{
float padSectorSize = sectorSize + sectorPadding;
float clipSize = Math.min(width, height);
int shownSectors = (int)(clipSize/padSectorSize);
clip.setSize(clipSize).setCenter(x + width/2f, y + height/2f);
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);
@@ -124,8 +124,8 @@ public class SectorsDialog extends FloatingDialog{
Vector2 mouse = Graphics.mouse();
for(int x = -shownSectors; x <= shownSectors; x++){
for(int y = -shownSectors; y <= shownSectors; y++){
for(int x = -shownSectorsX; x <= shownSectorsX; x++){
for(int y = -shownSectorsY; y <= shownSectorsY; y++){
int sectorX = offsetX + x;
int sectorY = offsetY + y;
@@ -133,19 +133,21 @@ public class SectorsDialog extends FloatingDialog{
float drawY = y + height/2f + sectorY * padSectorSize - offsetY * padSectorSize - panY % padSectorSize;
Sector sector = world.sectors().get(sectorX, sectorY);
int size = (sector == null ? 1 : sector.size);
float padding = (size-1) * sectorPadding;
int width = (sector == null ? 1 : sector.width);
int height = (sector == null ? 1 : sector.height);
float paddingx = (width-1) * sectorPadding;
float paddingy = (height-1) * sectorPadding;
if(sector != null && (sector.x != sectorX || sector.y != sectorY)){
continue;
}
drawX += (size-1)/2f*padSectorSize;
drawY += (size-1)/2f*padSectorSize;
drawX += (width-1)/2f*padSectorSize;
drawY += (height-1)/2f*padSectorSize;
if(sector != null && sector.texture != null){
Draw.color(Color.WHITE);
Draw.rect(sector.texture, drawX, drawY, sectorSize * size + padding, sectorSize * size + padding);
Draw.rect(sector.texture, drawX, drawY, sectorSize * width + paddingx, sectorSize * height + paddingy);
}
float stroke = 4f;
@@ -155,8 +157,8 @@ public class SectorsDialog extends FloatingDialog{
}else if(sector == selected){
Draw.color(Palette.place);
stroke = 6f;
}else if(Mathf.inRect(mouse.x, mouse.y, drawX - padSectorSize/2f * size, drawY - padSectorSize/2f * size,
drawX + padSectorSize/2f * size, drawY + padSectorSize/2f * size)){
}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(clicked){
selectSector(sector);
}
@@ -168,13 +170,13 @@ public class SectorsDialog extends FloatingDialog{
}
Lines.stroke(Unit.dp.scl(stroke));
Lines.crect(drawX, drawY, sectorSize * size + padding, sectorSize * size + padding, (int)stroke);
Lines.crect(drawX, drawY, sectorSize * width + paddingx, sectorSize * height + paddingy, (int)stroke);
}
}
Draw.color(Palette.accent);
Lines.stroke(Unit.dp.scl(4f));
Lines.crect(x + width/2f, y + height/2f, clipSize, clipSize);
Lines.crect(x + width/2f, y + height/2f, width, height);
Draw.reset();
Graphics.flush();

View File

@@ -81,14 +81,16 @@ public class BlocksFragment extends Fragment{
}
});
container.add(descTable).fillX().uniformX();
float w = 246f;
container.row();
main.add(descTable).width(w);
main.row();
//now add the block selection menu
selectTable = main.table("pane", select -> {})
.margin(10f).marginLeft(0f).marginRight(0f).marginTop(-5)
.touchable(Touchable.enabled).right().bottom().get();
.touchable(Touchable.enabled).right().bottom().width(w).get();
}).bottom().right().get();
});

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Scaling;
import io.anuke.mindustry.core.GameState.State;
@@ -15,15 +16,14 @@ import io.anuke.mindustry.net.Packets.AdminAction;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.ui.IntFormat;
import io.anuke.mindustry.ui.Minimap;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.ucore.core.*;
import io.anuke.ucore.graphics.Hue;
import io.anuke.ucore.scene.Element;
import io.anuke.ucore.scene.Group;
import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles;
@@ -103,7 +103,8 @@ public class HudFragment extends Fragment{
cont.row();
Table waves = cont.table(this::addWaveTable).touchable(Touchable.enabled).fillX().height(66f).get();
TextButton waves = cont.addButton("", ()->{}).fillX().height(66f).get();
addWaveTable(waves);
cont.row();
@@ -182,6 +183,27 @@ public class HudFragment extends Fragment{
blockfrag.build(Core.scene.getRoot());
}
public void showText(String text){
Table table = new Table("button");
table.update(() -> {
if(state.is(State.menu)){
table.remove();
}
});
table.margin(12);
table.addImage("icon-check").size(16*2).pad(3);
table.add(text).wrap().width(280f).get().setAlignment(Align.center, Align.center);
table.pack();
//create container table which will align and move
Table container = Core.scene.table();
container.top().add(table);
container.setTranslation(0, table.getPrefHeight());
container.actions(Actions.translateBy(0, -table.getPrefHeight(), 1f, Interpolation.fade), Actions.delay(4f),
//nesting actions() calls is necessary so the right prefHeight() is used
Actions.run(() -> container.actions(Actions.translateBy(0, table.getPrefHeight(), 1f, Interpolation.fade), Actions.removeActor())));
}
/**
* Show unlock notification for a new recipe.
*/
@@ -281,6 +303,16 @@ public class HudFragment extends Fragment{
}
}
public void showTextDialog(String str){
new FloatingDialog("$text.mission.info"){{
shouldPause = true;
setFillParent(false);
getCell(content()).growX();
content().margin(15).add(str).width(400f).wrap().get().setAlignment(Align.left, Align.left);
buttons().addButton("$text.continue", this::hide).size(140, 60).pad(4);
}}.show();
}
private void toggleMenus(){
wavetable.clearActions();
infolabel.clearActions();
@@ -312,27 +344,30 @@ public class HudFragment extends Fragment{
}
}
private void addWaveTable(Table table){
private void addWaveTable(TextButton table){
wavetable = table;
float uheight = 66f;
IntFormat wavef = new IntFormat("text.wave");
IntFormat timef = new IntFormat("text.wave.waiting");
table.clearChildren();
table.setTouchable(Touchable.enabled);
table.background("button");
table.left().table(text -> {
text.left();
text.label(() -> wavef.get(state.wave)).left().get().setFontScale(fontScale * 1.5f);
text.row();
text.label(() -> unitGroups[Team.red.ordinal()].size() > 0 && state.mode.disableWaveTimer ?
getEnemiesRemaining() : (state.mode.disableWaveTimer) ? "$text.waiting" :
timef.get((int) (state.wavetime / 60f))).minWidth(126).left();
table.labelWrap(() -> world.getSector() == null ? wavef.get(state.wave) :
Bundles.format("text.mission.display", world.getSector().currentMission().displayString())).growX();
table.clicked(() -> {
if(world.getSector() != null && world.getSector().currentMission().hasMessage()){
world.getSector().currentMission().showMessage();
}
});
table.add().growX();
table.visible(() -> !state.mode.disableWaves);
table.setDisabled(() -> !(world.getSector() != null && world.getSector().currentMission().hasMessage()));
table.visible(() -> !((world.getSector() == null && state.mode.disableWaves) || !state.mode.showMission));
playButton(uheight);
//playButton(uheight);
}
private void playButton(float uheight){

View File

@@ -59,7 +59,7 @@ public class MenuFragment extends Fragment{
maps = new MobileButton("icon-map", isize, "$text.maps", ui.maps::show),
load = new MobileButton("icon-load", isize, "$text.load", ui.load::show),
join = new MobileButton("icon-add", isize, "$text.joingame", ui.join::show),
editor = new MobileButton("icon-editor", isize, "$text.editor", () -> ui.loadAnd(ui.editor::show)),
editor = new MobileButton("icon-editor", isize, "$text.editor", () -> ui.loadGraphics(ui.editor::show)),
tools = new MobileButton("icon-tools", isize, "$text.settings", ui.settings::show),
unlocks = new MobileButton("icon-unlocks", isize, "$text.unlocks", ui.unlocks::show),
donate = new MobileButton("icon-donate", isize, "$text.donate", Platform.instance::openDonations);
@@ -114,7 +114,7 @@ public class MenuFragment extends Fragment{
out.row();
out.add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadAnd(ui.editor::show)));
out.add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadGraphics(ui.editor::show)));
out.add(new MenuButton("icon-map", "$text.maps", ui.maps::show));