diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 59fe4800e7..9e03774bcc 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -569,6 +569,7 @@ uncover = Uncover configure = Configure Loadout objective.research = [accent]Research:\n[]{0}[lightgray]{1} +objective.item = [accent]Obtain: [][lightgray]{0}[]/{1}\n{2}[lightgray]{3} loadout = Loadout resources = Resources diff --git a/core/src/mindustry/content/SectorPresets.java b/core/src/mindustry/content/SectorPresets.java index d43e902127..9069e5f88d 100644 --- a/core/src/mindustry/content/SectorPresets.java +++ b/core/src/mindustry/content/SectorPresets.java @@ -115,7 +115,7 @@ public class SectorPresets{ difficulty = 1; rules = r -> { - r.objectives.addAll(new ResearchObjective(Items.beryllium){{ + r.objectives.addAll(new ItemObjective(Items.beryllium, 20){{ markers = new ObjectiveMarker[]{ new TextMarker("Units can mine [accent]resources[] from walls.", 1984f, 2240f + 16f), new ShapeMarker(1984f, 2240f), diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 0a2a43e58a..f219474d48 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -313,6 +313,7 @@ public class Logic implements ApplicationListener{ if(!net.client() && first.complete()){ state.rules.objectives.remove(0); + first.completed(); if(!headless){ //delete markers for(var marker : first.markers){ diff --git a/core/src/mindustry/game/MapObjectives.java b/core/src/mindustry/game/MapObjectives.java index 786bd8a955..8179547333 100644 --- a/core/src/mindustry/game/MapObjectives.java +++ b/core/src/mindustry/game/MapObjectives.java @@ -5,10 +5,12 @@ import arc.func.*; import arc.graphics.*; import arc.graphics.g2d.*; import arc.util.*; +import mindustry.*; import mindustry.content.*; import mindustry.ctype.*; import mindustry.gen.*; import mindustry.graphics.*; +import mindustry.type.*; public class MapObjectives{ public static Prov[] allObjectiveTypes = new Prov[]{ @@ -45,6 +47,29 @@ public class MapObjectives{ } } + public static class ItemObjective extends MapObjective{ + public Item item = Items.copper; + public int amount = 1; + + public ItemObjective(Item item, int amount){ + this.item = item; + this.amount = amount; + } + + public ItemObjective(){ + } + + @Override + public String text(){ + return Core.bundle.format("objective.item", Vars.state.rules.defaultTeam.items().get(item), amount, item.emoji(), item.localizedName); + } + + @Override + public boolean complete(){ + return Vars.state.rules.defaultTeam.items().has(item, amount); + } + } + public static abstract class MapObjective{ public ObjectiveMarker[] markers = {}; @@ -52,6 +77,11 @@ public class MapObjectives{ return false; } + /** Called immediately after this objective is completed and removed from the rules. */ + public void completed(){ + + } + public void update(){ } @@ -61,10 +91,12 @@ public class MapObjectives{ } + /** Basic mission display text. */ public @Nullable String text(){ return null; } + /** Details that appear upon click. */ public @Nullable String details(){ return null; } diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index 569a596998..b704c3ebee 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -215,7 +215,7 @@ public class HudFragment{ }else{ logic.skipWave(); } - }).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip"); + }).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).name("skip").get().toBack(); }).width(dsize * 5 + 4f).name("statustable"); wavesMain.row(); @@ -744,7 +744,24 @@ public class HudFragment{ t.getChildren().get(1).toFront(); })).size(120f, 80).padRight(4); - table.labelWrap(() -> { + Cell[] lcell = {null}; + boolean[] couldSkip = {true}; + + lcell[0] = table.labelWrap(() -> { + + //update padding depend on whether the button to the right is there + boolean can = canSkipWave(); + if(can != couldSkip[0]){ + if(canSkipWave()){ + lcell[0].padRight(8f); + }else{ + lcell[0].padRight(-42f); + } + table.invalidateHierarchy(); + table.pack(); + couldSkip[0] = can; + } + builder.setLength(0); //objectives override mission?