Commit 7562ae99 authored by Michael Kamensky's avatar Michael Kamensky

Merge branch 'newBranch' into 'master'

Add Border Tint, Update libgdx to Nightly

See merge request core-developers/forge!2235
parents 4a7bb4e0 32621257
......@@ -616,7 +616,8 @@ public class AiController {
}
catch (IllegalArgumentException ex) {
System.err.println(ex.getMessage());
ComparatorUtil.verifyTransitivity(saComparator, all);
String assertex = ComparatorUtil.verifyTransitivity(saComparator, all);
Sentry.capture(ex.getMessage() + "\nAssertionError [verifyTransitivity]: " + assertex);
}
for (final SpellAbility sa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, player)) {
......@@ -1585,7 +1586,8 @@ public class AiController {
}
catch (IllegalArgumentException ex) {
System.err.println(ex.getMessage());
ComparatorUtil.verifyTransitivity(saComparator, all);
String assertex = ComparatorUtil.verifyTransitivity(saComparator, all);
Sentry.capture(ex.getMessage() + "\nAssertionError [verifyTransitivity]: " + assertex);
}
for (final SpellAbility sa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, player)) {
......
......@@ -15,8 +15,9 @@ public final class ComparatorUtil
* @param elements the elements to test against
* @throws AssertionError if the comparator is not transitive
*/
public static <T> void verifyTransitivity(Comparator<T> comparator, Collection<T> elements)
public static <T> String verifyTransitivity(Comparator<T> comparator, Collection<T> elements)
{
String exception = "";
for (T first: elements)
{
for (T second: elements)
......@@ -27,8 +28,12 @@ public final class ComparatorUtil
{
// Uncomment the following line to step through the failed case
//comparator.compare(first, second);
throw new AssertionError("compare(" + first + ", " + second + ") == " + result1 +
" but swapping the parameters returns " + result2);
/*throw new AssertionError("compare(" + first + ", " + second + ") == " + result1 +
" but swapping the parameters returns " + result2);*/
exception = "compare(" + first + ", " + second + ") == " + result1 +
" but swapping the parameters returns " + result2;
System.err.println(exception);
return exception;
}
}
}
......@@ -49,13 +54,19 @@ public final class ComparatorUtil
{
// Uncomment the following line to step through the failed case
//comparator.compare(first, third);
throw new AssertionError("compare(" + first + ", " + second + ") > 0, " +
/*throw new AssertionError("compare(" + first + ", " + second + ") > 0, " +
"compare(" + second + ", " + third + ") > 0, but compare(" + first + ", " + third + ") == " +
firstGreaterThanThird);
firstGreaterThanThird);*/
exception = "compare(" + first + ", " + second + ") > 0, " +
"compare(" + second + ", " + third + ") > 0, but compare(" + first + ", " + third + ") == " +
firstGreaterThanThird;
System.err.println(exception);
return exception;
}
}
}
}
return exception;
}
/**
......
......@@ -3155,6 +3155,7 @@ public class Card extends GameEntity implements Comparable<Card> {
public final void addColor(final String s, final boolean addToColors, final long timestamp) {
changedCardColors.put(timestamp, new CardColor(s, addToColors, timestamp));
currentState.getView().updateColors(this);
currentState.getView().updateHasChangeColors(!getChangedCardColors().isEmpty());
}
public final void removeColor(final long timestampIn) {
......@@ -3162,6 +3163,7 @@ public class Card extends GameEntity implements Comparable<Card> {
if (removeCol != null) {
currentState.getView().updateColors(this);
currentState.getView().updateHasChangeColors(!getChangedCardColors().isEmpty());
}
}
......
......@@ -523,7 +523,6 @@ public class CardView extends GameEntityView {
void updateChangedColorWords(Card c) {
set(TrackableProperty.ChangedColorWords, c.getChangedTextColorWords());
}
public Map<String, String> getChangedTypes() {
return get(TrackableProperty.ChangedTypes);
}
......@@ -706,11 +705,13 @@ public class CardView extends GameEntityView {
// update the color only while in Game
if (c.getGame() != null) {
currentStateView.updateColors(currentState);
currentStateView.updateHasChangeColors(!c.getChangedCardColors().isEmpty());
}
} else {
currentStateView.updateLoyalty(currentState);
}
currentState.getView().updateKeywords(c, currentState); //update keywords even if state doesn't change
currentState.getView().setOriginalColors(c); //set original Colors
CardState alternateState = isSplitCard && isFaceDown() ? c.getState(CardStateName.RightSplit) : c.getAlternateState();
......@@ -840,13 +841,22 @@ public class CardView extends GameEntityView {
public ColorSet getColors() {
return get(TrackableProperty.Colors);
}
public ColorSet getOriginalColors() {
return get(TrackableProperty.OriginalColors);
}
void updateColors(Card c) {
set(TrackableProperty.Colors, c.determineColor());
}
void updateColors(CardState c) {
set(TrackableProperty.Colors, ColorSet.fromMask(c.getColor()));
}
void setOriginalColors(Card c) {
set(TrackableProperty.OriginalColors, c.determineColor());
}
void updateHasChangeColors(boolean hasChangeColor) {
set(TrackableProperty.HasChangedColors, hasChangeColor);
}
public boolean hasChangeColors() { return get(TrackableProperty.HasChangedColors); }
public String getImageKey() {
return getImageKey(null);
}
......
......@@ -69,6 +69,7 @@ public enum TrackableProperty {
//Card State
Name(TrackableTypes.StringType),
Colors(TrackableTypes.ColorSetType),
OriginalColors(TrackableTypes.ColorSetType),
ImageKey(TrackableTypes.StringType),
Type(TrackableTypes.CardTypeViewType),
ManaCost(TrackableTypes.ManaCostType),
......@@ -80,6 +81,7 @@ public enum TrackableProperty {
Toughness(TrackableTypes.IntegerType),
Loyalty(TrackableTypes.StringType),
ChangedColorWords(TrackableTypes.StringMapType),
HasChangedColors(TrackableTypes.BooleanType),
ChangedTypes(TrackableTypes.StringMapType),
KeywordKey(TrackableTypes.StringType),
......
......@@ -563,6 +563,18 @@ public class Graphics {
}
public float getfloatAlphaComposite() { return alphaComposite; }
public void drawBorderImage(FImage image, Color color, float x, float y, float w, float h, boolean tint) {
image.draw(this, x, y, w, h);
if(tint){
float oldalpha = alphaComposite;
setAlphaComposite(0.8f);
drawRoundRect(2f, Color.WHITE, x, y, w, h, (h-w)/12);
setAlphaComposite(1f);
fillRoundRect(color, x, y, w, h, (h-w)/12);
setAlphaComposite(oldalpha);
}
}
public void drawImage(FImage image, float x, float y, float w, float h) {
drawImage(image, x, y, w, h, false);
}
......
......@@ -231,7 +231,9 @@ public class ImageCache {
return true;
return false;
}
public static FImage getBorderImage(CardView c) {
public static FImage getBorderImage(CardView c, boolean canshow) {
if (!canshow)
return BlackBorder;
if (isWhiteBordered(c))
return WhiteBorder;
return BlackBorder;
......@@ -241,4 +243,29 @@ public class ImageCache {
return WhiteBorder;
return BlackBorder;
}
public static Color getTint(CardView c) {
if (c == null)
return Color.CLEAR;
if (c.isFaceDown())
return Color.CLEAR;
CardView.CardStateView state = c.getCurrentState();
if (state.getColors().isColorless()) //Moonlace -> target spell or permanent becomes colorless.
return Color.valueOf("#A0A6A4");
else if (state.getColors().isMonoColor()) {
if (state.getColors().hasBlack())
return Color.valueOf("#48494a");
else if (state.getColors().hasBlue())
return Color.valueOf("#62b5f8");
else if (state.getColors().hasRed())
return Color.valueOf("#f6532d");
else if (state.getColors().hasGreen())
return Color.valueOf("#66cb35");
else if (state.getColors().hasWhite())
return Color.valueOf("#EEEBE1");
}
else if (state.getColors().isMulticolor())
return Color.valueOf("#F9E084");
return Color.CLEAR;
}
}
......@@ -326,7 +326,6 @@ public class CardImageRenderer {
public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h, float dispW, float dispH, boolean isCurrentCard) {
boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
//this one is currently using the mask, others are cropped and use generated borders from shaperenderer ...
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
if (image == null) { //draw details if can't draw zoom
drawDetails(g, card, gameView, altState, x, y, w, h);
......@@ -391,7 +390,7 @@ public class CardImageRenderer {
if (ImageCache.isExtendedArt(card))
g.drawImage(image, x, y, w, h);
else {
g.drawImage(ImageCache.getBorderImage(card), x, y, w, h);
g.drawImage(ImageCache.getBorderImage(card, canLook), x, y, w, h);
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f);
}
}
......
......@@ -120,6 +120,8 @@ public class CardRenderer {
}
public static Color getRarityColor(CardRarity rarity) {
if (rarity == null)// NPE from Rarity weird...
return Color.CLEAR;
switch(rarity) {
case Uncommon:
return fromDetailColor(DetailColors.UNCOMMON);
......@@ -427,7 +429,6 @@ public class CardRenderer {
g.fillRect(Color.BLACK, x, y, w, h);
}
}
public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate) {
boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING);
Texture image = new RendererCachedCardImage(card, false).getImage();
......@@ -456,7 +457,8 @@ public class CardRenderer {
if (ImageCache.isExtendedArt(card))
g.drawImage(image, x, y, w, h);
else {
g.drawImage(ImageCache.getBorderImage(card), x, y, w, h);
boolean t = (card.getCurrentState().getOriginalColors() != card.getCurrentState().getColors()) || card.getCurrentState().hasChangeColors();
g.drawBorderImage(ImageCache.getBorderImage(card, MatchController.instance.mayView(card)), ImageCache.getTint(card), x, y, w, h, t); //tint check for changed colors
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f);
}
}
......@@ -475,6 +477,9 @@ public class CardRenderer {
}
public static void drawCardWithOverlays(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos) {
boolean canShow = MatchController.instance.mayView(card);
float oldAlpha = g.getfloatAlphaComposite();
boolean unselectable = !MatchController.instance.isSelectable(card) && MatchController.instance.isSelecting();
float cx, cy, cw, ch;
cx = x; cy = y; cw = w; ch = h;
drawCard(g, card, x, y, w, h, pos, false);
......@@ -485,10 +490,6 @@ public class CardRenderer {
w -= 2 * padding;
h -= 2 * padding;
boolean canShow = MatchController.instance.mayView(card);
float oldAlpha = g.getfloatAlphaComposite();
boolean unselectable = !MatchController.instance.isSelectable(card) && MatchController.instance.isSelecting();
// TODO: A hacky workaround is currently used to make the game not leak the color information for Morph cards.
final CardStateView details = card.getCurrentState();
final boolean isFaceDown = card.isFaceDown();
......
......@@ -129,6 +129,7 @@ public class VField extends FContainer {
cardName.equals(c.getCurrentState().getName()) &&
card.hasSameCounters(c) &&
card.getCurrentState().getKeywordKey().equals(c.getCurrentState().getKeywordKey()) &&
card.getCurrentState().getColors() == c.getCurrentState().getColors() &&
card.isSick() == c.isSick() && //don't stack sick tokens on non sick
card.isToken() == c.isToken()) { //don't stack tokens on top of non-tokens
CardAreaPanel cPanel = CardAreaPanel.get(c);
......
......@@ -58,7 +58,7 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
public final void setCurrentPlayer(PlayerView player) {
player = TrackableTypes.PlayerViewType.lookup(player); //ensure we use the correct player
if (!gameControllers.containsKey(player)) {
if (hasLocalPlayers() && !isLocalPlayer(player)) { //add check if gameControllers is not empty
throw new IllegalArgumentException();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment