Skip to content
Snippets Groups Projects
Commit 39b99220 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

Merge branch 'fix-3.0.1-fonts' into 'fix-3.0.1'

#274 Fixed problem, when fonts were not loaded on time. Causing application to crash...



See merge request !291
parents d5c0e3a9 9441eb20
Branches
Tags
No related merge requests found
...@@ -132,11 +132,13 @@ public class Tablexia extends TablexiaApplication { ...@@ -132,11 +132,13 @@ public class Tablexia extends TablexiaApplication {
} }
private void startLoading(Locale locale) { private void startLoading(Locale locale) {
// Prepare fonts (Fonts need to be loaded before any screen is active)
ApplicationFontManager.getInstance().load();
// sync loaded screen with loader image // sync loaded screen with loader image
setScreen(Utility.getScreenForScreenClass(TablexiaSettings.LOADER_SCREEN, null)); setScreen(Utility.getScreenForScreenClass(TablexiaSettings.LOADER_SCREEN, null));
// async internal assets loading // async internal assets loading
ApplicationFontManager.getInstance().load();
ApplicationTextManager.getInstance().load(locale); ApplicationTextManager.getInstance().load(locale);
ApplicationInternalSoundManager.getInstance().load(); ApplicationInternalSoundManager.getInstance().load();
ApplicationInternalTextureManager.getInstance().load(); ApplicationInternalTextureManager.getInstance().load();
......
...@@ -2,6 +2,7 @@ package cz.nic.tablexia.loader; ...@@ -2,6 +2,7 @@ package cz.nic.tablexia.loader;
public interface IApplicationLoader { public interface IApplicationLoader {
public boolean update(); boolean update();
void dispose();
} }
package cz.nic.tablexia.loader.application; package cz.nic.tablexia.loader.application;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.g2d.DistanceFieldFont; import com.badlogic.gdx.graphics.g2d.DistanceFieldFont;
import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShaderProgram;
...@@ -13,7 +12,8 @@ import cz.nic.tablexia.loader.IApplicationLoader; ...@@ -13,7 +12,8 @@ import cz.nic.tablexia.loader.IApplicationLoader;
* @author Matyáš Latner * @author Matyáš Latner
* *
*/ */
public class ApplicationFontManager extends AssetManager implements IApplicationLoader { public class ApplicationFontManager implements IApplicationLoader {
public enum FontType_NEW { public enum FontType_NEW {
REGULAR_10 (10, false), REGULAR_10 (10, false),
REGULAR_12 (12, false), REGULAR_12 (12, false),
...@@ -97,14 +97,16 @@ public class ApplicationFontManager extends AssetManager implements IApplication ...@@ -97,14 +97,16 @@ public class ApplicationFontManager extends AssetManager implements IApplication
} }
return instance; return instance;
} }
@Override public ShaderProgram getDistanceFieldShader() {
public synchronized void dispose() { return distanceFieldShader;
super.dispose();
instance = null;
} }
private void loadSDFFont() { public DistanceFieldFont getDistanceFieldFont(FontType_NEW fontType) {
return fontType.isBold() ? robotoBoldFont : robotoRegularFont;
}
public void load() {
robotoRegularFont = new DistanceFieldFont(Gdx.files.internal(ROBOTO_REGULAR_FONT_FILE), false); robotoRegularFont = new DistanceFieldFont(Gdx.files.internal(ROBOTO_REGULAR_FONT_FILE), false);
robotoRegularFont.setUseIntegerPositions(false); robotoRegularFont.setUseIntegerPositions(false);
robotoRegularFont.setDistanceFieldSmoothing(ApplicationFontManager.DISTANCE_FIELD_FONT_SIZE); robotoRegularFont.setDistanceFieldSmoothing(ApplicationFontManager.DISTANCE_FIELD_FONT_SIZE);
...@@ -120,15 +122,16 @@ public class ApplicationFontManager extends AssetManager implements IApplication ...@@ -120,15 +122,16 @@ public class ApplicationFontManager extends AssetManager implements IApplication
// distanceFieldShader.pedantic = false; // distanceFieldShader.pedantic = false;
} }
public ShaderProgram getDistanceFieldShader() {
return distanceFieldShader;
}
public DistanceFieldFont getDistanceFieldFont(FontType_NEW fontType) { //////////////////////////// IApplicationLoader
return fontType.isBold() ? robotoBoldFont : robotoRegularFont;
@Override
public boolean update() {
return true;
} }
public void load() { @Override
loadSDFFont(); public synchronized void dispose() {
instance = null;
} }
} }
\ No newline at end of file
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