diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 268f0853ed..f492a6f473 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -574,6 +574,10 @@ settings.clear.confirm = Are you sure you want to clear this data?\nWhat is done settings.clearall.confirm = [scarlet]WARNING![]\nThis will clear all data, including saves, maps, unlocks and keybinds.\nOnce you press 'ok' the game will wipe all data and automatically exit. settings.clearsaves.confirm = Are you sure you want to clear all your saves? settings.clearsaves = Clear Saves +settings.clearresearch = Clear Research +settings.clearresearch.confirm = Are you sure you want to clear all of your campaign research? +settings.clearcampaignsaves = Clear Campaign Saves +settings.clearcampaignsaves.confirm = Are you sure you want to clear all of your campaign saves? paused = [accent]< Paused > clear = Clear banned = [scarlet]Banned diff --git a/core/src/mindustry/content/TechTree.java b/core/src/mindustry/content/TechTree.java index 6118ca7b74..63eb9f2679 100644 --- a/core/src/mindustry/content/TechTree.java +++ b/core/src/mindustry/content/TechTree.java @@ -605,8 +605,6 @@ public class TechTree implements ContentList{ public final ItemStack[] finishedRequirements; /** Extra objectives needed to research this. */ public Seq objectives = new Seq<>(); - /** Time required to research this content, in seconds. */ - public float time; /** Nodes that depend on this node. */ public final Seq children = new Seq<>(); @@ -617,7 +615,6 @@ public class TechTree implements ContentList{ this.content = content; this.requirements = requirements; this.depth = parent == null ? 0 : parent.depth + 1; - this.time = Seq.with(requirements).mapFloat(i -> i.item.cost * i.amount).sum() * 10; this.finishedRequirements = new ItemStack[requirements.length]; //load up the requirements that have been finished if settings are available @@ -632,6 +629,14 @@ public class TechTree implements ContentList{ all.add(this); } + /** Resets finished requirements and saves. */ + public void reset(){ + for(ItemStack stack : finishedRequirements){ + stack.amount = 0; + } + save(); + } + /** Removes this node from the tech tree. */ public void remove(){ all.remove(this); diff --git a/core/src/mindustry/ctype/UnlockableContent.java b/core/src/mindustry/ctype/UnlockableContent.java index fb182851e0..9e8fb954ec 100644 --- a/core/src/mindustry/ctype/UnlockableContent.java +++ b/core/src/mindustry/ctype/UnlockableContent.java @@ -125,6 +125,14 @@ public abstract class UnlockableContent extends MappableContent{ return unlocked || alwaysUnlocked; } + /** Locks this content again. */ + public void clearUnlock(){ + if(unlocked){ + unlocked = false; + Core.settings.put(name + "-unlocked", false); + } + } + /** @return whether this content is unlocked, or the player is in a custom (non-campaign) game. */ public boolean unlockedNow(){ return unlocked() || !state.isCampaign(); diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 975c8b82c8..d9d54ba91c 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -15,8 +15,7 @@ import static mindustry.Vars.*; /** A small section of a planet. */ public class Sector{ - private static final Seq tmpSeq1 = new Seq<>(), tmpSeq2 = new Seq<>(), tmpSeq3 = new Seq<>(); - private static final ObjectSet tmpSet = new ObjectSet<>(); + private static final Seq tmpSeq1 = new Seq<>(); public final SectorRect rect; public final Plane plane; @@ -80,6 +79,12 @@ public class Sector{ info = Core.settings.getJson(planet.name + "-s-" + id + "-info", SectorInfo.class, SectorInfo::new); } + /** Removes any sector info. */ + public void clearInfo(){ + info = new SectorInfo(); + Core.settings.remove(planet.name + "-s-" + id + "-info"); + } + public float getProductionScale(){ return Math.max(1f - info.damage, 0); } diff --git a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java index c00076d92b..d58b930e77 100644 --- a/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -14,8 +14,11 @@ import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.*; import arc.util.io.*; +import mindustry.content.*; +import mindustry.content.TechTree.*; import mindustry.core.GameState.*; import mindustry.core.*; +import mindustry.ctype.*; import mindustry.game.EventType.*; import mindustry.gen.*; import mindustry.graphics.*; @@ -116,6 +119,37 @@ public class SettingsMenuDialog extends SettingsDialog{ t.row(); + t.button("@settings.clearresearch", Icon.trash, style, () -> { + ui.showConfirm("@confirm", "@settings.clearresearch.confirm", () -> { + for(TechNode node : TechTree.all){ + node.reset(); + } + content.each(c -> { + if(c instanceof UnlockableContent u){ + u.clearUnlock(); + } + }); + }); + }).marginLeft(4); + + t.row(); + + t.button("@settings.clearcampaignsaves", Icon.trash, style, () -> { + ui.showConfirm("@confirm", "@settings.clearcampaignsaves.confirm", () -> { + for(var planet : content.planets()){ + for(var sec : planet.sectors){ + sec.clearInfo(); + if(sec.save != null){ + sec.save.delete(); + sec.save = null; + } + } + } + }); + }).marginLeft(4); + + t.row(); + t.button("@data.export", Icon.upload, style, () -> { if(ios){ Fi file = Core.files.local("mindustry-data-export.zip");