Skip to content

Commit 32bfa3f

Browse files
committed
Non-hardcoded campaign map loading
Ignore the last commit, I had apparently manually imported them myself.
1 parent 29af938 commit 32bfa3f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/testing/util/Setup.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import mindustry.core.*;
1010
import mindustry.game.EventType.*;
1111
import mindustry.gen.*;
12+
import mindustry.maps.*;
1213
import mindustry.mod.Mods.*;
1314
import mindustry.world.*;
1415
import testing.*;
@@ -117,6 +118,23 @@ public static void init(){
117118
setOffsetY(settings.getFloat("tu-offset-y"));
118119
});
119120

121+
//Add campaign maps to custom maps list
122+
if(settings.getBool("setting.tu-load-vanilla", true)){
123+
Events.on(ClientLoadEvent.class, e -> {
124+
content.sectors().each(sector -> {
125+
//Filter out campaign saves
126+
if(!files.internal("maps/" + sector.name + "." + mapExtension).exists()) return;
127+
128+
Map map = sector.generator.map;
129+
Reflect.set(map, "custom", false);
130+
maps.all().add(map);
131+
maps.queueNewPreview(map);
132+
});
133+
maps.all().sort();
134+
Reflect.invoke(maps, "createAllPreviews");
135+
});
136+
}
137+
120138
Events.on(WorldLoadEvent.class, e -> {
121139
if(posLabelAligned) return;
122140
pos.setAlignment(Align.right, Align.right);

src/testing/util/TUSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static void init(){
2424
t.pref(new Banner("test-utils-settings-banner", -1));
2525
t.pref(new FloatTextSetting("tu-offset-x", Setup::setOffsetX));
2626
t.pref(new FloatTextSetting("tu-offset-y", Setup::setOffsetY));
27+
t.checkPref("tu-load-vanilla", true);
2728
t.checkPref("tu-instakill", true);
2829
t.checkPref("tu-death-effect", true);
2930
t.checkPref("tu-despawns", true);

0 commit comments

Comments
 (0)