22 package com.realtime.crossfire.jxclient.main;
98 import java.io.FileOutputStream;
99 import java.io.IOException;
100 import java.io.OutputStreamWriter;
101 import java.io.Writer;
102 import java.lang.reflect.InvocationTargetException;
103 import java.util.MissingResourceException;
104 import java.util.ResourceBundle;
105 import javax.swing.SwingUtilities;
106 import org.jetbrains.annotations.NotNull;
107 import org.jetbrains.annotations.Nullable;
124 public static void main(@NotNull
final String[] args) {
125 Thread.currentThread().setName(
"JXClient:Main");
127 System.out.println(
"JXClient "+buildNumber+
" - Crossfire Java Client");
128 System.out.println(
"(C)2005-2008 by Yann \"Lauwenmark\" Chachkoff.");
129 System.out.println(
"(C)2006-2018 Andreas Kirschbaum.");
130 System.out.println(
"This software is placed under the GPL License");
144 return ResourceBundle.getBundle(
"build").getString(
"build.number");
145 }
catch (
final MissingResourceException ignored) {
158 final Writer debugProtocolOutputStreamWriter =
openDebugStream(options.getDebugProtocolFilename());
160 final Writer debugKeyboardOutputStreamWriter =
openDebugStream(options.getDebugKeyboardFilename());
162 final Writer debugMouseOutputStreamWriter =
openDebugStream(options.getDebugMouseFilename());
164 final Writer debugScreenOutputStreamWriter =
openDebugStream(options.getDebugScreenFilename());
166 final Writer debugSoundOutputStreamWriter =
openDebugStream(options.getDebugSoundFilename());
169 settings.
remove(
"resolution");
171 settings.
remove(
"height");
193 throw new AssertionError(ex);
216 SwingUtilities.invokeAndWait(() -> {
220 final Pickup characterPickup;
222 characterPickup =
new Pickup(commandQueue, optionManager);
224 throw new AssertionError(ex);
245 final File keybindingsFile;
248 }
catch (
final IOException ex) {
249 System.err.println(
"Cannot read keybindings file: "+ex.getMessage());
258 commandCallback.
init(guiManager);
260 final JXCSkinLoader jxcSkinLoader =
new JXCSkinLoader(model, inventoryView, floorView, spellsView, spellSkillsView, facesManager, mapUpdaterState, defaultKeyBindings, optionManager, options.getTileSize(), keybindingsManager, questsView, commandHistoryFactory, knowledgeView, knowledgeTypesView, options.isAvoidCopyArea(), guiManager);
261 final SkinLoader skinLoader =
new SkinLoader(commandCallback, metaserverModel, options.getResolution(), macros, windowRenderer, server, model.
getGuiStateManager(), tooltipManager, commandQueue, jxcSkinLoader, commandExecutor, shortcuts, characterModel, model.
getSmoothFaces(), guiCommandFactory);
266 final KeyHandler keyHandler =
new KeyHandler(debugKeyboardOutputStreamWriter, keybindingsManager, commandQueue, windowRenderer, defaultKeyHandler);
267 window[0] =
new JXCWindow(exiter, server, optionManager, model.
getGuiStateManager(), windowRenderer, commandQueue, guiManager, keyHandler, characterModel, connection);
268 window[0].
init(options.getResolution(), options.getSkin(), options.isFullScreen(), skinLoader);
269 keybindingsManager.loadKeybindings();
270 final String serverInfo = options.getServer();
271 if (serverInfo == null) {
277 exiter.waitForTermination();
278 SwingUtilities.invokeAndWait(window[0]::term);
279 soundManager.shutdown();
284 if (debugSoundOutputStreamWriter != null) {
285 debugSoundOutputStreamWriter.close();
289 if (debugScreenOutputStreamWriter != null) {
290 debugScreenOutputStreamWriter.close();
294 if (debugMouseOutputStreamWriter != null) {
295 debugMouseOutputStreamWriter.close();
299 if (debugKeyboardOutputStreamWriter != null) {
300 debugKeyboardOutputStreamWriter.close();
304 if (debugProtocolOutputStreamWriter != null) {
305 debugProtocolOutputStreamWriter.close();
308 }
catch (
final InterruptedException|InvocationTargetException|IOException ex) {
310 ex.printStackTrace();
312 throw new AssertionError(ex);
325 if (filename == null) {
329 Writer writer = null;
331 final FileOutputStream outputStream =
new FileOutputStream(filename);
334 writer =
new OutputStreamWriter(outputStream,
"UTF-8");
336 if (writer == null) {
337 outputStream.close();
340 }
catch (
final IOException ex) {
341 System.err.println(filename+
": cannot create output file: "+ex.getMessage());
static File getScaledImageCacheDir()
Returns the image cache directory for double size images.
A list to display spell skills.
Provides a view of all quests a character is doing.
static void main(@NotNull final String[] args)
The program entry point.
void remove(@NotNull final String key)
Removes a key.
START
Display the start screen.
Utility class to return references to settings files.
Provides a view of all items in the current player's inventory.
GuiStateManager getGuiStateManager()
SmoothFaces getSmoothFaces()
void init(@NotNull final GuiManager guiManager)
Creates a new instance.
Implements the "bind" command.
Implements the command "clear".
static final boolean DISABLE_START_GUI
TODO: Remove when more options are implemented in the start screen gui.
void start()
Starts operation.
Parser for loading JXCSkin instances from JXCSkinSources.
Implements the map model which is shown in the map and magic map views.
A Comparator that compares CfItem instances in inventory view order.
Maintains a set of named options.
KnowledgeManager getKnowledgeManager()
static String getBuildNumber()
Returns the build number as a string.
Writer debug information to a log file.
This is the entry point for JXClient.
void addOption(@NotNull final String optionName, @NotNull final String documentation, @NotNull final Option option)
Adds a new option.
Manages image information ("faces") needed to display the map view, items, and spell icons...
The main FaceQueue for loading faces.
Helper class to synthesize an "is poisoned" stat value.
Implements the "again" command.
Implements the "scripts" command.
static File getSettingsFile()
Returns the main settings file.
void changeGUI(@NotNull final GuiState guiState)
Sets a new GuiState.
Defines constants for pickup mode.
Displays knowledge items the player knows.
Helper class for creating file names for screenshot files.
Utility class to update a CfMap model from protocol commands.
Monitors stat changes and generates appropriate sound effects.
boolean getBoolean(@NotNull final SettingsEntry< Boolean > key)
Returns the boolean associated with the specified key at a node or.
void addCommand(@NotNull final Command command)
Adds an executable Command.
void connect(@NotNull final String serverInfo)
Connects to a Crossfire server.
Manages macro expansion in command strings.
Combines all model classes that are updated.
Monitors music commands and generates appropriate sound effects.
A disk based cache for image files.
Renders a Gui instance into a Frame.
Maintains currently running script processes.
Provides a view of all spells a character knows.
Tracks a GuiStateManager and updates a JXCConnection's character name.
static File getKeybindingsFile(@Nullable final CharSequence hostname, @Nullable final CharSequence character)
Returns the keybindings file.
Factory for creating Gui instances.
All defined entries in the settings file.
Helper class to synthesize an "active skill" stat value.
Implements the "script" command.
Maintains a set of key/value pairs.
Maintains the application's main GUI state.
Implements the "bindings" command, listing currently active keybindings (for both a character and the...
Handles keyboard input processing.
Update a CfMap model from protocol commands.
static File getOriginalImageCacheDir()
Returns the image cache directory.
Implements the command "set".
Implements the "scripttell" command.
Indicates about an incorrect option.
void setItemsManager(@NotNull final FacesManager facesManager)
Implements the "unbind" command.
static Writer openDebugStream(@Nullable final String filename)
Opens an debug output stream.
Factory for creating GUICommand instances from string representation.
Factory for creating GUICommand instances from string representation.
Default implementation of CrossfireServerConnection.
JXClient(@NotNull final Options options, @NotNull final String buildNumber)
The constructor of the class.
Maintains the character list for an account.
Implements the "scriptkill" command.
Implements the "screenshot" command.
static final SettingsEntry< Boolean > MESSAGE_LOG_SETTINGS_ENTRY
Whether to record of all text messages received from the server.
void init(@Nullable final Resolution resolution, @NotNull final String skinName, final boolean fullScreen, @NotNull final SkinLoader skinLoader)
Initializes the instance: loads and displays the skin.
Tracks a GuiStateManager and resets known faces whenever a new server connection has been established...
Implements the "exec" command.
A FaceQueue requesting faces by "askface" commands sent to the Crossfire server.
Allows to exit the application.
A KeyHandlerListener which updates the state of a GuiManager.
Logs received messages to a file.
Factory for creating CommandHistory instances by name.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
Maintains the pending (ncom) commands sent to the server.
Implements the "debug_messages" command.
METASERVER
Display the server selection screen.
Loader for JXCSkins and attaching them to the client.
SpellsManager getSpellsManager()
Tracks mouse actions and delivers mouse events to affected GUIElement.
Tracks received Crossfire messages and resets the "output-count" setting whenever a player logs in...
void setAskfaceFaceQueue(@NotNull final AskfaceFaceQueue askfaceFaceQueue)
Retrieves Face information by face ID.
void stop()
Stops operation.
Command line argument parser.
void parse(@NotNull final String[] args)
Parse command line arguments.
CommandHistory getCommandHistory(@NotNull final String ident)
Returns a CommandHistory instance by name.
Manages a list of Shortcuts.
A CommandCallback that delegates to a GuiManager.
Manages a set of key bindings.
static File getMetaserverCacheFile()
Returns the metaserver cache file.
QuestsManager getQuestsManager()
Implements the "scriptkillall" command.
Monitors sound and sound2 commands received from the server to generate sound effects.
Provides a view to all items comprising the current floor view.
static File getMagicMapImageCacheDir()
Returns the image cache directory for magic map sized images.
A CheckBoxOption that enables/disables sound support.
Parses and executes client-side commands.
Maintains a mapping of face numbers to face data.