Commit 6d0ac4dd authored by Anian Bühler's avatar Anian Bühler
Browse files

added 3-port infix-block

parent 8e54e8a8
Pipeline #1317 failed with stages
in 0 seconds
......@@ -891,6 +891,13 @@ public class BlockGenus {
&& newGenus.sockets.get(1).getPositionType() == BlockConnector.PositionType.BOTTOM) {
newGenus.isInfix = true;
}
//TODO: test -> 3 bottom connectors test - added by letsgoING
else if (newGenus.sockets != null && newGenus.sockets.size() == 3
&& newGenus.sockets.get(0).getPositionType() == BlockConnector.PositionType.BOTTOM
&& newGenus.sockets.get(1).getPositionType() == BlockConnector.PositionType.BOTTOM
&& newGenus.sockets.get(2).getPositionType() == BlockConnector.PositionType.BOTTOM) {
newGenus.isInfix = true;
}
} else if (genusChild.getNodeName().equals("Images")) {
/// LOAD BLOCK IMAGES ///
loadBlockImages(genusChild.getChildNodes(), newGenus);
......
......@@ -64,14 +64,10 @@ public class InfixBlockShape extends BlockShape {
gpBottom.lineTo(
(float) gpBottom.getCurrentPoint().getX() + BOTTOM_SOCKET_MIDDLE_SPACER,
(float) gpBottom.getCurrentPoint().getY());
} else if(block.isCommandBlock()) { //TODO: check //added by letsgoING for new setVariableBlock test
}else {
gpBottom.lineTo(
(float) gpBottom.getCurrentPoint().getX() + BOTTOM_SOCKET_SIDE_SPACER,
(float) gpBottom.getCurrentPoint().getY());
} else {
gpBottom.lineTo(
(float) gpBottom.getCurrentPoint().getX() + BOTTOM_SOCKET_SIDE_SPACER ,
(float) gpBottom.getCurrentPoint().getY());
}
......@@ -97,12 +93,13 @@ public class InfixBlockShape extends BlockShape {
(float) gpBottom.getCurrentPoint().getX() + BOTTOM_SOCKET_SIDE_SPACER,
(float) gpBottom.getCurrentPoint().getY());
//draw first socket - down right side
BCS.addDataSocket(gpBottom, curSocket.getKind(), false);
//rb.updateSocketPoint(curSocket, rightSocket);
} else { //there is a connected block
Block connectedBlock = rb.getWorkspace().getEnv().getBlock(curSocket.getBlockID());
//TODO: check why RBlock on second connector is always NULL???
RenderableBlock connectedRBlock = rb.getWorkspace().getEnv().getRenderableBlock(curSocket.getBlockID());
//calculate and update the new socket point
......@@ -246,43 +243,34 @@ public class InfixBlockShape extends BlockShape {
int bottomSocketWidth = 0;
//added by letsgoING for new setVariableBlock test
if (block.isCommandBlock()) {
for (BlockConnector socket : block.getSockets()) {
if (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) {
if (socket.getBlockID() == Block.NULL) {
//3 socket spacers = left of socket, between connectors, right of socket
bottomSocketWidth += BOTTOM_SOCKET_SIDE_SPACER + BOTTOM_SOCKET_MIDDLE_SPACER;
} else { //a block is connected to socket
//TODO get their assigned width from rb
if (rb.getSocketSpaceDimension(socket) != null) {
bottomSocketWidth += rb.getSocketSpaceDimension(socket).width;
}
for (BlockConnector socket : block.getSockets()) {
if (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) {
if (socket.getBlockID() == Block.NULL) {
//3 socket spacers = left of socket, between connectors, right of socket
bottomSocketWidth += BOTTOM_SOCKET_SIDE_SPACER;
if(block.isCommandBlock()) {//added by letsgoING for new setVariableBlock test
//TODO get correct size of socket
bottomSocketWidth += rb.accomodateLabelsWidth();
}
} else { //a block is connected to socket
//TODO get their assigned width from rb
if (rb.getSocketSpaceDimension(socket) != null) {
bottomSocketWidth += rb.getSocketSpaceDimension(socket).width;
if(block.isCommandBlock()) {//added by letsgoING for new setVariableBlock test
//TODO get correct size of socket
bottomSocketWidth += rb.accomodateLabelsWidth();
}
}
bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH;
// if it's a mirror plug, subtract for the other side, too.
if (rb.getWorkspace().getEnv().getBlock(socket.getBlockID()).getPlug().getPositionType() == BlockConnector.PositionType.MIRROR) {
bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH;
}
}
}
}
//if the sum of bottom sockets is greater than the calculated width, then use it
else {
for (BlockConnector socket : block.getSockets()) {
if (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) {
if (socket.getBlockID() == Block.NULL) {
//3 socket spacers = left of socket, between connectors, right of socket
bottomSocketWidth += BOTTOM_SOCKET_SIDE_SPACER;
} else { //a block is connected to socket
//TODO get their assigned width from rb
if (rb.getSocketSpaceDimension(socket) != null) {
bottomSocketWidth += rb.getSocketSpaceDimension(socket).width;
}
bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH;
// if it's a mirror plug, subtract for the other side, too.
if (rb.getWorkspace().getEnv().getBlock(socket.getBlockID()).getPlug().getPositionType() == BlockConnector.PositionType.MIRROR) {
bottomSocketWidth -= BlockConnectorShape.NORMAL_DATA_PLUG_WIDTH;
}
}
}
}
}
bottomSocketWidth += 2 * BOTTOM_SOCKET_MIDDLE_SPACER; //TODO need to decide for a size of the middle spacer and how to place them
......
......@@ -24,7 +24,10 @@ class SocketLabel extends BlockLabel {
* @return true if the specified socket should have a corresponding Blocklabel instance added to this.
*/
static boolean ignoreSocket(BlockConnector socket) {
return (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) || socket.getLabel().equals("");
//removed bottom-connector from ignore-list for new setVariable-Block by letsgoING
//TODO: TEST for all Blocks -> letsgoING
//return (socket.getPositionType() == BlockConnector.PositionType.BOTTOM) || socket.getLabel().equals("");
return socket.getLabel().equals("");
}
void update(Point2D socketPoint) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment