forked from External/mage
* GUI: new reworked GUI and card render engine, card icons and dozens of other fixes (see full list in related PR);
This commit is contained in:
parent
df98cc3e62
commit
a1da5ef437
304 changed files with 7266 additions and 5093 deletions
|
|
@ -1,42 +1,47 @@
|
|||
|
||||
|
||||
package mage.client.util;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
public class Event implements Serializable {
|
||||
private final Object source;
|
||||
private final Component component;
|
||||
|
||||
private final Object source; // can be null for non card events like popup from panel
|
||||
private final Component component; // component that raise the event (example: MageCard)
|
||||
private final ClientEventType eventType;
|
||||
private final int number;
|
||||
private final int xPos;
|
||||
private final int yPos;
|
||||
|
||||
private final MouseEvent mouseEvent;
|
||||
// force alt mouse state for fake mouse event (example: card's selector can add card to deck by panel's button instead double click)
|
||||
private final boolean mouseAltDown;
|
||||
|
||||
public Event(Object source, ClientEventType eventType) {
|
||||
this(source, eventType, 0);
|
||||
}
|
||||
|
||||
|
||||
public Event(Object source, ClientEventType eventType, int number) {
|
||||
this(source, eventType, number, 0, 0, null);
|
||||
}
|
||||
|
||||
public Event(Object source, ClientEventType eventType, int number, int xPos, int yPos, Component component) {
|
||||
this(source, eventType, number, xPos, yPos, component, null, false);
|
||||
}
|
||||
|
||||
public Event(Object source, ClientEventType eventType, int number, int xPos, int yPos, Component component,
|
||||
MouseEvent mouseEvent, boolean mouseAltDown) {
|
||||
this.source = source;
|
||||
this.eventType = eventType;
|
||||
this.number = number;
|
||||
this.xPos = 0;
|
||||
this.yPos = 0;
|
||||
this.component = null;
|
||||
}
|
||||
|
||||
public Event(Object source, ClientEventType eventType, int xPos, int yPos, Component component) {
|
||||
this.source = source;
|
||||
this.eventType = eventType;
|
||||
this.number =0;
|
||||
this.xPos = xPos;
|
||||
this.yPos = yPos;
|
||||
this.component = component;
|
||||
this.mouseEvent = mouseEvent;
|
||||
this.mouseAltDown = mouseAltDown;
|
||||
}
|
||||
|
||||
public Object getSource() {
|
||||
|
|
@ -62,5 +67,21 @@ public class Event implements Serializable {
|
|||
public Component getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MouseEvent getMouseEvent() {
|
||||
if (this.mouseEvent == null) {
|
||||
// GUI must catch a correct events, so look at stack trace and find a problem code with event generation
|
||||
throw new IllegalArgumentException("Error, found empty mouse event.");
|
||||
}
|
||||
|
||||
return mouseEvent;
|
||||
}
|
||||
|
||||
public boolean isMouseAltDown() {
|
||||
if (mouseEvent != null) {
|
||||
return mouseEvent.isAltDown();
|
||||
} else {
|
||||
return mouseAltDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue