Loadout selection + custom loadout schematics
This commit is contained in:
56
core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java
Normal file
56
core/src/mindustry/ui/dialogs/LaunchLoadoutDialog.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package mindustry.ui.dialogs;
|
||||
|
||||
import arc.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.SchematicsDialog.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/** Dialog for selecting loadout at sector launch. */
|
||||
public class LaunchLoadoutDialog extends BaseDialog{
|
||||
Schematic selected;
|
||||
|
||||
public LaunchLoadoutDialog(){
|
||||
super("$configure");
|
||||
}
|
||||
|
||||
public void show(CoreBlock core, Building build, Runnable confirm){
|
||||
cont.clear();
|
||||
buttons.clear();
|
||||
|
||||
addCloseButton();
|
||||
buttons.button("$ok", () -> {
|
||||
universe.updateLoadout(core, selected);
|
||||
confirm.run();
|
||||
hide();
|
||||
});
|
||||
|
||||
int cols = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
||||
ButtonGroup<Button> group = new ButtonGroup<>();
|
||||
selected = universe.getLoadout(core);
|
||||
|
||||
cont.pane(t -> {
|
||||
int i = 0;
|
||||
|
||||
for(Schematic s : schematics.getLoadouts(core)){
|
||||
|
||||
t.button(b -> b.add(new SchematicImage(s)), Styles.togglet, () -> selected = s)
|
||||
.group(group).pad(4).disabled(!build.items.has(s.requirements())).checked(s == selected).size(200f);
|
||||
|
||||
if(++i % cols == 0){
|
||||
t.row();
|
||||
}
|
||||
}
|
||||
}).growX().get().setScrollingDisabled(true, false);
|
||||
|
||||
//TODO configure items to launch with
|
||||
|
||||
show();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import static mindustry.ui.dialogs.PlanetDialog.Mode.*;
|
||||
public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
private final FrameBuffer buffer = new FrameBuffer(2, 2, true);
|
||||
private final PlanetRenderer planets = renderer.planets;
|
||||
private final LaunchLoadoutDialog loadouts = new LaunchLoadoutDialog();
|
||||
private final Table stable = new Table().background(Styles.black3);
|
||||
|
||||
private int launchRange;
|
||||
@@ -331,7 +332,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
return;
|
||||
}
|
||||
|
||||
hide();
|
||||
boolean shouldHide = true;
|
||||
|
||||
//save before launch.
|
||||
if(control.saves.getCurrent() != null && state.isGame()){
|
||||
@@ -344,14 +345,19 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
}
|
||||
|
||||
if(mode == launch){
|
||||
control.handleLaunch(launcher);
|
||||
zoom = 0.5f;
|
||||
shouldHide = false;
|
||||
loadouts.show((CoreBlock)launcher.block, launcher, () -> {
|
||||
control.handleLaunch(launcher);
|
||||
zoom = 0.5f;
|
||||
|
||||
ui.hudfrag.showLaunchDirect();
|
||||
Time.runTask(launchDuration, () -> control.playSector(sector));
|
||||
ui.hudfrag.showLaunchDirect();
|
||||
Time.runTask(launchDuration, () -> control.playSector(sector));
|
||||
});
|
||||
}else{
|
||||
control.playSector(sector);
|
||||
}
|
||||
|
||||
if(shouldHide) hide();
|
||||
}).growX().padTop(2f).height(50f).minWidth(170f);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class SchematicsDialog extends BaseDialog{
|
||||
});
|
||||
|
||||
rebuildPane[0] = () -> {
|
||||
int maxwidth = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
||||
int cols = Math.max((int)(Core.graphics.getWidth() / Scl.scl(230)), 1);
|
||||
|
||||
t.clear();
|
||||
int i = 0;
|
||||
@@ -153,7 +153,7 @@ public class SchematicsDialog extends BaseDialog{
|
||||
|
||||
sel[0].getStyle().up = Tex.pane;
|
||||
|
||||
if(++i % maxwidth == 0){
|
||||
if(++i % cols == 0){
|
||||
t.row();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user