Commit 247d2120 authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

#58 Remove dialog moved to initial screen. Minor fixes.

parent 2262592d
......@@ -19,7 +19,7 @@ mainmenu_screendebug=Debug Screen
mainmenu_panorama=Panorama
usermenu_newuser=+ Nový detektiv
usermenu_deleteuser= Smazat uživatele
usermenu_deleteuser= Opravdu chceš smazat uživatele
usermenu_dialog_yes = Ano
usermenu_dialog_no = Ne
......
......@@ -20,7 +20,7 @@ mainmenu_panorama=Panorama
usermenu_newuser=+ Neuer Detektiv
usermenu_deleteuser=Benutzer löschen
usermenu_deleteuser=Möchtest du dieses Profil wirklich löschen
usermenu_dialog_yes=Ja
usermenu_dialog_no=Nein
preloader_title=Wie spielt man?
......
......@@ -20,7 +20,7 @@ mainmenu_panorama=Panorama
usermenu_newuser=+ Nový detektív
usermenu_deleteuser=Zmazať užívateľa ?
usermenu_deleteuser=Naozaj chceš zmazať užívateľa
usermenu_dialog_yes=Áno
usermenu_dialog_no=Nie
preloader_title=Ako hrať?
......@@ -42,7 +42,7 @@ game_score_error=Počet chýb:
game_score_duration=Trvanie hry:
game_averagescore=Priemerný počet bodov:
game_averagescore_error=Priemerný počet chýb:
game_averagescore_duration=Priemerné trvanie hry:
game_averagescore_duration=Priemerné trvanie hry\:
game_robbery_title=Lupiči
game_robbery_description=Precvičovanie pracovnej pamäti
......
......@@ -3,10 +3,7 @@ package cz.nic.tablexia.menu.main.user;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import net.engio.mbassy.listener.Handler;
......@@ -19,16 +16,11 @@ import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.loader.application.ApplicationAtlasManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.user.UserMenuNewSelectBoxItemGroup;
import cz.nic.tablexia.menu.user.UserMenuSelectBoxItemGroup;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.screen.createuser.PanoramaScreen;
import cz.nic.tablexia.util.ui.AbstractTablexiaSelectBox;
import cz.nic.tablexia.util.ui.ClickListenerWithSound;
import cz.nic.tablexia.util.ui.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.DialogFactory;
import cz.nic.tablexia.util.ui.dialog.TextDialog;
/**
* Created by Matyáš Latner.
......@@ -53,10 +45,6 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS
private static final Color FOREGROUND_COLOR = new Color(0.322f, 0.278f, 0.255f, 1f);
private static final int ITEMS_OVERLAP_SIZE = 1;
private static final int BUTTON_OK_ID = 0;
private static final int BUTTON_CANCEL_ID = 1;
private static final int BUTTON_WIDTH = 100;
private static final int BUTTON_SPACE = 15;
private TextureRegionDrawable triangle;
private TextureRegionDrawable selector;
......@@ -71,48 +59,6 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS
};
private final ActorGestureListener gestureListener = new ActorGestureListener() {
@Override
public void touchDown(InputEvent event, float x, float y, int pointer, int button) {
super.touchDown(event, x, y, pointer, button);
}
@Override
public boolean longPress(Actor actor, float x, float y) {
final int index = Math.min(getItems().size - 1, (int) ((getList().getHeight() - y) / getList().getItemHeight()));
final UserMenuSelectBoxItemGroup selected = (UserMenuSelectBoxItemGroup) getItems().get(index);
if (!TablexiaSettings.getInstance().getSelectedUser().equals(selected.getUser())) {
// TODO: 12.1.16 rework dialog
// TODO: 12.1.16 check DE/SK delete user text
final TextDialog dialog = DialogFactory.createSquerBorderDialog(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_DELETE_USER) + " " + selected.getUser().getName() + " ?");
TablexiaButton buttonCancel = new TablexiaButton(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_DIALOGUE_NO), TablexiaButton.ButtonType.RED);
TablexiaButton buttonOK = new TablexiaButton(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_DIALOGUE_YES), TablexiaButton.ButtonType.GREEN);
buttonOK.setUserObject(BUTTON_OK_ID);
buttonCancel.setUserObject(BUTTON_CANCEL_ID);
ClickListener clickListener = new ClickListenerWithSound() {
@Override
public void onClick(InputEvent event, float x, float y) {
if (event.getListenerActor().getUserObject().equals(BUTTON_OK_ID)) {
selected.getUser().setDeleted(true);
User.updateUser(selected.getUser());
prepareActiveUsers();
}
dialog.hide();
}
};
buttonCancel.addListener(clickListener);
buttonOK.addListener(clickListener);
buttonOK.setDisabled(true);
buttonCancel.setDisabled(true);
dialog.add(buttonOK).width(BUTTON_WIDTH).spaceRight(BUTTON_SPACE);
dialog.add(buttonCancel).width(BUTTON_WIDTH).spaceLeft(BUTTON_SPACE);
dialog.setPosition(getStage().getWidth() / 2 - dialog.getWidth() / 2, getStage().getHeight() / 2 - dialog.getHeight() / 2);
dialog.show(getStage());
}
return true;
}
};
public UserSelectBox(float itemHeight) {
super(itemHeight);
ApplicationBus.getInstance().subscribe(this);
......@@ -125,7 +71,6 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS
private void prepareActiveUsers() {
removeCaptureListener(changeListener);
removeListener(gestureListener);
UserMenuSelectBoxItemGroup selectedUserItem = null;
List<UserSelectBoxItem> userItems = new ArrayList<UserSelectBoxItem>();
for (User user: User.selectActiveUsers()) {
......@@ -147,7 +92,6 @@ public class UserSelectBox extends AbstractTablexiaSelectBox<UserSelectBox.UserS
setSelected(selectedUserItem);
}
addCaptureListener(changeListener);
getList().addListener(gestureListener);
}
@Override
......
package cz.nic.tablexia.menu.user;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Container;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import net.engio.mbassy.listener.Handler;
......@@ -13,11 +17,16 @@ import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaApplication;
import cz.nic.tablexia.bus.ApplicationBus;
import cz.nic.tablexia.bus.event.MenuControlEvent;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.loader.application.ApplicationSoundManager;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.IMenuItem;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.screen.createuser.PanoramaScreen;
import cz.nic.tablexia.util.ui.ClickListenerWithSound;
import cz.nic.tablexia.util.ui.TablexiaButton;
import cz.nic.tablexia.util.ui.dialog.TablexiaDialog;
/**
* UserMenu container
......@@ -29,6 +38,10 @@ public class UserMenu extends AbstractMenu {
private static final MenuControlType MENU_CONTROL_TYPE = MenuControlType.AUTOMATIC;
private static final boolean MENU_SCREEN_PAUSE = false;
private static final int USER_ITEM_HEIGHT = 80;
private static final int DIALOGUE_WIDTH = 480;
private static final int DIALOGUE_HEIGHT = 180;
private static final int BUTTON_OK_ID = 0;
private static final int BUTTON_CANCEL_ID = 1;
public UserMenu(Float width, Float height) {
super(width, height);
......@@ -47,19 +60,53 @@ public class UserMenu extends AbstractMenu {
@Override
public void initMenuItems(Container<Group> layoutContainer) {
VerticalGroup menuItemsLayout = new VerticalGroup();
final VerticalGroup menuItemsLayout = new VerticalGroup();
ScrollPane scrollPane = new ScrollPane(menuItemsLayout);
Container<ScrollPane> container = new Container<ScrollPane>(scrollPane);
final ScrollPane scrollPane = new ScrollPane(menuItemsLayout);
final Container<ScrollPane> container = new Container<ScrollPane>(scrollPane);
container.setFillParent(true);
final float userMenuItemWidth = getBackground().getWidth();
for (final IMenuItem menuItem : User.selectActiveUsers()) {
Group userItemGroup = getGroupForMenuItem(menuItem, getWidth());
final Group userItemGroup = getGroupForMenuItem(menuItem, getWidth());
userItemGroup.setSize(userMenuItemWidth, USER_ITEM_HEIGHT);
userItemGroup.addListener(new ClickListener() {
userItemGroup.addListener(new ActorGestureListener() {
@Override
public boolean longPress(Actor actor, float x, float y) {
int index = menuItemsLayout.getChildren().indexOf(actor, false);
final User selected = User.selectActiveUsers().get(index);
// TODO: 12.1.16 rework dialog
String dialogText = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_DELETE_USER) + " " + selected.getName() + "?";
Label dialogLabel = new Label(dialogText,new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_18), Color.BLACK));
final TablexiaDialog dialog = new TablexiaDialog(getStage().getWidth() / 2 - DIALOGUE_WIDTH / 2, getStage().getHeight() / 2 - DIALOGUE_HEIGHT / 2,DIALOGUE_WIDTH,DIALOGUE_HEIGHT, TablexiaDialog.BackGroundType.DIALOG_SQUARE);
dialog.center();
TablexiaButton buttonCancel = new TablexiaButton(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_DIALOGUE_NO), TablexiaButton.ButtonType.RED);
TablexiaButton buttonOK = new TablexiaButton(ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.USERMENU_DIALOGUE_YES), TablexiaButton.ButtonType.GREEN);
dialog.button(buttonOK);
dialog.button(buttonCancel);
dialog.text(dialogLabel);
buttonOK.setUserObject(BUTTON_OK_ID);
buttonCancel.setUserObject(BUTTON_CANCEL_ID);
ClickListener clickListener = new ClickListenerWithSound() {
@Override
public void onClick(InputEvent event, float x, float y) {
if (event.getListenerActor().getUserObject().equals(BUTTON_OK_ID)) {
selected.setDeleted(true);
User.updateUser(selected);
menuItemsLayout.removeActor(userItemGroup);
}
dialog.hide();
}
};
buttonCancel.addListener(clickListener);
buttonOK.addListener(clickListener);
buttonOK.setDisabled(true);
buttonCancel.setDisabled(true);
dialog.show(getStage());
return true;
}
@Override
public void clicked(InputEvent event, float x, float y) {
public void tap(InputEvent event, float x, float y, int count, int button) {
ApplicationSoundManager.getInstance().getSound(ApplicationSoundManager.MAINMENU_BUTTON).play();
doMenuAction(menuItem.getMenuAction(), true, true);
menuItem.performAction();
......
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