Commit 829c408c authored by Drahomír Karchňák's avatar Drahomír Karchňák

#341 Added sound muted dialog variants for games and regular screens. Also...

#341 Added sound muted dialog variants for games and regular screens. Also added sound mute dialog for encyclopedia's play buttons...
parent 6ef518d8
......@@ -59,7 +59,8 @@ game_averagescore_error=Průměrný počet chyb:
game_averagescore_duration=Průměrné trvání hry:
game_quit_question=Opravdu chceš ukončit hru?
sound_muted_question=Pro pokračování ve hře je zapotřebí mít zapnutý zvuk. Přeješ si nyní zvuk zapnout a pokračovat?
sound_muted_question=Pro pokračování je zapotřebí mít zapnutý zvuk. Přeješ si nyní zvuk zapnout a pokračovat?
sound_muted_game_question=Pro pokračování ve hře je zapotřebí mít zapnutý zvuk. Přeješ si nyní zvuk zapnout a pokračovat?
game_robbery_title=Lupiči
game_robbery_description=Procvičování pracovní paměti
......
......@@ -59,7 +59,8 @@ game_averagescore_error=Durchschnittliche Fehlerzahl:
game_averagescore_duration=Durchschnittliche Spieldauer:
game_quit_question=Möchtest du wirklich das Spiel beenden?
sound_muted_question=[DE] Pro pokračování je zapotřebí mít zapnutý zvuk. Přeješ si nyní zvuk zapnout a pokračovat ?
sound_muted_question=[DE]Pro pokračování je zapotřebí mít zapnutý zvuk. Přeješ si nyní zvuk zapnout a pokračovat?[DE]
sound_muted_game_question=[DE]Pro pokračování ve hře je zapotřebí mít zapnutý zvuk. Přeješ si nyní zvuk zapnout a pokračovat?[DE]
game_robbery_title=Einbrecher
game_robbery_description=Training des Arbeitsgedächtnisses
......
......@@ -61,7 +61,8 @@ game_averagescore_error=Priemerný počet chýb:
game_averagescore_duration=Priemerné trvanie hry\:
game_quit_question=Naozaj chceš ukončiť hru?
sound_muted_question=[SK] Pre pokračovanie v hre je potrebné mať zapnutý zvuk. Chceš si zvuk teraz zapnúť a pokračovať?
sound_muted_question=Pre pokračovanie je potrebné mať zapnutý zvuk. Chceš si zvuk teraz zapnúť a pokračovať?
sound_muted_game_question=Pre pokračovanie v hre je potrebné mať zapnutý zvuk. Chceš si zvuk teraz zapnúť a pokračovať?
game_robbery_title=Lupiči
game_robbery_description=Precvičovanie pracovnej pamäti
......
......@@ -633,28 +633,31 @@ public abstract class TablexiaApplication implements ApplicationListener {
}
};
if(newScreen.isSoundMandatory() && TablexiaSettings.getInstance().isSoundMuted())
showSoundMutedDialog(newScreenAction);
else
performNewScreenAction(newScreenAction);
performNewScreenAction(newScreen, newScreenAction);
}
private void performNewScreenAction(final Runnable newScreenAction) {
if (screen.hasQuitConfirmDialog()) {
private void performNewScreenAction(final AbstractTablexiaScreen<?> newScreen, final Runnable newScreenAction) {
if(newScreen.isSoundMandatory() && TablexiaSettings.getInstance().isSoundMuted()) {
showSoundMutedDialog(newScreen, newScreenAction);
}
else if(screen.hasQuitConfirmDialog()){
showQuitConfirmDialog(newScreenAction);
} else {
}
else {
newScreenAction.run();
}
}
private void showSoundMutedDialog(final Runnable newScreenAction) {
private void showSoundMutedDialog(final AbstractTablexiaScreen<?> newScreen, final Runnable newScreenAction) {
TablexiaComponentDialogFactory.getInstance().createWarningYesNoDialog(
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SOUND_MUTED_QUESTION),
ApplicationTextManager.getInstance().getText(newScreen.prepareSoundMutedQuestion()),
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TablexiaSettings.getInstance().toggleSoundMute();
performNewScreenAction(newScreenAction);
if(screen.hasQuitConfirmDialog()) showQuitConfirmDialog(newScreenAction);
else newScreenAction.run();
}
},
true
......
......@@ -377,6 +377,11 @@ public abstract class AbstractTablexiaGame<T> extends AbstractTablexiaScreen<T>
return "game/" + screenName + "/";
}
@Override
public String prepareSoundMutedQuestion() {
return ApplicationTextManager.ApplicationTextsAssets.SOUND_MUTED_GAME_QUESTION;
}
@Override
public void setScreenViewCount(long userId, String screenName, long time) {
}
......
......@@ -92,6 +92,7 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl
public static final String GAME_QUIT_QUESTION = "game_quit_question";
public static final String SOUND_MUTED_QUESTION = "sound_muted_question";
public static final String SOUND_MUTED_GAME_QUESTION = "sound_muted_game_question";
public static final String SYNC_REQUEST_DIALOG_TEXT = "sync_request_dialog_text";
public static final String SYNC_REQUEST_BUTTON = "sync_request_button";
......
......@@ -44,6 +44,7 @@ import cz.nic.tablexia.loader.TablexiaAtlasManager;
import cz.nic.tablexia.loader.TablexiaDataManager;
import cz.nic.tablexia.loader.TablexiaSoundManager;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.model.UserDAO;
import cz.nic.tablexia.model.screen.ScreenDAO;
import cz.nic.tablexia.shared.model.User;
......@@ -398,6 +399,10 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter {
return false;
}
public String prepareSoundMutedQuestion() {
return ApplicationTextManager.ApplicationTextsAssets.SOUND_MUTED_QUESTION;
}
//////////////////////////// LOADING LISTENER
private void notifyLoadingCompleteListeners() {
......@@ -564,7 +569,7 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter {
}
private void playIntroMusic() {
if (introMusic != null) {
if (introMusic != null && !TablexiaSettings.getInstance().isSoundMuted()) {
introMusic.play();
}
}
......
......@@ -9,12 +9,14 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.JsonValue;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.screen.encyclopedia.EncyclopediaFont;
import cz.nic.tablexia.screen.encyclopedia.EncyclopediaScreen;
import cz.nic.tablexia.screen.encyclopedia.assets.EncyclopediaAssets;
import cz.nic.tablexia.util.ui.TablexiaLabel;
import cz.nic.tablexia.util.ui.button.ImageTablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialogFactory;
/**
* Created by Václav Tarantík on 23.9.15.
......@@ -67,15 +69,25 @@ public class Header extends Content {
button.setInputListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (button.isChecked()) {
button.text(screen.getText(EncyclopediaAssets.PAUSE));
button.setIcon(encyclopediaScreen.getPauseIcon());
encyclopediaScreen.playMusic(soundResource, button);
} else {
button.text(screen.getText(EncyclopediaAssets.PLAY));
button.setIcon(encyclopediaScreen.getPlayIcon());
encyclopediaScreen.togglePlaying();
}
Runnable playButtonAction = new Runnable() {
@Override
public void run() {
if (button.isChecked()) {
button.text(screen.getText(EncyclopediaAssets.PAUSE));
button.setIcon(encyclopediaScreen.getPauseIcon());
encyclopediaScreen.playMusic(soundResource, button);
} else {
button.text(screen.getText(EncyclopediaAssets.PLAY));
button.setIcon(encyclopediaScreen.getPlayIcon());
encyclopediaScreen.togglePlaying();
}
}
};
if(TablexiaSettings.getInstance().isSoundMuted())
showSoundMutedDialog(playButtonAction);
else
playButtonAction.run();
}
});
headerTable.add(headerLabel).maxWidth(parentContainerWidth - BUTTON_WIDTH - PAD_RIGHT).fillX().expandX().left();
......@@ -86,6 +98,20 @@ public class Header extends Content {
return headerTable;
}
private void showSoundMutedDialog(final Runnable onSuccessCallback) {
TablexiaComponentDialogFactory.getInstance().createWarningYesNoDialog(
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.SOUND_MUTED_QUESTION),
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TablexiaSettings.getInstance().toggleSoundMute();
onSuccessCallback.run();
}
},
true
).show(TablexiaComponentDialogFactory.WARNING_DIALOG_WIDTH, TablexiaComponentDialogFactory.WARNING_DIALOG_HEIGHT);
}
@Override
public Cell addToCell(Table contentTable, AbstractTablexiaScreen screen, float parentContainerWidth) {
return contentTable.add(render(screen, parentContainerWidth)).expandX().fillX().padBottom(PAD_BOTTOM).padTop(PAD_TOP).left();
......
......@@ -31,7 +31,6 @@ import cz.nic.tablexia.util.Utility;
/**
* Created by lhoracek
* Edited by Drahomir Karchnak on 2/12/15
*/
public class GameMenuScreen extends AbstractTablexiaScreen<int[][]> {
......
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