"Legacy" unlock loading

This commit is contained in:
Anuken
2018-11-19 15:08:18 -05:00
parent a932111040
commit de508ee68f

View File

@@ -1,6 +1,8 @@
package io.anuke.mindustry.game;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.game.EventType.UnlockEvent;
import io.anuke.mindustry.type.ContentType;
@@ -65,8 +67,27 @@ public class Unlocks{
save();
}
/**Loads 'legacy' unlocks. Will be removed in final release.*/
public void tryLoadLegacy(){
try{
ObjectMap<String, ObjectMap<ContentType, Array<String>>> sets = Settings.getObject("content-sets", ObjectMap.class, ObjectMap::new);
for(Entry<ContentType, Array<String>> entry : sets.get("root").entries()){
unlocked.put(entry.key, new ObjectSet<>());
unlocked.get(entry.key).addAll(entry.value);
}
}catch(Throwable t){
t.printStackTrace();
}
Settings.prefs().remove("content-sets");
Settings.save();
}
public void load(){
unlocked = Settings.getObject("unlockset", ObjectMap.class, ObjectMap::new);
if(Settings.has("content-sets")){
tryLoadLegacy();
}
}
public void save(){