Prevent card zoom crash

This commit is contained in:
drdev
2015-03-22 17:50:10 +00:00
parent 85131a511c
commit dbae03db95
6 changed files with 22 additions and 22 deletions

View File

@@ -16,9 +16,7 @@ import forge.assets.FSkinFont;
import forge.assets.ImageCache;
import forge.error.BugReporter;
import forge.error.ExceptionHandler;
import forge.game.GameView;
import forge.interfaces.IDeviceAdapter;
import forge.match.HostedMatch;
import forge.model.FModel;
import forge.properties.ForgeConstants;
import forge.properties.ForgePreferences;
@@ -26,6 +24,7 @@ import forge.properties.ForgePreferences.FPref;
import forge.screens.FScreen;
import forge.screens.SplashScreen;
import forge.screens.home.HomeScreen;
import forge.screens.match.MatchController;
import forge.sound.MusicPlaylist;
import forge.sound.SoundSystem;
import forge.toolbox.FContainer;
@@ -52,7 +51,6 @@ public class Forge implements ApplicationListener {
private static boolean exited;
private static int continuousRenderingCount = 1; //initialize to 1 since continuous rendering is the default
private static final Stack<FScreen> screens = new Stack<FScreen>();
public static HostedMatch hostedMatch;
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0) {
if (GuiBase.getInterface() == null) {
@@ -302,15 +300,15 @@ public class Forge implements ApplicationListener {
@Override
public void pause() {
if (hostedMatch != null) {
hostedMatch.pause();
if (MatchController.getHostedMatch() != null) {
MatchController.getHostedMatch().pause();
}
}
@Override
public void resume() {
if (hostedMatch != null) {
hostedMatch.resume();
if (MatchController.getHostedMatch() != null) {
MatchController.getHostedMatch().resume();
}
}
@@ -651,8 +649,4 @@ public class Forge implements ApplicationListener {
return handled;
}
}
public static GameView getGameView() {
return hostedMatch == null ? null : hostedMatch.getGameView();
}
}

View File

@@ -280,7 +280,6 @@ public class GuiMobile implements IGuiBase {
@Override
public HostedMatch hostMatch() {
return Forge.hostedMatch = new HostedMatch();
return MatchController.hostMatch();
}
}

View File

@@ -7,7 +7,6 @@ import java.util.Map.Entry;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import com.badlogic.gdx.math.Rectangle;
import forge.Forge;
import forge.Graphics;
import forge.ImageKeys;
import forge.assets.FSkinImage;
@@ -168,7 +167,7 @@ public class CardZoom extends FOverlay {
@Override
public void drawOverlay(Graphics g) {
final GameView gameView = Forge.getGameView();
final GameView gameView = MatchController.instance.getGameView();
float w = getWidth();
float h = getHeight();

View File

@@ -38,6 +38,7 @@ import forge.game.zone.ZoneType;
import forge.interfaces.IButton;
import forge.item.PaperCard;
import forge.match.AbstractGuiGame;
import forge.match.HostedMatch;
import forge.match.MatchButtonType;
import forge.model.FModel;
import forge.properties.ForgePreferences;
@@ -65,6 +66,7 @@ public class MatchController extends AbstractGuiGame {
private static final Map<String, FImage> avatarImages = new HashMap<String, FImage>();
private static HostedMatch hostedMatch;
private static MatchScreen view;
public static MatchScreen getView() {
@@ -128,7 +130,7 @@ public class MatchController extends AbstractGuiGame {
@Override
public void buildTouchListeners(float screenX, float screenY, ArrayList<FDisplayObject> listeners) {
if (screenY < view.getHeight() - VPrompt.HEIGHT) {
Forge.hostedMatch.pause();
hostedMatch.pause();
}
}
});
@@ -501,4 +503,12 @@ public class MatchController extends AbstractGuiGame {
return !view.stopAtPhase(playerTurn, phase);
}
public static HostedMatch hostMatch() {
hostedMatch = new HostedMatch();
return hostedMatch;
}
public static HostedMatch getHostedMatch() {
return hostedMatch;
}
}

View File

@@ -1,6 +1,5 @@
package forge.screens.match.views;
import forge.Forge;
import forge.assets.FSkinImage;
import forge.deck.Deck;
import forge.deck.FDeckViewer;
@@ -46,7 +45,7 @@ public class VGameMenu extends FDropDownMenu {
addItem(new FMenuItem("Deck List", FSkinImage.DECKLIST, new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
final Deck deck = Forge.hostedMatch.getGame().getPhaseHandler().getPlayerTurn().getRegisteredPlayer().getDeck();
final Deck deck = MatchController.getHostedMatch().getGame().getPhaseHandler().getPlayerTurn().getRegisteredPlayer().getDeck();
if (deck != null) {
FDeckViewer.show(deck);
}

View File

@@ -1,6 +1,5 @@
package forge.screens.match.winlose;
import forge.Forge;
import forge.game.GameView;
import forge.screens.match.MatchController;
import forge.toolbox.FEvent;
@@ -54,21 +53,21 @@ public class ControlWinLose {
view.hide();
saveOptions();
Forge.hostedMatch.continueMatch();
MatchController.getHostedMatch().continueMatch();
}
/** Action performed when "restart" button is pressed in default win/lose UI. */
public void actionOnRestart() {
view.hide();
saveOptions();
Forge.hostedMatch.restartMatch();
MatchController.getHostedMatch().restartMatch();
}
/** Action performed when "quit" button is pressed in default win/lose UI. */
public void actionOnQuit() {
// Reset other stuff
saveOptions();
Forge.hostedMatch.endCurrentGame();
MatchController.getHostedMatch().endCurrentGame();
view.hide();
}