Skip to content

Commit

Permalink
Editor: also can move tiles up and down now with shift + Q and E
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Jan 9, 2019
1 parent ecd3806 commit 47f8cd6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 21 deletions.
24 changes: 20 additions & 4 deletions DelvEdit/src/com/interrupt/dungeoneer/editor/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public enum EditorMode { Carve, Paint };
public ActionListener moveTileSouthAction;
public ActionListener moveTileEastAction;
public ActionListener moveTileWestAction;
public ActionListener moveTileUpAction;
public ActionListener moveTileDownAction;

public ActionListener raiseFloorAction;
public ActionListener lowerFloorAction;
Expand Down Expand Up @@ -493,28 +495,42 @@ public void actionPerformed(ActionEvent actionEvent) {
moveTileNorthAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
editorFrame.moveTiles(0, 1);
editorFrame.moveTiles(0, 1, 0);
}
};

moveTileSouthAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
editorFrame.moveTiles(0, -1);
editorFrame.moveTiles(0, -1, 0);
}
};

moveTileEastAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
editorFrame.moveTiles(1, 0);
editorFrame.moveTiles(1, 0, 0);
}
};

moveTileWestAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
editorFrame.moveTiles(-1, 0);
editorFrame.moveTiles(-1, 0, 0);
}
};

moveTileUpAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
editorFrame.moveTiles(0, 0, 0.5f);
}
};

moveTileDownAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
editorFrame.moveTiles(0, 0, -0.5f);
}
};

Expand Down
40 changes: 28 additions & 12 deletions DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ public enum MoveMode { NONE, DRAG, ROTATE }

public boolean canDelete = true;

protected static Array<Triangle> staticMeshCollisionTriangles = new Array<Triangle>();

protected Array<Vector3> spatialWorkerList = new Array<Vector3>();
protected Array<Vector3> spatialWorkerList = new Array<Vector3>();

public enum TileSurface {Ceiling, Floor, UpperWall, LowerWall};

