mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +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.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
@@ -137,6 +138,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
|
||||
if(slot>=0&&slot<NUMBER_OF_DECKS) {
|
||||
selectedDeckIndex = slot;
|
||||
deck = decks[selectedDeckIndex];
|
||||
if (!fantasyMode)
|
||||
setColorIdentity(DeckProxy.getColorIdentityforAdventure(deck));
|
||||
}
|
||||
}
|
||||
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(textInput).fillX().expandX();
|
||||
dialog.getButtonTable().row();
|
||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblRename"), new Runnable() {
|
||||
@Override
|
||||
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);
|
||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblRename"), () -> DeckSelectScene.this.rename())).align(Align.left);
|
||||
dialog.getButtonTable().add(Controls.newTextButton(Forge.getLocalizer().getMessage("lblAbort"), () -> dialog.hide())).align(Align.left);
|
||||
|
||||
back = ui.findActor("return");
|
||||
back.getLabel().setText(Forge.getLocalizer().getMessage("lblBack"));
|
||||
@@ -129,25 +119,12 @@ public class DeckSelectScene extends UIScene {
|
||||
edit.getLabel().setText(Forge.getLocalizer().getMessage("lblEdit"));
|
||||
rename = ui.findActor("rename");
|
||||
rename.getLabel().setText(Forge.getLocalizer().getMessage("lblRename"));
|
||||
ui.onButtonPress("return", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DeckSelectScene.this.back();
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
ui.onButtonPress("return", () -> DeckSelectScene.this.back());
|
||||
ui.onButtonPress("edit", () -> DeckSelectScene.this.edit());
|
||||
ui.onButtonPress("rename", () -> {
|
||||
textInput.setText(Current.player().getSelectedDeck().getName());
|
||||
dialog.show(stage);
|
||||
stage.setKeyboardFocus(textInput);
|
||||
});
|
||||
defColor = ui.findActor("return").getColor();
|
||||
|
||||
|
||||
@@ -128,12 +128,7 @@ public class RewardScene extends UIScene {
|
||||
public void resLoaded() {
|
||||
super.resLoaded();
|
||||
goldLabel=ui.findActor("gold");
|
||||
ui.onButtonPress("done", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
RewardScene.this.done();
|
||||
}
|
||||
});
|
||||
ui.onButtonPress("done", () -> RewardScene.this.done());
|
||||
doneButton = ui.findActor("done");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.adventure.stage;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
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.UIActor;
|
||||
import forge.adventure.world.WorldSave;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.FThreads;
|
||||
import forge.gui.GuiBase;
|
||||
|
||||
@@ -235,6 +237,12 @@ public class GameHUD extends Stage {
|
||||
|
||||
miniMap.setDrawable(new TextureRegionDrawable(miniMapTexture));
|
||||
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() {
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
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.utils.ActorGestureListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
@@ -571,6 +572,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
Image tooltip_image;
|
||||
Table tooltip_actor;
|
||||
float height;
|
||||
TextButton switchButton;
|
||||
//Vector2 tmp = new Vector2();
|
||||
|
||||
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.setSize(this.tooltip_image.getPrefWidth(), this.tooltip_image.getPrefHeight());
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
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));
|
||||
tooltip_actor.setX(actor.getRight());
|
||||
if (tooltip_actor.getX() + tooltip_actor.getWidth() > Scene.getIntendedWidth())
|
||||
@@ -600,14 +616,16 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
||||
@Override
|
||||
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
|
||||
tooltip_actor.remove();
|
||||
switchButton.remove();
|
||||
super.touchUp(event, x, y, pointer, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tap(InputEvent event, float x, float y, int count, int button) {
|
||||
if (count > 1)
|
||||
if (count > 1) {
|
||||
alternate = !alternate;
|
||||
switchTooltip();
|
||||
switchTooltip();
|
||||
}
|
||||
super.tap(event, x, y, count, button);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class WorldSave {
|
||||
if (isEasy) {
|
||||
DeckProxy dp = DeckProxy.getAllEasyStarterDecks().get(startingColorIdentity);
|
||||
starterDeck = dp.getDeck();
|
||||
identity = dp.setStarterDeckColorIdentity();
|
||||
identity = dp.getColorIdentityforAdventure();
|
||||
} else {
|
||||
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 IStorage<? extends IHasName> storage;
|
||||
|
||||
public static final Function<DeckProxy, String> FN_GET_NAME = new Function<DeckProxy, String>() {
|
||||
@Override
|
||||
public String apply(final DeckProxy arg0) {
|
||||
return arg0.getName();
|
||||
}
|
||||
};
|
||||
public static final Function<DeckProxy, String> FN_GET_NAME = arg0 -> arg0.getName();
|
||||
|
||||
// cached values
|
||||
protected ColorSet color;
|
||||
@@ -235,10 +230,13 @@ public class DeckProxy implements InventoryItem {
|
||||
}
|
||||
return deckIdentity;
|
||||
}
|
||||
public int setStarterDeckColorIdentity() {
|
||||
public int getColorIdentityforAdventure() {
|
||||
return getColorIdentityforAdventure(getDeck());
|
||||
}
|
||||
public static int getColorIdentityforAdventure(Deck deck) {
|
||||
int adventureColorIdentity = 0;
|
||||
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()) {
|
||||
case Main:
|
||||
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)
|
||||
public static final Predicate<DeckProxy> createPredicate(final Predicate<PaperCard> cardPredicate) {
|
||||
return new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy input) {
|
||||
for (final Entry<DeckSection, CardPool> deckEntry : input.getDeck()) {
|
||||
switch (deckEntry.getKey()) {
|
||||
case Main:
|
||||
case Sideboard:
|
||||
case Commander:
|
||||
for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) {
|
||||
if (!cardPredicate.apply(poolEntry.getKey())) {
|
||||
return false; //all cards in deck must pass card predicate to pass deck predicate
|
||||
}
|
||||
return input -> {
|
||||
for (final Entry<DeckSection, CardPool> deckEntry : input.getDeck()) {
|
||||
switch (deckEntry.getKey()) {
|
||||
case Main:
|
||||
case Sideboard:
|
||||
case Commander:
|
||||
for (final Entry<PaperCard, Integer> poolEntry : deckEntry.getValue()) {
|
||||
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;
|
||||
}
|
||||
|
||||
public static final Predicate<DeckProxy> IS_WHITE = new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy deck) {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.WHITE);
|
||||
}
|
||||
public static final Predicate<DeckProxy> IS_WHITE = deck -> {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.WHITE);
|
||||
};
|
||||
public static final Predicate<DeckProxy> IS_BLUE = new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy deck) {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.BLUE);
|
||||
}
|
||||
public static final Predicate<DeckProxy> IS_BLUE = deck -> {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.BLUE);
|
||||
};
|
||||
public static final Predicate<DeckProxy> IS_BLACK = new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy deck) {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.BLACK);
|
||||
}
|
||||
public static final Predicate<DeckProxy> IS_BLACK = deck -> {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.BLACK);
|
||||
};
|
||||
public static final Predicate<DeckProxy> IS_RED = new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy deck) {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.RED);
|
||||
}
|
||||
public static final Predicate<DeckProxy> IS_RED = deck -> {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.RED);
|
||||
};
|
||||
public static final Predicate<DeckProxy> IS_GREEN = new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy deck) {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.GREEN);
|
||||
}
|
||||
public static final Predicate<DeckProxy> IS_GREEN = deck -> {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.hasAnyColor(MagicColor.GREEN);
|
||||
};
|
||||
public static final Predicate<DeckProxy> IS_COLORLESS = new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy deck) {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.getColor() == 0;
|
||||
}
|
||||
public static final Predicate<DeckProxy> IS_COLORLESS = deck -> {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && cs.getColor() == 0;
|
||||
};
|
||||
public static final Predicate<DeckProxy> IS_MULTICOLOR = new Predicate<DeckProxy>() {
|
||||
@Override
|
||||
public boolean apply(final DeckProxy deck) {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && BinaryUtil.bitCount(cs.getColor()) > 1;
|
||||
}
|
||||
public static final Predicate<DeckProxy> IS_MULTICOLOR = deck -> {
|
||||
final ColorSet cs = deck.getColor();
|
||||
return cs != null && BinaryUtil.bitCount(cs.getColor()) > 1;
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user