mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
add switchbutton on HoldTooltip
- also update coloridentity based on selected deck - highlight deck text for empty deck
This commit is contained in:
@@ -10,6 +10,7 @@ import forge.adventure.util.*;
|
|||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
import forge.deck.CardPool;
|
import forge.deck.CardPool;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
|
import forge.deck.DeckProxy;
|
||||||
import forge.deck.DeckSection;
|
import forge.deck.DeckSection;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
@@ -137,6 +138,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
|||||||
if(slot>=0&&slot<NUMBER_OF_DECKS) {
|
if(slot>=0&&slot<NUMBER_OF_DECKS) {
|
||||||
selectedDeckIndex = slot;
|
selectedDeckIndex = slot;
|
||||||
deck = decks[selectedDeckIndex];
|
deck = decks[selectedDeckIndex];
|
||||||
|
if (!fantasyMode)
|
||||||
|
setColorIdentity(DeckProxy.getColorIdentityforAdventure(deck));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void updateDifficulty(DifficultyData diff) {
|
public void updateDifficulty(DifficultyData diff) {
|
||||||
|
|||||||
@@ -110,18 +110,8 @@ public class DeckSelectScene extends UIScene {
|
|||||||
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName")+": ")).align(Align.left);
|
dialog.getButtonTable().add(Controls.newLabel(Forge.getLocalizer().getMessage("lblName")+": ")).align(Align.left);
|
||||||
dialog.getButtonTable().add(textInput).fillX().expandX();
|
dialog.getButtonTable().add(textInput).fillX().expandX();
|
||||||
dialog.getButtonTable().row();
|
dialog.getButtonTable().row();
|
||||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblRename"), new Runnable() {
|
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblRename"), () -> DeckSelectScene.this.rename())).align(Align.left);
|
||||||
@Override
|
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> dialog.hide())).align(Align.left);
|
||||||
public void run() {
|
|
||||||
DeckSelectScene.this.rename();
|
|
||||||
}
|
|
||||||
})).align(Align.left);
|
|
||||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
dialog.hide();
|
|
||||||
}
|
|
||||||
})).align(Align.left);
|
|
||||||
|
|
||||||
back = ui.findActor("return");
|
back = ui.findActor("return");
|
||||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||||
@@ -129,25 +119,12 @@ public class DeckSelectScene extends UIScene {
|
|||||||
edit.getLabel().setText(Forge.getLocalizer().getMessage("lblEdit"));
|
edit.getLabel().setText(Forge.getLocalizer().getMessage("lblEdit"));
|
||||||
rename = ui.findActor("rename");
|
rename = ui.findActor("rename");
|
||||||
rename.getLabel().setText(Forge.getLocalizer().getMessage("lblRename"));
|
rename.getLabel().setText(Forge.getLocalizer().getMessage("lblRename"));
|
||||||
ui.onButtonPress("return", new Runnable() {
|
ui.onButtonPress("return", () -> DeckSelectScene.this.back());
|
||||||
@Override
|
ui.onButtonPress("edit", () -> DeckSelectScene.this.edit());
|
||||||
public void run() {
|
ui.onButtonPress("rename", () -> {
|
||||||
DeckSelectScene.this.back();
|
textInput.setText(Current.player().getSelectedDeck().getName());
|
||||||
}
|
dialog.show(stage);
|
||||||
});
|
stage.setKeyboardFocus(textInput);
|
||||||
ui.onButtonPress("edit", new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
DeckSelectScene.this.edit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ui.onButtonPress("rename", new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
textInput.setText(Current.player().getSelectedDeck().getName());
|
|
||||||
dialog.show(stage);
|
|
||||||
stage.setKeyboardFocus(textInput);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
defColor = ui.findActor("return").getColor();
|
defColor = ui.findActor("return").getColor();
|
||||||
|
|
||||||
|
|||||||
@@ -128,12 +128,7 @@ public class RewardScene extends UIScene {
|
|||||||
public void resLoaded() {
|
public void resLoaded() {
|
||||||
super.resLoaded();
|
super.resLoaded();
|
||||||
goldLabel=ui.findActor("gold");
|
goldLabel=ui.findActor("gold");
|
||||||
ui.onButtonPress("done", new Runnable() {
|
ui.onButtonPress("done", () -> RewardScene.this.done());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
RewardScene.this.done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
doneButton = ui.findActor("done");
|
doneButton = ui.findActor("done");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.adventure.stage;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
@@ -26,6 +27,7 @@ import forge.adventure.util.Controls;
|
|||||||
import forge.adventure.util.Current;
|
import forge.adventure.util.Current;
|
||||||
import forge.adventure.util.UIActor;
|
import forge.adventure.util.UIActor;
|
||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
|
import forge.deck.Deck;
|
||||||
import forge.gui.FThreads;
|
import forge.gui.FThreads;
|
||||||
import forge.gui.GuiBase;
|
import forge.gui.GuiBase;
|
||||||
|
|
||||||
@@ -235,6 +237,12 @@ public class GameHUD extends Stage {
|
|||||||
|
|
||||||
miniMap.setDrawable(new TextureRegionDrawable(miniMapTexture));
|
miniMap.setDrawable(new TextureRegionDrawable(miniMapTexture));
|
||||||
avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
avatar.setDrawable(new TextureRegionDrawable(Current.player().avatar()));
|
||||||
|
Deck deck = AdventurePlayer.current().getSelectedDeck();
|
||||||
|
if (deck == null || deck.isEmpty() || deck.getMain().toFlatList().size() < 30) {
|
||||||
|
deckActor.getLabel().setColor(Color.RED);
|
||||||
|
} else {
|
||||||
|
deckActor.getLabel().setColor(menuActor.getLabel().getColor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openDeck() {
|
private void openDeck() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Tooltip;
|
import com.badlogic.gdx.scenes.scene2d.ui.Tooltip;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
@@ -571,6 +572,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
Image tooltip_image;
|
Image tooltip_image;
|
||||||
Table tooltip_actor;
|
Table tooltip_actor;
|
||||||
float height;
|
float height;
|
||||||
|
TextButton switchButton;
|
||||||
//Vector2 tmp = new Vector2();
|
//Vector2 tmp = new Vector2();
|
||||||
|
|
||||||
public HoldTooltip(Image tooltip_image) {
|
public HoldTooltip(Image tooltip_image) {
|
||||||
@@ -580,12 +582,26 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
tooltip_actor.align(Align.center);
|
tooltip_actor.align(Align.center);
|
||||||
tooltip_actor.setSize(this.tooltip_image.getPrefWidth(), this.tooltip_image.getPrefHeight());
|
tooltip_actor.setSize(this.tooltip_image.getPrefWidth(), this.tooltip_image.getPrefHeight());
|
||||||
this.height = tooltip_actor.getHeight();
|
this.height = tooltip_actor.getHeight();
|
||||||
|
switchButton = Controls.newTextButton("Flip");
|
||||||
|
switchButton.addListener(new ClickListener() {
|
||||||
|
@Override
|
||||||
|
public void clicked(InputEvent event, float x, float y) {
|
||||||
|
alternate = !alternate;
|
||||||
|
switchTooltip();
|
||||||
|
super.clicked(event, x, y);
|
||||||
|
}
|
||||||
|
});
|
||||||
getGestureDetector().setLongPressSeconds(0.1f);
|
getGestureDetector().setLongPressSeconds(0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean longPress(Actor actor, float x, float y) {
|
public boolean longPress(Actor actor, float x, float y) {
|
||||||
|
TextButton done = actor.getStage().getRoot().findActor("done");
|
||||||
|
if (done != null && Reward.Type.Card.equals(reward.type)) {
|
||||||
|
switchButton.setBounds(done.getX(), done.getY(), done.getWidth(), done.getHeight());
|
||||||
|
if (reward.getCard().hasBackFace())
|
||||||
|
actor.getStage().addActor(switchButton);
|
||||||
|
}
|
||||||
//Vector2 point = actor.localToStageCoordinates(tmp.set(x, y));
|
//Vector2 point = actor.localToStageCoordinates(tmp.set(x, y));
|
||||||
tooltip_actor.setX(actor.getRight());
|
tooltip_actor.setX(actor.getRight());
|
||||||
if (tooltip_actor.getX() + tooltip_actor.getWidth() > Scene.getIntendedWidth())
|
if (tooltip_actor.getX() + tooltip_actor.getWidth() > Scene.getIntendedWidth())
|
||||||
@@ -600,14 +616,16 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
@Override
|
@Override
|
||||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
|
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
|
||||||
tooltip_actor.remove();
|
tooltip_actor.remove();
|
||||||
|
switchButton.remove();
|
||||||
super.touchUp(event, x, y, pointer, button);
|
super.touchUp(event, x, y, pointer, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tap(InputEvent event, float x, float y, int count, int button) {
|
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||||
if (count > 1)
|
if (count > 1) {
|
||||||
alternate = !alternate;
|
alternate = !alternate;
|
||||||
switchTooltip();
|
switchTooltip();
|
||||||
|
}
|
||||||
super.tap(event, x, y, count, button);
|
super.tap(event, x, y, count, button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public class WorldSave {
|
|||||||
if (isEasy) {
|
if (isEasy) {
|
||||||
DeckProxy dp = DeckProxy.getAllEasyStarterDecks().get(startingColorIdentity);
|
DeckProxy dp = DeckProxy.getAllEasyStarterDecks().get(startingColorIdentity);
|
||||||
starterDeck = dp.getDeck();
|
starterDeck = dp.getDeck();
|
||||||
identity = dp.setStarterDeckColorIdentity();
|
identity = dp.getColorIdentityforAdventure();
|
||||||
} else {
|
} else {
|
||||||
starterDeck = isFantasy ? DeckgenUtil.getRandomOrPreconOrThemeDeck("", false, false, false) : Config.instance().starterDecks()[startingColorIdentity];
|
starterDeck = isFantasy ? DeckgenUtil.getRandomOrPreconOrThemeDeck("", false, false, false) : Config.instance().starterDecks()[startingColorIdentity];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,7 @@ public class DeckProxy implements InventoryItem {
|
|||||||
protected final String deckType;
|
protected final String deckType;
|
||||||
protected final IStorage<? extends IHasName> storage;
|
protected final IStorage<? extends IHasName> storage;
|
||||||
|
|
||||||
public static final Function<DeckProxy, String> FN_GET_NAME = new Function<DeckProxy, String>() {
|
public static final Function<DeckProxy, String> FN_GET_NAME = arg0 -> arg0.getName();
|
||||||
@Override
|
|
||||||
public String apply(final DeckProxy arg0) {
|
|
||||||
return arg0.getName();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// cached values
|
// cached values
|
||||||
protected ColorSet color;
|
protected ColorSet color;
|
||||||
@@ -235,10 +230,13 @@ public class DeckProxy implements InventoryItem {
|
|||||||
}
|
}
|
||||||
return deckIdentity;
|
return deckIdentity;
|
||||||
}
|
}
|
||||||
public int setStarterDeckColorIdentity() {
|
public int getColorIdentityforAdventure() {
|
||||||
|
return getColorIdentityforAdventure(getDeck());
|
||||||
|
}
|
||||||
|
public static int getColorIdentityforAdventure(Deck deck) {
|
||||||
int adventureColorIdentity = 0;
|
int adventureColorIdentity = 0;
|
||||||
int w = 0, u = 0, b = 0, g = 0, r = 0, highest = -1;
|
int w = 0, u = 0, b = 0, g = 0, r = 0, highest = -1;
|
||||||
for (final Entry<DeckSection, CardPool> deckEntry : getDeck()) {
|
for (final Entry<DeckSection, CardPool> deckEntry : deck) {
|
||||||
switch (deckEntry.getKey()) {
|
switch (deckEntry.getKey()) {
|
||||||
case Main:
|
case Main:
|
||||||
case Sideboard:
|
case Sideboard:
|
||||||
@@ -530,26 +528,23 @@ public class DeckProxy implements InventoryItem {
|
|||||||
|
|
||||||
// Consider using a direct predicate to manage DeckProxies (not this tunnel to collection of paper cards)
|
// Consider using a direct predicate to manage DeckProxies (not this tunnel to collection of paper cards)
|
||||||
public static final Predicate<DeckProxy> createPredicate(final Predicate<PaperCard> cardPredicate) {
|
public static final Predicate<DeckProxy> createPredicate(final Predicate<PaperCard> cardPredicate) {
|
||||||
return new Predicate<DeckProxy>() {
|
return input -> {
|
||||||
@Override
|
for (final Entry<DeckSection, CardPool> deckEntry : input.getDeck()) {
|
||||||
public boolean apply(final DeckProxy input) {
|
switch (deckEntry.getKey()) {
|
||||||
for (final Entry<DeckSection, CardPool> deckEntry : input.getDeck()) {
|
case Main:
|
||||||
switch (deckEntry.getKey()) {
|
case Sideboard:
|
||||||
case Main:
|
case Commander:
|
||||||
case Sideboard:
|
for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) {
|
||||||
case Commander:
|
if (!cardPredicate.apply(poolEntry.getKey())) {
|
||||||
for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) {
|
return false; //all cards in deck must pass card predicate to pass deck predicate
|
||||||
if (!cardPredicate.apply(poolEntry.getKey())) {
|
|
||||||
return false; //all cards in deck must pass card predicate to pass deck predicate
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break; //ignore other sections
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break; //ignore other sections
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,54 +789,33 @@ public class DeckProxy implements InventoryItem {
|
|||||||
return randomLandSet;
|
return randomLandSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Predicate<DeckProxy> IS_WHITE = new Predicate<DeckProxy>() {
|
public static final Predicate<DeckProxy> IS_WHITE = deck -> {
|
||||||
@Override
|
final ColorSet cs = deck.getColor();
|
||||||
public boolean apply(final DeckProxy deck) {
|
return cs != null && cs.hasAnyColor(MagicColor.WHITE);
|
||||||
final ColorSet cs = deck.getColor();
|
|
||||||
return cs != null && cs.hasAnyColor(MagicColor.WHITE);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public static final Predicate<DeckProxy> IS_BLUE = new Predicate<DeckProxy>() {
|
public static final Predicate<DeckProxy> IS_BLUE = deck -> {
|
||||||
@Override
|
final ColorSet cs = deck.getColor();
|
||||||
public boolean apply(final DeckProxy deck) {
|
return cs != null && cs.hasAnyColor(MagicColor.BLUE);
|
||||||
final ColorSet cs = deck.getColor();
|
|
||||||
return cs != null && cs.hasAnyColor(MagicColor.BLUE);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public static final Predicate<DeckProxy> IS_BLACK = new Predicate<DeckProxy>() {
|
public static final Predicate<DeckProxy> IS_BLACK = deck -> {
|
||||||
@Override
|
final ColorSet cs = deck.getColor();
|
||||||
public boolean apply(final DeckProxy deck) {
|
return cs != null && cs.hasAnyColor(MagicColor.BLACK);
|
||||||
final ColorSet cs = deck.getColor();
|
|
||||||
return cs != null && cs.hasAnyColor(MagicColor.BLACK);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public static final Predicate<DeckProxy> IS_RED = new Predicate<DeckProxy>() {
|
public static final Predicate<DeckProxy> IS_RED = deck -> {
|
||||||
@Override
|
final ColorSet cs = deck.getColor();
|
||||||
public boolean apply(final DeckProxy deck) {
|
return cs != null && cs.hasAnyColor(MagicColor.RED);
|
||||||
final ColorSet cs = deck.getColor();
|
|
||||||
return cs != null && cs.hasAnyColor(MagicColor.RED);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public static final Predicate<DeckProxy> IS_GREEN = new Predicate<DeckProxy>() {
|
public static final Predicate<DeckProxy> IS_GREEN = deck -> {
|
||||||
@Override
|
final ColorSet cs = deck.getColor();
|
||||||
public boolean apply(final DeckProxy deck) {
|
return cs != null && cs.hasAnyColor(MagicColor.GREEN);
|
||||||
final ColorSet cs = deck.getColor();
|
|
||||||
return cs != null && cs.hasAnyColor(MagicColor.GREEN);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public static final Predicate<DeckProxy> IS_COLORLESS = new Predicate<DeckProxy>() {
|
public static final Predicate<DeckProxy> IS_COLORLESS = deck -> {
|
||||||
@Override
|
final ColorSet cs = deck.getColor();
|
||||||
public boolean apply(final DeckProxy deck) {
|
return cs != null && cs.getColor() == 0;
|
||||||
final ColorSet cs = deck.getColor();
|
|
||||||
return cs != null && cs.getColor() == 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
public static final Predicate<DeckProxy> IS_MULTICOLOR = new Predicate<DeckProxy>() {
|
public static final Predicate<DeckProxy> IS_MULTICOLOR = deck -> {
|
||||||
@Override
|
final ColorSet cs = deck.getColor();
|
||||||
public boolean apply(final DeckProxy deck) {
|
return cs != null && BinaryUtil.bitCount(cs.getColor()) > 1;
|
||||||
final ColorSet cs = deck.getColor();
|
|
||||||
return cs != null && BinaryUtil.bitCount(cs.getColor()) > 1;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user