Start of work on logic stuff
BIN
core/assets-raw/sprites/ui/logic-node.png
Normal file
After Width: | Height: | Size: 323 B |
BIN
core/assets-raw/sprites/ui/white-pane.9.png
Normal file
After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 180 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 181 KiB |
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
@ -33,6 +33,8 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
loadLogger();
|
||||
|
||||
loader = new LoadRenderer();
|
||||
Events.fire(new ClientCreateEvent());
|
||||
|
||||
|
@ -715,11 +715,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
public void drawStatus(){
|
||||
if(block.consumes.any()){
|
||||
if(block.enableDrawStatus && block.consumes.any()){
|
||||
float brcx = tile.drawx() + (block.size * tilesize / 2f) - (tilesize / 2f);
|
||||
float brcy = tile.drawy() - (block.size * tilesize / 2f) + (tilesize / 2f);
|
||||
|
||||
Draw.z(Layer.blockOver);
|
||||
Draw.z(Layer.power + 1);
|
||||
Draw.color(Pal.gray);
|
||||
Fill.square(brcx, brcy, 2.5f, 45);
|
||||
Draw.color(cons.status().color);
|
||||
|
174
core/src/mindustry/logic/LogicCanvas.java
Normal file
@ -0,0 +1,174 @@
|
||||
package mindustry.logic;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class LogicCanvas extends WidgetGroup{
|
||||
private static final Color backgroundCol = Color.black, gridCol = Pal.accent.cpy().mul(0.2f);
|
||||
|
||||
private Seq<LogicNode> nodes = new Seq<>();
|
||||
|
||||
{
|
||||
LogicElement e = new LogicElement();
|
||||
e.setPosition(Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f);
|
||||
addChild(e);
|
||||
e.pack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.color(backgroundCol);
|
||||
|
||||
Fill.crect(x, y, width, height);
|
||||
|
||||
Draw.color(gridCol);
|
||||
|
||||
float spacing = Scl.scl(50f);
|
||||
int xbars = (int)(width / spacing) + 1, ybars = (int)(width / spacing) + 1;
|
||||
|
||||
Lines.stroke(Scl.scl(3f));
|
||||
|
||||
for(int i = 0; i < xbars; i++){
|
||||
float cx = x + width/2f + (i - xbars/2) * spacing;
|
||||
Lines.line(cx, y, cx, y + height);
|
||||
}
|
||||
|
||||
for(int i = 0; i < ybars; i++){
|
||||
float cy = y + height/2f + (i - ybars/2) * spacing;
|
||||
Lines.line(0, cy, x + width, cy);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
|
||||
super.draw();
|
||||
}
|
||||
|
||||
static class LogicElement extends Table{
|
||||
LogicNode node;
|
||||
NodeField[] fields = {new NodeField(true, "input 1"), new NodeField(true, "input 2"), new NodeField(false, "output 1"), new NodeField(false, "output 2")};
|
||||
|
||||
LogicElement(){
|
||||
background(Tex.whitePane);
|
||||
setColor(Pal.accent.cpy().mul(0.9f).shiftSaturation(-0.3f));
|
||||
touchable = Touchable.enabled;
|
||||
|
||||
margin(0f);
|
||||
|
||||
table(Tex.whiteui, t -> {
|
||||
t.update(() -> {
|
||||
t.setColor(color);
|
||||
});
|
||||
|
||||
t.margin(8f);
|
||||
|
||||
t.add("Node").style(Styles.outlineLabel).color(color);
|
||||
t.add().growX();
|
||||
t.button(Icon.cancel, Styles.onlyi, () -> {
|
||||
|
||||
});
|
||||
}).growX().padBottom(5);
|
||||
|
||||
row();
|
||||
|
||||
defaults().size(190, 36);
|
||||
|
||||
for(NodeField field : fields){
|
||||
add(field).color(color);
|
||||
row();
|
||||
}
|
||||
|
||||
marginBottom(5);
|
||||
|
||||
addListener(new InputListener(){
|
||||
float lastx, lasty;
|
||||
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
Vec2 v = localToStageCoordinates(Tmp.v1.set(x, y));
|
||||
lastx = v.x;
|
||||
lasty = v.y;
|
||||
toFront();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void touchDragged(InputEvent event, float x, float y, int pointer){
|
||||
Vec2 v = localToStageCoordinates(Tmp.v1.set(x, y));
|
||||
|
||||
moveBy(v.x - lastx, v.y - lasty);
|
||||
lastx = v.x;
|
||||
lasty = v.y;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
float pad = 10f;
|
||||
Fill.dropShadow(x + width/2f, y + height/2f, width + pad, height + pad, 20f, 0.95f);
|
||||
|
||||
Draw.color(0, 0, 0, 0.3f);
|
||||
Fill.crect(x, y, width, height);
|
||||
Draw.reset();
|
||||
|
||||
super.draw();
|
||||
}
|
||||
}
|
||||
|
||||
static class NodeField extends Table{
|
||||
boolean input;
|
||||
ImageButton button;
|
||||
|
||||
NodeField(boolean input, String name){
|
||||
this.input = input;
|
||||
if(input){
|
||||
addIcon();
|
||||
left();
|
||||
}else{
|
||||
right();
|
||||
}
|
||||
|
||||
add(name).padLeft(5).padRight(5).style(Styles.outlineLabel);
|
||||
|
||||
if(!input){
|
||||
addIcon();
|
||||
}
|
||||
}
|
||||
|
||||
void addIcon(){
|
||||
float s = 30f;
|
||||
Cell<ImageButton> c = button(Tex.logicNode, Styles.colori, () -> {
|
||||
|
||||
}).size(s);
|
||||
|
||||
button = c.get();
|
||||
c.update(i -> i.getStyle().imageUpColor = color);
|
||||
|
||||
float pad = s/2f - 3f;
|
||||
|
||||
if(input){
|
||||
c.padLeft(-pad);
|
||||
}else{
|
||||
c.padRight(-pad);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Color color){
|
||||
super.setColor(color);
|
||||
|
||||
button.getStyle().imageUpColor = color;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,10 +3,14 @@ package mindustry.logic;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
public class LogicDialog extends BaseDialog{
|
||||
LogicCanvas canvas;
|
||||
|
||||
public LogicDialog(){
|
||||
super("");
|
||||
super("logic");
|
||||
|
||||
canvas = new LogicCanvas();
|
||||
|
||||
clear();
|
||||
addCloseButton();
|
||||
add(canvas).grow();
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class Styles{
|
||||
public static Drawable black, black9, black8, black6, black3, black5, none, flatDown, flatOver;
|
||||
public static ButtonStyle defaultb, waveb;
|
||||
public static TextButtonStyle defaultt, squaret, nodet, cleart, discordt, infot, clearPartialt, clearTogglet, clearToggleMenut, togglet, transt, fullTogglet;
|
||||
public static ImageButtonStyle defaulti, nodei, righti, emptyi, emptytogglei, selecti, cleari, clearFulli, clearPartiali, clearPartial2i, clearTogglei, clearTransi, clearToggleTransi, clearTogglePartiali;
|
||||
public static ImageButtonStyle defaulti, nodei, righti, emptyi, emptytogglei, selecti, onlyi, colori, cleari, clearFulli, clearPartiali, clearPartial2i, clearTogglei, clearTransi, clearToggleTransi, clearTogglePartiali;
|
||||
public static ScrollPaneStyle defaultPane, horizontalPane, smallPane;
|
||||
public static KeybindDialogStyle defaultKeybindDialog;
|
||||
public static SliderStyle defaultSlider, vSlider;
|
||||
@ -189,6 +189,14 @@ public class Styles{
|
||||
checked = buttonSelect;
|
||||
up = none;
|
||||
}};
|
||||
onlyi = new ImageButtonStyle(){{
|
||||
//imageDownColor = Pal.accent;
|
||||
imageUpColor = Color.black;
|
||||
}};
|
||||
colori = new ImageButtonStyle(){{
|
||||
//imageDownColor = Pal.accent;
|
||||
imageUpColor = Color.white;
|
||||
}};
|
||||
cleari = new ImageButtonStyle(){{
|
||||
down = flatOver;
|
||||
up = black;
|
||||
|
@ -92,6 +92,8 @@ public class Block extends UnlockableContent{
|
||||
public boolean squareSprite = true;
|
||||
/** whether this block absorbs laser attacks. */
|
||||
public boolean absorbLasers = false;
|
||||
/** if false, the status is never drawn */
|
||||
public boolean enableDrawStatus = true;
|
||||
/** tile entity health */
|
||||
public int health = -1;
|
||||
/** base block explosiveness */
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=419b6760c2c7e1a1053f707f64db32380424fe4f
|
||||
archash=c47296a40165be7bf7c15d4ae9262c3de401e48e
|
||||
|