From f3f52956f711658f42ef753b7ff46728da67aa54 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Sun, 29 May 2011 22:24:48 +0200 Subject: Tested and implemented player type selection in the settings panel git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@317 72836036-5685-4462-b002-a69064685172 --- src/jrummikub/view/ISettingsPanel.java | 10 ++++++++++ src/jrummikub/view/impl/SettingsPanel.java | 14 +++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src/jrummikub/view') diff --git a/src/jrummikub/view/ISettingsPanel.java b/src/jrummikub/view/ISettingsPanel.java index 28faec6..cc1431d 100644 --- a/src/jrummikub/view/ISettingsPanel.java +++ b/src/jrummikub/view/ISettingsPanel.java @@ -2,6 +2,8 @@ package jrummikub.view; import java.awt.Color; +import jrummikub.control.turn.TurnControlFactory; +import jrummikub.control.turn.TurnControlFactory.Type; import jrummikub.model.GameSettings; import jrummikub.util.IEvent; import jrummikub.util.IEvent1; @@ -64,6 +66,14 @@ public interface ISettingsPanel { */ public IEvent2 getChangePlayerNameEvent(); + /** + * The change player color event is emitted when the user wants change a + * player's type + * + * @return the event + */ + public IEvent2 getChangePlayerTypeEvent(); + /** * The change initial meld threshold event is emitted when the user wants * change the initial meld threshold diff --git a/src/jrummikub/view/impl/SettingsPanel.java b/src/jrummikub/view/impl/SettingsPanel.java index a96c5a7..02dfc10 100644 --- a/src/jrummikub/view/impl/SettingsPanel.java +++ b/src/jrummikub/view/impl/SettingsPanel.java @@ -41,6 +41,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import jrummikub.control.turn.TurnControlFactory; +import jrummikub.control.turn.TurnControlFactory.Type; import jrummikub.model.GameSettings; import jrummikub.model.PlayerSettings; import jrummikub.util.Event; @@ -312,10 +313,12 @@ class SettingsPanel extends JPanel implements ISettingsPanel { nameField.setText(settings.getName()); } // playerType.setSelectedIndex(0); - playerType.setSelectedIndex(Arrays.binarySearch( + int index = Arrays.binarySearch( TurnControlFactory.Type.values(), - settings.getTurnControlType())); - + settings.getTurnControlType()); + if (index != playerType.getSelectedIndex()) { + playerType.setSelectedIndex(index); + } colorButton.setIcon(ImageUtil.createColorIcon(settings.getColor(), 16, 2)); } @@ -494,4 +497,9 @@ class SettingsPanel extends JPanel implements ISettingsPanel { public void setJokerNumber(int jokerNumber) { jokerNumberSpinner.setValue(jokerNumber); } + + @Override + public IEvent2 getChangePlayerTypeEvent() { + return changePlayerTypeEvent; + } } -- cgit v1.2.3