Support for modded floors
This commit is contained in:
@@ -150,6 +150,7 @@ public class GlobalData{
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load(){
|
public void load(){
|
||||||
|
items.clear();
|
||||||
unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);
|
unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);
|
||||||
for(Item item : Vars.content.items()){
|
for(Item item : Vars.content.items()){
|
||||||
items.put(item, Core.settings.getInt("item-" + item.name, 0));
|
items.put(item, Core.settings.getInt("item-" + item.name, 0));
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import io.anuke.mindustry.game.*;
|
|||||||
import io.anuke.mindustry.gen.*;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.plugin.*;
|
import io.anuke.mindustry.plugin.*;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.ui.*;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
@@ -225,9 +224,6 @@ public class Mods implements Loadable{
|
|||||||
public void reloadContent(){
|
public void reloadContent(){
|
||||||
//epic memory leak
|
//epic memory leak
|
||||||
Core.atlas = new TextureAtlas(Core.files.internal("sprites/sprites.atlas"));
|
Core.atlas = new TextureAtlas(Core.files.internal("sprites/sprites.atlas"));
|
||||||
Tex.load();
|
|
||||||
Tex.loadStyles();
|
|
||||||
Styles.load();
|
|
||||||
loaded.clear();
|
loaded.clear();
|
||||||
disabled.clear();
|
disabled.clear();
|
||||||
load();
|
load();
|
||||||
@@ -244,6 +240,8 @@ public class Mods implements Loadable{
|
|||||||
content.init();
|
content.init();
|
||||||
content.load();
|
content.load();
|
||||||
content.loadColors();
|
content.loadColors();
|
||||||
|
data.load();
|
||||||
|
requiresReload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates all the content found in mod files. */
|
/** Creates all the content found in mod files. */
|
||||||
|
|||||||
@@ -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("[accent]" + mod.meta.name + "[lightgray] v" + mod.meta.version + (" | " + Core.bundle.get(mod.enabled() ? "mod.enabled" : "mod.disabled")));
|
||||||
title.add().growX();
|
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());
|
mods.setEnabled(mod, !mod.enabled());
|
||||||
setup();
|
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", () -> {
|
title.addImageButton(Icon.trash16Small, Styles.cleari, () -> ui.showConfirm("$confirm", "$mod.remove.confirm", () -> {
|
||||||
mods.removeMod(mod);
|
mods.removeMod(mod);
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import io.anuke.arc.*;
|
|||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
|
import io.anuke.arc.graphics.g2d.TextureAtlas.*;
|
||||||
import io.anuke.arc.math.*;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.math.geom.*;
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.entities.Effects.*;
|
import io.anuke.mindustry.entities.Effects.*;
|
||||||
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@ public class Floor extends Block{
|
|||||||
protected byte eq = 0;
|
protected byte eq = 0;
|
||||||
protected Array<Block> blenders = new Array<>();
|
protected Array<Block> blenders = new Array<>();
|
||||||
protected IntSet blended = new IntSet();
|
protected IntSet blended = new IntSet();
|
||||||
protected TextureRegion edgeRegion, edgierRegion;
|
protected TextureRegion edgeRegion;
|
||||||
|
|
||||||
public Floor(String name){
|
public Floor(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -81,7 +83,31 @@ public class Floor extends Block{
|
|||||||
}
|
}
|
||||||
region = variantRegions[0];
|
region = variantRegions[0];
|
||||||
edgeRegion = Core.atlas.find("edge");
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user