Skip to content

Commit

Permalink
Editor refresh lights when a light is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Interrupt committed Jan 4, 2019
1 parent 7b38b76 commit 6078ae0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
29 changes: 6 additions & 23 deletions DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -2775,25 +2775,9 @@ public boolean selectionHasEntityMarker() {
}

public void addEntity(Entity e) {
if(selected) {
int x = selectionX;
int y = selectionY;

String objCopy = Game.toJson(e);

Entity copy = Game.fromJson(e.getClass(), objCopy);
copy.x = x + 0.5f;
copy.y = y + 0.5f;

Tile at = level.getTileOrNull(x, y);
if(at != null) copy.z = at.floorHeight + 0.5f;

level.entities.add(copy);

markWorldAsDirty(x, y, 4);
}

history.saveState(level);
level.entities.add(e);
e.init(level, Source.EDITOR);
markWorldAsDirty((int)e.x, (int)e.y, 4);
}

public void clearSelectedMarkers() {
Expand Down Expand Up @@ -3314,10 +3298,7 @@ public void paste() {
copy.z += copyAt.getFloorHeight(0.5f, 0.5f);
}

level.entities.add(copy);
copy.init(level, Source.EDITOR);

markWorldAsDirty((int)copy.x, (int)copy.y, 4);
addEntity(copy);
}

// save undo history
Expand Down Expand Up @@ -3872,6 +3853,8 @@ public void doDelete() {
clearTiles();
}

refreshLights();

// save undo history
history.saveState(level);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ else if(surface.edge == TileEdges.South) {
}
}

editor.level.entities.add(entity);
entity.init(editor.level, Level.Source.EDITOR);
editor.markWorldAsDirty((int)entity.x, (int)entity.y, 4);
editor.addEntity(entity);

editor.refreshLights();
editor.history.saveState(editor.level);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ public void actionPerformed (ActionEvent event) {
newGroup.x = main.x;
newGroup.y = main.y;
newGroup.z = main.z;

editor.markWorldAsDirty((int)main.x, (int)main.y, 4);

for(Entity selected : additionalSelected) {
selected.x = selected.x - main.x;
Expand All @@ -130,7 +128,7 @@ public void actionPerformed (ActionEvent event) {
newGroup.entities.add(main);

level.entities.removeValue(main, true);
level.entities.add(newGroup);
editor.addEntity(newGroup);
}
});

Expand Down

0 comments on commit 6078ae0

Please sign in to comment.