From: Kimmo R. <ki...@us...> - 2011-01-25 20:29:20
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/group In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv28669/src/games/stendhal/client/gui/group Modified Files: GroupPanel.java Log Message: Added an invite button Index: GroupPanel.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/group/GroupPanel.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GroupPanel.java 25 Jan 2011 08:39:40 -0000 1.4 --- GroupPanel.java 25 Jan 2011 20:29:10 -0000 1.5 *************** *** 15,19 **** --- 15,21 ---- import games.stendhal.client.entity.User; import games.stendhal.client.gui.j2DClient; + import games.stendhal.client.gui.chatlog.HeaderLessEventLine; import games.stendhal.client.gui.layout.SBoxLayout; + import games.stendhal.common.NotificationType; import java.awt.Component; *************** *** 43,46 **** --- 45,52 ---- */ private static final int POPUP_OFFSET = 5; + /** Tooltip for inviting members for a new group */ + private static final String START_GROUP_TOOLTIP = "Start a new group"; + /** Tooptip for inviting members to an existing group */ + private static final String INVITE_TOOLTIP = "Invite a new member"; /** The main containing component. */ *************** *** 59,62 **** --- 65,70 ---- /** Button for sending a group message. */ private final JButton messageButton; + /** Button for inviting new members or starting a group */ + private final JButton inviteButton; /** *************** *** 97,105 **** messageButton.setFocusable(false); messageButton.setToolTipText("Send a message to all group members"); ! buttonBox.add(messageButton);; leaveGroupButton = new JButton("Leave"); leaveGroupButton.setEnabled(false); ! leaveGroupButton.addActionListener(new LeaveGroupButtonListener()); leaveGroupButton.setFocusable(false); leaveGroupButton.setToolTipText("Resign from the group"); --- 105,119 ---- messageButton.setFocusable(false); messageButton.setToolTipText("Send a message to all group members"); ! buttonBox.add(messageButton); ! ! inviteButton = new JButton("Invite"); ! inviteButton.setFocusable(false); ! inviteButton.setToolTipText(START_GROUP_TOOLTIP); ! inviteButton.addActionListener(new InviteActionListener()); ! buttonBox.add(inviteButton); leaveGroupButton = new JButton("Leave"); leaveGroupButton.setEnabled(false); ! leaveGroupButton.addActionListener(new LeaveActionListener()); leaveGroupButton.setFocusable(false); leaveGroupButton.setToolTipText("Resign from the group"); *************** *** 110,113 **** --- 124,128 ---- Insets margin = new Insets(oldMargin.top, 1, oldMargin.bottom, 1); messageButton.setMargin(margin); + inviteButton.setMargin(margin); leaveGroupButton.setMargin(margin); } *************** *** 141,144 **** --- 156,165 ---- leaveGroupButton.setEnabled(members != null); messageButton.setEnabled(members != null); + // Disable for now if the user is in a group, and enable it again + // if she is the group leader + inviteButton.setEnabled(members == null); + if (members == null) { + inviteButton.setToolTipText(START_GROUP_TOOLTIP); + } } *************** *** 150,153 **** --- 171,179 ---- void setLeader(String name) { memberList.setLeader(name); + + if (name.equals(User.getCharacterName())) { + inviteButton.setEnabled(true); + inviteButton.setToolTipText(INVITE_TOOLTIP); + } } *************** *** 190,194 **** * Listener for clicking the leave group button. */ ! private static class LeaveGroupButtonListener implements ActionListener { public void actionPerformed(ActionEvent arg0) { String[] args = { "part" }; --- 216,220 ---- * Listener for clicking the leave group button. */ ! private static class LeaveActionListener implements ActionListener { public void actionPerformed(ActionEvent arg0) { String[] args = { "part" }; *************** *** 197,200 **** --- 223,236 ---- } + /** + * Listener for clicking the invite button + */ + private static class InviteActionListener implements ActionListener { + public void actionPerformed(ActionEvent e) { + j2DClient.get().setChatLine("/group invite "); + j2DClient.get().addEventLine(new HeaderLessEventLine("Fill in the name of the player you want to invite", NotificationType.CLIENT)); + } + } + private class MemberListMouseListener extends MouseAdapter { @Override |