mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-10 07:47:25 +07:00
Added buttons to clear campaign saves & research
This commit is contained in:
@ -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.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.confirm = Are you sure you want to clear all your saves?
|
||||||
settings.clearsaves = Clear 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 >
|
paused = [accent]< Paused >
|
||||||
clear = Clear
|
clear = Clear
|
||||||
banned = [scarlet]Banned
|
banned = [scarlet]Banned
|
||||||
|
@ -605,8 +605,6 @@ public class TechTree implements ContentList{
|
|||||||
public final ItemStack[] finishedRequirements;
|
public final ItemStack[] finishedRequirements;
|
||||||
/** Extra objectives needed to research this. */
|
/** Extra objectives needed to research this. */
|
||||||
public Seq<Objective> objectives = new Seq<>();
|
public Seq<Objective> objectives = new Seq<>();
|
||||||
/** Time required to research this content, in seconds. */
|
|
||||||
public float time;
|
|
||||||
/** Nodes that depend on this node. */
|
/** Nodes that depend on this node. */
|
||||||
public final Seq<TechNode> children = new Seq<>();
|
public final Seq<TechNode> children = new Seq<>();
|
||||||
|
|
||||||
@ -617,7 +615,6 @@ public class TechTree implements ContentList{
|
|||||||
this.content = content;
|
this.content = content;
|
||||||
this.requirements = requirements;
|
this.requirements = requirements;
|
||||||
this.depth = parent == null ? 0 : parent.depth + 1;
|
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];
|
this.finishedRequirements = new ItemStack[requirements.length];
|
||||||
|
|
||||||
//load up the requirements that have been finished if settings are available
|
//load up the requirements that have been finished if settings are available
|
||||||
@ -632,6 +629,14 @@ public class TechTree implements ContentList{
|
|||||||
all.add(this);
|
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. */
|
/** Removes this node from the tech tree. */
|
||||||
public void remove(){
|
public void remove(){
|
||||||
all.remove(this);
|
all.remove(this);
|
||||||
|
@ -125,6 +125,14 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
return unlocked || alwaysUnlocked;
|
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. */
|
/** @return whether this content is unlocked, or the player is in a custom (non-campaign) game. */
|
||||||
public boolean unlockedNow(){
|
public boolean unlockedNow(){
|
||||||
return unlocked() || !state.isCampaign();
|
return unlocked() || !state.isCampaign();
|
||||||
|
@ -15,8 +15,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
/** A small section of a planet. */
|
/** A small section of a planet. */
|
||||||
public class Sector{
|
public class Sector{
|
||||||
private static final Seq<Sector> tmpSeq1 = new Seq<>(), tmpSeq2 = new Seq<>(), tmpSeq3 = new Seq<>();
|
private static final Seq<Sector> tmpSeq1 = new Seq<>();
|
||||||
private static final ObjectSet<Sector> tmpSet = new ObjectSet<>();
|
|
||||||
|
|
||||||
public final SectorRect rect;
|
public final SectorRect rect;
|
||||||
public final Plane plane;
|
public final Plane plane;
|
||||||
@ -80,6 +79,12 @@ public class Sector{
|
|||||||
info = Core.settings.getJson(planet.name + "-s-" + id + "-info", SectorInfo.class, SectorInfo::new);
|
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(){
|
public float getProductionScale(){
|
||||||
return Math.max(1f - info.damage, 0);
|
return Math.max(1f - info.damage, 0);
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,11 @@ import arc.scene.ui.layout.*;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.content.TechTree.*;
|
||||||
import mindustry.core.GameState.*;
|
import mindustry.core.GameState.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
|
import mindustry.ctype.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@ -116,6 +119,37 @@ public class SettingsMenuDialog extends SettingsDialog{
|
|||||||
|
|
||||||
t.row();
|
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, () -> {
|
t.button("@data.export", Icon.upload, style, () -> {
|
||||||
if(ios){
|
if(ios){
|
||||||
Fi file = Core.files.local("mindustry-data-export.zip");
|
Fi file = Core.files.local("mindustry-data-export.zip");
|
||||||
|
Reference in New Issue
Block a user