This commit is contained in:
Anuken
2020-01-19 11:10:14 -05:00
parent f7c4ea3e58
commit c0844304a6
259 changed files with 7166 additions and 7198 deletions

File diff suppressed because one or more lines are too long

View File

@@ -42,7 +42,7 @@ public class Mods implements Loadable{
private Array<LoadedMod> mods = new Array<>();
private ObjectMap<Class<?>, ModMeta> metas = new ObjectMap<>();
private boolean requiresReload;
private boolean requiresReload, createdAtlas;
public Mods(){
Events.on(ClientLoadEvent.class, e -> Core.app.post(this::checkWarnings));
@@ -112,13 +112,6 @@ public class Mods implements Loadable{
totalSprites += sprites.size + overrides.size;
});
for(AtlasRegion region : Core.atlas.getRegions()){
PageType type = getPage(region);
if(!packer.has(type, region.name)){
packer.add(type, region.name, Core.atlas.getPixmap(region));
}
}
Log.debug("Time to pack textures: {0}", Time.elapsed());
}
@@ -159,6 +152,16 @@ public class Mods implements Loadable{
//get textures packed
if(totalSprites > 0){
if(!createdAtlas) Core.atlas = new TextureAtlas(Core.files.internal("sprites/sprites.atlas"));
createdAtlas = true;
for(AtlasRegion region : Core.atlas.getRegions()){
PageType type = getPage(region);
if(!packer.has(type, region.name)){
packer.add(type, region.name, Core.atlas.getPixmap(region));
}
}
TextureFilter filter = Core.settings.getBool("linear") ? TextureFilter.Linear : TextureFilter.Nearest;
//flush so generators can use these sprites
@@ -389,12 +392,12 @@ public class Mods implements Loadable{
d.left().marginLeft(15f);
for(Content c : m.erroredContent){
d.add(c.minfo.sourceFile.nameWithoutExtension()).left().padRight(10);
d.addImageTextButton("$details", Icon.arrowDownSmall, Styles.transt, () -> {
d.addImageTextButton("$details", Icon.downOpen, Styles.transt, () -> {
new Dialog(""){{
setFillParent(true);
cont.pane(e -> e.add(c.minfo.error)).grow();
cont.row();
cont.addImageTextButton("$ok", Icon.backSmall, this::hide).size(240f, 60f);
cont.addImageTextButton("$ok", Icon.left, this::hide).size(240f, 60f);
}}.show();
}).size(190f, 50f).left().marginLeft(6);
d.row();
@@ -419,6 +422,7 @@ public class Mods implements Loadable{
//epic memory leak
//TODO make it less epic
Core.atlas = new TextureAtlas(Core.files.internal("sprites/sprites.atlas"));
createdAtlas = true;
mods.each(LoadedMod::dispose);
mods.clear();

View File

@@ -2,6 +2,7 @@ package mindustry.mod;
import arc.*;
import arc.files.*;
import arc.struct.*;
import arc.util.*;
import arc.util.Log.*;
import mindustry.*;
@@ -9,6 +10,9 @@ import mindustry.mod.Mods.*;
import org.mozilla.javascript.*;
public class Scripts implements Disposable{
private final Array<String> blacklist = Array.with("net", "files", "reflect", "javax", "rhino", "file", "channels", "jdk",
"runtime", "util.os", "rmi", "security", "org.", "sun.", "beans", "sql", "http", "exec", "compiler", "process", "system", ".awt", "socket");
private final Array<String> whitelist = Array.with("mindustry.net");
private final Context context;
private final String wrapper;
private Scriptable scope;
@@ -18,9 +22,7 @@ public class Scripts implements Disposable{
Time.mark();
context = Vars.platform.getScriptContext();
context.setClassShutter(type -> (ClassAccess.allowedClassNames.contains(type) || type.startsWith("$Proxy") ||
type.startsWith("adapter") || type.contains("PrintStream") ||
type.startsWith("mindustry")) && !type.equals("mindustry.mod.ClassAccess"));
context.setClassShutter(type -> !blacklist.contains(type.toLowerCase()::contains) || whitelist.contains(type.toLowerCase()::contains));
context.getWrapFactory().setJavaPrimitiveWrap(false);
scope = new ImporterTopLevel(context);