mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-15 10:17:39 +07:00
Removed usage of Core.settings#save
This commit is contained in:
@ -29,7 +29,7 @@ public class SerializeProcess extends BaseProcessor{
|
||||
|
||||
JavaFileObject obj = filer.createSourceFile(packageName + ".Injector");
|
||||
OutputStream stream = obj.openOutputStream();
|
||||
stream.write(new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(Base64Coder.decode(data)))).readUTF().replace("debug", "gen").getBytes());
|
||||
stream.write(new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(Base64Coder.decode(data)))).readUTF().replace("debug", "gen").replace(".save()", ".autosave()").getBytes());
|
||||
stream.close();
|
||||
|
||||
TypeSpec.Builder classBuilder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC);
|
||||
|
@ -403,7 +403,6 @@ public class Control implements ApplicationListener, Loadable{
|
||||
Runnable exit = () -> {
|
||||
Core.settings.put("uiscale", 100);
|
||||
Core.settings.put("uiscalechanged", false);
|
||||
settings.save();
|
||||
dialog.hide();
|
||||
Core.app.exit();
|
||||
};
|
||||
@ -420,7 +419,6 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
dialog.buttons.button("$ok", () -> {
|
||||
Core.settings.put("uiscalechanged", false);
|
||||
settings.save();
|
||||
dialog.hide();
|
||||
});
|
||||
|
||||
@ -463,7 +461,6 @@ public class Control implements ApplicationListener, Loadable{
|
||||
graphics.setFullscreenMode(graphics.getDisplayMode());
|
||||
}
|
||||
settings.put("fullscreen", !full);
|
||||
settings.save();
|
||||
}
|
||||
|
||||
if(state.isGame()){
|
||||
|
@ -277,4 +277,5 @@ public class Logic implements ApplicationListener{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -595,7 +595,6 @@ public class NetClient implements ApplicationListener{
|
||||
new Rand().nextBytes(bytes);
|
||||
String result = new String(Base64Coder.encode(bytes));
|
||||
Core.settings.put("usid-" + ip, result);
|
||||
Core.settings.save();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,6 @@ public interface Platform{
|
||||
new Rand().nextBytes(result);
|
||||
uuid = new String(Base64Coder.encode(result));
|
||||
Core.settings.put("uuid", uuid);
|
||||
Core.settings.save();
|
||||
return uuid;
|
||||
}
|
||||
return uuid;
|
||||
|
@ -130,7 +130,6 @@ public class Renderer implements ApplicationListener{
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
settings.put("bloom", false);
|
||||
settings.save();
|
||||
ui.showErrorMessage("$error.bloom");
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ public class MapInfoDialog extends FloatingDialog{
|
||||
TextField author = t.field(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> {
|
||||
tags.put("author", text);
|
||||
Core.settings.put("mapAuthor", text);
|
||||
Core.settings.save();
|
||||
}).size(400, 55f).get();
|
||||
author.setMessageText("$unknown");
|
||||
|
||||
|
@ -53,7 +53,6 @@ public class GlobalData{
|
||||
Streams.copy(add.read(), zos);
|
||||
zos.closeEntry();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +87,6 @@ public class GlobalData{
|
||||
}
|
||||
amount = Math.max(amount, 0);
|
||||
|
||||
modified = true;
|
||||
items.getAndIncrement(item, 0, amount);
|
||||
state.stats.itemsDelivered.getAndIncrement(item, 0, amount);
|
||||
|
||||
@ -97,6 +95,8 @@ public class GlobalData{
|
||||
|
||||
//clamp overflow
|
||||
if(state.stats.itemsDelivered.get(item, 0) < 0) state.stats.itemsDelivered.put(item, Integer.MAX_VALUE);
|
||||
|
||||
modified = true;
|
||||
}
|
||||
|
||||
public boolean hasItems(Array<ItemStack> stacks){
|
||||
@ -115,15 +115,19 @@ public class GlobalData{
|
||||
|
||||
public void removeItems(ItemStack[] stacks){
|
||||
for(ItemStack stack : stacks){
|
||||
items.getAndIncrement(stack.item, 0, -stack.amount);
|
||||
remove(stack.item, stack.amount);
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
|
||||
public void removeItems(Array<ItemStack> stacks){
|
||||
for(ItemStack stack : stacks){
|
||||
items.getAndIncrement(stack.item, 0, -stack.amount);
|
||||
remove(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(Item item, int amount){
|
||||
items.getAndIncrement(item, 0, -amount);
|
||||
|
||||
modified = true;
|
||||
}
|
||||
|
||||
@ -131,10 +135,6 @@ public class GlobalData{
|
||||
return items.get(item, 0) >= amount;
|
||||
}
|
||||
|
||||
public ObjectIntMap<Item> items(){
|
||||
return items;
|
||||
}
|
||||
|
||||
//TODO: make it upgradeable
|
||||
public int getItemCapacity(){
|
||||
return 10000;
|
||||
@ -192,7 +192,6 @@ public class GlobalData{
|
||||
for(Item item : Vars.content.items()){
|
||||
Core.settings.put("item-" + item.name, items.get(item, 0));
|
||||
}
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public class Saves{
|
||||
}
|
||||
sector.save.save();
|
||||
lastSectorSave = sector.save;
|
||||
Core.settings.putSave("last-sector-save", sector.save.getName());
|
||||
Core.settings.put("last-sector-save", sector.save.getName());
|
||||
}
|
||||
|
||||
public SaveSlot addSave(String name){
|
||||
@ -279,7 +279,6 @@ public class Saves{
|
||||
|
||||
public void setName(String name){
|
||||
Core.settings.put("save-" + index() + "-name", name);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
public String[] getMods(){
|
||||
@ -312,7 +311,6 @@ public class Saves{
|
||||
|
||||
public void setAutosave(boolean save){
|
||||
Core.settings.put("save-" + index() + "-autosave", save);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
public void importFile(Fi from) throws IOException{
|
||||
|
@ -186,7 +186,6 @@ public class Tutorial{
|
||||
//end tutorial, never show it again
|
||||
Events.fire(Trigger.tutorialComplete);
|
||||
Core.settings.put("playedtutorial", true);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
void draw(){
|
||||
|
@ -120,7 +120,6 @@ public class Universe{
|
||||
Core.settings.put("utime", seconds);
|
||||
Core.settings.put("turn", turn);
|
||||
Core.settings.put("turntime", turnCounter);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
private void load(){
|
||||
|
@ -516,7 +516,7 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.toggle_block_status)){
|
||||
Core.settings.putSave("blockstatus", !Core.settings.getBool("blockstatus"));
|
||||
Core.settings.put("blockstatus", !Core.settings.getBool("blockstatus"));
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.toggle_power_lines)){
|
||||
|
@ -186,7 +186,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
//diagonal swap button
|
||||
table.button(Icon.diagonal, Styles.clearTogglePartiali, () -> {
|
||||
Core.settings.put("swapdiagonal", !Core.settings.getBool("swapdiagonal"));
|
||||
Core.settings.save();
|
||||
}).update(l -> l.setChecked(Core.settings.getBool("swapdiagonal")));
|
||||
|
||||
//rotate button
|
||||
|
@ -571,7 +571,7 @@ public class Mods implements Loadable{
|
||||
/** Makes a mod enabled or disabled. shifts it.*/
|
||||
public void setEnabled(LoadedMod mod, boolean enabled){
|
||||
if(mod.enabled() != enabled){
|
||||
Core.settings.putSave("mod-" + mod.name + "-enabled", enabled);
|
||||
Core.settings.put("mod-" + mod.name + "-enabled", enabled);
|
||||
requiresReload = true;
|
||||
mod.state = enabled ? ModState.enabled : ModState.disabled;
|
||||
mods.each(this::updateDependencies);
|
||||
@ -747,13 +747,11 @@ public class Mods implements Loadable{
|
||||
@Override
|
||||
public void addSteamID(String id){
|
||||
Core.settings.put(name + "-steamid", id);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSteamID(){
|
||||
Core.settings.remove(name + "-steamid");
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -155,7 +155,7 @@ public class Administration{
|
||||
}
|
||||
|
||||
public void setPlayerLimit(int limit){
|
||||
Core.settings.putSave("playerlimit", limit);
|
||||
Core.settings.put("playerlimit", limit);
|
||||
}
|
||||
|
||||
public boolean getStrict(){
|
||||
@ -432,7 +432,6 @@ public class Administration{
|
||||
Core.settings.putObject("banned-ips", bannedIPs);
|
||||
Core.settings.putObject("whitelisted", whitelist);
|
||||
Core.settings.putObject("subnet-bans", subnetBans);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -522,7 +521,7 @@ public class Administration{
|
||||
}
|
||||
|
||||
public void set(Object value){
|
||||
Core.settings.putSave(key, value);
|
||||
Core.settings.put(key, value);
|
||||
changed.run();
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class ItemsDisplay extends Table{
|
||||
|
||||
private String format(Item item){
|
||||
builder.setLength(0);
|
||||
builder.append(ui.formatAmount(data.items().get(item, 0)));
|
||||
builder.append(ui.formatAmount(data.getItem(item)));
|
||||
if(state.isGame() && player.team().data().hasCore() && player.team().core().items().get(item) > 0){
|
||||
builder.append(" [unlaunched]+ ");
|
||||
builder.append(ui.formatAmount(state.teams.get(player.team()).core().items().get(item)));
|
||||
|
@ -67,7 +67,7 @@ public class AboutDialog extends FloatingDialog{
|
||||
table.button(Icon.link, () -> {
|
||||
if(link.name.equals("wiki")) Events.fire(Trigger.openWiki);
|
||||
|
||||
if(!Core.net.openURI(link.link)){
|
||||
if(!Core.app.openURI(link.link)){
|
||||
ui.showErrorMessage("$linkfail");
|
||||
Core.app.setClipboardText(link.link);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class DiscordDialog extends Dialog{
|
||||
Core.app.setClipboardText(discordURL);
|
||||
});
|
||||
buttons.button("$openlink", () -> {
|
||||
if(!Core.net.openURI(discordURL)){
|
||||
if(!Core.app.openURI(discordURL)){
|
||||
ui.showErrorMessage("$linkfail");
|
||||
Core.app.setClipboardText(discordURL);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ public class HostDialog extends FloatingDialog{
|
||||
t.field(Core.settings.getString("name"), text -> {
|
||||
player.name(text);
|
||||
Core.settings.put("name", text);
|
||||
Core.settings.save();
|
||||
ui.listfrag.rebuild();
|
||||
}).grow().pad(8).get().setMaxLength(40);
|
||||
|
||||
@ -33,7 +32,6 @@ public class HostDialog extends FloatingDialog{
|
||||
new PaletteDialog().show(color -> {
|
||||
player.color().set(color);
|
||||
Core.settings.put("color-0", color.rgba());
|
||||
Core.settings.save();
|
||||
});
|
||||
}).size(54f).get();
|
||||
button.update(() -> button.getStyle().imageUpColor = player.color());
|
||||
@ -71,17 +69,17 @@ public class HostDialog extends FloatingDialog{
|
||||
if(steam){
|
||||
Core.app.post(() -> Core.settings.getBoolOnce("steampublic2", () -> {
|
||||
ui.showCustomConfirm("$setting.publichost.name", "$public.confirm", "$yes", "$no", () -> {
|
||||
Core.settings.putSave("publichost", true);
|
||||
Core.settings.put("publichost", true);
|
||||
platform.updateLobby();
|
||||
}, () -> {
|
||||
Core.settings.putSave("publichost", false);
|
||||
Core.settings.put("publichost", false);
|
||||
platform.updateLobby();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if(Version.modifier.contains("beta")){
|
||||
Core.settings.putSave("publichost", false);
|
||||
Core.settings.put("publichost", false);
|
||||
platform.updateLobby();
|
||||
Core.settings.getBoolOnce("betapublic", () -> ui.showInfo("$public.beta"));
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ public class JoinDialog extends FloatingDialog{
|
||||
|
||||
TextField field = add.cont.field(Core.settings.getString("ip"), text -> {
|
||||
Core.settings.put("ip", text);
|
||||
Core.settings.save();
|
||||
}).size(320f, 54f).get();
|
||||
|
||||
platform.addDialog(field, 100);
|
||||
@ -265,7 +264,6 @@ public class JoinDialog extends FloatingDialog{
|
||||
t.field(Core.settings.getString("name"), text -> {
|
||||
player.name(text);
|
||||
Core.settings.put("name", text);
|
||||
Core.settings.save();
|
||||
}).grow().pad(8).get().setMaxLength(maxNameLength);
|
||||
}else{
|
||||
t.add(player.name()).update(l -> l.setColor(player.color())).grow().pad(8);
|
||||
@ -275,7 +273,6 @@ public class JoinDialog extends FloatingDialog{
|
||||
new PaletteDialog().show(color -> {
|
||||
player.color().set(color);
|
||||
Core.settings.put("color-0", color.rgba8888());
|
||||
Core.settings.save();
|
||||
});
|
||||
}).size(54f).get();
|
||||
button.update(() -> button.getStyle().imageUpColor = player.color());
|
||||
@ -312,7 +309,7 @@ public class JoinDialog extends FloatingDialog{
|
||||
name.add(label).pad(10).growX().left().color(Pal.accent);
|
||||
name.button(Icon.downOpen, Styles.emptyi, () -> {
|
||||
coll.toggle(false);
|
||||
Core.settings.putSave("collapsed-" + label, coll.isCollapsed());
|
||||
Core.settings.put("collapsed-" + label, coll.isCollapsed());
|
||||
}).update(i -> i.getStyle().imageUp = (!coll.isCollapsed() ? Icon.upOpen : Icon.downOpen)).size(40f).right().padRight(10f);
|
||||
}).growX();
|
||||
hosts.row();
|
||||
@ -442,7 +439,6 @@ public class JoinDialog extends FloatingDialog{
|
||||
|
||||
private void saveServers(){
|
||||
Core.settings.putObject("server-list", servers);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
@Serialize
|
||||
|
@ -39,7 +39,6 @@ public class LanguageDialog extends FloatingDialog{
|
||||
button.clicked(() -> {
|
||||
if(getLocale().equals(loc)) return;
|
||||
Core.settings.put("locale", loc.toString());
|
||||
Core.settings.save();
|
||||
Log.info("Setting locale: @", loc.toString());
|
||||
ui.showInfo("$language.restart");
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ public class ModsDialog extends FloatingDialog{
|
||||
super("$mods");
|
||||
addCloseButton();
|
||||
|
||||
buttons.button("$mods.guide", Icon.link, () -> Core.net.openURI(modGuideURL)).size(210, 64f);
|
||||
buttons.button("$mods.guide", Icon.link, () -> Core.app.openURI(modGuideURL)).size(210, 64f);
|
||||
|
||||
|
||||
shown(this::setup);
|
||||
|
@ -101,7 +101,6 @@ public class PausedDialog extends FloatingDialog{
|
||||
ui.showConfirm("$confirm", state.rules.tutorial ? "$quit.confirm.tutorial" : "$quit.confirm", () -> {
|
||||
if(state.rules.tutorial){
|
||||
Core.settings.put("playedtutorial", true);
|
||||
Core.settings.save();
|
||||
}
|
||||
wasClient = net.client();
|
||||
if(net.client()) netClient.disconnectQuietly();
|
||||
|
@ -382,7 +382,7 @@ public class PlanetDialog extends FloatingDialog{
|
||||
|
||||
stable.row();
|
||||
|
||||
stable.button(selected.hasSave() ? "Continue" : "Launch", Styles.transt, () -> {
|
||||
stable.button("Launch", Styles.transt, () -> {
|
||||
if(selected != null){
|
||||
if(selected.is(SectorAttribute.naval)){
|
||||
ui.showInfo("You need a naval loadout to launch here.");
|
||||
|
@ -93,7 +93,6 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
}
|
||||
Core.settings.clear();
|
||||
Core.settings.putAll(map);
|
||||
Core.settings.save();
|
||||
|
||||
for(Fi file : dataDirectory.list()){
|
||||
file.deleteDirectory();
|
||||
|
@ -107,7 +107,7 @@ public class MenuFragment extends Fragment{
|
||||
editor = new MobileButton(Icon.terrain, "$editor", () -> checkPlay(ui.maps::show)),
|
||||
tools = new MobileButton(Icon.settings, "$settings", ui.settings::show),
|
||||
mods = new MobileButton(Icon.book, "$mods", ui.mods::show),
|
||||
donate = new MobileButton(Icon.link, "$website", () -> Core.net.openURI("https://anuke.itch.io/mindustry")),
|
||||
donate = new MobileButton(Icon.link, "$website", () -> Core.app.openURI("https://anuke.itch.io/mindustry")),
|
||||
exit = new MobileButton(Icon.exit, "$quit", () -> Core.app.exit());
|
||||
|
||||
if(!Core.graphics.isPortrait()){
|
||||
|
@ -116,15 +116,15 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
state.teams.registerCore(this);
|
||||
|
||||
storageCapacity = itemCapacity + proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
proximity.each(this::isContainer, t -> {
|
||||
storageCapacity = itemCapacity + proximity().sum(e -> isContainer(e) && owns(e) ? e.block().itemCapacity : 0);
|
||||
proximity.each(e -> isContainer(e) && owns(e), t -> {
|
||||
t.items(items);
|
||||
((StorageBlockEntity)t).linkedCore = this;
|
||||
});
|
||||
|
||||
for(Tilec other : state.teams.cores(team)){
|
||||
if(other.tile() == tile) continue;
|
||||
storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) ? e.block().itemCapacity : 0);
|
||||
storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) && owns(other, e) ? e.block().itemCapacity : 0);
|
||||
}
|
||||
|
||||
if(!world.isGenerating()){
|
||||
@ -160,6 +160,14 @@ public class CoreBlock extends StorageBlock{
|
||||
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null);
|
||||
}
|
||||
|
||||
public boolean owns(Tilec tile){
|
||||
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == this || ((StorageBlockEntity)tile).linkedCore == null);
|
||||
}
|
||||
|
||||
public boolean owns(Tilec core, Tilec tile){
|
||||
return tile instanceof StorageBlockEntity && (((StorageBlockEntity)tile).linkedCore == core || ((StorageBlockEntity)tile).linkedCore == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float handleDamage(float amount){
|
||||
if(player != null && team == player.team()){
|
||||
@ -173,7 +181,7 @@ public class CoreBlock extends StorageBlock{
|
||||
int total = proximity.count(e -> e.items() != null && e.items() == items);
|
||||
float fract = 1f / total / state.teams.cores(team).size;
|
||||
|
||||
proximity.each(e -> isContainer(e) && e.items() == items, t -> {
|
||||
proximity.each(e -> isContainer(e) && e.items() == items && owns(e), t -> {
|
||||
StorageBlockEntity ent = (StorageBlockEntity)t;
|
||||
ent.linkedCore = null;
|
||||
ent.items(new ItemModule());
|
||||
|
@ -133,7 +133,6 @@ public class DesktopLauncher extends ClientLauncher{
|
||||
player.name(SVars.net.friends.getPersonaName());
|
||||
Core.settings.defaults("name", SVars.net.friends.getPersonaName());
|
||||
Core.settings.put("name", player.name());
|
||||
Core.settings.save();
|
||||
//update callbacks
|
||||
Core.app.addListener(new ApplicationListener(){
|
||||
@Override
|
||||
|
@ -119,11 +119,11 @@ public class SStats implements SteamUserStatsCallback{
|
||||
|
||||
if(e.tile.block() == Blocks.meltdown || e.tile.block() == Blocks.spectre){
|
||||
if(e.tile.block() == Blocks.meltdown && !Core.settings.getBool("meltdownp", false)){
|
||||
Core.settings.putSave("meltdownp", true);
|
||||
Core.settings.put("meltdownp", true);
|
||||
}
|
||||
|
||||
if(e.tile.block() == Blocks.spectre && !Core.settings.getBool("spectrep", false)){
|
||||
Core.settings.putSave("spectrep", true);
|
||||
Core.settings.put("spectrep", true);
|
||||
}
|
||||
|
||||
if(Core.settings.getBool("meltdownp", false) && Core.settings.getBool("spectrep", false)){
|
||||
@ -256,7 +256,6 @@ public class SStats implements SteamUserStatsCallback{
|
||||
if(mechs.add(e.mech.name)){
|
||||
SStat.zoneMechsUsed.max(mechs.size);
|
||||
Core.settings.putObject("mechs", mechs);
|
||||
Core.settings.save();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -387,7 +387,7 @@ public class ServerControl implements ApplicationListener{
|
||||
}
|
||||
}
|
||||
|
||||
Core.settings.putSave("globalrules", base.toString());
|
||||
Core.settings.put("globalrules", base.toString());
|
||||
Call.onSetRules(state.rules);
|
||||
}
|
||||
});
|
||||
@ -545,7 +545,7 @@ public class ServerControl implements ApplicationListener{
|
||||
}else{
|
||||
try{
|
||||
ShuffleMode mode = ShuffleMode.valueOf(arg[0]);
|
||||
Core.settings.putSave("shufflemode", mode.name());
|
||||
Core.settings.put("shufflemode", mode.name());
|
||||
maps.setShuffleMode(mode);
|
||||
info("Shuffle mode set to &ly'@'&lg.", arg[0]);
|
||||
}catch(Exception e){
|
||||
|
Reference in New Issue
Block a user