Commit 6fbfd849 authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

Merge branch 'desktop-exit-button' into 'V3.7'

Desktop exit button

See merge request !647
parents db0ab749 4e1e10a8
......@@ -286,6 +286,8 @@ user_rank_11=Vrchní rada
sync_request_dialog_text=Zadej číslo průkazu:
sync_request_qr_dialog_text=Zadej číslo průkazu nebo naskenuj QR kód, který nalezneš ve svém profilu.
sync_request_button=Synchronizovat uživatele
exit_app_button=Ukončit aplikaci
exit_app_message=Opravdu chceš ukončit aplikaci?
sync_request_wrong_id=Špatně zadaný kód.
sync_request_error=Synchronizace se nezdařila, zkuste to prosím později.
sync_qr_request_button=Synchronizovat uživatele (QR)
......
......@@ -287,6 +287,8 @@ user_rank_11=Oberrat
sync_request_dialog_text=Trage deine Ausweisnummer ein:
sync_request_qr_dialog_text=Trage deine Ausweisnummer ein oder scanne den QR-Code ein, den du in deinem Profil findest.
sync_request_button=Account synchronisieren
exit_app_button=App beenden
exit_app_message=Möchtest du die App wirklich beenden?
sync_request_wrong_id=Falsch geschriebener Code.
sync_request_error=Die Synchronisierung ist fehlgeschlagen, bitte versuche es später noch einmal.
sync_qr_request_button=Account synchronisieren (QR)
......
......@@ -287,6 +287,8 @@ user_rank_11=Šefmajster
sync_request_dialog_text=Zadaj číslo preukazu:
sync_request_qr_dialog_text=Zadaj číslo preukazu alebo naskenuj QR kód, ktorý nájdeš vo svojom profile.
sync_request_button=Synchronizovať užívateľa
exit_app_button=Ukončiť aplikáciu
exit_app_message=Naozaj chceš ukončiť aplikáciu?
sync_request_wrong_id=Zle zadaný kód.
sync_request_error=Synchronizácia sa nepodarila, skúste to prosím neskôr.
sync_qr_request_button=Synchronizovať užívateľa (QR)
......
......@@ -67,6 +67,8 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp
public static final String MAINMENU_ICON_PROFILE_UNPRESSED = MAINMENU_PATH + "icon_profile_unpressed";
public static final String MAINMENU_ICON_LOGOUT_PRESSED = MAINMENU_PATH + "icon_logout_pressed";
public static final String MAINMENU_ICON_LOGOUT_UNPRESSED = MAINMENU_PATH + "icon_logout_unpressed";
public static final String MAINMENU_ICON_EXIT_PRESSED = MAINMENU_PATH + "icon_exit_pressed";
public static final String MAINMENU_ICON_EXIT_UNPRESSED = MAINMENU_PATH + "icon_exit_unpressed";
public static final String MAINMENU_ICON_STATISTICS_PRESSED = MAINMENU_PATH + "icon_statistics_pressed";
public static final String MAINMENU_ICON_STATISTICS_UNPRESSED = MAINMENU_PATH + "icon_statistics_unpressed";
public static final String MAINMENU_CHILDITEM_BACKGROUND = MAINMENU_PATH + "childitem_background";
......
......@@ -148,6 +148,9 @@ public class ApplicationTextManager extends TablexiaDataManager<I18NBundle> impl
public static final String SYNC_REQUEST_WRONG_ID = "sync_request_wrong_id";
public static final String SYNC_REQUEST_ERROR = "sync_request_error";
public static final String EXIT_APP_BUTTON = "exit_app_button";
public static final String EXIT_MESSAGE = "exit_app_message";
public static final String USER_RANK_1 = "user_rank_1";
public static final String USER_RANK_2 = "user_rank_2";
public static final String USER_RANK_3 = "user_rank_3";
......
......@@ -39,6 +39,8 @@ import cz.nic.tablexia.screen.gamemenu.OfficeMenuScreen;
import cz.nic.tablexia.screen.halloffame.HallOfFameScreen;
import cz.nic.tablexia.screen.profile.ProfileScreen;
import cz.nic.tablexia.screen.statistics.StatisticsScreen;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialogFactory;
public enum MainMenuDefinition implements IMenuItem {
......@@ -77,19 +79,26 @@ public enum MainMenuDefinition implements IMenuItem {
if(!Tablexia.getActualScreen().handleScreenExit(null, logoutAction)) logoutAction.run();
}
},
EXIT (true, new String[]{ApplicationAtlasManager.MAINMENU_ICON_EXIT_UNPRESSED, ApplicationAtlasManager.MAINMENU_ICON_EXIT_PRESSED}, ApplicationTextManager.ApplicationTextsAssets.EXIT_APP_BUTTON, null, AbstractMenu.MenuAction.CLOSE, null) {
@Override
public void performAction() {
TablexiaComponentDialog exitDialog = TablexiaComponentDialogFactory.getInstance().createExitDialog();
exitDialog.show(TablexiaComponentDialogFactory.WARNING_DIALOG_WIDTH, TablexiaComponentDialogFactory.WARNING_DIALOG_HEIGHT);
}
};
private static final Class<MainMenuItemGroup> MENU_ITEM_GROUP_CLASS = MainMenuItemGroup.class;
private boolean debug;
private boolean desktopOnly;
private String[] icons;
private String menuTextKey;
private IMenuItem[] submenu;
private AbstractMenu.MenuAction menuAction;
private ApplicationEvent action;
MainMenuDefinition(boolean debug, String[] icons, String nameResource, IMenuItem[] submenu, AbstractMenu.MenuAction menuAction, ApplicationEvent action) {
this.debug = debug;
MainMenuDefinition(boolean desktopOnly, String[] icons, String nameResource, IMenuItem[] submenu, AbstractMenu.MenuAction menuAction, ApplicationEvent action) {
this.desktopOnly = desktopOnly;
this.icons = icons;
this.menuTextKey = nameResource;
this.submenu = submenu;
......@@ -137,10 +146,9 @@ public enum MainMenuDefinition implements IMenuItem {
public static List<MainMenuDefinition> getItemsForMenu() {
List<MainMenuDefinition> mainMenu = new ArrayList<MainMenuDefinition>();
for (MainMenuDefinition mainMenuDefinition : MainMenuDefinition.values()) {
if (TablexiaSettings.getInstance().getBuildType().isDebugMenu() || !mainMenuDefinition.debug) {
if(!mainMenuDefinition.desktopOnly || TablexiaSettings.getInstance().getPlatform() == TablexiaSettings.Platform.DESKTOP)
mainMenu.add(mainMenuDefinition);
}
}
return mainMenu;
}
}
......@@ -39,7 +39,6 @@ import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.bus.event.DeleteUserSynchronizationEvent;
import cz.nic.tablexia.bus.event.MenuControlEvent;
import cz.nic.tablexia.loader.application.ApplicationAvatarManager;
import cz.nic.tablexia.game.ranksystem.UserRankManager;
......@@ -54,7 +53,6 @@ import cz.nic.tablexia.sync.RestSynchronizationService;
import cz.nic.tablexia.sync.work.DownloadUser;
import cz.nic.tablexia.sync.work.PushDataToServer;
import cz.nic.tablexia.sync.work.SyncWork;
import cz.nic.tablexia.util.ui.ClickListenerWithSound;
import cz.nic.tablexia.util.ui.button.StandardTablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialog;
import cz.nic.tablexia.util.ui.dialog.TablexiaComponentDialogFactory;
......@@ -206,6 +204,31 @@ public class UserMenu extends AbstractMenu {
menuItemsLayout.addActor(userDownload);
menuItemsLayout.expand().fill();
if(TablexiaSettings.getInstance().getPlatform() == TablexiaSettings.Platform.DESKTOP) {
final UserMenuExitSelectBoxItemGroup exitApp = new UserMenuExitSelectBoxItemGroup() {
@Override
public void performAction() {
TablexiaComponentDialog exitDialog = TablexiaComponentDialogFactory.getInstance().createExitDialog();
exitDialog.show(TablexiaComponentDialogFactory.WARNING_DIALOG_WIDTH, TablexiaComponentDialogFactory.WARNING_DIALOG_HEIGHT);
}
@Override
public User getUser() {
return null;
}
};
exitApp.setSize(userMenuItemWidth, USER_ITEM_HEIGHT);
exitApp.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
ApplicationInternalSoundManager.getInstance().getSound(ApplicationInternalSoundManager.BUTTON_CLICKED).play();
exitApp.performAction();
}
});
menuItemsLayout.addActor(exitApp);
menuItemsLayout.expand().fill();
}
scrollPane = new ScrollPane(menuItemsLayout);
container = new Container<>(scrollPane);
container.align(Align.top);
......
/*
* Copyright (C) 2017 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.menu.user;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Align;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.main.user.UserSelectBox;
import cz.nic.tablexia.util.ui.TablexiaLabel;
/**
* Created by Aneta Steimarová on 1.2.18.
*/
public abstract class UserMenuExitSelectBoxItemGroup extends Actor implements UserSelectBox.UserSelectBoxItem {
private static final String EXIT_APP_TEXT_KEY = ApplicationTextManager.ApplicationTextsAssets.EXIT_APP_BUTTON;
private static final ApplicationFontManager.FontType EXIT_APP_TEXT_FONT = ApplicationFontManager.FontType.BOLD_20;
private static final Color EXIT_APP_TEXT_COLOR = new Color(0.098f, 0.086f, 0.075f, 1f);
private static final int EXIT_APP_TEXT_ALIGN = Align.center;
private final NinePatch background;
private TablexiaLabel textLabel;
public UserMenuExitSelectBoxItemGroup() {
background = ApplicationAtlasManager.getInstance().getPatch(ApplicationAtlasManager.USERMENU_MENUBUTTON_BACKGROUND);
textLabel = new TablexiaLabel(ApplicationTextManager.getInstance().getText(EXIT_APP_TEXT_KEY), new TablexiaLabel.TablexiaLabelStyle(EXIT_APP_TEXT_FONT, EXIT_APP_TEXT_COLOR));
textLabel.setAlignment(EXIT_APP_TEXT_ALIGN);
}
public abstract void performAction();
@Override
public void draw(Batch batch, float parentAlpha) {
EXIT_APP_TEXT_COLOR.a = parentAlpha;
background.draw(batch, getX(), getY(), getWidth(), getHeight());
textLabel.setBounds(getX(), getY(), getWidth(), getHeight());
textLabel.draw(batch, parentAlpha);
}
}
......@@ -17,6 +17,7 @@
package cz.nic.tablexia.util.ui.dialog;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
......@@ -28,6 +29,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
......@@ -99,6 +101,24 @@ public class TablexiaComponentDialogFactory implements Disposable {
return createWarningYesNoDialog(text, yesInputListener, null, hideOnBackButton, true);
}
public TablexiaComponentDialog createExitDialog() {
return TablexiaComponentDialogFactory.getInstance().createWarningYesNoDialog(
ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.EXIT_MESSAGE),
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
},
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Tablexia.getActualScreen().resetExitDialogState();
}
},
true, true);
}
public TablexiaComponentDialog createWarningYesNoDialog(String text, InputListener yesInputListener, InputListener noInputListener, boolean hideOnBackButton, boolean useOnce) {
ArrayList<TablexiaDialogComponentAdapter> adapters = new ArrayList<TablexiaDialogComponentAdapter>();
......
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