From 70283ae34d16eb1a952f14820524c2f3e60294af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Thu, 22 May 2014 09:08:16 +0200 Subject: [PATCH] Fixed crash with font loading too early in fullscreen on start --- src/mightypork/gamecore/gui/screens/ScreenRegistry.java | 6 +++++- src/mightypork/gamecore/resources/BaseLazyResource.java | 8 ++++++-- src/mightypork/gamecore/resources/fonts/GLFont.java | 1 + .../gamecore/resources/fonts/impl/TextureBackedFont.java | 1 + src/mightypork/rogue/RogueApp.java | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mightypork/gamecore/gui/screens/ScreenRegistry.java b/src/mightypork/gamecore/gui/screens/ScreenRegistry.java index 8c072a5..a95918c 100644 --- a/src/mightypork/gamecore/gui/screens/ScreenRegistry.java +++ b/src/mightypork/gamecore/gui/screens/ScreenRegistry.java @@ -6,6 +6,8 @@ import java.util.HashMap; import java.util.Map; import java.util.TreeSet; +import org.newdawn.slick.opengl.GLUtils; + import mightypork.gamecore.core.modules.AppAccess; import mightypork.gamecore.core.modules.AppModule; import mightypork.gamecore.gui.events.LayoutChangeEvent; @@ -83,6 +85,8 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener, toShow.setActive(true); active = toShow; + + fireLayoutUpdateEvent(); } @@ -110,7 +114,7 @@ public class ScreenRegistry extends AppModule implements ScreenRequestListener, @Override public void onViewportChanged(ViewportChangeEvent event) { - fireLayoutUpdateEvent(); + if(active != null) fireLayoutUpdateEvent(); } diff --git a/src/mightypork/gamecore/resources/BaseLazyResource.java b/src/mightypork/gamecore/resources/BaseLazyResource.java index 0cef349..a67f0d6 100644 --- a/src/mightypork/gamecore/resources/BaseLazyResource.java +++ b/src/mightypork/gamecore/resources/BaseLazyResource.java @@ -36,8 +36,12 @@ public abstract class BaseLazyResource implements LazyResource, Destroyable { @Override public synchronized final void load() { - if (loadFailed) return; - if (loadAttempted) return; + if (!loadFailed && loadAttempted) return; + +// +// if (loadFailed) return; +// if (loadAttempted) return; +// loadAttempted = true; loadFailed = false; diff --git a/src/mightypork/gamecore/resources/fonts/GLFont.java b/src/mightypork/gamecore/resources/fonts/GLFont.java index e5cd671..0ff64ba 100644 --- a/src/mightypork/gamecore/resources/fonts/GLFont.java +++ b/src/mightypork/gamecore/resources/fonts/GLFont.java @@ -1,6 +1,7 @@ package mightypork.gamecore.resources.fonts; +import mightypork.gamecore.resources.TextureBasedResource; import mightypork.gamecore.util.math.color.Color; import mightypork.gamecore.util.math.constraints.vect.Vect; diff --git a/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java b/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java index db53f2f..9a850c0 100644 --- a/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java +++ b/src/mightypork/gamecore/resources/fonts/impl/TextureBackedFont.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Map; import mightypork.gamecore.logging.Log; +import mightypork.gamecore.resources.TextureBasedResource; import mightypork.gamecore.resources.fonts.GLFont; import mightypork.gamecore.resources.textures.FilterMode; import mightypork.gamecore.resources.textures.LazyTexture; diff --git a/src/mightypork/rogue/RogueApp.java b/src/mightypork/rogue/RogueApp.java index 987a9d6..507d9e5 100644 --- a/src/mightypork/rogue/RogueApp.java +++ b/src/mightypork/rogue/RogueApp.java @@ -139,7 +139,7 @@ public final class RogueApp extends BaseApp implements ViewportChangeListener, S getEventBus().send(new RogueStateRequest(RogueState.MAIN_MENU, true)); } } - }, true)); + }, false)); }