Commit fb38a9f3 authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

Merge with V3.5

parent 67f7cb59
......@@ -20,7 +20,7 @@ game_concept=Herní koncept, Grafika
game_concept_details=Jakub Rumler
developers=Programátoři
developers_details_1=Luboš Horáček, Matyáš Latner, Václav Tarantík, František Šimon
developers_details_2=Anton Danilov, Vitaliy Vashchenko, Drahomír Karchňák, Aneta Steimarová
developers_details_2=Anton Danilov, Vitaliy Vashchenko, Drahomír Karchňák, Aneta Steimarová, Lukáš Mařík
about_info_1 =Aplikace na podporu jedinců s\u00A0dyslexií, vyvinutá Laboratořemi sdružení CZ.NIC.
illustrators=Ilustrace
illustrators_details=Aneta Biskupová
......
......@@ -20,7 +20,7 @@ game_concept=Spielkonzept, Grafik
game_concept_details=Jakub Rumler
developers=Programmierer
developers_details_1=Luboš Horáček, Matyáš Latner, Václav Tarantík, František Šimon
developers_details_2=Anton Danilov, Vitaliy Vashchenko, Drahomír Karchňák, Aneta Steimarová
developers_details_2=Anton Danilov, Vitaliy Vashchenko, Drahomír Karchňák, Aneta Steimarová, Lukáš Mařík
about_info_1=Tablexia ist eine App, die vom Labor der Vereinigung CZ.NIC. zu Trainingszwecken für Menschen mit einer Lese-und Rechtschreibschwäche entwickelt wurde.
illustrators=Bilder
illustrators_details=Aneta Biskupová
......
......@@ -20,7 +20,7 @@ game_concept=Herný koncept, Grafika
game_concept_details=Jakub Rumler
developers=Programátori
developers_details_1=Luboš Horáček, Matyáš Latner, Václav Tarantík, František Šimon
developers_details_2=Anton Danilov, Vitaliy Vashchenko, Drahomír Karchňák, Aneta Steimarová
developers_details_2=Anton Danilov, Vitaliy Vashchenko, Drahomír Karchňák, Aneta Steimarová, Lukáš Mařík
about_info_1=Aplikácia na podporu jedincov s\u00A0dyslexiou vyvinutá Laboratóriami združenia CZ.NIC.
illustrators=Ilustrácie
illustrators_details=Aneta Biskupová
......
......@@ -210,37 +210,55 @@ task prepareGraphicAssets(dependsOn: prepareAssets) {
new File("${assetsDir.absolutePath}/${assetsSourceDirName}/").eachDir() { langDir ->
langDir.eachDir() { sectionDir ->
sectionDir.eachDir() { atlasDir ->
if (assetsGameDirectory.equals(sectionDir.name) && !assetsGameGlobalDirectory.equals(atlasDir.name)) {
atlasDir.eachDir() { difficultyDir ->
if (!assetsGameExcludedDirectory.equals(difficultyDir.name)) {
String packFileName = assetsGameCommonDifficultyDirectory.equals(difficultyDir.name) ? atlasDir.name : difficultyDir.name;
TexturePacker.process(settings,
"${difficultyDir}",
"${assetsDir.absolutePath}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/",
"${packFileName}")
} else {
task("${name}_" + sectionDir.name + "_" + langDir.name + "_" + atlasDir.name + "_" + difficultyDir.name, type: Copy) {
from difficultyDir
into "${buildDir}/${assetsDirName}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/${difficultyDir.name}"
include '**/*'
includeEmptyDirs false
outputs.upToDateWhen { false }
}.execute()
//If section dir has no dirs, copy whole content
if (hasAtlasDir(sectionDir)) {
sectionDir.eachDir() { atlasDir ->
if (assetsGameDirectory.equals(sectionDir.name) && !assetsGameGlobalDirectory.equals(atlasDir.name)) {
atlasDir.eachDir() { difficultyDir ->
if (!assetsGameExcludedDirectory.equals(difficultyDir.name)) {
String packFileName = assetsGameCommonDifficultyDirectory.equals(difficultyDir.name) ? atlasDir.name : difficultyDir.name;
TexturePacker.process(settings,
"${difficultyDir}",
"${assetsDir.absolutePath}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/",
"${packFileName}")
} else {
task("${name}_" + sectionDir.name + "_" + langDir.name + "_" + atlasDir.name + "_" + difficultyDir.name, type: Copy) {
from difficultyDir
into "${buildDir}/${assetsDirName}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/${difficultyDir.name}"
include '**/*'
includeEmptyDirs false
outputs.upToDateWhen { false }
}.execute()
}
}
} else {
TexturePacker.process(settings,
"${atlasDir}",
"${assetsDir.absolutePath}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/",
"${atlasDir.name}")
}
} else {
TexturePacker.process(settings,
"${atlasDir}",
"${assetsDir.absolutePath}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/",
"${atlasDir.name}")
}
} else {
task("${name}_" + sectionDir.name + "_" + langDir.name, type: Copy) {
from sectionDir
into "${buildDir}/${assetsDirName}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}"
include '**/*'
includeEmptyDirs false
outputs.upToDateWhen { false }
}.execute()
}
}
}
}
}
def hasAtlasDir(File file) {
for(File f : file.listFiles()) {
if(f.isDirectory()) return true;
}
return false;
}
task zipAssets(dependsOn: [prepareSoundAssets, prepareGraphicAssets, prepareJsonAssets]) {
doLast {
new File(project(":core").projectDir.absolutePath + "/${assetsDirName}").eachDir() { dir ->
......
......@@ -29,7 +29,6 @@ import net.engio.mbassy.bus.error.IPublicationErrorHandler;
import net.engio.mbassy.bus.error.PublicationError;
import net.engio.mbassy.listener.Handler;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
......@@ -41,6 +40,7 @@ import cz.nic.tablexia.bus.ApplicationBus.ApplicationEvent;
import cz.nic.tablexia.game.ranksystem.UserRankManager;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationAvatarManager;
import cz.nic.tablexia.loader.application.TablexiaBadgesManager;
import cz.nic.tablexia.loader.application.ApplicationExternalSoundManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationInternalSoundManager;
......@@ -298,6 +298,8 @@ public class Tablexia extends TablexiaApplication {
ApplicationExternalSoundManager.getInstance().load();
ApplicationAtlasManager.getInstance().load();
TablexiaBadgesManager.initialize();
loadingComplete = false;
}
......@@ -456,6 +458,7 @@ public class Tablexia extends TablexiaApplication {
super.dispose();
TablexiaStorage.getInstance().dispose();
TablexiaSettings.getInstance().dispose();
TablexiaBadgesManager.getInstance().dispose();
TablexiaComponentDialogFactory.getInstance().dispose();
clearLoadedData();
}
......
......@@ -67,6 +67,7 @@ import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationInternalSoundManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.loader.application.TablexiaBadgesManager;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.game.GameMenuItemGroup;
import cz.nic.tablexia.menu.main.MainMenu;
......@@ -390,6 +391,8 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
createDebugEndGameButton();
}
TablexiaBadgesManager.getInstance().refreshBadges();
performGameLoaded(screenState);
} catch (Throwable t) {
Log.err(getClass(), "Cannot resume screen state!", t);
......
......@@ -550,6 +550,13 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
actionsStripWidget.setSize(ACTION_STRIP_WIDGET_WIDTH, getStage().getHeight());
actionsStripWidget.setPosition(getStage().getWidth() - actionsStripWidget.getWidth(), getViewportBottomY());
resizeDimmer();
if(sequenceStarted){
stopGameSequence();
resetGameState();
goToPlanningMode(Integer.valueOf(selectedActionPosition));
disableStartButton(false);
}
}
private void prepareBackground() {
......
......@@ -65,6 +65,7 @@ import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.util.MusicUtil;
import cz.nic.tablexia.util.ui.AnimatedImage;
import cz.nic.tablexia.util.ui.TablexiaLabel;
import cz.nic.tablexia.util.ui.TablexiaNoBlendingImage;
import cz.nic.tablexia.util.ui.button.StandardTablexiaButton;
import cz.nic.tablexia.util.ui.dialog.components.AnimatedImageContentDialogComponent;
import cz.nic.tablexia.util.ui.dialog.components.FixedSpaceContentDialogComponent;
......@@ -167,7 +168,7 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
ruleMessage = new Group();
//Adds Backgrounds
Image background = new Image(getApplicationTextureRegion(ApplicationAtlasManager.BACKGROUND_WOODEN));
Image background = new TablexiaNoBlendingImage(getApplicationTextureRegion(ApplicationAtlasManager.BACKGROUND_WOODEN));
setActorToFullScene(background);
ruleMessage.addActor(background);
......
......@@ -18,6 +18,7 @@
package cz.nic.tablexia.game.ranksystem;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.EventListener;
import com.badlogic.gdx.scenes.scene2d.Group;
......@@ -30,6 +31,7 @@ import com.badlogic.gdx.utils.Align;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.TablexiaBadgesManager;
import cz.nic.tablexia.loader.application.ApplicationExternalSoundManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
......@@ -48,9 +50,9 @@ public class RankAnimation extends Group {
private static final Color DIMMER_COLOR = new Color(0, 0, 0, DIMMER_ALPHA);
private static final int BACKGROUND_SHINE_COUNT = 3;
private static final float BACKGROUND_SHINE_SIZE = 0.92f;
private static final int BACKGROUND_SHINE_RAYS_COUNT = 6;
private static final float BACKGROUND_SHINE_RAY_SIZE = 0.52f;
private static final float BACKGROUND_SHINE_ROTATION = 67.8f;
private static final float BACKGROUND_SHINE_ROTATION_SPEED = 9;
private static final float BACKGROUND_SHINE_ROTATION_SPEED_DIFF = 2;
private static final float BACKGROUND_SHINE_FADEIN_DURATION = 0.5f;
......@@ -124,24 +126,31 @@ public class RankAnimation extends Group {
private void prepareShines() {
shinesGroup.setSize(this.getWidth(), this.getHeight());
Image[] shineImages = new Image[BACKGROUND_SHINE_COUNT];
for(int i = 0; i < BACKGROUND_SHINE_COUNT; i++) {
shineImages[i] = new Image(ApplicationAtlasManager.getInstance().getTextureRegion(ApplicationAtlasManager.RANK_UP_BACKGROUND));
shineImages[i].setSize(this.getWidth() * BACKGROUND_SHINE_SIZE, this.getWidth() * BACKGROUND_SHINE_SIZE);
shineImages[i].setPosition(this.getWidth()/2 - shineImages[i].getWidth()/2, this.getHeight()/2 - shineImages[i].getHeight()/2);
shineImages[i].setOrigin(Align.center);
shineImages[i].setColor(BACKGROUND_SHINE_COLORS[i % BACKGROUND_SHINE_COLORS.length]);
//Initial rotation
shineImages[i].setRotation(i * BACKGROUND_SHINE_ROTATION);
//Rotating animation
int direction = (i % 2) == 0 ? 1 : -1;
shineImages[i].addAction(Actions.forever(Actions.rotateBy(direction * 360, BACKGROUND_SHINE_ROTATION_SPEED + i * BACKGROUND_SHINE_ROTATION_SPEED_DIFF)));
//Add shine image
shinesGroup.addActor(shineImages[i]);
Group singleShinesGroup = new Group();
singleShinesGroup.setSize(this.getWidth(), this.getHeight());
float angle = 360 / BACKGROUND_SHINE_RAYS_COUNT;
for(int j = 0; j < BACKGROUND_SHINE_RAYS_COUNT; j++) {
Image ray = ScaleUtil.createImageToHeight(
ApplicationAtlasManager.getInstance().getTextureRegion(ApplicationAtlasManager.RANK_UP_BACKGROUND),
singleShinesGroup.getHeight() * BACKGROUND_SHINE_RAY_SIZE
);
ray.setPosition(singleShinesGroup.getWidth() / 2 - ray.getWidth() / 2, singleShinesGroup.getHeight() / 2);
ray.setOrigin(Align.bottom);
ray.setRotation(angle * j);
ray.setColor(BACKGROUND_SHINE_COLORS[i % BACKGROUND_SHINE_COLORS.length]);
singleShinesGroup.addActor(ray);
}
angle = 360 / BACKGROUND_SHINE_COUNT;
singleShinesGroup.setOrigin(Align.center);
singleShinesGroup.setRotation(i * angle);
int direction = i % 2 == 0 ? 1 : -1;
singleShinesGroup.addAction(Actions.forever(Actions.rotateBy(direction * 360, BACKGROUND_SHINE_ROTATION_SPEED + i * BACKGROUND_SHINE_ROTATION_SPEED_DIFF)));
shinesGroup.addActor(singleShinesGroup);
}
//Initially hidden
......@@ -156,13 +165,13 @@ public class RankAnimation extends Group {
}
private void prepareOldBadge() {
prepareBadgeGroup(oldBadgeGroup, oldRank);
prepareBadgeGroup(oldBadgeGroup, oldRank, TablexiaBadgesManager.getInstance().getCurrentRankBadgeTexture());
this.addActor(oldBadgeGroup);
}
private void prepareNewBadge() {
prepareBadgeGroup(newBadgeGroup, newRank);
prepareBadgeGroup(newBadgeGroup, newRank, TablexiaBadgesManager.getInstance().getNextRankBadgeTexture());
newBadgeGroup.addAction(Actions.alpha(0));
newBadgeGroup.addAction(Actions.moveBy(BADGE_SLIDE_DISTANCE * this.getWidth(), 0));
......@@ -170,8 +179,8 @@ public class RankAnimation extends Group {
this.addActor(newBadgeGroup);
}
private void prepareBadgeGroup(Group group, UserRankManager.UserRank userRank) {
Image badgeImage = createBadgeImage(userRank);
private void prepareBadgeGroup(Group group, UserRankManager.UserRank userRank, Texture badgeTexture) {
Image badgeImage = createBadgeImage(badgeTexture);
group.setSize(badgeImage.getWidth(), badgeImage.getHeight());
group.setPosition(this.getWidth() / 2f - group.getWidth() / 2f, this.getHeight() / 2f - group.getHeight() / 2f);
group.addActor(badgeImage);
......@@ -193,8 +202,8 @@ public class RankAnimation extends Group {
return badgeLabel;
}
private Image createBadgeImage(UserRankManager.UserRank userRank) {
return ScaleUtil.createImageToHeight(ApplicationAtlasManager.getInstance().getTextureRegion(userRank.getBadgeImageKey()), this.getHeight() * BADGE_HEIGHT);
private Image createBadgeImage(Texture badgeTexture) {
return ScaleUtil.createImageToHeight(badgeTexture, this.getHeight() * BADGE_HEIGHT);
}
private void animateBadges() {
......
......@@ -17,7 +17,6 @@
package cz.nic.tablexia.game.ranksystem;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -29,6 +28,7 @@ import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.game.GameMenuItemGroup;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.model.game.GameDAO;
import cz.nic.tablexia.screen.halloffame.assets.HallOfFameAssets;
import cz.nic.tablexia.shared.model.Game;
import cz.nic.tablexia.shared.model.User;
import cz.nic.tablexia.util.Log;
......@@ -38,33 +38,34 @@ import cz.nic.tablexia.util.Log;
*/
public class UserRankManager {
public enum UserRank {
RANK_NONE ( 0, false, false, null, ApplicationAtlasManager.BADGE_NONE, ApplicationAtlasManager.BADGE_NONE_ICON, 0),
RANK_I ( 1, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_1, ApplicationAtlasManager.BADGE_1, ApplicationAtlasManager.BADGE_1_ICON, 3),
RANK_II ( 2, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_2, ApplicationAtlasManager.BADGE_2, ApplicationAtlasManager.BADGE_2_ICON, 9),
RANK_III ( 3, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_3, ApplicationAtlasManager.BADGE_3, ApplicationAtlasManager.BADGE_3_ICON, 18),
RANK_IV ( 4, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_4, ApplicationAtlasManager.BADGE_4, ApplicationAtlasManager.BADGE_4_ICON, 30),
RANK_V ( 5, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_5, ApplicationAtlasManager.BADGE_5, ApplicationAtlasManager.BADGE_5_ICON, 48),
RANK_VI ( 6, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_6, ApplicationAtlasManager.BADGE_6, ApplicationAtlasManager.BADGE_6_ICON, 73),
RANK_VII ( 7, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_7, ApplicationAtlasManager.BADGE_7, ApplicationAtlasManager.BADGE_7_ICON, 105),
RANK_VIII ( 8, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_8, ApplicationAtlasManager.BADGE_8, ApplicationAtlasManager.BADGE_8_ICON, 145),
RANK_IX ( 9, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_9, ApplicationAtlasManager.BADGE_9, ApplicationAtlasManager.BADGE_9_ICON, 193),
RANK_X (10, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_10, ApplicationAtlasManager.BADGE_10, ApplicationAtlasManager.BADGE_10_ICON, 248),
RANK_XI (11, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_11, ApplicationAtlasManager.BADGE_11, ApplicationAtlasManager.BADGE_11_ICON, 316);
RANK_NONE ( 0, false, false, null, ApplicationAtlasManager.BADGE_NONE_ICON, HallOfFameAssets.BADGE_NONE, 0),
RANK_I ( 1, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_1, ApplicationAtlasManager.BADGE_1_ICON, HallOfFameAssets.BADGE_1, 3),
RANK_II ( 2, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_2, ApplicationAtlasManager.BADGE_2_ICON, HallOfFameAssets.BADGE_2, 9),
RANK_III ( 3, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_3, ApplicationAtlasManager.BADGE_3_ICON, HallOfFameAssets.BADGE_3, 18),
RANK_IV ( 4, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_4, ApplicationAtlasManager.BADGE_4_ICON, HallOfFameAssets.BADGE_4, 30),
RANK_V ( 5, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_5, ApplicationAtlasManager.BADGE_5_ICON, HallOfFameAssets.BADGE_5, 48),
RANK_VI ( 6, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_6, ApplicationAtlasManager.BADGE_6_ICON, HallOfFameAssets.BADGE_6, 73),
RANK_VII ( 7, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_7, ApplicationAtlasManager.BADGE_7_ICON, HallOfFameAssets.BADGE_7, 105),
RANK_VIII ( 8, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_8, ApplicationAtlasManager.BADGE_8_ICON, HallOfFameAssets.BADGE_8, 145),
RANK_IX ( 9, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_9, ApplicationAtlasManager.BADGE_9_ICON, HallOfFameAssets.BADGE_9, 193),
RANK_X (10, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_10, ApplicationAtlasManager.BADGE_10_ICON, HallOfFameAssets.BADGE_10, 248),
RANK_XI (11, true, true, ApplicationTextManager.ApplicationTextsAssets.USER_RANK_11, ApplicationAtlasManager.BADGE_11_ICON, HallOfFameAssets.BADGE_11, 316);
private int id;
private String nameKey;
private String badgeImage, badgeIcon;
private String badgeIcon;
private final String hallOfFameBadge;
//This value is not final as it can be influenced by RankComputingScripts
private int experiencePointsNeeded;
private boolean userMenu, badgeBoard;
UserRank(int id, boolean userMenu, boolean badgeBoard, String nameKey, String badgeImage, String badgeIcon, int experiencePointsNeeded) {
UserRank(int id, boolean userMenu, boolean badgeBoard, String nameKey, String badgeIcon, String hallOfFameBadge, int experiencePointsNeeded) {
this.id = id;
this.nameKey = nameKey;
this.badgeImage = badgeImage;
this.badgeIcon = badgeIcon;
this.hallOfFameBadge = hallOfFameBadge;
this.experiencePointsNeeded = experiencePointsNeeded;
this.userMenu = userMenu;
......@@ -110,14 +111,14 @@ public class UserRankManager {
return badgeBoard;
}
public String getBadgeImageKey() {
return badgeImage;
}
public String getBadgeIconKey() {
return badgeIcon;
}
public String getHallOfFameBadge() {
return hallOfFameBadge;
}
public String getNameKey() {
return nameKey;
}
......@@ -389,6 +390,7 @@ public class UserRankManager {
rankComputeDataMap.put(user.getId(), rankComputeData);
ApplicationBus.getInstance().post(new GameMenuItemGroup.RefreshMainMenuProgressBarsEvent()).asynchronously();
}
public static class UserRankUpEvent implements ApplicationBus.ApplicationEvent {
......
......@@ -138,30 +138,6 @@ public abstract class TablexiaAbstractFileManager extends AssetManager {
}
}
public enum AvatarsStorageType implements StorageType {
INTERNAL(RootStorageType.INTERNAL, AvatarsStorageType.AVATARS_DIRECTORY),
EXTERNAL(RootStorageType.LOCAL, AvatarsStorageType.AVATARS_DIRECTORY);
public static final String AVATARS_DIRECTORY = "avatars/";
private String storagePath;
private FileHandleResolver resolver;
AvatarsStorageType(RootStorageType rootStorageType, String assetsPath) {
this.storagePath = rootStorageType.getStoragePath() + assetsPath;
this.resolver = rootStorageType.getResolver();
}
public String getStoragePath() {
return storagePath;
}
public FileHandleResolver getResolver() {
return resolver;
}
}
public enum DataStorageType implements StorageType {
INTERNAL(RootStorageType.INTERNAL, DataStorageType.DATA_DIRECTORY),
......
......@@ -101,18 +101,6 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp
public static final String USERMENU_MENUITEM_CUSTOM_AVATAR = AVATAR_PATH+"custom_avatar";
public static final String BADGE_PATH = "badge/";
public static final String BADGE_NONE = BADGE_PATH + "badge_none";
public static final String BADGE_1 = BADGE_PATH + "badge1";
public static final String BADGE_2 = BADGE_PATH + "badge2";
public static final String BADGE_3 = BADGE_PATH + "badge3";
public static final String BADGE_4 = BADGE_PATH + "badge4";
public static final String BADGE_5 = BADGE_PATH + "badge5";
public static final String BADGE_6 = BADGE_PATH + "badge6";
public static final String BADGE_7 = BADGE_PATH + "badge7";
public static final String BADGE_8 = BADGE_PATH + "badge8";
public static final String BADGE_9 = BADGE_PATH + "badge9";
public static final String BADGE_10 = BADGE_PATH + "badge10";
public static final String BADGE_11 = BADGE_PATH + "badge11";
public static final String BADGE_NONE_ICON = BADGE_PATH + "badge_none_icon";
public static final String BADGE_1_ICON = BADGE_PATH + "badge1_icon";
......
/*
* Copyright (C) 2016 CZ.NIC, z.s.p.o. (http://www.nic.cz/)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cz.nic.tablexia.loader.application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import net.engio.mbassy.listener.Handler;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.game.ranksystem.UserRankManager;
import cz.nic.tablexia.loader.TablexiaTextureManager;
import cz.nic.tablexia.loader.zip.TablexiaAssetsManager;
import cz.nic.tablexia.shared.model.User;
/**
* Created by drahomir on 8/4/17.
*/
public class TablexiaBadgesManager extends TablexiaTextureManager {
private static final String BADGES_ASSETS_PATH = "badges/";
private static final String BADGE_IMAGE_FILE_EXT = ".png";
private enum FullRankBadges {
BADGE_NONE (UserRankManager.UserRank.RANK_NONE, BADGES_ASSETS_PATH + "badge_none" + BADGE_IMAGE_FILE_EXT),
BADGE_1 (UserRankManager.UserRank.RANK_I, BADGES_ASSETS_PATH + "badge1" + BADGE_IMAGE_FILE_EXT),
BADGE_2 (UserRankManager.UserRank.RANK_II, BADGES_ASSETS_PATH + "badge2" + BADGE_IMAGE_FILE_EXT),
BADGE_3 (UserRankManager.UserRank.RANK_III, BADGES_ASSETS_PATH + "badge3" + BADGE_IMAGE_FILE_EXT),
BADGE_4 (UserRankManager.UserRank.RANK_IV, BADGES_ASSETS_PATH + "badge4" + BADGE_IMAGE_FILE_EXT),
BADGE_5 (UserRankManager.UserRank.RANK_V, BADGES_ASSETS_PATH + "badge5" + BADGE_IMAGE_FILE_EXT),
BADGE_6 (UserRankManager.UserRank.RANK_VI, BADGES_ASSETS_PATH + "badge6" + BADGE_IMAGE_FILE_EXT),
BADGE_7 (UserRankManager.UserRank.RANK_VII, BADGES_ASSETS_PATH + "badge7" + BADGE_IMAGE_FILE_EXT),
BADGE_8 (UserRankManager.UserRank.RANK_VIII, BADGES_ASSETS_PATH + "badge8" + BADGE_IMAGE_FILE_EXT),
BADGE_9 (UserRankManager.UserRank.RANK_IX, BADGES_ASSETS_PATH + "badge9" + BADGE_IMAGE_FILE_EXT),
BADGE_10 (UserRankManager.UserRank.RANK_X, BADGES_ASSETS_PATH + "badge10" + BADGE_IMAGE_FILE_EXT),
BADGE_11 (UserRankManager.UserRank.RANK_XI, BADGES_ASSETS_PATH + "badge11" + BADGE_IMAGE_FILE_EXT);
private UserRankManager.UserRank userRank;
private String filePath;
FullRankBadges(UserRankManager.UserRank userRank, String filePath) {
this.userRank = userRank;
this.filePath = filePath;
}
public static String getFilePathForUserRank(UserRankManager.UserRank rank) {
for(FullRankBadges badge : values()) {
if(badge.userRank == rank) return badge.filePath;
}
return FullRankBadges.BADGE_NONE.filePath;
}
}
private static TablexiaBadgesManager instance;
private UserRankManager.UserRank loadedRank = null;
private UserRankManager.UserRank nextRankCache;
private String loadedRankPath, nextRankCachePath;
private TablexiaBadgesManager() {}
public static void initialize() {
if(instance == null) {
instance = new TablexiaBadgesManager();
ApplicationBus.getInstance().subscribe(instance);
}
}
public static TablexiaBadgesManager getInstance() {
return instance;
}
@Handler
public void onUserSelectedEvent(TablexiaSettings.SelectedUserEvent selectedUserEvent) {
refreshBadges();
}
@Handler
public void onTablexiaAssetsManagerEvent(TablexiaAssetsManager.AssetsManagerEvent assetsManagerEvent) {
if(assetsManagerEvent.getEventType() == TablexiaAssetsManager.AssetsManagerEvent.AssetsManagerEventType.LoadFinished) {
refreshBadges();
}
}
private void loadAssetsForCurrentUser() {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
loadTexture(loadedRankPath = FullRankBadges.getFilePathForUserRank(loadedRank));
loadTexture(nextRankCachePath = FullRankBadges.getFilePathForUserRank(nextRankCache));
finishLoading();
}
});
}
public void refreshBadges() {
User currentUser = TablexiaSettings.getInstance().getSelectedUser();
UserRankManager.UserRank rank = UserRankManager.UserRank.RANK_NONE;
UserRankManager rankManager = UserRankManager.getInstance();
if(currentUser != null && rankManager != null) {
rank = rankManager.getRank(currentUser);
}
if(rank != null && rank != loadedRank) {
disposeAllLoadedAssets();
loadedRank = rank;
nextRankCache = UserRankManager.UserRank.getNextRank(loadedRank);
loadAssetsForCurrentUser();
}
}
public Texture getCurrentRankBadgeTexture() {
return getTexture(loadedRankPath);
}
public Texture getNextRankBadgeTexture() {
return getTexture(nextRankCachePath);
}
@Override
public Texture getTexture(String textureName) {
Texture texture = super.getTexture(textureName);
texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
return texture;
}
private void disposeAllLoadedAssets() {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
clear();
}
});
}
}
\ No newline at end of file
......@@ -154,7 +154,7 @@ public abstract class AbstractMenu extends Stack implements Disposable {
public static final float APP_NAME_TEXT_PADDING_LEFT = 10f;
public static final float SOUND_MUTE_BUTTON_PADDING_LEFT = 5f;