Support for modded floors

This commit is contained in:
Anuken
2019-10-03 08:59:53 -04:00
parent cce0040eaf
commit 92d7efeea2
4 changed files with 33 additions and 8 deletions

View File

@@ -150,6 +150,7 @@ public class GlobalData{
@SuppressWarnings("unchecked")
public void load(){
items.clear();
unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);
for(Item item : Vars.content.items()){
items.put(item, Core.settings.getInt("item-" + item.name, 0));

View File

@@ -18,7 +18,6 @@ import io.anuke.mindustry.game.*;
import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.plugin.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.*;
import java.io.*;
import java.net.*;
@@ -225,9 +224,6 @@ public class Mods implements Loadable{
public void reloadContent(){
//epic memory leak
Core.atlas = new TextureAtlas(Core.files.internal("sprites/sprites.atlas"));
Tex.load();
Tex.loadStyles();
Styles.load();
loaded.clear();
disabled.clear();
load();
@@ -244,6 +240,8 @@ public class Mods implements Loadable{
content.init();
content.load();
content.loadColors();
data.load();
requiresReload = false;
}
/** Creates all the content found in mod files. */

View File

@@ -60,10 +60,10 @@ public class ModsDialog extends FloatingDialog{
title.add("[accent]" + mod.meta.name + "[lightgray] v" + mod.meta.version + (" | " + Core.bundle.get(mod.enabled() ? "mod.enabled" : "mod.disabled")));
title.add().growX();
title.addButton(mod.enabled() ? "$mod.disable" : "$mod.enable", Styles.cleart, () -> {
title.addImageTextButton(mod.enabled() ? "$mod.disable" : "$mod.enable", mod.enabled() ? Icon.arrowDownSmall : Icon.arrowUpSmall, Styles.cleart, () -> {
mods.setEnabled(mod, !mod.enabled());
setup();
}).height(50f).margin(8f).width(100f);
}).height(50f).margin(8f).width(130f);
title.addImageButton(Icon.trash16Small, Styles.cleari, () -> ui.showConfirm("$confirm", "$mod.remove.confirm", () -> {
mods.removeMod(mod);

View File

@@ -4,10 +4,12 @@ import io.anuke.arc.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.graphics.g2d.TextureAtlas.*;
import io.anuke.arc.math.*;
import io.anuke.arc.math.geom.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.entities.Effects.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*;
@@ -53,7 +55,7 @@ public class Floor extends Block{
protected byte eq = 0;
protected Array<Block> blenders = new Array<>();
protected IntSet blended = new IntSet();
protected TextureRegion edgeRegion, edgierRegion;
protected TextureRegion edgeRegion;
public Floor(String name){
super(name);
@@ -81,7 +83,31 @@ public class Floor extends Block{
}
region = variantRegions[0];
edgeRegion = Core.atlas.find("edge");
edgierRegion = Core.atlas.find("edgier");
}
@Override
public void createIcons(PixmapPacker out, PixmapPacker editor){
super.createIcons(out, editor);
editor.pack("editor-" + name, Core.atlas.getPixmap((AtlasRegion)icon(Cicon.full)).crop());
if(blendGroup != this){
return;
}
Color color = new Color();
Color color2 = new Color();
PixmapRegion image = Core.atlas.getPixmap((AtlasRegion)generateIcons()[0]);
PixmapRegion edge = Core.atlas.getPixmap("edge-stencil");
Pixmap result = new Pixmap(edge.width, edge.height);
for(int x = 0; x < edge.width; x++){
for(int y = 0; y < edge.height; y++){
edge.getPixel(x, y, color);
result.draw(x, y, color.mul(color2.set(image.getPixel(x % image.width, y % image.height))));
}
}
out.pack(name + "-edge", result);
}
@Override