use of eidolons.swing.components.obj.drawing.DrawMaster.INTERACTIVE_ELEMENT in project Eidolons by IDemiurge.
the class BfMouseListener method mouseClicked.
@Override
public void mouseClicked(MouseEvent e) {
if (checkAnimationClick(e)) {
return;
}
if (checkDynamicButtonClick(e)) {
return;
}
point = e.getPoint();
cellComp = gridComp.getCompByPoint(e.getPoint());
Point relativePoint = new Point(point.x % gridComp.getCellWidth(), point.y % gridComp.getCellHeight());
objClicked = null;
for (Rectangle rect : cellComp.getMouseMap().keySet()) {
if (rect.contains(relativePoint)) {
Object object = cellComp.getMouseMap().get(rect);
if (object instanceof INTERACTIVE_ELEMENT) {
INTERACTIVE_ELEMENT element = (INTERACTIVE_ELEMENT) object;
switch(element) {
case STACK:
// if (CoreEngine.isLevelEditor())
objClicked = DialogMaster.objChoice("Which object?", cellComp.getObjects().toArray(new DC_Obj[cellComp.getObjects().size()]));
break;
case AP:
break;
case COUNTERS:
break;
case ITEMS:
Collection<? extends Obj> droppedItems = cellComp.getGame().getDroppedItemManager().getDroppedItems(cellComp.getTerrainObj());
break;
case LOCKS:
break;
case TRAPS:
break;
}
// break ;
} else if (object instanceof Obj) {
if (object instanceof Unit) {
if (objClicked != null) {
int index = cellComp.getObjects().indexOf(objClicked);
int index2 = cellComp.getObjects().indexOf(object);
LogMaster.log(1, objClicked + "'s " + index + " vs " + object + "'s " + index2);
if (index > index2) // TODO so we need to keep this always sorted...
{
continue;
}
}
Unit unit = (Unit) object;
if (unit.isOverlaying()) {
// corpseClicked(unit);
if (unit.getVisibilityLevel() == VisionEnums.VISIBILITY_LEVEL.CONCEALED) {
continue;
}
objClicked = unit;
break;
} else {
objClicked = unit;
continue;
}
} else if (object instanceof DC_Cell) {
if (e.isAltDown()) {
objClicked = (DC_Obj) object;
break;
} else if (objClicked == null) {
objClicked = (DC_Obj) object;
}
// ?
continue;
}
}
// if (objClicked == null)
// return; // ??
}
}
if (objClicked == null) {
objClicked = cellComp.getTopObjOrCell();
}
if (CoreEngine.isLevelEditor()) {
if (objClicked instanceof DC_Cell) {
return;
}
}
boolean right = SwingUtilities.isRightMouseButton(e);
if (right) {
objClicked.invokeRightClicked();
// gridComp.getGame().getManager().rightClicked(objClicked);
} else {
gridComp.getGame().getManager().objClicked(objClicked);
}
boolean debugMode = gridComp.getGame().isDebugMode();
if (debugMode) {
gridComp.getGame().getDebugMaster().setArg(objClicked);
}
if (e.isAltDown()) {
if (debugMode) {
invokeAltClick(right);
} else {
new Thread(new Runnable() {
public void run() {
gridComp.getGame().getMovementManager().moveTo(objClicked);
}
}, "moveTo thread").start();
}
}
if (e.isShiftDown()) {
invokeShiftClick(right);
}
if (e.isControlDown()) {
invokeControlClick(right);
}
}
Aggregations