Deployment dialog replaced

This commit is contained in:
Anuken
2020-01-12 20:01:32 -05:00
parent e6f1d194ae
commit c637ec15ff
13 changed files with 87 additions and 45 deletions

View File

@ -67,7 +67,7 @@ public class UI implements ApplicationListener, Loadable{
public TraceDialog traces;
public DatabaseDialog database;
public ContentInfoDialog content;
public DeployDialog deploy;
public PlanetDialog planet;
public TechTreeDialog tech;
//public MinimapDialog minimap;
public SchematicsDialog schematics;
@ -235,7 +235,7 @@ public class UI implements ApplicationListener, Loadable{
traces = new TraceDialog();
maps = new MapsDialog();
content = new ContentInfoDialog();
deploy = new DeployDialog();
planet = new PlanetDialog();
tech = new TechTreeDialog();
mods = new ModsDialog();
schematics = new SchematicsDialog();

View File

@ -48,7 +48,7 @@ public class MusicControl{
public void update(){
if(state.is(State.menu)){
silenced = false;
if(ui.deploy.isShown()){
if(ui.planet.isShown()){
play(Musics.launch);
}else if(ui.editor.isShown()){
play(Musics.editor);

View File

@ -4,7 +4,7 @@ import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
class Pgrid{
class PlanetGrid{
private static final float x = -0.525731112119133606f;
private static final float z = -0.850650808352039932f;
@ -14,18 +14,20 @@ class Pgrid{
new Vec3(z, x, 0), new Vec3(-z, x, 0), new Vec3(z, -x, 0), new Vec3(-z, -x, 0)
};
private static final int[][] iTilesP = {
private static final int[][] iTilesP = {
{9, 4, 1, 6, 11}, {4, 8, 10, 6, 0}, {11, 7, 3, 5, 9}, {2, 7, 10, 8, 5},
{9, 5, 8, 1, 0}, {2, 3, 8, 4, 9}, {0, 1, 10, 7, 11}, {11, 6, 10, 3, 2},
{5, 3, 10, 1, 4}, {2, 5, 4, 0, 11}, {3, 7, 6, 1, 8}, {7, 2, 9, 0, 6}
};
private static PlanetGrid[] cache = new PlanetGrid[10];
int size;
Ptile[] tiles;
Corner[] corners;
Edge[] edges;
Pgrid(int size){
PlanetGrid(int size){
this.size = size;
tiles = new Ptile[tileCount(size)];
@ -44,16 +46,29 @@ class Pgrid{
}
}
static Pgrid newGrid(int size){
if(size == 0){
return initialGrid();
}else{
return subdividedGrid(newGrid(size - 1));
static PlanetGrid newGrid(int size){
//cache grids between calls, since only ~5 different grids total are needed
if(size < cache.length && cache[size] != null){
return cache[size];
}
PlanetGrid result;
if(size == 0){
result = initialGrid();
}else{
result = subdividedGrid(newGrid(size - 1));
}
//store grid in cache
if(size < cache.length){
cache[size] = result;
}
return result;
}
static Pgrid initialGrid(){
Pgrid grid = new Pgrid(0);
static PlanetGrid initialGrid(){
PlanetGrid grid = new PlanetGrid(0);
for(Ptile t : grid.tiles){
t.v = iTiles[t.id];
@ -97,8 +112,8 @@ class Pgrid{
return grid;
}
static Pgrid subdividedGrid(Pgrid prev){
Pgrid grid = new Pgrid(prev.size + 1);
static PlanetGrid subdividedGrid(PlanetGrid prev){
PlanetGrid grid = new PlanetGrid(prev.size + 1);
int prevTiles = prev.tiles.length;
int prevCorners = prev.corners.length;
@ -148,7 +163,7 @@ class Pgrid{
return grid;
}
static void addCorner(int id, Pgrid grid, int t1, int t2, int t3){
static void addCorner(int id, PlanetGrid grid, int t1, int t2, int t3){
Corner c = grid.corners[id];
Ptile[] t = {grid.tiles[t1], grid.tiles[t2], grid.tiles[t3]};
c.v = Tmp.v31.set(t[0].v).add(t[1].v).add(t[2].v).cpy().nor();
@ -158,7 +173,7 @@ class Pgrid{
}
}
static void addEdge(int id, Pgrid grid, int t1, int t2){
static void addEdge(int id, PlanetGrid grid, int t1, int t2){
Edge e = grid.edges[id];
Ptile[] t = {grid.tiles[t1], grid.tiles[t2]};
Corner[] c = {

View File

@ -8,13 +8,13 @@ import arc.math.geom.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import arc.util.noise.*;
import mindustry.graphics.Pgrid.*;
import mindustry.graphics.PlanetGrid.*;
public class PlanetMesh{
private float[] floats = new float[3 + 3 + 1];
private Vec3 center = new Vec3(0, 0, 0);
private Mesh mesh;
private Pgrid grid;
private PlanetGrid grid;
private float color;
private boolean lines;
@ -27,7 +27,7 @@ public class PlanetMesh{
this.radius = radius;
this.lines = lines;
this.color = color.toFloatBits();
this.grid = Pgrid.newGrid(divisions);
this.grid = PlanetGrid.newGrid(divisions);
int vertices = grid.tiles.length * 12 * (3 + 3 + 1);

View File

@ -7,13 +7,13 @@ import arc.graphics.g3d.*;
import arc.input.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.graphics.Pgrid.*;
import mindustry.graphics.PlanetGrid.*;
public class PlanetRenderer{
private Camera3D cam = new Camera3D();
private float lastX, lastY;
private PlanetMesh planet = new PlanetMesh(3, 1f, false, Color.royal);
private PlanetMesh planet = new PlanetMesh(4, 1f, false, Color.royal);
private PlanetMesh outline = new PlanetMesh(3, 1.01f, true, Pal.accent);
private VertexBatch3D batch = new VertexBatch3D(false, true, 0);
@ -24,8 +24,7 @@ public class PlanetRenderer{
public void draw(){
Draw.flush();
Gl.clearColor(0, 0, 0, 1);
Gl.clear(Gl.depthBufferBit | Gl.colorBufferBit);
Gl.clear(Gl.depthBufferBit);
Gl.enable(Gl.depthTest);
input();
@ -38,15 +37,13 @@ public class PlanetRenderer{
planet.render(cam.combined());
//outline.render(cam.combined());
//Log.info(cam.position + " " + cam.getPickRay(Core.input.mouseX(), Core.input.mouseY()));
Ptile tile = outline.getTile(cam.getPickRay(Core.input.mouseX(), Core.input.mouseY()));
if(tile != null){
for(int i = 0; i < tile.corners.length + 1; i++){
batch.color(Pal.accent);
batch.vertex(tile.corners[i % tile.corners.length].v);
for(int i = 0; i < tile.corners.length; i++){
batch.color(1f, 1f, 1f, 0.5f);
batch.vertex(tile.corners[i].v);
}
batch.flush(cam.combined(), Gl.lineStrip);
batch.flush(cam.combined(), Gl.triangleFan);
}
Gl.disable(Gl.depthTest);

View File

@ -29,6 +29,7 @@ import mindustry.ui.layout.TreeLayout.*;
import static mindustry.Vars.*;
//TODO remove (legacy, no longer needed)
public class DeployDialog extends FloatingDialog{
private final float nodeSize = Scl.scl(230f);
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
@ -105,7 +106,7 @@ public class DeployDialog extends FloatingDialog{
bounds.y += nodeSize*0.4f;
}
public void setup(){
void setup(){
platform.updateRPC();
cont.clear();

View File

@ -88,7 +88,7 @@ public class GameOverDialog extends FloatingDialog{
hide();
state.set(State.menu);
logic.reset();
ui.deploy.show();
ui.planet.show();
}).size(130f, 60f);
}else{
buttons.addButton("$menu", () -> {

View File

@ -0,0 +1,29 @@
package mindustry.ui.dialogs;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.ui.*;
import static mindustry.Vars.ui;
public class PlanetDialog extends FloatingDialog{
private PlanetRenderer renderer = new PlanetRenderer();
public PlanetDialog(){
super("", Styles.fullDialog);
addCloseButton();
buttons.addImageTextButton("$techtree", Icon.tree, () -> ui.tech.show()).size(230f, 64f);
shown(this::setup);
}
void setup(){
cont.clear();
titleTable.remove();
cont.addRect((x, y, w, h) -> {
renderer.draw();
}).grow();
}
}

View File

@ -56,7 +56,7 @@ public class TechTreeDialog extends FloatingDialog{
treeLayout();
});
hidden(ui.deploy::setup);
hidden(ui.planet::setup);
addCloseButton();

View File

@ -152,10 +152,10 @@ public class ZoneInfoDialog extends FloatingDialog{
if(!data.isUnlocked(zone)){
Sounds.unlock.play();
data.unlockContent(zone);
ui.deploy.setup();
ui.planet.setup();
setup(zone);
}else{
ui.deploy.hide();
ui.planet.hide();
data.removeItems(zone.getLaunchCost());
hide();
control.playZone(zone);

View File

@ -1,14 +1,15 @@
package mindustry.ui.fragments;
import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.*;
import arc.scene.event.*;
import mindustry.graphics.*;
/** Fades in a black overlay.*/
public class FadeInFragment extends Fragment{
private static final float duration = 40f;
float time = 0f;
PlanetRenderer rend = new PlanetRenderer();
@Override
public void build(Group parent){
@ -20,10 +21,9 @@ public class FadeInFragment extends Fragment{
@Override
public void draw(){
//Draw.color(0f, 0f, 0f, Mathf.clamp(1f - time));
//Fill.crect(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
//Draw.color();
rend.draw();
Draw.color(0f, 0f, 0f, Mathf.clamp(1f - time));
Fill.crect(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
Draw.color();
}
@Override
@ -31,7 +31,7 @@ public class FadeInFragment extends Fragment{
super.act(delta);
time += 1f / duration;
if(time > 1){
//remove();
remove();
}
}
});

View File

@ -100,7 +100,7 @@ public class MenuFragment extends Fragment{
container.defaults().size(size).pad(5).padTop(4f);
MobileButton
play = new MobileButton(Icon.play2, "$campaign", () -> checkPlay(ui.deploy::show)),
play = new MobileButton(Icon.play2, "$campaign", () -> checkPlay(ui.planet::show)),
custom = new MobileButton(Icon.playCustom, "$customgame", () -> checkPlay(ui.custom::show)),
maps = new MobileButton(Icon.load, "$loadgame", () -> checkPlay(ui.load::show)),
join = new MobileButton(Icon.add, "$joingame", () -> checkPlay(ui.join::show)),
@ -165,7 +165,7 @@ public class MenuFragment extends Fragment{
buttons(t,
new Buttoni("$play", Icon.play2Small,
new Buttoni("$campaign", Icon.play2Small, () -> checkPlay(ui.deploy::show)),
new Buttoni("$campaign", Icon.play2Small, () -> checkPlay(ui.planet::show)),
new Buttoni("$joingame", Icon.addSmall, () -> checkPlay(ui.join::show)),
new Buttoni("$customgame", Icon.editorSmall, () -> checkPlay(ui.custom::show)),
new Buttoni("$loadgame", Icon.loadSmall, () -> checkPlay(ui.load::show)),

View File

@ -262,7 +262,7 @@ public class DesktopLauncher extends ClientLauncher{
}else{
if(ui.editor != null && ui.editor.isShown()){
presence.state = "In Editor";
}else if(ui.deploy != null && ui.deploy.isShown()){
}else if(ui.planet != null && ui.planet.isShown()){
presence.state = "In Launch Selection";
}else{
presence.state = "In Menu";