mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Support showing magnified view of ViewWinLose log when tapping on it
This commit is contained in:
@@ -9,7 +9,9 @@ import forge.assets.FSkinTexture;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.screens.FScreen;
|
||||
import forge.screens.match.views.VPrompt;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FDisplayObject;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.toolbox.FScrollPane;
|
||||
|
||||
public abstract class FDropDown extends FScrollPane {
|
||||
@@ -61,23 +63,26 @@ public abstract class FDropDown extends FScrollPane {
|
||||
public void setVisible(boolean visible0) {
|
||||
if (isVisible() == visible0) { return; }
|
||||
|
||||
//add/remove drop down from current screen when its visibility changes
|
||||
FScreen screen = Forge.getCurrentScreen();
|
||||
//add/remove drop down from current screen or top overlay when its visibility changes
|
||||
FContainer container = FOverlay.getTopOverlay();
|
||||
if (container == null) {
|
||||
container = Forge.getCurrentScreen();
|
||||
}
|
||||
if (visible0) {
|
||||
updateSizeAndPosition();
|
||||
|
||||
if (autoHide()) { //add invisible backdrop if needed to allow auto-hiding when pressing outide drop down
|
||||
backdrop = new Backdrop();
|
||||
backdrop.setSize(screen.getWidth(), screen.getHeight());
|
||||
screen.add(backdrop);
|
||||
backdrop.setSize(container.getWidth(), container.getHeight());
|
||||
container.add(backdrop);
|
||||
}
|
||||
screen.add(this);
|
||||
container.add(this);
|
||||
}
|
||||
else {
|
||||
screen.remove(this);
|
||||
container.remove(this);
|
||||
if (backdrop != null) {
|
||||
backdrop.setVisible(false);
|
||||
screen.remove(backdrop);
|
||||
container.remove(backdrop);
|
||||
backdrop = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@ public class FTooltip extends FDropDown {
|
||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
private static final float PADDING = Utils.scaleMin(5);
|
||||
|
||||
FDisplayObject owner;
|
||||
float x, y;
|
||||
private FDisplayObject owner;
|
||||
private float x, y;
|
||||
private final String text;
|
||||
|
||||
public void show(FDisplayObject owner0, float x0, float y0) {
|
||||
owner = owner0;
|
||||
@@ -44,8 +45,6 @@ public class FTooltip extends FDropDown {
|
||||
setBounds(Math.round(x), Math.round(y), Math.round(paneSize.getWidth()), Math.round(paneSize.getHeight()));
|
||||
}
|
||||
|
||||
private final String text;
|
||||
|
||||
public FTooltip(String text0) {
|
||||
text = text0;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import forge.game.GameLogEntry;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.GameOutcome;
|
||||
import forge.game.player.Player;
|
||||
import forge.menu.FMagnifyView;
|
||||
import forge.model.FModel;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FContainer;
|
||||
@@ -81,7 +82,13 @@ public class ViewWinLose extends FOverlay {
|
||||
btnContinue.setEnabled(!game0.getMatch().isMatchOver());
|
||||
|
||||
lblLog = add(new FLabel.Builder().text("Game Log").align(HAlignment.CENTER).fontSize(18).build());
|
||||
txtLog = add(new FTextArea(game.getGameLog().getLogText(null).replace("[COMPUTER]", "[AI]")));
|
||||
txtLog = add(new FTextArea(game.getGameLog().getLogText(null).replace("[COMPUTER]", "[AI]")) {
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
FMagnifyView.show(txtLog, txtLog.getText(), FTextArea.FORE_COLOR, ViewWinLose.this.getBackColor(), txtLog.getFont());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
txtLog.setFontSize(14);
|
||||
|
||||
btnCopyLog = add(new FLabel.ButtonBuilder().text("Copy to clipboard").command(new FEventHandler() {
|
||||
|
||||
@@ -54,6 +54,10 @@ public abstract class FOverlay extends FContainer {
|
||||
super.setVisible(visible0);
|
||||
}
|
||||
|
||||
public FSkinColor getBackColor() {
|
||||
return backColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(Graphics g) {
|
||||
g.fillRect(backColor, 0, 0, this.getWidth(), this.getHeight());
|
||||
|
||||
@@ -7,14 +7,16 @@ import forge.Forge.Graphics;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
import forge.assets.TextRenderer;
|
||||
|
||||
public class FTextArea extends FScrollPane {
|
||||
private static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
public static final FSkinColor FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||
|
||||
private String text;
|
||||
private FSkinFont font;
|
||||
private HAlignment alignment;
|
||||
private Vector2 insets;
|
||||
private final TextRenderer renderer = new TextRenderer(true);
|
||||
|
||||
public FTextArea() {
|
||||
this("");
|
||||
@@ -46,18 +48,21 @@ public class FTextArea extends FScrollPane {
|
||||
revalidate();
|
||||
}
|
||||
|
||||
public FSkinFont getFont() {
|
||||
return font;
|
||||
}
|
||||
|
||||
public float getPreferredHeight(float width) {
|
||||
return font.getFont().getWrappedBounds(text, width - 2 * insets.x).height +
|
||||
font.getFont().getLineHeight() - font.getFont().getCapHeight(); //account for height below baseline of final line
|
||||
return renderer.getWrappedBounds(text, font, width - 2 * insets.x).height + 2 * insets.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
|
||||
return new ScrollBounds(visibleWidth, getPreferredHeight(visibleWidth) + 2 * insets.y);
|
||||
return new ScrollBounds(visibleWidth, getPreferredHeight(visibleWidth));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(Graphics g) {
|
||||
g.drawText(text, font, FORE_COLOR, insets.x - getScrollLeft(), insets.y - getScrollTop(), getScrollWidth() - 2 * insets.x, getScrollHeight() - 2 * insets.y, true, alignment, false);
|
||||
renderer.drawText(g, text, font, FORE_COLOR, insets.x - getScrollLeft(), insets.y - getScrollTop(), getScrollWidth() - 2 * insets.x, getScrollHeight() - 2 * insets.y, true, alignment, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user