Expand All @@ -124,12 +122,7 @@ public class PickedSurface {

public PickedSurface pickedSurface = new PickedSurface();

Matrix4 selectionTempMatrix = new Matrix4();
Matrix4 selectionTempMatrix2 = new Matrix4();
BoundingBox selectionTempBoundingBox = new BoundingBox();

Vector3 selectionTempVector1 = new Vector3();
Vector3 selectionTempVector2 = new Vector3();

FrameBuffer pickerFrameBuffer = null;
Pixmap pickerPixelBuffer = null;
Expand Down Expand Up @@ -2025,11 +2018,16 @@ else if(pickedEntity != null && pickedEntity == hoveredEntity || additionalSelec
}
if(pickedEntity == null) movingEntity = false;

boolean turnLeft = editorInput.isKeyPressed(Keys.Q) || (Gdx.input.getDeltaX() < 0 && Gdx.input.isButtonPressed(Buttons.MIDDLE));
boolean turnRight = editorInput.isKeyPressed(Keys.E) || (Gdx.input.getDeltaX() > 0 && Gdx.input.isButtonPressed(Buttons.MIDDLE));
boolean turnLeft = (Gdx.input.getDeltaX() < 0 && Gdx.input.isButtonPressed(Buttons.MIDDLE));
boolean turnRight = (Gdx.input.getDeltaX() > 0 && Gdx.input.isButtonPressed(Buttons.MIDDLE));
boolean turnUp = (Gdx.input.getDeltaY() > 0 && Gdx.input.isButtonPressed(Buttons.MIDDLE));
boolean turnDown = (Gdx.input.getDeltaY() < 0 && Gdx.input.isButtonPressed(Buttons.MIDDLE));

turnLeft |= Gdx.input.isKeyPressed(Keys.LEFT) && !Gdx.input.isKeyPressed(Keys.SHIFT_LEFT);
turnRight |= Gdx.input.isKeyPressed(Keys.RIGHT) && !Gdx.input.isKeyPressed(Keys.SHIFT_LEFT);
turnUp |= Gdx.input.isKeyPressed(Keys.DOWN) && !Gdx.input.isKeyPressed(Keys.SHIFT_LEFT);
turnDown |= Gdx.input.isKeyPressed(Keys.UP) && !Gdx.input.isKeyPressed(Keys.SHIFT_LEFT);

if(turnLeft) {
rota += rotSpeed;
if(rota > maxRot) rota = maxRot;
Expand Down Expand Up @@ -2075,6 +2073,13 @@ else if(turnDown) {
zm = 1f;
}

if(editorInput.isKeyPressed(Keys.Q) && !editorInput.isKeyPressed(Keys.SHIFT_LEFT)) {
camZ -= 0.1f;
}
if(editorInput.isKeyPressed(Keys.E) && !editorInput.isKeyPressed(Keys.SHIFT_LEFT)) {
camZ += 0.1f;
}

if (editorInput.isKeyPressed(Keys.SHIFT_LEFT)) {
xm *= 2.0f;
zm *= 2.0f;
Expand Down Expand Up @@ -4049,7 +4054,7 @@ public Decal getDecal() {
return sd;
}

public void moveTiles(int moveX, int moveY) {
public void moveTiles(int moveX, int moveY, float moveZ) {
int selX = selectionX;
int selY = selectionY;
int selWidth = selectionWidth;
Expand Down Expand Up @@ -4077,7 +4082,15 @@ public void moveTiles(int moveX, int moveY) {
int tileX = selX + x + moveX;
int tileY = selY + y + moveY;

level.setTile(tileX, tileY, moving[x + y * selectionWidth]);
Tile t = moving[x + y * selectionWidth];

if(moveZ != 0 && t != null) {
t.floorHeight += moveZ;
t.ceilHeight += moveZ;
}

level.setTile(tileX, tileY, t);

markWorldAsDirty(tileX, tileY, 1);
}
}
Expand All @@ -4099,6 +4112,8 @@ public void moveTiles(int moveX, int moveY) {

selectionX += moveX;
selectionY += moveY;
selectionHeights.add(moveZ, moveZ);

controlPoints.clear();
}

Expand All @@ -4112,6 +4127,7 @@ public void moveTiles(int moveX, int moveY) {
for(Entity e : allSelected) {
e.x += moveX;
e.y += moveY;
e.z += moveZ;
markWorldAsDirty((int)e.x, (int)e.y, 1);
}

Expand Down
13 changes: 8 additions & 5 deletions DelvEdit/src/com/interrupt/dungeoneer/editor/ui/EditorUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,20 @@ public void actionPerformed(ActionEvent event) {
.addItem(new MenuItem("Paint Surface Texture", smallSkin, editor.paintWallAction).setAccelerator(new MenuAccelerator(Keys.NUM_1, false, false)))
.addItem(new MenuItem("Grab Surface Texture", smallSkin, editor.pickWallAction).setAccelerator(new MenuAccelerator(Keys.NUM_2, false, false)))
.addItem(new MenuItem("Pick Surface Texture", smallSkin, editor.pickNewWallTexAction).setAccelerator(new MenuAccelerator(Keys.NUM_2, false, true)))
.addItem(new MenuItem("Flood Fill Surface Texture", smallSkin, editor.fillTextureAction).setAccelerator(new MenuAccelerator(Keys.NUM_5, false, false)))
.addItem(new MenuItem("Flood Fill Surface Texture", smallSkin, editor.fillTextureAction).setAccelerator(new MenuAccelerator(Keys.NUM_1, false, true)))
)
.addItem(new MenuItem("Tiles", smallSkin)
.addItem(new MenuItem("Raise Floor", smallSkin, editor.raiseFloorAction).setAccelerator(new MenuAccelerator(Keys.NUM_3, false, false)))
.addItem(new MenuItem("Lower Floor", smallSkin, editor.lowerFloorAction).setAccelerator(new MenuAccelerator(Keys.NUM_3, false, true)))
.addItem(new MenuItem("Raise Ceiling", smallSkin, editor.raiseCeilingAction).setAccelerator(new MenuAccelerator(Keys.NUM_4, false, false)))
.addItem(new MenuItem("Lower Ceiling", smallSkin, editor.lowerCeilingAction).setAccelerator(new MenuAccelerator(Keys.NUM_4, false, true)))
.addItem(new MenuItem("Move North", smallSkin, editor.moveTileNorthAction).setAccelerator(new MenuAccelerator(Keys.UP, false, false)))
.addItem(new MenuItem("Move South", smallSkin, editor.moveTileSouthAction).setAccelerator(new MenuAccelerator(Keys.DOWN, false, false)))
.addItem(new MenuItem("Move East", smallSkin, editor.moveTileEastAction).setAccelerator(new MenuAccelerator(Keys.LEFT, false, false)))
.addItem(new MenuItem("Move West", smallSkin, editor.moveTileWestAction).setAccelerator(new MenuAccelerator(Keys.RIGHT, false, false)))
.addSeparator()
.addItem(new MenuItem("Move North", smallSkin, editor.moveTileNorthAction).setAccelerator(new MenuAccelerator(Keys.UP, false, true)))
.addItem(new MenuItem("Move South", smallSkin, editor.moveTileSouthAction).setAccelerator(new MenuAccelerator(Keys.DOWN, false, true)))
.addItem(new MenuItem("Move East", smallSkin, editor.moveTileEastAction).setAccelerator(new MenuAccelerator(Keys.LEFT, false, true)))
.addItem(new MenuItem("Move West", smallSkin, editor.moveTileWestAction).setAccelerator(new MenuAccelerator(Keys.RIGHT, false, true)))
.addItem(new MenuItem("Move Up", smallSkin, editor.moveTileUpAction).setAccelerator(new MenuAccelerator(Keys.E, false, true)))
.addItem(new MenuItem("Move Down", smallSkin, editor.moveTileDownAction).setAccelerator(new MenuAccelerator(Keys.Q, false, true)))
)
.addItem(new MenuItem("Rotate Wall Angle", smallSkin, editor.rotateWallAngle).setAccelerator(new MenuAccelerator(Keys.U, false, false)))
.addItem(new MenuItem("Flatten", smallSkin)
Expand Down

0 comments on commit 47f8cd6

Please sign in to comment.