Added content order

This commit is contained in:
Leo-MathGuy 2024-04-24 20:12:57 +05:00
parent 0a50e7dc48
commit 76f85df33f

View File

@ -728,6 +728,9 @@ public class Mods implements Loadable{
Seq<LoadRun> runs = new Seq<>();
for(LoadedMod mod : orderedMods()){
ObjectMap<String, LoadRun> currentRun = new ObjectMap<>();
String[] contentOrder = mod.meta.contentOrder;
if(mod.root.child("content").exists()){
Fi contentRoot = mod.root.child("content");
for(ContentType type : ContentType.all){
@ -735,15 +738,34 @@ public class Mods implements Loadable{
Fi folder = contentRoot.child(lower + (lower.endsWith("s") ? "" : "s"));
if(folder.exists()){
for(Fi file : folder.findAll(f -> f.extension().equals("json") || f.extension().equals("hjson"))){
runs.add(new LoadRun(type, file, mod));
if(contentOrder == null){
runs.add(new LoadRun(type, file, mod));
}else{
currentRun.put(file.nameWithoutExtension(), new LoadRun(type, file, mod));
}
}
}
}
}
Seq<String> added = new Seq<>();
if(contentOrder != null){
for (String contentName : contentOrder){
LoadRun run = currentRun.get(contentName);
if(run != null){
runs.add(run);
added.add(contentName);
}else{
Log.warn("Cannot find content defined in contentOrder: @", contentName);
}
}
}
Seq<String> left = currentRun.keys().toSeq();
left.removeAll(added);
runs.addAll(left.map(name -> currentRun.get(name)).sort());
}
//make sure mod content is in proper order
runs.sort();
for(LoadRun l : runs){
Content current = content.getLastAdded();
try{
@ -1210,6 +1232,8 @@ public class Mods implements Loadable{
public float texturescale = 1.0f;
/** If true, bleeding is skipped and no content icons are generated. */
public boolean pregenerated;
/** If set, load the mod content in this order by content names */
public String[] contentOrder;
public String displayName(){
//useless, kept for legacy reasons