This commit is contained in:
Anuken
2020-08-05 09:47:11 -04:00
parent 75eed2926a
commit 54d37b63b3
11 changed files with 42 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@@ -41,7 +41,7 @@ public class Vars implements Loadable{
/** Maximum schematic size.*/ /** Maximum schematic size.*/
public static final int maxSchematicSize = 32; public static final int maxSchematicSize = 32;
/** All schematic base64 starts with this string.*/ /** All schematic base64 starts with this string.*/
public static final String schematicBaseStart ="bXNjaAB"; public static final String schematicBaseStart ="bXNjaA";
/** IO buffer size. */ /** IO buffer size. */
public static final int bufferSize = 8192; public static final int bufferSize = 8192;
/** global charset, since Android doesn't support the Charsets class */ /** global charset, since Android doesn't support the Charsets class */

View File

@@ -2,8 +2,9 @@ package mindustry.entities.comp;
import mindustry.annotations.Annotations.*; import mindustry.annotations.Annotations.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.world.*;
import static mindustry.Vars.collisions; import static mindustry.Vars.*;
@Component @Component
abstract class ElevationMoveComp implements Velc, Posc, Flyingc, Hitboxc{ abstract class ElevationMoveComp implements Velc, Posc, Flyingc, Hitboxc{
@@ -20,4 +21,13 @@ abstract class ElevationMoveComp implements Velc, Posc, Flyingc, Hitboxc{
} }
} }
@Override
public void update(){
Tile tile = tileOn();
if(!net.client() && tile != null && tile.solid() && !isFlying()){
kill();
}
}
} }

View File

@@ -42,7 +42,6 @@ import static mindustry.Vars.*;
public class Schematics implements Loadable{ public class Schematics implements Loadable{
private static final Schematic tmpSchem = new Schematic(new Seq<>(), new StringMap(), 0, 0); private static final Schematic tmpSchem = new Schematic(new Seq<>(), new StringMap(), 0, 0);
private static final Schematic tmpSchem2 = new Schematic(new Seq<>(), new StringMap(), 0, 0); private static final Schematic tmpSchem2 = new Schematic(new Seq<>(), new StringMap(), 0, 0);
public static final String base64Header = "bXNjaAB";
private static final byte[] header = {'m', 's', 'c', 'h'}; private static final byte[] header = {'m', 's', 'c', 'h'};
private static final byte version = 1; private static final byte version = 1;

View File

@@ -16,6 +16,7 @@ import mindustry.ui.*;
public class LogicCanvas extends WidgetGroup{ public class LogicCanvas extends WidgetGroup{
private static final Color backgroundCol = Color.black, gridCol = Pal.accent.cpy().mul(0.2f); private static final Color backgroundCol = Color.black, gridCol = Pal.accent.cpy().mul(0.2f);
private static final Color outCol = Pal.place, inCol = Pal.remove;
private Seq<LogicNode> nodes = new Seq<>(); private Seq<LogicNode> nodes = new Seq<>();
@@ -75,20 +76,21 @@ public class LogicCanvas extends WidgetGroup{
t.add("Node").style(Styles.outlineLabel).color(color); t.add("Node").style(Styles.outlineLabel).color(color);
t.add().growX(); t.add().growX();
t.button(Icon.cancel, Styles.onlyi, () -> { t.button(Icon.cancel, Styles.onlyi, () -> {
//TODO disconnect things
remove();
}); });
}).growX().padBottom(5); }).growX().padBottom(6);
row(); row();
defaults().size(190, 36); defaults().height(30);
for(NodeField field : fields){ for(NodeField field : fields){
add(field).color(color); add(field).align(field.input ? Align.left : Align.right);
row(); row();
} }
marginBottom(5); marginBottom(7);
addListener(new InputListener(){ addListener(new InputListener(){
float lastx, lasty; float lastx, lasty;
@@ -132,14 +134,20 @@ public class LogicCanvas extends WidgetGroup{
NodeField(boolean input, String name){ NodeField(boolean input, String name){
this.input = input; this.input = input;
setColor(input ? inCol : outCol);
float marg = 24f;
if(input){ if(input){
addIcon(); addIcon();
left(); left();
marginRight(marg);
}else{ }else{
right(); right();
marginLeft(marg);
} }
add(name).padLeft(5).padRight(5).style(Styles.outlineLabel); add(name).padLeft(5).padRight(5).style(Styles.outlineLabel).color(color);
if(!input){ if(!input){
addIcon(); addIcon();
@@ -153,7 +161,8 @@ public class LogicCanvas extends WidgetGroup{
}).size(s); }).size(s);
button = c.get(); button = c.get();
c.update(i -> i.getStyle().imageUpColor = color); button.userObject = this;
button.getStyle().imageUpColor = color;
float pad = s/2f - 3f; float pad = s/2f - 3f;
@@ -163,12 +172,5 @@ public class LogicCanvas extends WidgetGroup{
c.padRight(-pad); c.padRight(-pad);
} }
} }
@Override
public void setColor(Color color){
super.setColor(color);
button.getStyle().imageUpColor = color;
}
} }
} }

View File

@@ -45,7 +45,7 @@ public class ContentParser{
return result; return result;
}else{ }else{
String str = data.asString(); String str = data.asString();
if(str.startsWith(Schematics.base64Header)){ if(str.startsWith(Vars.schematicBaseStart)){
return Schematics.readBase64(str); return Schematics.readBase64(str);
}else{ }else{
return Schematics.read(Vars.tree.get("schematics/" + str + "." + Vars.schematicExtension)); return Schematics.read(Vars.tree.get("schematics/" + str + "." + Vars.schematicExtension));

View File

@@ -40,6 +40,7 @@ public class PowerNode extends PowerBlock{
configurable = true; configurable = true;
consumesPower = false; consumesPower = false;
outputsPower = false; outputsPower = false;
config(Integer.class, (entity, value) -> { config(Integer.class, (entity, value) -> {
PowerModule power = entity.power; PowerModule power = entity.power;
Building other = world.build(value); Building other = world.build(value);
@@ -80,12 +81,20 @@ public class PowerNode extends PowerBlock{
config(Point2[].class, (tile, value) -> { config(Point2[].class, (tile, value) -> {
tile.power.links.clear(); tile.power.links.clear();
IntSeq old = new IntSeq(tile.power.links);
//clear old
for(int i = 0; i < old.size; i++){
int cur = old.get(i);
configurations.get(Integer.class).get(tile, cur);
}
//set new
for(Point2 p : value){ for(Point2 p : value){
if(tile.power.links.size < maxNodes){ int newPos = Point2.pack(p.x + tile.tileX(), p.y + tile.tileY());
tile.power.links.add(Point2.pack(p.x + tile.tileX(), p.y + tile.tileY())); configurations.get(Integer.class).get(tile, newPos);
}
} }
tile.updatePowerGraph();
}); });
} }