diff --git a/core/assets/planets/TODO.dat b/core/assets/planets/TODO.dat index 1e45afd783..9f0778d116 100644 Binary files a/core/assets/planets/TODO.dat and b/core/assets/planets/TODO.dat differ diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index c6851b70ac..67ddfb2dee 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -197,7 +197,7 @@ public class World{ public void loadSector(Sector sector){ state.rules.sector = sector; - int size = (int)(sector.rect.radius * 3200); + int size = sector.getSize(); loadGenerator(size, size, tiles -> sector.planet.generator.generate(tiles, sector)); } diff --git a/core/src/mindustry/maps/planet/TestPlanetGenerator.java b/core/src/mindustry/maps/planet/TestPlanetGenerator.java index 005415e57b..d1b93a57c6 100644 --- a/core/src/mindustry/maps/planet/TestPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/TestPlanetGenerator.java @@ -8,7 +8,6 @@ import arc.util.*; import arc.util.noise.*; import mindustry.content.*; import mindustry.maps.generators.*; -import mindustry.type.*; import mindustry.world.*; import static mindustry.Vars.*; @@ -17,8 +16,6 @@ public class TestPlanetGenerator extends PlanetGenerator{ Simplex noise = new Simplex(); RidgedPerlin rid = new RidgedPerlin(1, 2); float scl = 5f; - Sector sector; - Tiles tiles; //TODO generate array from planet image later Block[][] arr = { diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index fcaaef06b0..a7e78a45c0 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -3,9 +3,11 @@ package mindustry.type; import arc.math.geom.*; import arc.math3d.*; import arc.util.*; +import arc.util.ArcAnnotate.*; import arc.util.io.*; import mindustry.*; import mindustry.ctype.*; +import mindustry.game.Saves.*; import mindustry.graphics.PlanetGrid.*; import mindustry.world.*; @@ -30,6 +32,14 @@ public class Sector{ this.data = data; } + public int getSize(){ + return (int)(rect.radius * 3200); + } + + public @Nullable SaveSlot getSave(){ + return Vars.headless ? null : Vars.control.saves.getSectorSave(this); + } + //TODO implement public boolean isLaunchWave(int wave){ return metCondition() && wave % launchPeriod == 0; @@ -94,7 +104,7 @@ public class Sector{ /** Cached data about a sector. */ public static class SectorData{ - public Content[] resources = {}; + public UnlockableContent[] resources = {}; public int spawnX, spawnY; public Block[] floors = {}; @@ -116,7 +126,7 @@ public class Sector{ } public void read(Reads read){ - resources = new Content[read.s()]; + resources = new UnlockableContent[read.s()]; for(int i = 0; i < resources.length; i++){ resources[i] = Vars.content.getByID(ContentType.all[read.b()], read.s()); } diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 2e7b1edb6b..4162ddf7ef 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -10,7 +10,9 @@ import arc.math.geom.*; import arc.scene.event.*; import arc.scene.ui.layout.*; import arc.util.*; +import arc.util.ArcAnnotate.*; import mindustry.content.*; +import mindustry.ctype.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.graphics.PlanetGrid.*; @@ -31,8 +33,8 @@ public class PlanetDialog extends FloatingDialog{ private Planet planet = Planets.starter; private float lastX, lastY; - private Sector selected, hovered; - private Table selectTable; + private @Nullable Sector selected, hovered; + private Table stable, infoTable; public PlanetDialog(){ super("", Styles.fullDialog); @@ -75,18 +77,23 @@ public class PlanetDialog extends FloatingDialog{ @Override public void tap(InputEvent event, float x, float y, int count, KeyCode button){ selected = hovered; + if(selected != null){ + updateSelected(); + } } }); - selectTable = new Table(t -> { - t.background(Tex.button); + infoTable = new Table(); + + stable = new Table(t -> { + t.background(Styles.black3); t.margin(12f); t.add("this is some arbitrary text."); }); - selectTable.act(1f); - selectTable.pack(); - selectTable.setPosition(0, 0, Align.center); + stable.act(1f); + stable.pack(); + stable.setPosition(0, 0, Align.center); shown(this::setup); } @@ -112,6 +119,7 @@ public class PlanetDialog extends FloatingDialog{ cam.lookAt(0, 0, 0); cam.update(); + projector.proj(cam.combined()); batch.proj(cam.combined()); PlanetMesh outline = outline(planet.size); @@ -130,25 +138,70 @@ public class PlanetDialog extends FloatingDialog{ if(selected != null){ drawSelection(selected); - - projector.proj(cam.combined()); - projector.setPlane( - //origin on sector position - Tmp.v33.set(selected.tile.v).setLength(outlineRad + 0.05f), - //face up - selected.plane.project(Tmp.v32.set(selected.tile.v).add(Vec3.Y)).sub(selected.tile.v).nor(), - //right vector - Tmp.v31.set(Tmp.v32).add(selected.tile.v).rotate(selected.tile.v, 90).sub(selected.tile.v).nor() - ); - - Draw.batch(projector, () -> { - selectTable.draw(); - }); } + Draw.batch(projector, () -> { + if(hovered != null){ + setPlane(hovered); + Fonts.outline.draw("" + hovered.id, 0, 0, Align.center); + } + + if(selected != null){ + setPlane(selected); + stable.draw(); + } + }); + + /* + Vec3 pos = cam.project(Tmp.v31.set(selected.tile.v).setLength(outlineRad)); + selectTable.setPosition(pos.x, pos.y, Align.center); + selectTable.draw(); + */ + Gl.disable(Gl.depthTest); } + private void updateSelected(){ + stable.clear(); + stable.background(Styles.black6); + + //TODO add strings to bundle after prototyping is done + + stable.add("[accent]" + selected.id).row(); + stable.addImage().color(Pal.accent).fillX().height(3f).pad(3f).row(); + stable.add(selected.getSave() != null ? selected.getSave().getPlayTime() : "[lightgray]Unexplored").row(); + + stable.add("Resources:").row(); + stable.table(t -> { + t.left(); + int idx = 0; + int max = 5; + for(UnlockableContent c : selected.data.resources){ + t.addImage(c.icon(Cicon.small)).padRight(3); + if(++idx % max == 0) t.row(); + } + + for(int i = 0; i < Math.min(selected.data.floorCounts.length, 3); i++){ + t.addImage(selected.data.floors[i].icon(Cicon.small)).padRight(3); + if(++idx % max == 0) t.row(); + } + }).fillX().row(); + + stable.pack(); + stable.setPosition(0, 0, Align.center); + } + + private void setPlane(Sector sector){ + projector.setPlane( + //origin on sector position + Tmp.v33.set(sector.tile.v).setLength(outlineRad + 0.001f), + //face up + sector.plane.project(Tmp.v32.set(sector.tile.v).add(Vec3.Y)).sub(sector.tile.v).nor(), + //right vector + Tmp.v31.set(Tmp.v32).add(sector.tile.v).rotate(sector.tile.v, 90).sub(sector.tile.v).nor() + ); + } + private void drawHover(Sector sector){ for(Corner c : sector.tile.corners){ batch.color(outlineColor); diff --git a/gradle.properties b/gradle.properties index 08c8a34a64..c14da3278b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=5b1a532e4d5630a39cf83a4f3263dc265f609a20 +archash=c6cf22b91f58e7f050574885e18d2b1d9640563f diff --git a/tools/src/mindustry/tools/SectorDataGenerator.java b/tools/src/mindustry/tools/SectorDataGenerator.java index cd2188abba..ec1688f32f 100644 --- a/tools/src/mindustry/tools/SectorDataGenerator.java +++ b/tools/src/mindustry/tools/SectorDataGenerator.java @@ -77,7 +77,7 @@ public class SectorDataGenerator{ data.floors[i] = entries.get(i).key; } - data.resources = content.asArray().sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))).toArray(Content.class); + data.resources = content.asArray().sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))).toArray(UnlockableContent.class); if(count[0]++ % 10 == 0){ Log.info("&lyDone with sector &lm{0}/{1}", count[0], planet.sectors.size);