Commit 653f60c5 authored by Drahomír Karchňák's avatar Drahomír Karchňák

#341 Sound muting button should work correctly now. Added pop up dialog when...

#341 Sound muting button should work correctly now. Added pop up dialog when trying to visit screen that requires sounds while having sounds muted...
parent 3c72f409
......@@ -26,7 +26,7 @@ mainmenu_statistics=Statistiky
mainmenu_encyclopedia=Encyklopedie
mainmenu_preferences=Nastavení
mainmenu_about=O aplikaci
mainmenu_sounds=[CS]Zvuky
mainmenu_sounds=Vypnout zvuky
mainmenu_logout=Odhlásit
mainmenu_screendebug=Debug Screen
mainmenu_panorama=Panorama
......@@ -60,6 +60,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=V následující obrazovce je nutné mít zapnuté zvuky. Přejete si je zapnout ?
game_robbery_title=Lupiči
game_robbery_description=Procvičování pracovní paměti
game_robbery_preloader=Na začátku hry si přečti pravidlo, podle kterého poznáš lupiče. Zapamatuj si\u00A0ho.\nSleduj lidi vcházející do místnosti a\u00A0dotykem lupiče označ.
......
......@@ -60,6 +60,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] Zvuky??
game_robbery_title=Einbrecher
game_robbery_description=Training des Arbeitsgedächtnisses
game_robbery_preloader=Lies dir zu Beginn des Spiels durch, wie du den Einbrecher bzw. die Einbrecherin erkennst. Merke dir diese Beschreibung.\nBeobachte die Leute, die den Raum betreten, und markiere mit einer Berührung den Einbrecher bzw. die Einbrecherin.
......
......@@ -62,6 +62,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] Zvuky??
game_robbery_title=Lupiči
game_robbery_description=Precvičovanie pracovnej pamäti
game_robbery_preloader=Prečítaj a zapamätaj si pravidlo, podľa ktorého spoznáš lupiča. Sleduj ľudí prichádzajúcich do miestnosti a dotykom lupiča označ.
......
......@@ -633,7 +633,10 @@ public abstract class TablexiaApplication implements ApplicationListener {
}
};
performNewScreenAction(newScreenAction);
if(newScreen.isSoundMandatory() && TablexiaSettings.getInstance().isSoundMuted())
showSoundMutedDialog();
else
performNewScreenAction(newScreenAction);
}
private void performNewScreenAction(final Runnable newScreenAction) {
......@@ -644,6 +647,20 @@ public abstract class TablexiaApplication implements ApplicationListener {
}
}
private void showSoundMutedDialog() {
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();
}
},
true
).show(TablexiaComponentDialogFactory.WARNING_DIALOG_WIDTH, TablexiaComponentDialogFactory.WARNING_DIALOG_HEIGHT);
ApplicationBus.getInstance().post(new MenuControlEvent(MainMenu.class, AbstractMenu.MenuAction.OPEN, true)).asynchronously();
}
/**
* Return current screen
*
......
......@@ -141,9 +141,4 @@ public enum GameDefinition implements ApplicationEvent, IMenuItem {
public String[] getIcons() {
return new String[0]; // TODO
}
@Override
public boolean isToggle() {
return false;
}
}
......@@ -2,7 +2,6 @@ package cz.nic.tablexia.game.games.kidnapping;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.EventListener;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
......@@ -130,7 +129,12 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
screenResized(0, 0);
}
@Override
public boolean isSoundMandatory() {
return true;
}
private void prepareRuleMessage() {
ruleMessage = new Group();
......
......@@ -92,6 +92,8 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl
public static final String GAME_AVERAGE_SCORE_DURATION = "game_averagescore_duration";
public static final String GAME_QUIT_QUESTION = "game_quit_question";
public static final String SOUND_MUTED_QUESTION = "sound_muted_question";
public static final String SYNC_REQUEST_DIALOG_TEXT = "sync_request_dialog_text";
public static final String SYNC_REQUEST_BUTTON = "sync_request_button";
}
......
......@@ -10,6 +10,5 @@ public interface IMenuItem {
Class<? extends Group> getItemGroupClass();
AbstractMenu.MenuAction getMenuAction();
IMenuItem[] getSubmenu();
String[] getIcons();
boolean isToggle();
String[] getIcons();
}
......@@ -55,11 +55,6 @@ public enum GameMenuDefinition implements ApplicationBus.ApplicationEvent, IMenu
return null;
}
@Override
public boolean isToggle() {
return false;
}
@Override
public Class<? extends Group> getItemGroupClass() {
return MENU_ITEM_GROUP_CLASS;
......
......@@ -26,7 +26,6 @@ import cz.nic.tablexia.screen.viewport.ViewportDebugScreen;
public enum MainMenuDefinition implements IMenuItem {
GAMES (false, new String[]{ApplicationAtlasManager.MAINMENU_ICON_GAMES_UNPRESSED, ApplicationAtlasManager.MAINMENU_ICON_GAMES_PRESSED}, ApplicationTextManager.ApplicationTextsAssets.MAINMENU_GAMES, GameMenuDefinition.values(), null, null) {
@Override
public void performAction() {
ApplicationBus.getInstance().post(new SubMenuControlEvent(MainMenu.class, this, SubMenuControlEvent.SubMenuAction.TOGGLE)).asynchronously();
......@@ -43,8 +42,8 @@ public enum MainMenuDefinition implements IMenuItem {
}
@Override
public boolean isToggle() {
return true;
public Class<? extends Group> getItemGroupClass() {
return MainMenuSoundItemGroup.class;
}
},
LOGOUT (false, new String[]{ApplicationAtlasManager.MAINMENU_ICON_LOGOUT_UNPRESSED, ApplicationAtlasManager.MAINMENU_ICON_LOGOUT_PRESSED}, ApplicationTextManager.ApplicationTextsAssets.MAINMENU_LOGOUT, null, AbstractMenu.MenuAction.CLOSE, null) {
......@@ -107,11 +106,6 @@ public enum MainMenuDefinition implements IMenuItem {
return icons;
}
@Override
public boolean isToggle() {
return false;
}
public IMenuItem[] getSubmenu() {
return submenu;
}
......
......@@ -40,27 +40,7 @@ public class MainMenuItemGroup extends Container<Table> {
fillX();
layoutTable.align(Align.left);
setActor(layoutTable);
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if(menuItem.isToggle() && inTapSquare(x, y)) {
if(isCurrentlyPressed()) setUnpressed();
else setPressed();
}
}
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if(!menuItem.isToggle()) setPressed();
return super.touchDown(event, x, y, pointer, button);
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
super.touchUp(event, x, y, pointer, button);
if(!menuItem.isToggle()) setUnpressed();
}
});
initializeDefaultListener();
setTouchable(Touchable.enabled);
// highliter
......@@ -98,6 +78,22 @@ public class MainMenuItemGroup extends Container<Table> {
layoutTable.add(new Image(ApplicationAtlasManager.getInstance().getColorTexture(DIVIDER_COLOR))).fillX();
}
protected void initializeDefaultListener() {
addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
setPressed();
return super.touchDown(event, x, y, pointer, button);
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
super.touchUp(event, x, y, pointer, button);
setUnpressed();
}
});
}
private Image createIcon(String iconName, Stack iconStack) {
Image icon = null;
if (iconName != null) {
......@@ -129,8 +125,4 @@ public class MainMenuItemGroup extends Container<Table> {
iconPressedImage.setVisible(true);
}
}
public boolean isCurrentlyPressed() {
return iconPressedImage.isVisible();
}
}
package cz.nic.tablexia.menu.main;
import net.engio.mbassy.listener.Handler;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.menu.IMenuItem;
/**
* Created by drahomir on 7/15/16.
*/
public class MainMenuSoundItemGroup extends MainMenuItemGroup {
public MainMenuSoundItemGroup(final IMenuItem menuItem, float width) {
super(menuItem, width);
ApplicationBus.getInstance().subscribe(this);
}
@Override
protected void initializeDefaultListener() {} //Turns off default behaviour
@Handler
public void handleSoundMuteEvent(TablexiaSettings.SoundMuteEvent soundMuteEvent) {
if(soundMuteEvent.isSoundMuted()) setPressed();
else setUnpressed();
}
}
\ No newline at end of file
......@@ -60,9 +60,4 @@ public class UserMenuItem implements IMenuItem {
public IMenuItem[] getSubmenu() {
return null;
}
@Override
public boolean isToggle() {
return false;
}
}
\ No newline at end of file
......@@ -392,6 +392,11 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter {
return PRELOADER_DEFAULT_ASSETS_PATH + screenName + "/" + Utility.transformLocalAssetsPath(DEFAULT_PRELOADER_SPEECH_FILE) + SOUND_FILE_TYPE;
}
//////////////////////////// SOUND
public boolean isSoundMandatory() {
return false;
}
//////////////////////////// LOADING LISTENER
......
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