Sector preset display
This commit is contained in:
@@ -145,6 +145,7 @@ filename = File Name:
|
|||||||
unlocked = New content unlocked!
|
unlocked = New content unlocked!
|
||||||
completed = [accent]Completed
|
completed = [accent]Completed
|
||||||
techtree = Tech Tree
|
techtree = Tech Tree
|
||||||
|
overview = Overview
|
||||||
research.list = [lightgray]Research:
|
research.list = [lightgray]Research:
|
||||||
research = Research
|
research = Research
|
||||||
researched = [lightgray]{0} researched.
|
researched = [lightgray]{0} researched.
|
||||||
|
|||||||
@@ -508,6 +508,7 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
t.update(() -> t.setPosition(Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f, Align.center));
|
t.update(() -> t.setPosition(Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f, Align.center));
|
||||||
t.actions(Actions.fadeOut(duration, Interp.pow4In), Actions.remove());
|
t.actions(Actions.fadeOut(duration, Interp.pow4In), Actions.remove());
|
||||||
t.pack();
|
t.pack();
|
||||||
|
t.act(0.1f);
|
||||||
Core.scene.add(t);
|
Core.scene.add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public class SectorInfo{
|
|||||||
public @Nullable String icon;
|
public @Nullable String icon;
|
||||||
/** Version of generated waves. When it doesn't match, new waves are generated. */
|
/** Version of generated waves. When it doesn't match, new waves are generated. */
|
||||||
public int waveVersion = -1;
|
public int waveVersion = -1;
|
||||||
|
/** Whether this sector was indicated to the player or not. */
|
||||||
|
public boolean shown = false;
|
||||||
|
|
||||||
/** Special variables for simulation. */
|
/** Special variables for simulation. */
|
||||||
public float sumHealth, sumRps, sumDps, waveHealthBase, waveHealthSlope, waveDpsBase, waveDpsSlope;
|
public float sumHealth, sumRps, sumDps, waveHealthBase, waveHealthSlope, waveDpsBase, waveDpsSlope;
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ public class Scripts implements Disposable{
|
|||||||
String name = "sounds/" + soundName;
|
String name = "sounds/" + soundName;
|
||||||
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
||||||
|
|
||||||
if(Core.assets.contains(path, Sound.class)) return Core.assets.get(path, Sound.class);
|
|
||||||
var sound = new Sound();
|
var sound = new Sound();
|
||||||
AssetDescriptor<?> desc = Core.assets.load(path, Sound.class, new SoundParameter(sound));
|
AssetDescriptor<?> desc = Core.assets.load(path, Sound.class, new SoundParameter(sound));
|
||||||
desc.errored = Throwable::printStackTrace;
|
desc.errored = Throwable::printStackTrace;
|
||||||
@@ -108,7 +107,6 @@ public class Scripts implements Disposable{
|
|||||||
String name = "music/" + soundName;
|
String name = "music/" + soundName;
|
||||||
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
String path = Vars.tree.get(name + ".ogg").exists() ? name + ".ogg" : name + ".mp3";
|
||||||
|
|
||||||
if(Core.assets.contains(path, Music.class)) return Core.assets.get(path, Music.class);
|
|
||||||
var music = new Music();
|
var music = new Music();
|
||||||
AssetDescriptor<?> desc = Core.assets.load(path, Music.class, new MusicParameter(music));
|
AssetDescriptor<?> desc = Core.assets.load(path, Music.class, new MusicParameter(music));
|
||||||
desc.errored = Throwable::printStackTrace;
|
desc.errored = Throwable::printStackTrace;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import arc.scene.*;
|
|||||||
import arc.scene.event.*;
|
import arc.scene.event.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
@@ -32,6 +33,7 @@ import static mindustry.ui.dialogs.PlanetDialog.Mode.*;
|
|||||||
public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||||
//if true, enables launching anywhere for testing
|
//if true, enables launching anywhere for testing
|
||||||
public static boolean debugSelect = false;
|
public static boolean debugSelect = false;
|
||||||
|
public static float sectorShowDuration = 60f * 2.4f;
|
||||||
|
|
||||||
public final FrameBuffer buffer = new FrameBuffer(2, 2, true);
|
public final FrameBuffer buffer = new FrameBuffer(2, 2, true);
|
||||||
public final PlanetRenderer planets = renderer.planets;
|
public final PlanetRenderer planets = renderer.planets;
|
||||||
@@ -44,20 +46,40 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
public Mode mode = look;
|
public Mode mode = look;
|
||||||
public boolean launching;
|
public boolean launching;
|
||||||
public Cons<Sector> listener = s -> {};
|
public Cons<Sector> listener = s -> {};
|
||||||
|
public Seq<Sector> newPresets = new Seq<>();
|
||||||
|
public float presetShow = 0f;
|
||||||
|
public boolean showed = false;
|
||||||
|
|
||||||
public PlanetDialog(){
|
public PlanetDialog(){
|
||||||
super("", Styles.fullDialog);
|
super("", Styles.fullDialog);
|
||||||
|
|
||||||
shouldPause = true;
|
shouldPause = true;
|
||||||
|
|
||||||
addCloseListener();
|
keyDown(key -> {
|
||||||
|
if(key == KeyCode.escape || key == KeyCode.back){
|
||||||
|
if(showing() && newPresets.size > 1){
|
||||||
|
//clear all except first, which is the last sector.
|
||||||
|
newPresets.truncate(1);
|
||||||
|
}else if(selected != null){
|
||||||
|
selected = null;
|
||||||
|
updateSelected();
|
||||||
|
}else{
|
||||||
|
Core.app.post(this::hide);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
buttons.defaults().size(200f, 56f).pad(2);
|
buttons.defaults().size(200f, 56f).pad(2);
|
||||||
|
buttons.bottom().margin(0).marginBottom(-9);
|
||||||
|
|
||||||
buttons.button("@back", Icon.left, this::hide);
|
buttons.button("@back", Icon.left, this::hide);
|
||||||
buttons.button("@techtree", Icon.tree, () -> ui.research.show());
|
buttons.button("@techtree", Icon.tree, () -> ui.research.show());
|
||||||
buttons.bottom().margin(0).marginBottom(-8);
|
|
||||||
|
|
||||||
dragged((cx, cy) -> {
|
dragged((cx, cy) -> {
|
||||||
|
if(showing()){
|
||||||
|
newPresets.clear();
|
||||||
|
}
|
||||||
|
|
||||||
Vec3 pos = planets.camPos;
|
Vec3 pos = planets.camPos;
|
||||||
|
|
||||||
float upV = pos.angle(Vec3.Y);
|
float upV = pos.angle(Vec3.Y);
|
||||||
@@ -94,6 +116,25 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
planets.zoom = 1f;
|
planets.zoom = 1f;
|
||||||
selectAlpha = 0f;
|
selectAlpha = 0f;
|
||||||
launchSector = state.getSector();
|
launchSector = state.getSector();
|
||||||
|
presetShow = 0f;
|
||||||
|
showed = false;
|
||||||
|
|
||||||
|
newPresets.clear();
|
||||||
|
|
||||||
|
//announce new presets
|
||||||
|
for(SectorPreset preset : content.sectors()){
|
||||||
|
if(preset.unlocked() && !preset.sector.info.shown && !preset.sector.hasBase()){
|
||||||
|
newPresets.add(preset.sector);
|
||||||
|
preset.sector.info.shown = true;
|
||||||
|
preset.sector.saveInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(newPresets.any()){
|
||||||
|
newPresets.add(planets.planet.getLastSector());
|
||||||
|
}
|
||||||
|
|
||||||
|
newPresets.reverse();
|
||||||
|
|
||||||
if(planets.planet.getLastSector() != null){
|
if(planets.planet.getLastSector() != null){
|
||||||
lookAt(planets.planet.getLastSector());
|
lookAt(planets.planet.getLastSector());
|
||||||
@@ -102,6 +143,20 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
return super.show();
|
return super.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showOverview(){
|
||||||
|
//TODO implement later if necessary
|
||||||
|
/*
|
||||||
|
sectors.captured = Captured Sectors
|
||||||
|
sectors.explored = Explored Sectors
|
||||||
|
sectors.production.total = Total Production
|
||||||
|
sectors.resources.total = Total Resources
|
||||||
|
*/
|
||||||
|
var dialog = new BaseDialog("@overview");
|
||||||
|
dialog.addCloseButton();
|
||||||
|
|
||||||
|
dialog.add("@sectors.captured");
|
||||||
|
}
|
||||||
|
|
||||||
public void showSelect(Sector sector, Cons<Sector> listener){
|
public void showSelect(Sector sector, Cons<Sector> listener){
|
||||||
selected = null;
|
selected = null;
|
||||||
hovered = null;
|
hovered = null;
|
||||||
@@ -149,6 +204,10 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
return launchFrom;
|
return launchFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean showing(){
|
||||||
|
return newPresets.any();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderSectors(Planet planet){
|
public void renderSectors(Planet planet){
|
||||||
|
|
||||||
@@ -159,7 +218,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
|
|
||||||
Color color =
|
Color color =
|
||||||
sec.hasBase() ? Tmp.c2.set(Team.sharded.color).lerp(Team.crux.color, sec.hasEnemyBase() ? 0.5f : 0f) :
|
sec.hasBase() ? Tmp.c2.set(Team.sharded.color).lerp(Team.crux.color, sec.hasEnemyBase() ? 0.5f : 0f) :
|
||||||
sec.preset != null ? Team.derelict.color :
|
sec.preset != null ? Tmp.c2.set(Team.derelict.color).lerp(Color.white, Mathf.absin(Time.time(), 10f, 1f)) :
|
||||||
sec.hasEnemyBase() ? Team.crux.color :
|
sec.hasEnemyBase() ? Team.crux.color :
|
||||||
null;
|
null;
|
||||||
|
|
||||||
@@ -255,7 +314,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
selectAlpha = 1f;
|
selectAlpha = 1f;
|
||||||
|
|
||||||
cont.clear();
|
cont.clear();
|
||||||
titleTable.remove();
|
cont.margin(0f);
|
||||||
|
|
||||||
cont.stack(
|
cont.stack(
|
||||||
new Element(){
|
new Element(){
|
||||||
@@ -264,6 +323,8 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
addListener(new ElementGestureListener(){
|
addListener(new ElementGestureListener(){
|
||||||
@Override
|
@Override
|
||||||
public void tap(InputEvent event, float x, float y, int count, KeyCode button){
|
public void tap(InputEvent event, float x, float y, int count, KeyCode button){
|
||||||
|
if(showing()) return;
|
||||||
|
|
||||||
if(hovered != null && (canSelect(hovered) || debugSelect)){
|
if(hovered != null && (canSelect(hovered) || debugSelect)){
|
||||||
selected = hovered;
|
selected = hovered;
|
||||||
}
|
}
|
||||||
@@ -311,6 +372,23 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
//title text
|
||||||
|
new Table(t -> {
|
||||||
|
t.visible = !mobile;
|
||||||
|
t.touchable = Touchable.disabled;
|
||||||
|
t.top();
|
||||||
|
t.add("").update(l -> {
|
||||||
|
l.getText().setLength(0);
|
||||||
|
if(hovered != null){
|
||||||
|
if(!canSelect(hovered)){
|
||||||
|
l.getText().append("[gray]").append(Iconc.lock).append(" ").append(Core.bundle.get("locked"));
|
||||||
|
}else{
|
||||||
|
l.getText().append("[accent][[ [white]").append(hovered.name()).append("[accent] ]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l.invalidateHierarchy();
|
||||||
|
}).growX().labelAlign(Align.center).center().padTop(-30f);
|
||||||
})).grow();
|
})).grow();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -335,6 +413,11 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void lookAt(Sector sector, float alpha){
|
||||||
|
float len = planets.camPos.len();
|
||||||
|
planets.camPos.slerp(Tmp.v31.set(sector.tile.v).rotate(Vec3.Y, -sector.planet.getRotation()).setLength(len), alpha);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta){
|
public void act(float delta){
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
@@ -347,13 +430,32 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
|
|
||||||
//smooth camera toward the sector
|
//smooth camera toward the sector
|
||||||
if(mode == look && launching){
|
if(mode == look && launching){
|
||||||
float len = planets.camPos.len();
|
lookAt(selected, 0.1f);
|
||||||
planets.camPos.slerp(Tmp.v31.set(selected.tile.v).rotate(Vec3.Y,-selected.planet.getRotation()).setLength(len), 0.1f);
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
stable.remove();
|
stable.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(showing()){
|
||||||
|
Sector to = newPresets.peek();
|
||||||
|
|
||||||
|
presetShow += Time.delta;
|
||||||
|
|
||||||
|
lookAt(to, 0.11f);
|
||||||
|
zoom = 0.75f;
|
||||||
|
|
||||||
|
if(presetShow >= 20f && !showed && newPresets.size > 1){
|
||||||
|
showed = true;
|
||||||
|
ui.announce(Iconc.lockOpen + " [accent]" + to.name(), 2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(presetShow > sectorShowDuration){
|
||||||
|
newPresets.pop();
|
||||||
|
showed = false;
|
||||||
|
presetShow = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(planets.planet.isLandable()){
|
if(planets.planet.isLandable()){
|
||||||
hovered = planets.planet.getSector(planets.cam.getMouseRay(), PlanetRenderer.outlineRad);
|
hovered = planets.planet.getSector(planets.cam.getMouseRay(), PlanetRenderer.outlineRad);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in New Issue
Block a user