mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-20 12:58:38 +03:00
Possibly fixed tests / Added support for mod icons
This commit is contained in:
parent
c339a0ecdf
commit
6080a7e4bc
@ -2,7 +2,6 @@ package mindustry.mod;
|
||||
|
||||
import arc.*;
|
||||
import arc.assets.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
@ -10,6 +9,7 @@ import arc.graphics.Texture.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.g2d.TextureAtlas.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.io.*;
|
||||
@ -142,6 +142,17 @@ public class Mods implements Loadable{
|
||||
|
||||
@Override
|
||||
public void loadSync(){
|
||||
for(LoadedMod mod : mods){
|
||||
//try to load icon for each mod that can have one
|
||||
if(mod.root.child("icon.png").exists()){
|
||||
try{
|
||||
mod.iconTexture = new Texture(mod.root.child("icon.png"));
|
||||
}catch(Throwable t){
|
||||
Log.err("Failed to load icon for mod '" + mod.name + "'.", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(packer == null) return;
|
||||
Time.mark();
|
||||
|
||||
@ -408,6 +419,7 @@ public class Mods implements Loadable{
|
||||
//TODO make it less epic
|
||||
Core.atlas = new TextureAtlas(Core.files.internal("sprites/sprites.atlas"));
|
||||
|
||||
mods.each(LoadedMod::dispose);
|
||||
mods.clear();
|
||||
Core.bundle = I18NBundle.createBundle(Core.files.internal("bundles/bundle"), Core.bundle.getLocale());
|
||||
load();
|
||||
@ -643,7 +655,7 @@ public class Mods implements Loadable{
|
||||
}
|
||||
|
||||
/** Represents a plugin that has been loaded from a jar file.*/
|
||||
public static class LoadedMod implements Publishable{
|
||||
public static class LoadedMod implements Publishable, Disposable{
|
||||
/** The location of this mod's zip file/folder on the disk. */
|
||||
public final Fi file;
|
||||
/** The root zip file; points to the contents of this mod. In the case of folders, this is the same as the mod's file. */
|
||||
@ -664,6 +676,8 @@ public class Mods implements Loadable{
|
||||
public ObjectSet<Content> erroredContent = new ObjectSet<>();
|
||||
/** Current state of this mod. */
|
||||
public ModState state = ModState.enabled;
|
||||
/** Icon texture. Should be disposed. */
|
||||
public @Nullable Texture iconTexture;
|
||||
|
||||
public LoadedMod(Fi file, Fi root, Mod main, ModMeta meta){
|
||||
this.root = root;
|
||||
@ -701,6 +715,13 @@ public class Mods implements Loadable{
|
||||
return Version.build >= Strings.parseInt(meta.minGameVersion, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
if(iconTexture != null){
|
||||
iconTexture.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSteamID(){
|
||||
return Core.settings.getString(name + "-steamid", null);
|
||||
|
@ -27,6 +27,7 @@ public class PowerTestFixture{
|
||||
@BeforeAll
|
||||
static void initializeDependencies(){
|
||||
Core.graphics = new FakeGraphics();
|
||||
Vars.state = new GameState();
|
||||
Vars.content = new ContentLoader(){
|
||||
@Override
|
||||
public void handleMappableContent(MappableContent content){
|
||||
|
Loading…
Reference in New Issue
Block a user