Skip to content

Commit 7bce704

Browse files
committed
Adding hovered to selection class
1 parent f2c1b17 commit 7bce704

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

DelvEdit/src/com/interrupt/dungeoneer/editor/EditorApplication.java

+13-23
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ protected Decal newObject () {
302302
private boolean showLights = false;
303303
private boolean lightsDirty = true;
304304

305-
private Entity hoveredEntity = null;
306305
private boolean movingEntity = false;
307306
private DragMode dragMode = DragMode.NONE;
308307
private MoveMode moveMode = MoveMode.DRAG;
@@ -491,11 +490,11 @@ public void render() {
491490
renderer.clearLights();
492491
renderer.clearDecals();
493492

494-
if(!ui.isShowingMenuOrModal() && pickedControlPoint == null && hoveredEntity == null && Editor.selection.picked == null) {
493+
if(!ui.isShowingMenuOrModal() && pickedControlPoint == null && Editor.selection.hovered == null && Editor.selection.picked == null) {
495494
updatePickedSurface();
496495
}
497496

498-
if((!Gdx.input.isButtonPressed(Buttons.LEFT) || ui.isShowingMenuOrModal()) && pickedControlPoint == null && hoveredEntity == null && Editor.selection.picked == null) {
497+
if((!Gdx.input.isButtonPressed(Buttons.LEFT) || ui.isShowingMenuOrModal()) && pickedControlPoint == null && Editor.selection.hovered == null && Editor.selection.picked == null) {
499498
renderPickedSurface();
500499
}
501500

@@ -604,7 +603,7 @@ public void draw() {
604603
else if(Editor.selection.isSelected(e)) {
605604
e.editorState = EditorState.picked;
606605
}
607-
else if(e == hoveredEntity) {
606+
else if(e == Editor.selection.hovered) {
608607
e.editorState = EditorState.hovered;
609608
}
610609
else {
@@ -621,7 +620,7 @@ else if(e == hoveredEntity) {
621620
if(e == Editor.selection.picked) {
622621
e.editorState = EditorState.picked;
623622
}
624-
else if(e == hoveredEntity) {
623+
else if(e == Editor.selection.hovered) {
625624
e.editorState = EditorState.hovered;
626625
}
627626
else {
@@ -708,7 +707,7 @@ else if(e == hoveredEntity) {
708707
shouldDrawBox = false;
709708
}
710709

711-
if(Editor.selection.picked == null && hoveredEntity == null || tileDragging) {
710+
if(Editor.selection.picked == null && Editor.selection.hovered == null || tileDragging) {
712711
if(!selected || (!(pickedControlPoint != null || movingControlPoint) &&
713712
editorInput.isButtonPressed(Input.Buttons.LEFT) && Gdx.input.justTouched())) {
714713

@@ -1389,7 +1388,7 @@ else if(dragMode == DragMode.Y) {
13891388
}
13901389
}
13911390

1392-
if(Editor.selection.picked != null && ((hoveredEntity == null || Editor.selection.isSelected(hoveredEntity)) || hoveredEntity == Editor.selection.picked || movingEntity)) {
1391+
if(Editor.selection.picked != null && ((Editor.selection.hovered == null || Editor.selection.isSelected(Editor.selection.hovered)) || Editor.selection.hovered == Editor.selection.picked || movingEntity)) {
13931392
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
13941393
Gdx.gl.glEnable(GL20.GL_ALPHA);
13951394
Gdx.gl.glEnable(GL20.GL_BLEND);
@@ -1527,7 +1526,7 @@ private void GlPickEntity() {
15271526
int b = (int)(pickedPixelBufferColor.b * 255);
15281527
int index = (r & 0xff) << 16 | (g & 0xff) << 8 | (b & 0xff);
15291528

1530-
hoveredEntity = renderer.entitiesForPicking.get(index);
1529+
Editor.selection.hovered = renderer.entitiesForPicking.get(index);
15311530
//Gdx.app.log("Picking", pickedPixelBufferColor.toString());
15321531
}
15331532
catch (Exception ex) {
@@ -2090,7 +2089,7 @@ public void tick() {
20902089

20912090
if(Gdx.input.isKeyJustPressed(Keys.TAB)) {
20922091
Editor.selection.picked = null;
2093-
hoveredEntity = null;
2092+
Editor.selection.hovered = null;
20942093
}
20952094

20962095
// Try to pick an entity
@@ -2107,20 +2106,20 @@ public void tick() {
21072106
if(movingControlPoint || pickedControlPoint != null) {
21082107
// don't select entities
21092108
}
2110-
else if(hoveredEntity == null && Editor.selection.picked == null) {
2109+
else if(Editor.selection.hovered == null && Editor.selection.picked == null) {
21112110
selected = true;
21122111
}
21132112
else {
21142113
if(!readLeftClick) {
2115-
if(Editor.selection.picked != null && hoveredEntity != null && hoveredEntity != Editor.selection.picked && !Editor.selection.isSelected(hoveredEntity) && (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.SHIFT_RIGHT))) {
2116-
pickAdditionalEntity(hoveredEntity);
2114+
if(Editor.selection.picked != null && Editor.selection.hovered != null && Editor.selection.hovered != Editor.selection.picked && !Editor.selection.isSelected(Editor.selection.hovered) && (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.SHIFT_RIGHT))) {
2115+
pickAdditionalEntity(Editor.selection.hovered);
21172116
}
2118-
else if(Editor.selection.picked != null && Editor.selection.picked == hoveredEntity || Editor.selection.isSelected(hoveredEntity)) {
2117+
else if(Editor.selection.picked != null && Editor.selection.picked == Editor.selection.hovered || Editor.selection.isSelected(Editor.selection.hovered)) {
21192118
movingEntity = true;
21202119
}
21212120
else {
21222121
clearEntitySelection();
2123-
pickEntity(hoveredEntity);
2122+
pickEntity(Editor.selection.hovered);
21242123
}
21252124
}
21262125
}
@@ -4199,15 +4198,6 @@ public Vector3 getIntersection() {
41994198
return new Vector3(getSelectionX(), floorPos, getSelectionY());
42004199
}
42014200

4202-
public Entity getPickedOrHoveredEntity() {
4203-
if(Editor.selection.picked != null) return Editor.selection.picked;
4204-
return hoveredEntity;
4205-
}
4206-
4207-
public Entity getHoveredEntity() {
4208-
return hoveredEntity;
4209-
}
4210-
42114201
public MoveMode getMoveMode() {
42124202
return moveMode;
42134203
}

DelvEdit/src/com/interrupt/dungeoneer/editor/selection/EditorSelection.java

+3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44
import com.interrupt.dungeoneer.entities.Entity;
55

66
public class EditorSelection {
7+
public Entity hovered;
78
public Entity picked;
89
public Array<Entity> selected;
910
public TileSelection tiles;
1011

1112
public EditorSelection() {
13+
hovered = null;
1214
picked = null;
1315
selected = new Array<Entity>();
1416
tiles = new TileSelection();
1517
}
1618

1719
public void clear() {
20+
hovered = null;
1821
picked = null;
1922
selected.clear();
2023
}

DelvEdit/src/com/interrupt/dungeoneer/editor/ui/EditorUi.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public boolean touchDown(InputEvent event, float x, float y, int pointer, int bu
429429

430430
// must have touched the stage, should we show an entity properties menu?
431431
if(button == Input.Buttons.LEFT && touched == mainTable) {
432-
if(entityPropertiesPane != null && Editor.app.getHoveredEntity() == null) {
432+
if(entityPropertiesPane != null && Editor.selection.hovered == null) {
433433
sidebarTable.setVisible(false);
434434
}
435435
}
@@ -615,9 +615,9 @@ public void touchUp(int x, int y, int pointer, int button) {
615615
float currentTime = Editor.app.time;
616616
if (currentTime - rightClickTime > 0.5) return;
617617

618-
if (Editor.selection.picked != null || Editor.app.getHoveredEntity() != null) {
618+
if (Editor.selection.picked != null || Editor.selection.hovered != null) {
619619
Entity sel = Editor.selection.picked;
620-
if (sel == null) sel = Editor.app.getHoveredEntity();
620+
if (sel == null) sel = Editor.selection.hovered;
621621

622622
if (Editor.app.getMoveMode() == EditorApplication.MoveMode.ROTATE) {
623623
Editor.app.clearEntitySelection();

0 commit comments

Comments
 (0)