22 package com.realtime.crossfire.jxclient.window;
35 import java.awt.Frame;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
117 @SuppressWarnings(
"FieldCanBeLocal")
121 public void start() {
126 public void metaserver() {
131 public void preConnecting(@NotNull
final String serverInfo) {
136 public void connecting(@NotNull
final String serverInfo) {
146 public void connected() {
151 public void connectFailed(@NotNull
final String reason) {
164 public void pickupChanged(
final int pickupOptions) {
194 public void setFrame(@Nullable
final Frame frame) {
221 if (this.character == null ? character == null : this.character.equals(character)) {
228 if (hostname != null && this.character != null) {
232 settings.
remove(
"pickup_"+hostname+
"_"+this.character);
241 if (hostname != null && character != null) {
243 assert hostname != null;
253 @SuppressWarnings(
"IfMayBeConditional")
259 if (hostname == null) {
261 }
else if (character == null) {
262 title = TITLE_PREFIX+
" - "+
hostname;
264 title = TITLE_PREFIX+
" - "+hostname+
" - "+
character;
266 frame.setTitle(title);
273 public void setHost(@Nullable
final String serverInfo) {
274 @Nullable
final String newHostname;
276 if (serverInfo == null) {
281 final String[] tmp = serverInfo.split(
":", 2);
282 newHostname = tmp[0];
286 if ((
hostname == null ? newHostname == null :
hostname.equals(newHostname)) &&
port == newPort) {
String hostname
The currently connected server.
Frame frame
The Frame for updating the title or.
Interface for listeners interested gui state changes.
Maintains the current GuiState.
void remove(@NotNull final String key)
Removes a key.
void connect()
Connects to the Crossfire server.
void addCrossfirePickupListener(@NotNull CrossfirePickupListener listener)
Adds a listener to be notified about received "pickup" messages.
long getLong(@NotNull final SettingsEntry< Long > key)
Returns the long associated with the specified key at a node or.
final Logger logger
The Logger that is notified about changed server names.
long getPickupMode()
Returns the pickup mode.
String getHostname()
Returns the currently connected server.
final CrossfirePickupListener crossfirePickupListener
The CrossfirePickupListener for tracking pickup mode changes.
JXCConnection(@NotNull final KeybindingsManager keybindingsManager, @NotNull final Shortcuts shortcuts, @NotNull final Settings settings, @NotNull final Pickup characterPickup, @NotNull final CrossfireServerConnection server, @NotNull final GuiStateManager guiStateManager, @NotNull final Logger logger)
Creates a new instance.
static final int DEFAULT_CROSSFIRE_PORT
The default port number for Crossfire servers.
static void loadShortcuts(@NotNull final Shortcuts shortcuts, @NotNull final CharSequence hostname, @NotNull final CharSequence character)
Load shortcut info from the backing file.
void setHostname(@Nullable final String hostname)
Updates the hostname.
Defines constants for pickup mode.
void setCharacter(@Nullable final String character)
Updates the active character name.
int getPort()
Returns the currently connected port.
static void saveShortcuts(@NotNull final Shortcuts shortcuts)
Save all shortcut info to the backing file.
final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.
void disconnect(@NotNull String reason)
Disconnects from the server.
void putLong(@NotNull final SettingsEntry< Long > key, final long value)
Stores a key/value pair.
All defined entries in the settings file.
Maintains a set of key/value pairs.
Interface for listeners interested in "pickup" messages.
String character
The currently logged in character.
static int parseInt(@NotNull final String string, final int defaultValue)
Converts a string into an int value.
void connect(@NotNull String hostname, int port)
Attempts to connect the client to a server.
final CrossfireServerConnection server
The CrossfireServerConnection instance used to connect to the Crossfire server.
static final String TITLE_PREFIX
The prefix for the window title.
void disconnect(@NotNull final String reason)
Disconnects from the Crossfire server.
static SettingsEntry< Long > getPickupSettingsEntry(@NotNull final String hostname, @NotNull final String characterName)
Returns the SettingsEntry for the default pickup mode of a character.
void setFrame(@Nullable final Frame frame)
Sets the Frame for updating the title.
Utility class for parsing strings into numbers.
void setHost(@Nullable final String serverInfo)
Updates information about the connected host.
final Settings settings
The settings instance to use.
void putString(@NotNull final SettingsEntry<?> key, @NotNull final String value)
Stores a key/value pair.
Logs received messages to a file.
static final SettingsEntry< String > SERVER
The server to which the previous connection was made.
void unloadPerCharacterBindings()
Unloads (clears and saves) the per-character key bindings.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
final Pickup characterPickup
The Pickup instance to update.
void updateTitle()
Updates the window title to reflect the current connection state.
static final long PU_NOTHING
Pickup mode: nothing.
void removeCrossfirePickupListener(@NotNull CrossfirePickupListener listener)
Removes a listener to be notified about received "pickup" messages.
final Shortcuts shortcuts
The Shortcuts to update.
Manages a list of Shortcuts.
Connection progress states of the Crossfire server connection.
void loadPerCharacterBindings(@NotNull final CharSequence hostname, @NotNull final CharSequence character)
Loads the per-character key bindings.
int port
The currently connected port.
void updatePickupMode(final long pickupMode, final boolean sendToServer)
Sets the pickup mode.
final KeybindingsManager keybindingsManager
The KeybindingsManager to update.