mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Fix so buttons can be clicked while prompt magnify open
This commit is contained in:
@@ -18,17 +18,14 @@ public class FMagnifyView extends FDropDown {
|
||||
private String text;
|
||||
private FSkinColor foreColor, backColor;
|
||||
private FSkinFont font;
|
||||
private float offsetX, width;
|
||||
|
||||
public static void show(FDisplayObject owner0, String text0, FSkinColor foreColor0, FSkinColor backColor0, FSkinFont font0, float offsetX0, float width0) {
|
||||
public static void show(FDisplayObject owner0, String text0, FSkinColor foreColor0, FSkinColor backColor0, FSkinFont font0) {
|
||||
FMagnifyView view = new FMagnifyView();
|
||||
view.owner = owner0;
|
||||
view.text = text0;
|
||||
view.foreColor = foreColor0;
|
||||
view.backColor = backColor0;
|
||||
view.font = font0;
|
||||
view.offsetX = offsetX0;
|
||||
view.width = width0;
|
||||
view.show();
|
||||
}
|
||||
private FMagnifyView() {
|
||||
@@ -36,16 +33,16 @@ public class FMagnifyView extends FDropDown {
|
||||
|
||||
@Override
|
||||
protected void updateSizeAndPosition() {
|
||||
float x = owner.getScreenPosition().x + offsetX;
|
||||
float x = owner.getScreenPosition().x;
|
||||
float y = owner.getScreenPosition().y + owner.getHeight();
|
||||
paneSize = updateAndGetPaneSize(width, y);
|
||||
paneSize = updateAndGetPaneSize(owner.getWidth(), y);
|
||||
float height = paneSize.getHeight();
|
||||
if (height > y) {
|
||||
height = y;
|
||||
}
|
||||
y -= height;
|
||||
|
||||
setBounds(Math.round(x), Math.round(y), Math.round(width), Math.round(height));
|
||||
setBounds(Math.round(x), Math.round(y), Math.round(owner.getWidth()), Math.round(height));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,7 @@ import forge.menu.FMagnifyView;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FButton.Corner;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.toolbox.FEvent.FEventHandler;
|
||||
import forge.util.Utils;
|
||||
|
||||
@@ -26,11 +27,14 @@ public class VPrompt extends FContainer {
|
||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
private static final FSkinFont FONT = FSkinFont.get(14);
|
||||
|
||||
private final TextRenderer renderer = new TextRenderer();
|
||||
private final FButton btnOk, btnCancel;
|
||||
private final MessageLabel lblMessage;
|
||||
private String message;
|
||||
|
||||
public VPrompt(String okText, String cancelText, FEventHandler okCommand, FEventHandler cancelCommand) {
|
||||
lblMessage = add(new MessageLabel());
|
||||
lblMessage.setLeft(BTN_WIDTH);
|
||||
lblMessage.setHeight(HEIGHT);
|
||||
btnOk = add(new FButton(okText, okCommand));
|
||||
btnCancel = add(new FButton(cancelText, cancelCommand));
|
||||
btnOk.setSize(BTN_WIDTH, HEIGHT);
|
||||
@@ -59,34 +63,39 @@ public class VPrompt extends FContainer {
|
||||
//SDisplayUtil.remind(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
//if not enough room for prompt at given size, show magnify view
|
||||
float offsetX = BTN_WIDTH + PADDING;
|
||||
float maxWidth = getWidth() - 2 * offsetX;
|
||||
float maxHeight = getHeight() - 2 * PADDING;
|
||||
TextBounds textBounds = renderer.getWrappedBounds(message, FONT, maxWidth);
|
||||
if (textBounds.height > maxHeight) {
|
||||
FMagnifyView.show(this, message, FORE_COLOR, BACK_COLOR, FONT, offsetX, maxWidth);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLayout(float width, float height) {
|
||||
btnCancel.setLeft(width - BTN_WIDTH);
|
||||
lblMessage.setWidth(width - 2 * BTN_WIDTH);
|
||||
btnCancel.setLeft(lblMessage.getRight());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(Graphics g) {
|
||||
float w = getWidth();
|
||||
float h = getHeight();
|
||||
g.fillRect(BACK_COLOR, 0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
private class MessageLabel extends FDisplayObject {
|
||||
private final TextRenderer renderer = new TextRenderer();
|
||||
|
||||
g.fillRect(BACK_COLOR, 0, 0, w, h);
|
||||
if (!StringUtils.isEmpty(message)) {
|
||||
float x = BTN_WIDTH + PADDING;
|
||||
float y = PADDING;
|
||||
renderer.drawText(g, message, FONT, FORE_COLOR, x, y, w - 2 * x, h - 2 * y, true, HAlignment.CENTER, true);
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
//if not enough room for prompt at given size, show magnify view
|
||||
float maxWidth = getWidth() - 2 * PADDING;
|
||||
float maxHeight = getHeight() - 2 * PADDING;
|
||||
TextBounds textBounds = renderer.getWrappedBounds(message, FONT, maxWidth);
|
||||
if (textBounds.height > maxHeight) {
|
||||
FMagnifyView.show(this, message, FORE_COLOR, BACK_COLOR, FONT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g) {
|
||||
if (!StringUtils.isEmpty(message)) {
|
||||
float x = PADDING;
|
||||
float y = PADDING;
|
||||
renderer.drawText(g, message, FONT, FORE_COLOR, x, y, getWidth() - 2 * x, getHeight() - 2 * y, true, HAlignment.CENTER, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ViewWinLose extends FOverlay {
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
if (txtLog.getMaxScrollTop() > 0) {
|
||||
FMagnifyView.show(txtLog, txtLog.getText(), FTextArea.FORE_COLOR, ViewWinLose.this.getBackColor(), txtLog.getFont(), 0, txtLog.getWidth());
|
||||
FMagnifyView.show(txtLog, txtLog.getText(), FTextArea.FORE_COLOR, ViewWinLose.this.getBackColor(), txtLog.getFont());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user