mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Network Improvements
This commit is contained in:
@@ -69,13 +69,15 @@ public class Forge implements ApplicationListener {
|
||||
public static String locale = "en-US";
|
||||
public static boolean hdbuttons = false;
|
||||
public static boolean hdstart = false;
|
||||
public static boolean isPortraitMode = false;
|
||||
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value) {
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation) {
|
||||
if (GuiBase.getInterface() == null) {
|
||||
clipboard = clipboard0;
|
||||
deviceAdapter = deviceAdapter0;
|
||||
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||
GuiBase.enablePropertyConfig(value);
|
||||
isPortraitMode = androidOrientation;
|
||||
}
|
||||
return app;
|
||||
}
|
||||
@@ -373,6 +375,8 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
|
||||
public static boolean isLandscapeMode() {
|
||||
if(GuiBase.isAndroid())
|
||||
return !isPortraitMode;
|
||||
return screenWidth > screenHeight;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinColor.Colors;
|
||||
@@ -80,14 +81,14 @@ public abstract class FScreen extends FContainer {
|
||||
|
||||
@Override
|
||||
protected final void doLayout(float width, float height) {
|
||||
if (width > height) { //handle landscape layout special
|
||||
if(GuiBase.isAndroid() && Forge.isLandscapeMode()) {
|
||||
doLandscapeLayout(width, height);
|
||||
}
|
||||
else if (header != null) {
|
||||
} else if (width > height) { //handle landscape layout special
|
||||
doLandscapeLayout(width, height);
|
||||
} else if (header != null) {
|
||||
header.setBounds(0, 0, width, header.getPreferredHeight());
|
||||
doLayout(header.getHeight(), width, height);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
doLayout(0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import forge.deck.DeckSection;
|
||||
import forge.deck.DeckType;
|
||||
import forge.deck.FDeckChooser;
|
||||
|
||||
import forge.net.server.FServerManager;
|
||||
import forge.util.Localizer;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -530,6 +531,8 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
||||
|
||||
GuiBase.setNetworkplay(allowNetworking);
|
||||
|
||||
setStartButtonAvailability();
|
||||
|
||||
for (int i = 0; i < cbPlayerCount.getSelectedItem(); i++) {
|
||||
final boolean hasPanel = i < playerPanels.size();
|
||||
if (i < playerCount) {
|
||||
@@ -731,4 +734,11 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
||||
public FScrollPane getPlayersScroll() {
|
||||
return playersScroll;
|
||||
}
|
||||
|
||||
public void setStartButtonAvailability() {
|
||||
if (lobby.isAllowNetworking() && FServerManager.getInstance() != null)
|
||||
btnStart.setVisible(FServerManager.getInstance().isHosting());
|
||||
else
|
||||
btnStart.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,15 +125,12 @@ public class MatchController extends AbstractGuiGame {
|
||||
|
||||
@Override
|
||||
public void refreshField() {
|
||||
if(!GuiBase.isNetworkplay()) //TODO alternate method for update Netplay...
|
||||
return;
|
||||
if(getGameView() == null)
|
||||
if(!GuiBase.isNetworkplay())
|
||||
return;
|
||||
if(getGameView().getPhase() == null)
|
||||
return;
|
||||
if (getGameView().getPhase().phaseforUpdateField())
|
||||
for (final VPlayerPanel pnl : view.getPlayerPanels().values())
|
||||
pnl.getField().update(false);
|
||||
refreshCardDetails(null);
|
||||
}
|
||||
|
||||
public boolean hotSeatMode() {
|
||||
|
||||
@@ -565,6 +565,7 @@ public class MatchScreen extends FScreen {
|
||||
float x = 0;
|
||||
float y;
|
||||
float w = getWidth();
|
||||
Color color = Color.CYAN;
|
||||
|
||||
//field separator lines
|
||||
if (!Forge.isLandscapeMode()) {
|
||||
@@ -591,17 +592,43 @@ public class MatchScreen extends FScreen {
|
||||
|
||||
//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())
|
||||
|
||||
if(playerPanel.getPlayer().getHasPriority())
|
||||
g.setAlphaComposite(0.8f);
|
||||
else
|
||||
g.setAlphaComposite(0f);
|
||||
g.drawRect(4f, Color.CYAN, playerPanel.getField().getLeft(), adjustY, playerPanel.getField().getWidth(), adjustH);
|
||||
|
||||
if(MatchController.instance.getGameView()!= null) {
|
||||
if(MatchController.instance.getGameView().getPhase()!=null)
|
||||
{
|
||||
if(MatchController.instance.getGameView().getPhase().isCombatPhase()){
|
||||
if(playerPanel.getPlayer() == MatchController.instance.getCurrentPlayer())
|
||||
g.setAlphaComposite(0.8f);
|
||||
else
|
||||
g.setAlphaComposite(0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(MatchController.instance.getGameView().getCombat() != null) {
|
||||
if(playerPanel.getPlayer() == MatchController.instance.getGameView().getPlayerTurn())
|
||||
color = Color.RED;
|
||||
else
|
||||
color = Color.LIME;
|
||||
}
|
||||
else
|
||||
color = Color.CYAN;
|
||||
}
|
||||
|
||||
g.drawRect(4f, color, playerPanel.getField().getLeft(), adjustY, playerPanel.getField().getWidth(), adjustH);
|
||||
g.setAlphaComposite(oldAlphaComposite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Graphics;
|
||||
import forge.GuiBase;
|
||||
import forge.card.CardZoom;
|
||||
import forge.card.CardRenderer.CardStackPosition;
|
||||
import forge.card.CardZoom.ActivateHandler;
|
||||
@@ -184,7 +185,10 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
|
||||
|
||||
@Override
|
||||
public String getActivateAction(int index) {
|
||||
return MatchController.instance.getGameController().getActivateDescription(orderedCards.get(index));
|
||||
if(!GuiBase.isNetworkplay()) //causes lag on netplay client side
|
||||
return MatchController.instance.getGameController().getActivateDescription(orderedCards.get(index));
|
||||
|
||||
return "Activate | Cast | Play (if allowed)"; //simple text on card zoom swipe up
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,7 +66,11 @@ public class VZoneDisplay extends VCardDisplayArea {
|
||||
}
|
||||
|
||||
private void setRevealedPanel(int idx) {
|
||||
revealedPanel = cardPanels.get(idx);
|
||||
try {
|
||||
revealedPanel = cardPanels.get(idx); //??? on network match, triggered by card ability
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
return;
|
||||
}
|
||||
clearChildren();
|
||||
if (Forge.isLandscapeMode()) {
|
||||
//for landscape mode, just show revealed card on top
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package forge.screens.online;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.interfaces.ILobbyView;
|
||||
import forge.match.GameLobby;
|
||||
@@ -11,6 +13,7 @@ import forge.net.IOnlineLobby;
|
||||
import forge.net.NetConnectUtil;
|
||||
import forge.net.OfflineLobby;
|
||||
import forge.net.client.FGameClient;
|
||||
import forge.net.server.FServerManager;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.screens.LoadingOverlay;
|
||||
import forge.screens.constructed.LobbyScreen;
|
||||
@@ -47,6 +50,7 @@ public class OnlineLobbyScreen extends LobbyScreen implements IOnlineLobby {
|
||||
fGameClient = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConn(String msg) {
|
||||
clearGameLobby();
|
||||
Forge.back();
|
||||
@@ -54,7 +58,15 @@ public class OnlineLobbyScreen extends LobbyScreen implements IOnlineLobby {
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SOptionPane.showMessageDialog(msg, "Error", FSkinProp.ICO_WARNING);
|
||||
final boolean callBackAlwaysTrue = SOptionPane.showOptionDialog(msg, "Error", FSkinProp.ICO_WARNING, ImmutableList.of("Ok"), 1) == 0;
|
||||
if (callBackAlwaysTrue) { //to activate online menu popup when player press play online
|
||||
GuiBase.setInterrupted(false);
|
||||
|
||||
if(FServerManager.getInstance() != null)
|
||||
FServerManager.getInstance().stopServer();
|
||||
if(getfGameClient() != null)
|
||||
closeClient();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -73,6 +85,10 @@ public class OnlineLobbyScreen extends LobbyScreen implements IOnlineLobby {
|
||||
|
||||
@Override
|
||||
public void onActivate() {
|
||||
if (GuiBase.isInterrupted()) {
|
||||
GuiBase.setInterrupted(false);
|
||||
return;
|
||||
}
|
||||
if (getGameLobby() == null) {
|
||||
setGameLobby(getLobby());
|
||||
//prompt to connect to server when offline lobby activated
|
||||
|
||||
Reference in New Issue
Block a user