mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Support drawing prompt rotated 180 degrees
This commit is contained in:
@@ -28,6 +28,7 @@ public class Graphics {
|
|||||||
|
|
||||||
private final SpriteBatch batch = new SpriteBatch();
|
private final SpriteBatch batch = new SpriteBatch();
|
||||||
private final ShapeRenderer shapeRenderer = new ShapeRenderer();
|
private final ShapeRenderer shapeRenderer = new ShapeRenderer();
|
||||||
|
private final Vector3 tmp = new Vector3();
|
||||||
private float regionHeight;
|
private float regionHeight;
|
||||||
private Rectangle bounds;
|
private Rectangle bounds;
|
||||||
private Rectangle visibleBounds;
|
private Rectangle visibleBounds;
|
||||||
@@ -63,7 +64,15 @@ public class Graphics {
|
|||||||
}
|
}
|
||||||
public boolean startClip(float x, float y, float w, float h) {
|
public boolean startClip(float x, float y, float w, float h) {
|
||||||
batch.flush(); //must flush batch to prevent other things not rendering
|
batch.flush(); //must flush batch to prevent other things not rendering
|
||||||
if (!ScissorStack.pushScissors(new Rectangle(adjustX(x), adjustY(y, h), w, h))) {
|
|
||||||
|
Rectangle clip = new Rectangle(adjustX(x), adjustY(y, h), w, h);
|
||||||
|
if (isTransformed) { //transform position if needed
|
||||||
|
tmp.set(clip.x + clip.width / 2, clip.y + clip.height / 2, 0);
|
||||||
|
tmp.mul(batch.getTransformMatrix());
|
||||||
|
clip.x = tmp.x - clip.width / 2;
|
||||||
|
clip.y = tmp.y - clip.height / 2;
|
||||||
|
}
|
||||||
|
if (!ScissorStack.pushScissors(clip)) {
|
||||||
failedClipCount++; //tracked failed clips to prevent calling popScissors on endClip
|
failedClipCount++; //tracked failed clips to prevent calling popScissors on endClip
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -86,15 +95,30 @@ public class Graphics {
|
|||||||
|
|
||||||
final Rectangle parentBounds = bounds;
|
final Rectangle parentBounds = bounds;
|
||||||
bounds = new Rectangle(parentBounds.x + displayObj.getLeft(), parentBounds.y + displayObj.getTop(), displayObj.getWidth(), displayObj.getHeight());
|
bounds = new Rectangle(parentBounds.x + displayObj.getLeft(), parentBounds.y + displayObj.getTop(), displayObj.getWidth(), displayObj.getHeight());
|
||||||
displayObj.setScreenPosition(bounds.x, bounds.y);
|
if (isTransformed) { //transform screen position if needed
|
||||||
|
tmp.set(bounds.x + bounds.width / 2, regionHeight - bounds.y - bounds.height / 2, 0);
|
||||||
|
tmp.mul(batch.getTransformMatrix());
|
||||||
|
displayObj.setScreenPosition(tmp.x - bounds.width / 2, regionHeight - tmp.y - bounds.height / 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
displayObj.setScreenPosition(bounds.x, bounds.y);
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle intersection = Utils.getIntersection(bounds, visibleBounds);
|
Rectangle intersection = Utils.getIntersection(bounds, visibleBounds);
|
||||||
if (intersection != null) { //avoid drawing object if it's not within visible region
|
if (intersection != null) { //avoid drawing object if it's not within visible region
|
||||||
final Rectangle backup = visibleBounds;
|
final Rectangle backup = visibleBounds;
|
||||||
visibleBounds = intersection;
|
visibleBounds = intersection;
|
||||||
|
|
||||||
|
if (displayObj.getRotate180()) {
|
||||||
|
setRotateTransform(displayObj.getWidth() / 2, displayObj.getHeight() / 2, 180);
|
||||||
|
}
|
||||||
|
|
||||||
displayObj.draw(this);
|
displayObj.draw(this);
|
||||||
|
|
||||||
|
if (displayObj.getRotate180()) {
|
||||||
|
clearTransform();
|
||||||
|
}
|
||||||
|
|
||||||
visibleBounds = backup;
|
visibleBounds = backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public class MatchScreen extends FScreen {
|
|||||||
MatchUtil.getGameView().selectButtonCancel();
|
MatchUtil.getGameView().selectButtonCancel();
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
topPlayerPrompt.setRotate180(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
topPlayerPrompt = null;
|
topPlayerPrompt = null;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public abstract class FDisplayObject {
|
|||||||
|
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
private boolean rotate180 = false;
|
||||||
private final Rectangle bounds = new Rectangle();
|
private final Rectangle bounds = new Rectangle();
|
||||||
private final Vector2 screenPosition = new Vector2();
|
private final Vector2 screenPosition = new Vector2();
|
||||||
|
|
||||||
@@ -92,6 +93,13 @@ public abstract class FDisplayObject {
|
|||||||
visible = b0;
|
visible = b0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getRotate180() {
|
||||||
|
return rotate180;
|
||||||
|
}
|
||||||
|
public void setRotate180(boolean b0) {
|
||||||
|
rotate180 = b0;
|
||||||
|
}
|
||||||
|
|
||||||
//override to return true if drawOverlay should be called on container before drawing this object
|
//override to return true if drawOverlay should be called on container before drawing this object
|
||||||
protected boolean drawAboveOverlay() {
|
protected boolean drawAboveOverlay() {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user