Deployment dialog replaced
This commit is contained in:
@@ -67,7 +67,7 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
public TraceDialog traces;
|
public TraceDialog traces;
|
||||||
public DatabaseDialog database;
|
public DatabaseDialog database;
|
||||||
public ContentInfoDialog content;
|
public ContentInfoDialog content;
|
||||||
public DeployDialog deploy;
|
public PlanetDialog planet;
|
||||||
public TechTreeDialog tech;
|
public TechTreeDialog tech;
|
||||||
//public MinimapDialog minimap;
|
//public MinimapDialog minimap;
|
||||||
public SchematicsDialog schematics;
|
public SchematicsDialog schematics;
|
||||||
@@ -235,7 +235,7 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
traces = new TraceDialog();
|
traces = new TraceDialog();
|
||||||
maps = new MapsDialog();
|
maps = new MapsDialog();
|
||||||
content = new ContentInfoDialog();
|
content = new ContentInfoDialog();
|
||||||
deploy = new DeployDialog();
|
planet = new PlanetDialog();
|
||||||
tech = new TechTreeDialog();
|
tech = new TechTreeDialog();
|
||||||
mods = new ModsDialog();
|
mods = new ModsDialog();
|
||||||
schematics = new SchematicsDialog();
|
schematics = new SchematicsDialog();
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class MusicControl{
|
|||||||
public void update(){
|
public void update(){
|
||||||
if(state.is(State.menu)){
|
if(state.is(State.menu)){
|
||||||
silenced = false;
|
silenced = false;
|
||||||
if(ui.deploy.isShown()){
|
if(ui.planet.isShown()){
|
||||||
play(Musics.launch);
|
play(Musics.launch);
|
||||||
}else if(ui.editor.isShown()){
|
}else if(ui.editor.isShown()){
|
||||||
play(Musics.editor);
|
play(Musics.editor);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import arc.math.*;
|
|||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
|
||||||
class Pgrid{
|
class PlanetGrid{
|
||||||
private static final float x = -0.525731112119133606f;
|
private static final float x = -0.525731112119133606f;
|
||||||
private static final float z = -0.850650808352039932f;
|
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)
|
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, 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},
|
{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}
|
{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;
|
int size;
|
||||||
Ptile[] tiles;
|
Ptile[] tiles;
|
||||||
Corner[] corners;
|
Corner[] corners;
|
||||||
Edge[] edges;
|
Edge[] edges;
|
||||||
|
|
||||||
Pgrid(int size){
|
PlanetGrid(int size){
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
||||||
tiles = new Ptile[tileCount(size)];
|
tiles = new Ptile[tileCount(size)];
|
||||||
@@ -44,16 +46,29 @@ class Pgrid{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Pgrid newGrid(int size){
|
static PlanetGrid newGrid(int size){
|
||||||
if(size == 0){
|
//cache grids between calls, since only ~5 different grids total are needed
|
||||||
return initialGrid();
|
if(size < cache.length && cache[size] != null){
|
||||||
}else{
|
return cache[size];
|
||||||
return subdividedGrid(newGrid(size - 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(){
|
static PlanetGrid initialGrid(){
|
||||||
Pgrid grid = new Pgrid(0);
|
PlanetGrid grid = new PlanetGrid(0);
|
||||||
|
|
||||||
for(Ptile t : grid.tiles){
|
for(Ptile t : grid.tiles){
|
||||||
t.v = iTiles[t.id];
|
t.v = iTiles[t.id];
|
||||||
@@ -97,8 +112,8 @@ class Pgrid{
|
|||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Pgrid subdividedGrid(Pgrid prev){
|
static PlanetGrid subdividedGrid(PlanetGrid prev){
|
||||||
Pgrid grid = new Pgrid(prev.size + 1);
|
PlanetGrid grid = new PlanetGrid(prev.size + 1);
|
||||||
|
|
||||||
int prevTiles = prev.tiles.length;
|
int prevTiles = prev.tiles.length;
|
||||||
int prevCorners = prev.corners.length;
|
int prevCorners = prev.corners.length;
|
||||||
@@ -148,7 +163,7 @@ class Pgrid{
|
|||||||
return grid;
|
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];
|
Corner c = grid.corners[id];
|
||||||
Ptile[] t = {grid.tiles[t1], grid.tiles[t2], grid.tiles[t3]};
|
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();
|
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];
|
Edge e = grid.edges[id];
|
||||||
Ptile[] t = {grid.tiles[t1], grid.tiles[t2]};
|
Ptile[] t = {grid.tiles[t1], grid.tiles[t2]};
|
||||||
Corner[] c = {
|
Corner[] c = {
|
||||||
@@ -8,13 +8,13 @@ import arc.math.geom.*;
|
|||||||
import arc.util.ArcAnnotate.*;
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.noise.*;
|
import arc.util.noise.*;
|
||||||
import mindustry.graphics.Pgrid.*;
|
import mindustry.graphics.PlanetGrid.*;
|
||||||
|
|
||||||
public class PlanetMesh{
|
public class PlanetMesh{
|
||||||
private float[] floats = new float[3 + 3 + 1];
|
private float[] floats = new float[3 + 3 + 1];
|
||||||
private Vec3 center = new Vec3(0, 0, 0);
|
private Vec3 center = new Vec3(0, 0, 0);
|
||||||
private Mesh mesh;
|
private Mesh mesh;
|
||||||
private Pgrid grid;
|
private PlanetGrid grid;
|
||||||
|
|
||||||
private float color;
|
private float color;
|
||||||
private boolean lines;
|
private boolean lines;
|
||||||
@@ -27,7 +27,7 @@ public class PlanetMesh{
|
|||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
this.color = color.toFloatBits();
|
this.color = color.toFloatBits();
|
||||||
this.grid = Pgrid.newGrid(divisions);
|
this.grid = PlanetGrid.newGrid(divisions);
|
||||||
|
|
||||||
int vertices = grid.tiles.length * 12 * (3 + 3 + 1);
|
int vertices = grid.tiles.length * 12 * (3 + 3 + 1);
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ import arc.graphics.g3d.*;
|
|||||||
import arc.input.*;
|
import arc.input.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.graphics.Pgrid.*;
|
import mindustry.graphics.PlanetGrid.*;
|
||||||
|
|
||||||
public class PlanetRenderer{
|
public class PlanetRenderer{
|
||||||
private Camera3D cam = new Camera3D();
|
private Camera3D cam = new Camera3D();
|
||||||
private float lastX, lastY;
|
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 PlanetMesh outline = new PlanetMesh(3, 1.01f, true, Pal.accent);
|
||||||
private VertexBatch3D batch = new VertexBatch3D(false, true, 0);
|
private VertexBatch3D batch = new VertexBatch3D(false, true, 0);
|
||||||
|
|
||||||
@@ -24,8 +24,7 @@ public class PlanetRenderer{
|
|||||||
|
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.flush();
|
Draw.flush();
|
||||||
Gl.clearColor(0, 0, 0, 1);
|
Gl.clear(Gl.depthBufferBit);
|
||||||
Gl.clear(Gl.depthBufferBit | Gl.colorBufferBit);
|
|
||||||
Gl.enable(Gl.depthTest);
|
Gl.enable(Gl.depthTest);
|
||||||
|
|
||||||
input();
|
input();
|
||||||
@@ -38,15 +37,13 @@ public class PlanetRenderer{
|
|||||||
planet.render(cam.combined());
|
planet.render(cam.combined());
|
||||||
//outline.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()));
|
Ptile tile = outline.getTile(cam.getPickRay(Core.input.mouseX(), Core.input.mouseY()));
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
for(int i = 0; i < tile.corners.length + 1; i++){
|
for(int i = 0; i < tile.corners.length; i++){
|
||||||
batch.color(Pal.accent);
|
batch.color(1f, 1f, 1f, 0.5f);
|
||||||
batch.vertex(tile.corners[i % tile.corners.length].v);
|
batch.vertex(tile.corners[i].v);
|
||||||
}
|
}
|
||||||
batch.flush(cam.combined(), Gl.lineStrip);
|
batch.flush(cam.combined(), Gl.triangleFan);
|
||||||
}
|
}
|
||||||
|
|
||||||
Gl.disable(Gl.depthTest);
|
Gl.disable(Gl.depthTest);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import mindustry.ui.layout.TreeLayout.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
//TODO remove (legacy, no longer needed)
|
||||||
public class DeployDialog extends FloatingDialog{
|
public class DeployDialog extends FloatingDialog{
|
||||||
private final float nodeSize = Scl.scl(230f);
|
private final float nodeSize = Scl.scl(230f);
|
||||||
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
|
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
|
||||||
@@ -105,7 +106,7 @@ public class DeployDialog extends FloatingDialog{
|
|||||||
bounds.y += nodeSize*0.4f;
|
bounds.y += nodeSize*0.4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setup(){
|
void setup(){
|
||||||
platform.updateRPC();
|
platform.updateRPC();
|
||||||
|
|
||||||
cont.clear();
|
cont.clear();
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class GameOverDialog extends FloatingDialog{
|
|||||||
hide();
|
hide();
|
||||||
state.set(State.menu);
|
state.set(State.menu);
|
||||||
logic.reset();
|
logic.reset();
|
||||||
ui.deploy.show();
|
ui.planet.show();
|
||||||
}).size(130f, 60f);
|
}).size(130f, 60f);
|
||||||
}else{
|
}else{
|
||||||
buttons.addButton("$menu", () -> {
|
buttons.addButton("$menu", () -> {
|
||||||
|
|||||||
29
core/src/mindustry/ui/dialogs/PlanetDialog.java
Normal file
29
core/src/mindustry/ui/dialogs/PlanetDialog.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,7 +56,7 @@ public class TechTreeDialog extends FloatingDialog{
|
|||||||
treeLayout();
|
treeLayout();
|
||||||
});
|
});
|
||||||
|
|
||||||
hidden(ui.deploy::setup);
|
hidden(ui.planet::setup);
|
||||||
|
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
|
|||||||
@@ -152,10 +152,10 @@ public class ZoneInfoDialog extends FloatingDialog{
|
|||||||
if(!data.isUnlocked(zone)){
|
if(!data.isUnlocked(zone)){
|
||||||
Sounds.unlock.play();
|
Sounds.unlock.play();
|
||||||
data.unlockContent(zone);
|
data.unlockContent(zone);
|
||||||
ui.deploy.setup();
|
ui.planet.setup();
|
||||||
setup(zone);
|
setup(zone);
|
||||||
}else{
|
}else{
|
||||||
ui.deploy.hide();
|
ui.planet.hide();
|
||||||
data.removeItems(zone.getLaunchCost());
|
data.removeItems(zone.getLaunchCost());
|
||||||
hide();
|
hide();
|
||||||
control.playZone(zone);
|
control.playZone(zone);
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package mindustry.ui.fragments;
|
package mindustry.ui.fragments;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.graphics.g2d.*;
|
||||||
|
import arc.math.*;
|
||||||
import arc.scene.*;
|
import arc.scene.*;
|
||||||
import arc.scene.event.*;
|
import arc.scene.event.*;
|
||||||
import mindustry.graphics.*;
|
|
||||||
|
|
||||||
/** Fades in a black overlay.*/
|
/** Fades in a black overlay.*/
|
||||||
public class FadeInFragment extends Fragment{
|
public class FadeInFragment extends Fragment{
|
||||||
private static final float duration = 40f;
|
private static final float duration = 40f;
|
||||||
float time = 0f;
|
float time = 0f;
|
||||||
PlanetRenderer rend = new PlanetRenderer();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
@@ -20,10 +21,9 @@ public class FadeInFragment extends Fragment{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
//Draw.color(0f, 0f, 0f, Mathf.clamp(1f - time));
|
Draw.color(0f, 0f, 0f, Mathf.clamp(1f - time));
|
||||||
//Fill.crect(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
|
Fill.crect(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||||
//Draw.color();
|
Draw.color();
|
||||||
rend.draw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -31,7 +31,7 @@ public class FadeInFragment extends Fragment{
|
|||||||
super.act(delta);
|
super.act(delta);
|
||||||
time += 1f / duration;
|
time += 1f / duration;
|
||||||
if(time > 1){
|
if(time > 1){
|
||||||
//remove();
|
remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class MenuFragment extends Fragment{
|
|||||||
container.defaults().size(size).pad(5).padTop(4f);
|
container.defaults().size(size).pad(5).padTop(4f);
|
||||||
|
|
||||||
MobileButton
|
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)),
|
custom = new MobileButton(Icon.playCustom, "$customgame", () -> checkPlay(ui.custom::show)),
|
||||||
maps = new MobileButton(Icon.load, "$loadgame", () -> checkPlay(ui.load::show)),
|
maps = new MobileButton(Icon.load, "$loadgame", () -> checkPlay(ui.load::show)),
|
||||||
join = new MobileButton(Icon.add, "$joingame", () -> checkPlay(ui.join::show)),
|
join = new MobileButton(Icon.add, "$joingame", () -> checkPlay(ui.join::show)),
|
||||||
@@ -165,7 +165,7 @@ public class MenuFragment extends Fragment{
|
|||||||
|
|
||||||
buttons(t,
|
buttons(t,
|
||||||
new Buttoni("$play", Icon.play2Small,
|
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("$joingame", Icon.addSmall, () -> checkPlay(ui.join::show)),
|
||||||
new Buttoni("$customgame", Icon.editorSmall, () -> checkPlay(ui.custom::show)),
|
new Buttoni("$customgame", Icon.editorSmall, () -> checkPlay(ui.custom::show)),
|
||||||
new Buttoni("$loadgame", Icon.loadSmall, () -> checkPlay(ui.load::show)),
|
new Buttoni("$loadgame", Icon.loadSmall, () -> checkPlay(ui.load::show)),
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
}else{
|
}else{
|
||||||
if(ui.editor != null && ui.editor.isShown()){
|
if(ui.editor != null && ui.editor.isShown()){
|
||||||
presence.state = "In Editor";
|
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";
|
presence.state = "In Launch Selection";
|
||||||
}else{
|
}else{
|
||||||
presence.state = "In Menu";
|
presence.state = "In Menu";
|
||||||
|
|||||||
Reference in New Issue
Block a user