Commit 7f13c133 authored by Drahomír Karchňák's avatar Drahomír Karchňák

#86 Tweaked new loading bar. Added shadow under loading bar and moved loading...

#86 Tweaked new loading bar. Added shadow under loading bar and moved loading status text. Also edited few glyphs in new fonts...
parent f8a03d54
......@@ -51,7 +51,7 @@ char id=74 x=438 y=262 width=32 height=39 xoffset=-8 yoffset=-1 xad
char id=75 x=470 y=262 width=36 height=39 xoffset=-8 yoffset=-1 xadvance=20 page=0 chnl=0
char id=76 x=0 y=302 width=31 height=39 xoffset=-8 yoffset=-1 xadvance=17 page=0 chnl=0
char id=77 x=31 y=302 width=40 height=39 xoffset=-8 yoffset=-1 xadvance=28 page=0 chnl=0
char id=78 x=71 y=302 width=35 height=39 xoffset=-8 yoffset=-1 xadvance=23 page=0 chnl=0
char id=78 x=71 y=302 width=35 height=39 xoffset=-8 yoffset=-1 xadvance=22 page=0 chnl=0
char id=79 x=106 y=302 width=36 height=39 xoffset=-8 yoffset=-1 xadvance=22 page=0 chnl=0
char id=80 x=142 y=302 width=34 height=39 xoffset=-8 yoffset=-1 xadvance=21 page=0 chnl=0
char id=81 x=102 y=138 width=36 height=43 xoffset=-8 yoffset=-1 xadvance=22 page=0 chnl=0
......@@ -175,7 +175,7 @@ char id=249 x=313 y=222 width=32 height=40 xoffset=-7 yoffset=-2 xad
char id=250 x=345 y=222 width=32 height=40 xoffset=-8 yoffset=-2 xadvance=18 page=0 chnl=0
char id=251 x=377 y=222 width=32 height=40 xoffset=-8 yoffset=-2 xadvance=18 page=0 chnl=0
char id=252 x=394 y=380 width=32 height=39 xoffset=-8 yoffset=-1 xadvance=18 page=0 chnl=0
char id=253 x=211 y=0 width=32 height=47 xoffset=-8 yoffset=-2 xadvance=16 page=0 chnl=0
char id=253 x=211 y=0 width=32 height=47 xoffset=-8 yoffset=-2 xadvance=17 page=0 chnl=0
char id=254 x=243 y=0 width=32 height=47 xoffset=-8 yoffset=-2 xadvance=18 page=0 chnl=0
char id=255 x=425 y=0 width=32 height=46 xoffset=-8 yoffset=-1 xadvance=16 page=0 chnl=0
char id=268 x=346 y=93 width=35 height=45 xoffset=-8 yoffset=-7 xadvance=21 page=0 chnl=0
......@@ -183,7 +183,7 @@ char id=269 x=71 y=262 width=31 height=40 xoffset=-8 yoffset=-2 xad
char id=270 x=278 y=93 width=34 height=45 xoffset=-8 yoffset=-7 xadvance=21 page=0 chnl=0
char id=271 x=0 y=262 width=40 height=40 xoffset=-8 yoffset=-2 xadvance=20 page=0 chnl=0
char id=282 x=141 y=93 width=32 height=45 xoffset=-8 yoffset=-7 xadvance=18 page=0 chnl=0
char id=283 x=409 y=222 width=33 height=40 xoffset=-8 yoffset=-2 xadvance=17 page=0 chnl=0
char id=283 x=409 y=222 width=33 height=40 xoffset=-9 yoffset=-2 xadvance=18 page=0 chnl=0
char id=317 x=426 y=380 width=31 height=39 xoffset=-8 yoffset=-1 xadvance=17 page=0 chnl=0
char id=318 x=134 y=262 width=29 height=40 xoffset=-8 yoffset=-2 xadvance=11 page=0 chnl=0
char id=327 x=381 y=93 width=35 height=45 xoffset=-8 yoffset=-7 xadvance=23 page=0 chnl=0
......
......@@ -81,7 +81,7 @@ char id=104 x=448 y=140 width=30 height=40 xoffset=-7 yoffset=-2 xad
char id=105 x=478 y=140 width=20 height=40 xoffset=-7 yoffset=-2 xadvance=8 page=0 chnl=0
char id=106 x=50 y=0 width=24 height=47 xoffset=-10 yoffset=-2 xadvance=8 page=0 chnl=0
char id=107 x=0 y=185 width=31 height=40 xoffset=-8 yoffset=-2 xadvance=16 page=0 chnl=0
char id=108 x=31 y=185 width=20 height=40 xoffset=-7 yoffset=-2 xadvance=7 page=0 chnl=0
char id=108 x=31 y=185 width=20 height=40 xoffset=-7 yoffset=-2 xadvance=8 page=0 chnl=0
char id=109 x=0 y=421 width=40 height=33 xoffset=-8 yoffset=5 xadvance=28 page=0 chnl=0
char id=110 x=40 y=421 width=30 height=33 xoffset=-7 yoffset=5 xadvance=18 page=0 chnl=0
char id=111 x=70 y=421 width=32 height=33 xoffset=-9 yoffset=5 xadvance=18 page=0 chnl=0
......@@ -147,7 +147,7 @@ char id=221 x=218 y=49 width=35 height=46 xoffset=-8 yoffset=-8 xad
char id=222 x=161 y=343 width=32 height=39 xoffset=-8 yoffset=-1 xadvance=19 page=0 chnl=0
char id=223 x=144 y=185 width=32 height=40 xoffset=-8 yoffset=-2 xadvance=19 page=0 chnl=0
char id=224 x=176 y=185 width=31 height=40 xoffset=-8 yoffset=-2 xadvance=17 page=0 chnl=0
char id=225 x=207 y=185 width=31 height=40 xoffset=-8 yoffset=-2 xadvance=17 page=0 chnl=0
char id=225 x=207 y=185 width=31 height=40 xoffset=-9 yoffset=-2 xadvance=17 page=0 chnl=0
char id=226 x=193 y=343 width=31 height=39 xoffset=-8 yoffset=-1 xadvance=17 page=0 chnl=0
char id=227 x=224 y=343 width=31 height=39 xoffset=-8 yoffset=-1 xadvance=17 page=0 chnl=0
char id=228 x=255 y=343 width=31 height=39 xoffset=-8 yoffset=-1 xadvance=17 page=0 chnl=0
......@@ -164,7 +164,7 @@ char id=238 x=348 y=343 width=28 height=39 xoffset=-8 yoffset=-1 xad
char id=239 x=376 y=343 width=28 height=39 xoffset=-8 yoffset=-1 xadvance=8 page=0 chnl=0
char id=240 x=380 y=185 width=31 height=40 xoffset=-8 yoffset=-2 xadvance=19 page=0 chnl=0
char id=241 x=404 y=343 width=30 height=39 xoffset=-8 yoffset=-1 xadvance=18 page=0 chnl=0
char id=242 x=411 y=185 width=32 height=40 xoffset=-8 yoffset=-2 xadvance=18 page=0 chnl=0
char id=242 x=411 y=185 width=32 height=40 xoffset=-8 yoffset=-2 xadvance=18 page=0 chnl=0
char id=243 x=443 y=185 width=32 height=40 xoffset=-8 yoffset=-2 xadvance=18 page=0 chnl=0
char id=244 x=434 y=343 width=32 height=39 xoffset=-8 yoffset=-1 xadvance=18 page=0 chnl=0
char id=245 x=466 y=343 width=32 height=39 xoffset=-8 yoffset=-1 xadvance=18 page=0 chnl=0
......@@ -187,7 +187,7 @@ char id=283 x=92 y=382 width=31 height=39 xoffset=-8 yoffset=-1 xad
char id=317 x=271 y=382 width=31 height=39 xoffset=-8 yoffset=-1 xadvance=17 page=0 chnl=0
char id=318 x=66 y=225 width=25 height=40 xoffset=-8 yoffset=-2 xadvance=10 page=0 chnl=0
char id=327 x=0 y=140 width=35 height=45 xoffset=-8 yoffset=-7 xadvance=23 page=0 chnl=0
char id=328 x=241 y=382 width=30 height=39 xoffset=-8 yoffset=-1 xadvance=18 page=0 chnl=0
char id=328 x=241 y=382 width=30 height=39 xoffset=-8 yoffset=-1 xadvance=16 page=0 chnl=0
char id=344 x=295 y=95 width=34 height=45 xoffset=-8 yoffset=-7 xadvance=20 page=0 chnl=0
char id=345 x=123 y=382 width=26 height=39 xoffset=-8 yoffset=-1 xadvance=11 page=0 chnl=0
char id=352 x=364 y=95 width=33 height=45 xoffset=-8 yoffset=-7 xadvance=19 page=0 chnl=0
......
......@@ -13,6 +13,12 @@ system_retry=Znovu
zipassetloader_error=Chyba: Nemohu stáhnout dodatečná data! Zkontrolujte prosím připojení k internetu.
zipassetloader_download_request: Právě využíváte mobilní připojení k internetu. Tablexia potřebuje stáhnout ~150 MB herních dat. Přejete si je stáhnout nyní ?
# <!-- Loading status texts -->
loading_status_check=Kontrolují se soubory hry…
loading_status_download=Stahuji soubory hry…
loading_status_assets=Kopírují se soubory…
loading_status_sync=Synchronizují se data…
mainmenu_games=Hry
mainmenu_halloffame=Síň slávy
mainmenu_statistics=Statistiky
......
......@@ -13,6 +13,13 @@ system_retry=Wieder
zipassetloader_error=Fehler: Nicht, um zusätzliche Daten Download! Bitte überprüfen Sie Ihre Internetverbindung.
zipassetloader_download_request: [DE - Upravit v application_de.properities] Právě využíváte mobilní připojení k internetu. Tablexia potřebuje stáhnout ~150 MB herních dat. Přejete si je stáhnout nyní ?
# <!-- Loading status texts -->
loading_status_check=Spiel-Dateien werden überprüft…
loading_status_download=Spiel-Dateien werden runtergeladen…
loading_status_assets=Dateien werden kopiert…
loading_status_sync=Daten werden synchronisiert…
mainmenu_games=Spiele
mainmenu_halloffame=Ruhmeshalle
mainmenu_statistics=Statistiken
......
......@@ -13,7 +13,11 @@ system_retry=Znovu
zipassetloader_error=Chyba: Nemôžem stiahnuť dodatočná dáta! Skontrolujte prosím pripojenie k internetu.
zipassetloader_download_request: [SK upravit v application_sk.properties] Právě využíváte mobilní připojení k internetu. Tablexia potřebuje stáhnout ~150 MB herních dat. Přejete si je stáhnout nyní ?
user_logout_message=Naozaj chceš odhlásiť súčasného užívateľa?
# <!-- Loading status texts -->
loading_status_check=Kontrolujú sa súbory…
loading_status_download=Sťahujem súbory z hry…
loading_status_assets=Kopírujú sa súbory…
loading_status_sync=Synchronizujú sa data…
mainmenu_games=Hry
mainmenu_halloffame=Sieň slávy
......@@ -30,6 +34,10 @@ usermenu_newuser=+ Nový detektív
usermenu_deleteuser=Naozaj chceš zmazať užívateľa
usermenu_dialog_yes=Áno
usermenu_dialog_no=Nie
user_logout_message=Naozaj chceš odhlásiť súčasného užívateľa?
preloader_title=Ako hrať?
confirm_button=Rozumiem
......
......@@ -21,6 +21,7 @@ public class ApplicationFontManager extends AssetManager implements IApplication
REGULAR_16 (16, false),
REGULAR_18 (18, false),
REGULAR_20 (20, false),
REGULAR_24 (24, false),
REGULAR_26 (26, false),
REGULAR_30 (30, false),
REGULAR_35 (35, false),
......@@ -35,6 +36,7 @@ public class ApplicationFontManager extends AssetManager implements IApplication
BOLD_16 (16, true),
BOLD_18 (18, true),
BOLD_20 (20, true),
BOLD_24 (24, true),
BOLD_26 (26, true),
BOLD_30 (30, true),
BOLD_35 (35, true),
......
......@@ -16,11 +16,17 @@ public class LoaderAssets {
public static final String LOADER_BIG_HAND = BASE_PATH + "screen_loader_bighand.png";
public static final String LOADER_LAUNCH_LOGO = BASE_PATH + "launch";
public static final String LOADER_TEXTS = BASE_PATH + "lines";
public static final String LOADER_LOGIN_TEXT = BASE_PATH + "login";
public static final String LOADER_BAR_BACKGROUND = BASE_PATH + "bar_bg.png";
public static final String LOADER_BAR_FOREGROUND = BASE_PATH + "bar_fg.png";
public static final String LOADER_BAR_SHADOW = BASE_PATH + "bar_shadow.png";
public static final int LOADER_BAR_SHADOW_LEFT_RIGHT = 40;
public static final int LOADER_BAR_SHADOW_TOP_BOTTOM = 2;
public static final String LOADER_STATUS_CHECK = "loading_status_check";
public static final String LOADER_STATUS_DOWNLOAD = "loading_status_download";
public static final String LOADER_STATUS_ASSETS = "loading_status_assets";
public static final String LOADER_STATUS_SYNC = "loading_status_sync";
}
......@@ -3,6 +3,7 @@ package cz.nic.tablexia.screen.loader;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.ParallelAction;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
......@@ -38,15 +39,15 @@ public class LoaderScreen extends AbstractTablexiaScreen<Void> {
private static final float LAUNCH_LOGO_Y_TOP_OFFSET = 0.10f;
//Loading Bar
private static final float LOADING_BAR_WIDTH = 0.40f;
private static final float LOADING_BAR_WIDTH = 0.52f;
private static final float LOADING_BAR_OFFSET_Y = 0.16f;
private static final float LOADING_STATUS_TEXT_WIDTH = 0.40f;
private static final float LOADING_BAR_FADE_IN_TIME = 0.5f;
private static final float LOADING_BAR_FADE_OUT_TIME = 0.5f;
private static final float LOADING_BAR_FADE_OUT_TIME = 0.5f;
//Loading Status Text
private static final float STATUS_TEXT_FADE_IN_TIME = 0.5f;
private static final float STATUS_TEXT_FADE_OUT_TIME = 0.5f;
private static final float STATUS_TEXT_FADE_OUT_TIME = 0.5f;
private static final float LOADING_STATUS_TOP_OFFSET = 2f;
//Please Login Text
private static final float LOGIN_TEXT_WIDTH = 0.43f;
......@@ -196,11 +197,11 @@ public class LoaderScreen extends AbstractTablexiaScreen<Void> {
//Localized textures
textureManager.loadTexture(LoaderAssets.LOADER_LAUNCH_LOGO + "_" + currentLanguage + ".png");
textureManager.loadTexture(LoaderAssets.LOADER_TEXTS + "_" + currentLanguage + ".png");
textureManager.loadTexture(LoaderAssets.LOADER_LOGIN_TEXT + "_" + currentLanguage + ".png");
textureManager.loadTexture(LoaderAssets.LOADER_BAR_BACKGROUND);
textureManager.loadTexture(LoaderAssets.LOADER_BAR_FOREGROUND);
textureManager.loadTexture(LoaderAssets.LOADER_BAR_SHADOW);
textureManager.finishLoading();
}
......@@ -209,11 +210,11 @@ public class LoaderScreen extends AbstractTablexiaScreen<Void> {
texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
loginText = new Image(texture);
loginText.setSize(getSceneWidth() * LOGIN_TEXT_WIDTH, (getSceneWidth() * LOGIN_TEXT_WIDTH) * (texture.getHeight() / (float)texture.getWidth()));
loginText.setSize(getSceneWidth() * LOGIN_TEXT_WIDTH, (getSceneWidth() * LOGIN_TEXT_WIDTH) * (texture.getHeight() / (float) texture.getWidth()));
loginText.setPosition(getSceneWidth() / 2 - loginText.getWidth() / 2,
getSceneInnerBottomY() + getSceneInnerHeight() / 2 - loginText.getHeight() / 2
);
getSceneInnerBottomY() + getSceneInnerHeight() / 2 - loginText.getHeight() / 2
);
loginText.addAction(Actions.alpha(0));
getStage().addActor(loginText);
......@@ -225,17 +226,17 @@ public class LoaderScreen extends AbstractTablexiaScreen<Void> {
*/
private void showLoginText() {
loginText.addAction(
new SequenceAction(Actions.delay(LOGIN_TEXT_SHOW_DELAY),
new ParallelAction(
Actions.fadeIn(LOGIN_TEXT_FADE_IN_TIME),
Actions.run(new Runnable() {
@Override
public void run() {
Music music = getMusic(LOGIN_SPEECH);
if (music != null) music.play();
}
})
))
new SequenceAction(Actions.delay(LOGIN_TEXT_SHOW_DELAY),
new ParallelAction(
Actions.fadeIn(LOGIN_TEXT_FADE_IN_TIME),
Actions.run(new Runnable() {
@Override
public void run() {
Music music = getMusic(LOGIN_SPEECH);
if (music != null) music.play();
}
})
))
);
}
......@@ -304,7 +305,14 @@ public class LoaderScreen extends AbstractTablexiaScreen<Void> {
//Skin for LoadingBar
LoadingBar.LoadingBarSkin skin = new LoadingBar.LoadingBarSkin(
textureManager.getTexture(LoaderAssets.LOADER_BAR_FOREGROUND),
textureManager.getTexture(LoaderAssets.LOADER_BAR_BACKGROUND)
textureManager.getTexture(LoaderAssets.LOADER_BAR_BACKGROUND),
new NinePatch(
textureManager.getTexture(LoaderAssets.LOADER_BAR_SHADOW),
LoaderAssets.LOADER_BAR_SHADOW_LEFT_RIGHT,
LoaderAssets.LOADER_BAR_SHADOW_LEFT_RIGHT,
LoaderAssets.LOADER_BAR_SHADOW_TOP_BOTTOM,
LoaderAssets.LOADER_BAR_SHADOW_TOP_BOTTOM
)
);
//Creates loading bar
......@@ -321,15 +329,13 @@ public class LoaderScreen extends AbstractTablexiaScreen<Void> {
}
public void prepareLoadingStatusText() {
Texture tex = textureManager.getTexture(LoaderAssets.LOADER_TEXTS + "_" + currentLanguage + ".png");
tex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
loadingStatusText = new LoadingStatusText(tex);
float width = LOADING_STATUS_TEXT_WIDTH * getSceneWidth();
float height = width * (loadingStatusText.getSourceLineHeight() / tex.getWidth());
loadingStatusText.setSize(width, height);
loadingStatusText.setPosition(getSceneWidth() / 2 - loadingStatusText.getWidth() / 2, loadingBar.getY() + loadingBar.getHeight() + 10);
loadingStatusText.setVisible(false);
loadingStatusText = new LoadingStatusText();
loadingStatusText.setBounds(
loadingBar.getX(),
loadingBar.getY() - LOADING_STATUS_TOP_OFFSET,
loadingBar.getWidth(),
loadingBar.getHeight()
);
getStage().addActor(loadingStatusText);
}
......@@ -348,16 +354,17 @@ public class LoaderScreen extends AbstractTablexiaScreen<Void> {
}
private void showStatusText(float time) {
if(!loadingStatusText.isVisible()) {
loadingStatusText.addAction(Actions.alpha(0));
loadingStatusText.setVisible(true);
loadingStatusText.addAction(Actions.fadeIn(time));
}
}
if(loadingStatusText.isVisible())
return;
loadingStatusText.setVisible(true);
loadingStatusText.addAction(Actions.fadeIn(time));
}
private void hideStatusText(float time) {
if(loadingStatusText.isVisible()) {
loadingStatusText.addAction(new SequenceAction(Actions.fadeOut(time), Actions.visible(false)));
}
}
if(!loadingStatusText.isVisible())
return;
loadingStatusText.addAction(new SequenceAction(Actions.fadeOut(time), Actions.visible(false)));
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package cz.nic.tablexia.screen.loader;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Actor;
......@@ -17,14 +18,16 @@ public class LoadingBar extends Actor {
*/
public static class LoadingBarSkin {
private Texture foregroundImage, backgroundImage;
private NinePatch shadow;
public LoadingBarSkin(Texture foregroundImage, Texture backgroundImage) {
public LoadingBarSkin(Texture foregroundImage, Texture backgroundImage, NinePatch shadow) {
super();
this.foregroundImage = foregroundImage;
this.backgroundImage = backgroundImage;
this.foregroundImage.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
this.backgroundImage.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
this.shadow = shadow;
}
public Texture getForegroundImage() {
......@@ -34,16 +37,25 @@ public class LoadingBar extends Actor {
public Texture getBackgroundImage() {
return backgroundImage;
}
}
private static final float IDLE_BAR_WIDTH = 0.1f;
private static final float IDLE_BAR_SPEED = .75f;
public NinePatch getShadow() {
return shadow;
}
}
public enum LoadingBarActivity {
PROGRESS, // Is showing progress
IDLE, // IDLE/Infinite state
}
private static final float SHADOW_RIGHT_PADDING = 0.0f;
private static final float SHADOW_LEFT_PADDING = 0.05f;
private static final float SHADOW_TOP_PADDING = 0.05f;
private static final float SHADOW_BOTTOM_PADDING = 0.05f;
private static final float IDLE_BAR_WIDTH = 0.1f;
private static final float IDLE_BAR_SPEED = .75f;
//max and current value
private float current;
......@@ -99,14 +111,25 @@ public class LoadingBar extends Actor {
batch.enableBlending();
/*
* Draw Shadow Layer
*/
skin.shadow.draw(
batch,
getX() - SHADOW_LEFT_PADDING * getWidth(),
getY() - SHADOW_BOTTOM_PADDING * getHeight(),
getWidth() + (SHADOW_LEFT_PADDING + SHADOW_RIGHT_PADDING) * getWidth(),
getHeight() + (SHADOW_BOTTOM_PADDING + SHADOW_TOP_PADDING) * getHeight()
);
/*
* Draw Background Layer
*/
float borderX = (skin.foregroundImage.getWidth() - skin.backgroundImage.getWidth()) / 2;
float borderY = (skin.foregroundImage.getHeight() - skin.backgroundImage.getHeight()) / 2;
float relativeBorderX = borderX / skin.getForegroundImage().getWidth();
float relativeBorderY = borderY / skin.getForegroundImage().getHeight();
float relativeBorderX = borderX / skin.foregroundImage.getWidth();
float relativeBorderY = borderY / skin.foregroundImage.getHeight();
float offsetX = relativeBorderX * getWidth();
float offsetY = relativeBorderY * getHeight();
......
package cz.nic.tablexia.screen.loader;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
import com.badlogic.gdx.utils.Align;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.util.ui.TablexiaLabel;
/**
* Created by Drahomir Karchnak on 10/12/15.
*/
public class LoadingStatusText extends Actor{
/**
* Defines all the possible lines
* and their line index in the texture
*/
public class LoadingStatusText extends TablexiaLabel {
/**
* Defines all the possible lines
*/
public enum StatusText {
NONE(-1),
ASSETS_CHECK(0),
ASSETS_CHECK_OK(1),
DOWNLOADING_ASSETS(2),
EXTRACTING_ASSETS(3);
NONE(""),
ASSETS_CHECK(LoaderAssets.LOADER_STATUS_CHECK),
DOWNLOADING_ASSETS(LoaderAssets.LOADER_STATUS_DOWNLOAD),
EXTRACTING_ASSETS(LoaderAssets.LOADER_STATUS_ASSETS),
SYNCHRONIZING(LoaderAssets.LOADER_STATUS_SYNC);
private int lineIndex;
private String textKey;
StatusText(int lineIndex) {
this.lineIndex = lineIndex;
StatusText(String textKey) {
this.textKey = textKey;
}
public int getLineIndex() {
return lineIndex;
public String getTextKey() {
return textKey;
}
}
//Texture with al the lines and current line
private Texture linesTexture;
private StatusText statusText = StatusText.NONE;
private static final ApplicationFontManager.FontType_NEW STATUS_TEXT_FONT_TYPE = ApplicationFontManager.FontType_NEW.REGULAR_24;
private static final Color STATUS_TEXT_FONT_COLOR = Color.WHITE;
public LoadingStatusText(Texture linesTexture) {
this.linesTexture = linesTexture;
setSize(linesTexture.getWidth(), getSourceLineHeight());
public LoadingStatusText() {
super("", new TablexiaLabelStyle(STATUS_TEXT_FONT_TYPE, STATUS_TEXT_FONT_COLOR));
setAlignment(Align.center);
}
public void setStatusText(StatusText text) {
statusText = text;
if(text == StatusText.NONE)
setText("");
else {
setText(ApplicationTextManager.getInstance().getText(text.getTextKey()));
}
}
/**
* Changes current status text with fade in/out animation
* @param text
* @param time
*/
/**
* Changes current status text with fade in/out animation
* @param text
* @param time
*/
public void changeText(final StatusText text, float time) {
addAction(new SequenceAction(
Actions.fadeOut(time/2),
Actions.fadeOut(time / 2),
Actions.run(new Runnable() {
@Override
public void run() {
setStatusText(text);
}
}),
Actions.fadeIn(time/2)));
}
/**
* Calculates height of a single line in the texture
* @return
*/
public float getSourceLineHeight() {
return linesTexture.getHeight() / (float) (StatusText.values().length - 1);
}
@Override
public void draw(Batch batch, float parentAlpha) {
if(statusText != StatusText.NONE) {
float lineHeight = getSourceLineHeight();
batch.setColor(this.getColor().r, this.getColor().g, this.getColor().b, this.getColor().a * parentAlpha);
batch.enableBlending();
batch.draw(linesTexture,
getX(),
getY(),
getWidth(),
getHeight(),
0,
(int) (statusText.getLineIndex() * lineHeight),
linesTexture.getWidth(),
(int) (lineHeight),
false,
false);
}
super.draw(batch, parentAlpha);
Actions.fadeIn(time / 2)));
}
}
}
\ No newline at end of file
Markdown is supported
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