Campaign mechanics
This commit is contained in:
@@ -23,7 +23,7 @@ import static mindustry.gen.Tex.*;
|
||||
|
||||
@StyleDefaults
|
||||
public class Styles{
|
||||
public static Drawable black, black9, black8, black6, black3, none, flatDown, flatOver;
|
||||
public static Drawable black, black9, black8, black6, black3, black5, none, flatDown, flatOver;
|
||||
public static ButtonStyle defaultb, waveb;
|
||||
public static TextButtonStyle defaultt, squaret, nodet, cleart, discordt, infot, clearPartialt, clearTogglet, clearToggleMenut, togglet, transt;
|
||||
public static ImageButtonStyle defaulti, nodei, righti, emptyi, emptytogglei, selecti, cleari, clearFulli, clearPartiali, clearPartial2i, clearTogglei, clearTransi, clearToggleTransi, clearTogglePartiali;
|
||||
@@ -40,6 +40,7 @@ public class Styles{
|
||||
black9 = whiteui.tint(0f, 0f, 0f, 0.9f);
|
||||
black8 = whiteui.tint(0f, 0f, 0f, 0.8f);
|
||||
black6 = whiteui.tint(0f, 0f, 0f, 0.6f);
|
||||
black5 = whiteui.tint(0f, 0f, 0f, 0.5f);
|
||||
black3 = whiteui.tint(0f, 0f, 0f, 0.3f);
|
||||
none = whiteui.tint(0f, 0f, 0f, 0f);
|
||||
flatDown = createFlatDown();
|
||||
|
||||
@@ -34,6 +34,12 @@ public class PausedDialog extends BaseDialog{
|
||||
});
|
||||
|
||||
if(!mobile){
|
||||
//TODO localize
|
||||
cont.label(() -> state.getSector() == null ? "" :
|
||||
"[lightgray]Next turn in [accent]" + state.getSector().displayTimeRemaining())
|
||||
.visible(() -> state.getSector() != null).colspan(2);
|
||||
cont.row();
|
||||
|
||||
float dw = 220f;
|
||||
cont.defaults().width(dw).height(55).pad(5f);
|
||||
|
||||
@@ -45,7 +51,10 @@ public class PausedDialog extends BaseDialog{
|
||||
//}else{
|
||||
// cont.button("$database", Icon.book, ui.database::show);
|
||||
//}
|
||||
cont.button("placeholder", Icon.warning, () -> ui.showInfo("go away"));
|
||||
//TODO remove
|
||||
cont.button("launch core", Icon.warning, () -> ui.planet.show(state.getSector(), player.team().core()))
|
||||
.disabled(b -> player.team().core() == null || !player.team().core().items.has(player.team().core().block.requirements))
|
||||
.visible(() -> state.isCampaign());
|
||||
cont.button("$settings", Icon.settings, ui.settings::show);
|
||||
|
||||
if(!state.rules.tutorial){
|
||||
|
||||
@@ -7,6 +7,7 @@ import arc.graphics.gl.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
@@ -197,19 +198,36 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
||||
cont.clear();
|
||||
titleTable.remove();
|
||||
|
||||
//add listener to the background rect, so it doesn't get unnecessary touch input
|
||||
cont.rect((x, y, w, h) -> planets.render(this)).grow().get().addListener(new ElementGestureListener(){
|
||||
@Override
|
||||
public void tap(InputEvent event, float x, float y, int count, KeyCode button){
|
||||
if(hovered != null && (mode == launch ? canLaunch(hovered) && hovered != launchSector : hovered.unlocked())){
|
||||
selected = hovered;
|
||||
}
|
||||
|
||||
if(selected != null){
|
||||
updateSelected();
|
||||
}
|
||||
cont.stack(
|
||||
new Element(){
|
||||
{
|
||||
//add listener to the background rect, so it doesn't get unnecessary touch input
|
||||
addListener(new ElementGestureListener(){
|
||||
@Override
|
||||
public void tap(InputEvent event, float x, float y, int count, KeyCode button){
|
||||
if(hovered != null && (mode == launch ? canLaunch(hovered) && hovered != launchSector : hovered.unlocked())){
|
||||
selected = hovered;
|
||||
}
|
||||
|
||||
if(selected != null){
|
||||
updateSelected();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
planets.render(PlanetDialog.this);
|
||||
}
|
||||
},
|
||||
new Table(t -> {
|
||||
//TODO localize
|
||||
t.top();
|
||||
t.label(() -> "Turn " + universe.turn()).style(Styles.outlineLabel).color(Pal.accent);
|
||||
})).grow();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,6 +47,7 @@ public class HudFragment extends Fragment{
|
||||
|
||||
//TODO details and stuff
|
||||
Events.on(SectorCaptureEvent.class, e ->{
|
||||
//TODO localize
|
||||
showToast("Sector[accent] captured[]!");
|
||||
});
|
||||
|
||||
@@ -55,6 +56,16 @@ public class HudFragment extends Fragment{
|
||||
coreItems.resetUsed();
|
||||
});
|
||||
|
||||
Events.on(TurnEvent.class, e -> {
|
||||
ui.announce("[accent][[ Turn " + universe.turn() + " ]");
|
||||
});
|
||||
|
||||
//paused table
|
||||
parent.fill(t -> {
|
||||
t.top().visible(() -> state.isPaused() && !state.isOutOfTime()).touchable(Touchable.disabled);
|
||||
t.table(Styles.black5, top -> top.add("$paused").style(Styles.outlineLabel).pad(8f)).growX();
|
||||
});
|
||||
|
||||
//TODO tear this all down
|
||||
//menu at top left
|
||||
parent.fill(cont -> {
|
||||
@@ -254,6 +265,27 @@ public class HudFragment extends Fragment{
|
||||
.update(label -> label.getColor().set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time(), 2f, 1f)))).touchable(Touchable.disabled);
|
||||
});
|
||||
|
||||
//paused table for when the player is out of time
|
||||
parent.fill(t -> {
|
||||
t.top().visible(() -> state.isOutOfTime());
|
||||
t.table(Styles.black5, top -> {
|
||||
//TODO localize when done
|
||||
top.add("Out of sector time.").style(Styles.outlineLabel).color(Pal.accent).update(l -> l.color.a = Mathf.absin(Time.globalTime(), 7f, 1f)).colspan(2);
|
||||
top.row();
|
||||
|
||||
top.defaults().pad(2).size(150f, 54f);
|
||||
top.button("Next Turn", () -> {
|
||||
universe.runTurn();
|
||||
state.set(State.playing);
|
||||
});
|
||||
|
||||
top.button("Back to Planet", () -> {
|
||||
ui.paused.runExitSave();
|
||||
ui.planet.show();
|
||||
});
|
||||
}).margin(8).growX();
|
||||
});
|
||||
|
||||
//tutorial text
|
||||
parent.fill(t -> {
|
||||
Runnable resize = () -> {
|
||||
@@ -276,12 +308,6 @@ public class HudFragment extends Fragment{
|
||||
Events.on(ResizeEvent.class, e -> resize.run());
|
||||
});
|
||||
|
||||
//paused table
|
||||
parent.fill(t -> {
|
||||
t.top().visible(() -> state.isPaused()).touchable(Touchable.disabled);
|
||||
t.table(Tex.buttonTrans, top -> top.add("$paused").pad(5f));
|
||||
});
|
||||
|
||||
//'saving' indicator
|
||||
parent.fill(t -> {
|
||||
t.bottom().visible(() -> control.saves.isSaving());
|
||||
@@ -335,14 +361,6 @@ public class HudFragment extends Fragment{
|
||||
}).visible(() -> state.isCampaign() && content.items().contains(i -> state.secinfo.getExport(i) > 0));
|
||||
});
|
||||
|
||||
//TODO move, select loadout, consume resources
|
||||
parent.fill(t -> {
|
||||
t.bottom().visible(() -> state.isCampaign() && player.team().core() != null);
|
||||
|
||||
t.button("test launch", Icon.warning, () -> ui.planet.show(state.getSector(), player.team().core()))
|
||||
.width(150f).disabled(b -> player.team().core() == null || !player.team().core().items.has(player.team().core().block.requirements)); //disable core when missing resources for launch
|
||||
});
|
||||
|
||||
blockfrag.build(parent);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user