mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Merge branch 'master' into 'master'
Various Improvement (Android) See merge request core-developers/forge!2110
This commit is contained in:
@@ -1073,6 +1073,14 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
game.fireEvent(new GameEventGameRestarted(playerTurn));
|
game.fireEvent(new GameEventGameRestarted(playerTurn));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update Priority for all players
|
||||||
|
for (final Player p : game.getPlayers()) {
|
||||||
|
if(getPriorityPlayer() == p)
|
||||||
|
p.setHasPriority(true);
|
||||||
|
else
|
||||||
|
p.setHasPriority(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2672,6 +2672,12 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
public void setExtraTurnCount(final int val) {
|
public void setExtraTurnCount(final int val) {
|
||||||
view.setExtraTurnCount(val);
|
view.setExtraTurnCount(val);
|
||||||
}
|
}
|
||||||
|
public void setHasPriority(final boolean val) {
|
||||||
|
view.setHasPriority(val);
|
||||||
|
}
|
||||||
|
public boolean isAI() {
|
||||||
|
return view.isAI();
|
||||||
|
}
|
||||||
|
|
||||||
public void initVariantsZones(RegisteredPlayer registeredPlayer) {
|
public void initVariantsZones(RegisteredPlayer registeredPlayer) {
|
||||||
PlayerZone bf = getZone(ZoneType.Battlefield);
|
PlayerZone bf = getZone(ZoneType.Battlefield);
|
||||||
|
|||||||
@@ -205,6 +205,13 @@ public class PlayerView extends GameEntityView {
|
|||||||
set(TrackableProperty.ExtraTurnCount, val);
|
set(TrackableProperty.ExtraTurnCount, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getHasPriority() {
|
||||||
|
return get(TrackableProperty.HasPriority);
|
||||||
|
}
|
||||||
|
public void setHasPriority(final boolean val) {
|
||||||
|
set(TrackableProperty.HasPriority, val);
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxHandSize() {
|
public int getMaxHandSize() {
|
||||||
return get(TrackableProperty.MaxHandSize);
|
return get(TrackableProperty.MaxHandSize);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ public enum TrackableProperty {
|
|||||||
Mana(TrackableTypes.ManaMapType, FreezeMode.IgnoresFreeze),
|
Mana(TrackableTypes.ManaMapType, FreezeMode.IgnoresFreeze),
|
||||||
IsExtraTurn(TrackableTypes.BooleanType),
|
IsExtraTurn(TrackableTypes.BooleanType),
|
||||||
ExtraTurnCount(TrackableTypes.IntegerType),
|
ExtraTurnCount(TrackableTypes.IntegerType),
|
||||||
|
HasPriority(TrackableTypes.BooleanType),
|
||||||
|
|
||||||
//SpellAbility
|
//SpellAbility
|
||||||
HostCard(TrackableTypes.CardViewType),
|
HostCard(TrackableTypes.CardViewType),
|
||||||
|
|||||||
@@ -533,6 +533,7 @@ public class Graphics {
|
|||||||
alphaComposite = 1;
|
alphaComposite = 1;
|
||||||
batch.setColor(Color.WHITE);
|
batch.setColor(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
public float getfloatAlphaComposite() { return alphaComposite; }
|
||||||
|
|
||||||
public void drawImage(FImage image, float x, float y, float w, float h) {
|
public void drawImage(FImage image, float x, float y, float w, float h) {
|
||||||
drawImage(image, x, y, w, h, false);
|
drawImage(image, x, y, w, h, false);
|
||||||
|
|||||||
@@ -558,39 +558,37 @@ public class CardRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if (counterBoxBaseWidth + font.getBounds(String.valueOf(maxCounters)).width > w) {
|
//if (counterBoxBaseWidth + font.getBounds(String.valueOf(maxCounters)).width > w) {
|
||||||
layout.setText(font, String.valueOf(maxCounters));
|
if(font != null && !String.valueOf(maxCounters).isEmpty()){
|
||||||
|
layout.setText(font, String.valueOf(maxCounters));
|
||||||
if (counterBoxBaseWidth + layout.width > w) {
|
if (counterBoxBaseWidth + layout.width > w) {
|
||||||
|
drawCounterImage(card, g, x, y, w, h);
|
||||||
drawCounterImage(card, g, x, y, w, h);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<CounterType, Integer> counterEntry : card.getCounters().entrySet()) {
|
for (Map.Entry<CounterType, Integer> counterEntry : card.getCounters().entrySet()) {
|
||||||
|
|
||||||
final CounterType counter = counterEntry.getKey();
|
final CounterType counter = counterEntry.getKey();
|
||||||
final int numberOfCounters = counterEntry.getValue();
|
final int numberOfCounters = counterEntry.getValue();
|
||||||
//final float counterBoxRealWidth = counterBoxBaseWidth + font.getBounds(String.valueOf(numberOfCounters)).width + 4;
|
//final float counterBoxRealWidth = counterBoxBaseWidth + font.getBounds(String.valueOf(numberOfCounters)).width + 4;
|
||||||
layout.setText(font, String.valueOf(numberOfCounters));
|
if(font != null && !String.valueOf(numberOfCounters).isEmpty()){
|
||||||
final float counterBoxRealWidth = counterBoxBaseWidth + layout.width + 4;
|
layout.setText(font, String.valueOf(numberOfCounters));
|
||||||
|
final float counterBoxRealWidth = counterBoxBaseWidth + layout.width + 4;
|
||||||
|
|
||||||
final float counterYOffset = spaceFromTopOfCard - (currentCounter++ * (counterBoxHeight + counterBoxSpacing));
|
final float counterYOffset = spaceFromTopOfCard - (currentCounter++ * (counterBoxHeight + counterBoxSpacing));
|
||||||
|
|
||||||
g.fillRect(counterBackgroundColor, x - 3, counterYOffset, counterBoxRealWidth, counterBoxHeight);
|
g.fillRect(counterBackgroundColor, x - 3, counterYOffset, counterBoxRealWidth, counterBoxHeight);
|
||||||
|
|
||||||
if (!counterColorCache.containsKey(counter)) {
|
if (!counterColorCache.containsKey(counter)) {
|
||||||
counterColorCache.put(counter, new Color(counter.getRed() / 255.0f, counter.getGreen() / 255.0f, counter.getBlue() / 255.0f, 1.0f));
|
counterColorCache.put(counter, new Color(counter.getRed() / 255.0f, counter.getGreen() / 255.0f, counter.getBlue() / 255.0f, 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
Color counterColor = counterColorCache.get(counter);
|
||||||
|
|
||||||
|
drawText(g, counter.getCounterOnCardDisplayName(), font, counterColor, x + 2 + additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, Align.left);
|
||||||
|
drawText(g, String.valueOf(numberOfCounters), font, counterColor, x + counterBoxBaseWidth - 4f - additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, Align.left);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color counterColor = counterColorCache.get(counter);
|
|
||||||
|
|
||||||
drawText(g, counter.getCounterOnCardDisplayName(), font, counterColor, x + 2 + additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, Align.left);
|
|
||||||
drawText(g, String.valueOf(numberOfCounters), font, counterColor, x + counterBoxBaseWidth - 4f - additionalXOffset, counterYOffset, counterBoxRealWidth, counterBoxHeight, Align.left);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int GL_BLEND = GL20.GL_BLEND;
|
private static final int GL_BLEND = GL20.GL_BLEND;
|
||||||
@@ -600,22 +598,22 @@ public class CardRenderer {
|
|||||||
if (color.a < 1) { //enable blending so alpha colored shapes work properly
|
if (color.a < 1) { //enable blending so alpha colored shapes work properly
|
||||||
Gdx.gl.glEnable(GL_BLEND);
|
Gdx.gl.glEnable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
if(font != null && !text.isEmpty()) {
|
||||||
|
layout.setText(font, text);
|
||||||
|
TextBounds textBounds = new TextBounds(layout.width, layout.height);
|
||||||
|
|
||||||
layout.setText(font, text);
|
float textHeight = textBounds.height;
|
||||||
TextBounds textBounds = new TextBounds(layout.width, layout.height);
|
if (h > textHeight) {
|
||||||
|
y += (h - textHeight) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
float textHeight = textBounds.height;
|
font.setColor(color);
|
||||||
if (h > textHeight) {
|
font.draw(g.getBatch(), text, g.adjustX(x), g.adjustY(y, 0), w, horizontalAlignment, true);
|
||||||
y += (h - textHeight) / 2;
|
|
||||||
|
if (color.a < 1) {
|
||||||
|
Gdx.gl.glDisable(GL_BLEND);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
font.setColor(color);
|
|
||||||
font.draw(g.getBatch(), text, g.adjustX(x), g.adjustY(y, 0), w, horizontalAlignment, true);
|
|
||||||
|
|
||||||
if (color.a < 1) {
|
|
||||||
Gdx.gl.glDisable(GL_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawCounterImage(final CardView card, final Graphics g, final float x, final float y, final float w, final float h) {
|
private static void drawCounterImage(final CardView card, final Graphics g, final float x, final float y, final float w, final float h) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package forge.screens;
|
package forge.screens;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
@@ -91,6 +92,12 @@ public class LoadingOverlay extends FOverlay {
|
|||||||
float panelHeight = logoSize + fontHeight + 4 * padding;
|
float panelHeight = logoSize + fontHeight + 4 * padding;
|
||||||
|
|
||||||
float y = (getHeight() - panelHeight) / 2;
|
float y = (getHeight() - panelHeight) / 2;
|
||||||
|
float oldAlpha = g.getfloatAlphaComposite();
|
||||||
|
//dark translucent back..
|
||||||
|
g.setAlphaComposite(0.6f);
|
||||||
|
g.fillRect(Color.BLACK, 0, 0, getWidth(), getHeight());
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
//overlay
|
||||||
g.fillRect(BACK_COLOR, x, y, panelWidth, panelHeight);
|
g.fillRect(BACK_COLOR, x, y, panelWidth, panelHeight);
|
||||||
g.drawRect(Utils.scale(2), FORE_COLOR, x, y, panelWidth, panelHeight);
|
g.drawRect(Utils.scale(2), FORE_COLOR, x, y, panelWidth, panelHeight);
|
||||||
y += padding;
|
y += padding;
|
||||||
|
|||||||
@@ -269,7 +269,8 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
@Override
|
@Override
|
||||||
protected void startMatch() {
|
protected void startMatch() {
|
||||||
for (int i = 0; i < getNumPlayers(); i++) {
|
for (int i = 0; i < getNumPlayers(); i++) {
|
||||||
updateDeck(i);
|
updateDeck(i);//TODO: Investigate why AI names cannot be overriden?
|
||||||
|
updateName(i, getPlayerName(i));
|
||||||
}
|
}
|
||||||
//set this so we cant get any multi/rapid tap on start button
|
//set this so we cant get any multi/rapid tap on start button
|
||||||
Forge.setLoadingaMatch(true);
|
Forge.setLoadingaMatch(true);
|
||||||
@@ -614,6 +615,12 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateName(final int playerIndex, final String name) {
|
||||||
|
if (playerChangeListener != null) {
|
||||||
|
playerChangeListener.update(playerIndex, UpdateLobbyPlayerEvent.nameUpdate(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setReady(final int index, final boolean ready) {
|
void setReady(final int index, final boolean ready) {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
updateDeck(index);
|
updateDeck(index);
|
||||||
|
|||||||
@@ -3,7 +3,11 @@ package forge.screens.match;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
@@ -569,6 +573,23 @@ public class MatchScreen extends FScreen {
|
|||||||
y = bottomPlayerPanel.getTop() + bottomPlayerPanel.getField().getHeight();
|
y = bottomPlayerPanel.getTop() + bottomPlayerPanel.getField().getHeight();
|
||||||
g.drawLine(1, BORDER_COLOR, x, y, w, y);
|
g.drawLine(1, BORDER_COLOR, x, y, w, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Draw Priority Human Multiplayer 2 player
|
||||||
|
float oldAlphaComposite = g.getfloatAlphaComposite();
|
||||||
|
if ((getPlayerPanels().keySet().size() == 2) && (countHuman() == 2)){
|
||||||
|
for (VPlayerPanel playerPanel: playerPanelsList){
|
||||||
|
midField = playerPanel.getTop();
|
||||||
|
y = midField - 0.5f;
|
||||||
|
float adjustY = Forge.isLandscapeMode() ? y + 1f : midField;
|
||||||
|
float adjustH = Forge.isLandscapeMode() ? playerPanel.getField().getBottom() - 1f : playerPanel.getBottom() - 1f;
|
||||||
|
if(playerPanel.getPlayer().getHasPriority() && !playerPanel.getPlayer().isAI())
|
||||||
|
g.setAlphaComposite(0.8f);
|
||||||
|
else
|
||||||
|
g.setAlphaComposite(0f);
|
||||||
|
g.drawRect(4f, Color.CYAN, playerPanel.getField().getLeft(), adjustY, playerPanel.getField().getWidth(), adjustH);
|
||||||
|
g.setAlphaComposite(oldAlphaComposite);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
|
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
|
||||||
@@ -673,5 +694,13 @@ public class MatchScreen extends FScreen {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
private int countHuman(){
|
||||||
|
int humanplayers = 0;
|
||||||
|
for (VPlayerPanel playerPanel: playerPanelsList) {
|
||||||
|
if(!playerPanel.getPlayer().isAI())
|
||||||
|
humanplayers++;
|
||||||
|
}
|
||||||
|
return humanplayers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ public final class UpdateLobbyPlayerEvent implements NetEvent {
|
|||||||
public static UpdateLobbyPlayerEvent deckUpdate(final DeckSection section, final CardPool cards) {
|
public static UpdateLobbyPlayerEvent deckUpdate(final DeckSection section, final CardPool cards) {
|
||||||
return new UpdateLobbyPlayerEvent(section, cards);
|
return new UpdateLobbyPlayerEvent(section, cards);
|
||||||
}
|
}
|
||||||
|
public static UpdateLobbyPlayerEvent nameUpdate(final String name) {
|
||||||
|
return new UpdateLobbyPlayerEvent(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UpdateLobbyPlayerEvent(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
private UpdateLobbyPlayerEvent(final Deck deck) {
|
private UpdateLobbyPlayerEvent(final Deck deck) {
|
||||||
this.deck = deck;
|
this.deck = deck;
|
||||||
|
|||||||
Reference in New Issue
Block a user