Crossfire JXClient, Trunk  R20561
GuiManagerCommandCallback.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.main;
23 
29 import org.jetbrains.annotations.NotNull;
30 
35 public class GuiManagerCommandCallback implements CommandCallback {
36 
40  @NotNull
41  private final Exiter exiter;
42 
46  @NotNull
48 
52  @NotNull
54 
59  @NotNull
60  private String lastAccountPassword = "";
61 
67  public GuiManagerCommandCallback(@NotNull final Exiter exiter, @NotNull final CrossfireServerConnection server) {
68  this.exiter = exiter;
69  this.server = server;
70  }
71 
76  @Deprecated
77  public void init(@NotNull final GuiManager guiManager) {
78  this.guiManager = guiManager;
79  }
80 
84  @Override
85  public void quitApplication() {
86  exiter.terminate();
87  }
88 
92  @Override
93  public void openDialog(@NotNull final String dialog) {
94  guiManager.openDialog(dialog);
95  }
96 
100  @Override
101  public void toggleDialog(@NotNull final String dialog) {
102  guiManager.toggleDialog(dialog);
103  }
104 
108  @Override
109  public void closeDialog(@NotNull final String dialog) {
110  guiManager.closeDialog(dialog);
111  }
112 
116  @NotNull
117  @Override
118  public CommandList getCommandList(@NotNull final String args) throws NoSuchCommandException {
119  return guiManager.getCommandList(args);
120  }
121 
125  @Override
126  public void updatePlayerName(@NotNull final String playerName) {
127  guiManager.updatePlayerName(playerName);
128  }
129 
133  @Override
134  public void activateCommandInput(@NotNull final String newText) {
135  guiManager.activateCommandInput(newText);
136  }
137 
141  @Override
142  public boolean createKeyBinding(final boolean perCharacter, @NotNull final CommandList commandList) {
143  return guiManager.createKeyBinding(perCharacter, commandList);
144  }
145 
149  @Override
150  public boolean removeKeyBinding(final boolean perCharacter) {
151  return guiManager.removeKeyBinding(perCharacter);
152  }
153 
157  @Override
158  public void accountLogin(@NotNull final String login, @NotNull final String password) {
159  server.sendAccountLogin(login, password);
160  lastAccountPassword = password;
161  }
162 
166  @Override
167  public void accountCreate(@NotNull final String login, @NotNull final String password) {
168  server.sendAccountCreate(login, password);
169  lastAccountPassword = password;
170  }
171 
175  @Override
176  public void accountPlayCharacter(@NotNull final String name) {
177  server.sendAccountPlay(name);
178  }
179 
183  @Override
184  public void accountLink(final int force, @NotNull final String login, @NotNull final String password) {
185  server.sendAccountLink(force, login, password);
186  }
187 
191  @Override
192  public void accountCreateCharacter(@NotNull final String login) {
193  server.sendAccountCharacterCreate(login, lastAccountPassword);
194  }
195 
199  @Override
200  public void accountPassword(@NotNull final String currentPassword, @NotNull final String newPassword) {
201  server.sendAccountPassword(currentPassword, newPassword);
202  }
203 
204 }
String lastAccountPassword
The last sent account or character password.
void sendAccountPassword(@NotNull String currentPassword, @NotNull String newPassword)
Sends a request to change the account's password.
void updatePlayerName(@NotNull final String playerName)
Sets the current player name.Does nothing if not currently in the character name prompt. the player name
void activateCommandInput(@NotNull final String newText)
Activates the command input text field.If the skin defines more than one input field, the first matching one is selected. If neither the main gui nor any visible dialog has an input text field, invisible GUIs are checked as well. If one is found, it is made visible. the new command text if non-null
void sendAccountLink(int force, @NotNull String login, @NotNull String password)
Sends a request to add an existing character to an account.
void init(@NotNull final GuiManager guiManager)
Creates a new instance.
void sendAccountLogin(@NotNull String login, @NotNull String password)
Asks for an account login.
boolean createKeyBinding(final boolean perCharacter, @NotNull final CommandList cmdList)
Adds a key binding.
void accountLogin(@NotNull final String login, @NotNull final String password)
Login to an account.login password
void openDialog(@NotNull final String name)
Opens a dialog by name.
void updatePlayerName(@NotNull final String playerName)
Sets the current player name.
void toggleDialog(@NotNull final String name)
Toggles a dialog.
void sendAccountCharacterCreate(@NotNull String login, @NotNull String password)
Sends a request to create a new character associated to the account.
void sendAccountCreate(@NotNull String login, @NotNull String password)
Sends a request to create a new account.
CommandList getCommandList(@NotNull final String args)
Returns a named command list.
void accountLink(final int force, @NotNull final String login, @NotNull final String password)
Links a character to the current account.0 to allow failure, 1 to force in certain situations the cha...
void accountPlayCharacter(@NotNull final String name)
Plays a character from the current account.the character's name
GUIText activateCommandInput()
Activates the command input text field.
void accountCreate(@NotNull final String login, @NotNull final String password)
Creates an account.the account's name the account's password
void toggleDialog(@NotNull final String dialog)
Toggles a dialog.the dialog to toggle
boolean removeKeyBinding(final boolean perCharacter)
Removes a key binding.
final CrossfireServerConnection server
The CrossfireServerConnection for sending commands.
void accountCreateCharacter(@NotNull final String login)
Creates a character.The password should be the last from accountLogin or accountCreate. the character's name
boolean removeKeyBinding(final boolean perCharacter)
Removes a key binding.whether a per-character key binding should be removed whether the key bindings ...
Maintains the application's main GUI state.
Definition: GuiManager.java:60
Interface that defines callback functions needed by commands.
boolean createKeyBinding(final boolean perCharacter, @NotNull final CommandList commandList)
Adds a key binding.whether a per-character key binding should be added the command list to execute on...
void closeDialog(@NotNull final String name)
Closes the given dialog.
void terminate()
Terminates the application.
Definition: Exiter.java:41
GuiManagerCommandCallback(@NotNull final Exiter exiter, @NotNull final CrossfireServerConnection server)
Creates a new instance.
Allows to exit the application.
Definition: Exiter.java:30
void openDialog(@NotNull final String dialog)
Opens a dialog.Does nothing if the dialog is open. the dialog to open
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
void accountPassword(@NotNull final String currentPassword, @NotNull final String newPassword)
Change the account password.the current account password the new account password ...
CommandList getCommandList(@NotNull final String args)
Returns a command list.the command list arguments the command list if the command list does not exist...
void sendAccountPlay(@NotNull String name)
Sends a request to play a character from an account.
void closeDialog(@NotNull final String dialog)
Closes a dialog.Does nothing if the dialog is not open. the dialog to close