Skip to content

Commit

Permalink
Merge branch 'develop' of bitbucket.org:bitbmp/oop17-perudo into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lory696 committed Mar 19, 2017
2 parents 837be46 + 3021de1 commit c568c1e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/perudo/view/swing/components/TopMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import perudo.model.User;
import perudo.view.swing.panels.menu.ChangeNamePanel;
import perudo.view.swing.panels.menu.CreateLobbyPanel;
Expand Down Expand Up @@ -50,7 +52,8 @@ public TopMenu() {

final JMenu perudoMenu = (JMenu) factory.createMenu(MENU_PERUDO);
perudoMenu.setMnemonic(KeyEvent.VK_P);
final JMenuItem miBackMenu = (JMenuItem) factory.createMenuItem(MENU_PERUDO_BACKTOMENU, KeyEvent.VK_B, MENU_PERUDO_BACKTOMENU_TOOLTIP);
final JMenuItem miBackMenu = (JMenuItem) factory.createMenuItem(MENU_PERUDO_BACKTOMENU, KeyEvent.VK_B,
MENU_PERUDO_BACKTOMENU_TOOLTIP);
miBackMenu.addActionListener(e -> {
if (this.user.isPresent()) {
this.returnMenu = true;
Expand Down Expand Up @@ -79,8 +82,13 @@ public TopMenu() {
miCreateLobby.addActionListener(e -> {
final int n = JOptionPane.showConfirmDialog(TopMenu.this, pnlcreatelobby, CreateLobbyPanel.TITLE,
JOptionPane.OK_CANCEL_OPTION, 0, Icon.APPLICATION_ICON.getIcon());
if (n == JOptionPane.YES_OPTION && this.user.isPresent()) {
ControllerSingleton.getController().createLobby(this.user.get(), pnlcreatelobby.getGameSettings());
if (n == JOptionPane.YES_OPTION && this.user.isPresent() && pnlcreatelobby.getName().trim().length() > 0) {
try {
ControllerSingleton.getController().createLobby(this.user.get(), pnlcreatelobby.getGameSettings());
} catch (IllegalArgumentException ex) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(this), ex.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
}
}
});
lobbyMenu.add(miCreateLobby);
Expand Down
2 changes: 1 addition & 1 deletion src/perudo/view/swing/panels/menu/CreateLobbyPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CreateLobbyPanel extends JPanel {
* Panel icon respath.
*/
public static final String ICON_RESPATH = "/images/perudo-logo.png";
private static final String DEFAULT_NAME = "Default lobby";
private static final String DEFAULT_NAME = "DefaultLobby";
private static final String LABEL_NAME = "Name";
private static final String LABEL_PLAYERS_NUM = "Max players";
private static final String LABEL_DICES_NUM = "Max dices";
Expand Down
9 changes: 7 additions & 2 deletions src/perudo/view/swing/panels/menu/LobbyListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
import perudo.model.Lobby;
import perudo.model.User;
Expand All @@ -34,7 +35,6 @@ public class LobbyListPanel extends JPanel {
private static final String CREATE_LOBBY_BUTTON_TEXT = "Create new lobby";
private static final String CHANGE_NAME_BUTTON_TEXT = "Change username";


private final JPanel pnlLobbyList;
private final GridBagConstraints cnst;
private Optional<User> user;
Expand Down Expand Up @@ -66,7 +66,12 @@ public LobbyListPanel() {
final int n = JOptionPane.showConfirmDialog(this, pnlCreateLobby, CreateLobbyPanel.TITLE,
JOptionPane.OK_CANCEL_OPTION, 0, Icon.APPLICATION_ICON.getIcon());
if (n == JOptionPane.YES_OPTION && this.user.isPresent() && pnlCreateLobby.getName().trim().length() > 0) {
ControllerSingleton.getController().createLobby(this.user.get(), pnlCreateLobby.getGameSettings());
try {
ControllerSingleton.getController().createLobby(this.user.get(), pnlCreateLobby.getGameSettings());
} catch (IllegalArgumentException ex) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(this), ex.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
}
}
});
paneldown.add(btnCreateLobby);
Expand Down

0 comments on commit c568c1e

Please sign in to comment.