22 package com.realtime.crossfire.jxclient.skin.io;
74 import java.awt.Component;
75 import java.io.IOException;
76 import java.io.LineNumberReader;
77 import org.jetbrains.annotations.NotNull;
78 import org.jetbrains.annotations.Nullable;
134 public GUICommand parseCommandArgs(@NotNull
final Args args, @Nullable
final AbstractGUIElement element, @NotNull
final String command, @NotNull
final GuiStateManager guiStateManager, @NotNull
final CommandExecutor commandExecutor, @NotNull
final LineNumberReader lnr, @NotNull
final CommandQueue commandQueue, @NotNull
final CrossfireServerConnection crossfireServerConnection, @NotNull
final CommandCallback commandCallback, @NotNull
final Macros macros)
throws IOException,
JXCSkinException {
135 if (command.equals(
"SHOW")) {
138 if (command.equals(
"HIDE")) {
141 if (command.equals(
"TOGGLE")) {
144 if (command.equals(
"PRINT")) {
147 if (command.equals(
"QUIT")) {
148 return parseQuit(element, commandCallback);
150 if (command.equals(
"CONNECT")) {
153 if (command.equals(
"DISCONNECT")) {
156 if (command.equals(
"GUI_META")) {
159 if (command.equals(
"GUI_START")) {
162 if (command.equals(
"GUI_EXECUTE_ELEMENT")) {
165 if (command.equals(
"DIALOG_OPEN")) {
168 if (command.equals(
"DIALOG_TOGGLE")) {
171 if (command.equals(
"DIALOG_CLOSE")) {
174 if (command.equals(
"GUI_EXECUTE_COMMAND")) {
177 if (command.equals(
"EXEC_SELECTION")) {
180 if (command.equals(
"MOVE_SELECTION")) {
183 if (command.equals(
"SCROLL_LIST")) {
186 if (command.equals(
"SCROLL") || command.equals(
"SCROLL_NEVER")) {
187 return parseScroll(args, element, command.equals(
"SCROLL"));
189 if (command.equals(
"SCROLL_RESET")) {
192 if (command.equals(
"MOVE_FOCUS")) {
195 if (command.equals(
"ACCOUNT_LOGIN")) {
198 if (command.equals(
"ACCOUNT_CREATE")) {
201 if (command.equals(
"ACCOUNT_PLAY")) {
204 if (command.equals(
"ACCOUNT_LINK")) {
207 if (command.equals(
"ACCOUNT_CREATE_CHARACTER")) {
210 if (command.equals(
"ACCOUNT_PASSWORD")) {
213 if (command.equals(
"SELECT")) {
227 if (element == null) {
228 throw new IOException(
"<element> is required");
242 if (element == null) {
243 throw new IOException(
"<element> is required");
257 if (element == null) {
258 throw new IOException(
"<element> is required");
273 if (element != null) {
274 throw new IOException(
"<element> is not allowed");
290 if (element != null) {
291 throw new IOException(
"<element> is not allowed");
306 if (element == null) {
307 throw new IOException(
"<element> is required");
310 if (!(element instanceof
GUIText)) {
311 throw new IOException(
"'"+element+
"' must be an input field");
327 if (element != null) {
328 throw new IOException(
"<element> is not allowed");
344 if (element != null) {
345 throw new IOException(
"<element> is not allowed");
361 if (element != null) {
362 throw new IOException(
"<element> is not allowed");
376 if (element == null) {
377 throw new IOException(
"<element> is required");
380 if (!(element instanceof
GUIItem)) {
381 throw new IOException(
"'"+element+
"' must be an item element");
398 if (element != null) {
399 throw new IOException(
"<element> is not allowed");
402 final String name = args.get();
418 if (element != null) {
419 throw new IOException(
"<element> is not allowed");
422 final String name = args.get();
438 if (element != null) {
439 throw new IOException(
"<element> is not allowed");
442 final String name = args.get();
460 if (element != null) {
461 throw new IOException(
"<element> is not allowed");
481 if (element == null) {
482 throw new IOException(
"<element> is required");
486 throw new IOException(
"'"+element+
"' must be an item list");
503 if (diffLines == 0 && diffElements == 0) {
504 throw new IOException(
"Invalid zero scroll distance");
507 if (element == null) {
508 throw new IOException(
"<element> is required");
511 if (!(element instanceof
GUIList)) {
512 throw new IOException(
"'"+element+
"' must be a list");
529 throw new IOException(
"Invalid zero scroll distance");
532 if (element == null) {
533 throw new IOException(
"<element> is required");
537 throw new IOException(
"'"+element+
"' must be a scrollable");
556 throw new IOException(
"Invalid zero scroll distance");
559 if (element == null) {
560 throw new IOException(
"<element> is required");
564 throw new IOException(
"'"+element+
"' must be a scrollable element");
578 if (element == null) {
579 throw new IOException(
"<element> is required");
583 throw new IOException(
"'"+element+
"' must be a scrollable element");
599 final Object nextElement = definedGUIElements.
lookup(args.get());
601 throw new IOException(
"'"+args.getPrev()+
"' cannot become active");
605 if (apply != 0 && apply != 1) {
606 throw new IOException(
"<apply> must be 0 or 1");
609 if (element == null) {
610 throw new IOException(
"<element> is required");
613 if (!(element instanceof ActivatableGUIElement)) {
614 throw new IOException(
"'"+element+
"' cannot become active");
617 return new ScrollNextCommand((ActivatableGUIElement)nextElement, (ActivatableGUIElement)element, apply != 0);
629 if (element == null) {
630 throw new IOException(
"<element> is required");
645 if (element == null) {
646 throw new IOException(
"<element> is required");
661 if (element == null) {
662 throw new IOException(
"<element> is required");
677 if (element == null) {
678 throw new IOException(
"<element> is required");
693 if (element == null) {
694 throw new IOException(
"<element> is required");
709 if (element == null) {
710 throw new IOException(
"<element> is required");
727 if (element == null) {
728 throw new IOException(
"<element> is required");
732 throw new IOException(
"'"+element+
"' must be a selectable element");
static GUICommand parseSelect(@NotNull final Args args, @Nullable final GUIElement element)
Parses and builds a "SELECT" command.
static GUICommand parseGuiExecuteCommand(@NotNull final Args args, @Nullable final GUIElement element, @NotNull final CommandExecutor commandExecutor, @NotNull final LineNumberReader lnr, @NotNull final Macros macros)
Parses and builds a "GUI_EXECUTE_COMMAND" command.
A GUICommand which moves the selected element in a GUIList element.
A GUICommand which connects to a Crossfire server.
Maintains the current GuiState.
GUICommand parseDialogClose(@NotNull final Args args, @Nullable final GUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds a "DIALOG_CLOSE" command.
final FloorView floorView
The FloorView to use.
A GUICommand which executes (i.e., simulates a left-button mouse click on) an GUIItem.
static GUICommand parseMoveSelection(@NotNull final Args args, @Nullable final GUIElement element)
Parses and builds a "MOVE_SELECTION" command.
A GUICommand sending an account login request to the server.
GUICommand parseExecSelection(@NotNull final Args args, @Nullable final GUIElement element, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection crossfireServerConnection)
Parses and builds a "" command.
static GUICommand parsePrint(@Nullable final GUIElement element)
Parses and builds a "PRINT" command.
static GUICommand parseShow(@Nullable final Component element)
Parses and builds a "SHOW" command.
GUICommand parseDialogOpen(@NotNull final Args args, @Nullable final GUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds a "DIALOG_OPEN" command.
GUICommand parseMoveFocus(@NotNull final Args args, @Nullable final GUIElement element)
Parses and builds a "MOVE_FOCUS" command.
Gui addDialog(@NotNull final String name)
Creates a new dialog instance.
A GUICommand which opens a Gui dialog.
static< T extends Enum< T > T parseEnum(@NotNull final Class< T > class_, @NotNull final String name, @NotNull final String ident)
Parses an enum constant.
Parser for integer expressions.
A GUICommand which shows the start screen.
static int parseInt(@NotNull final String str)
Parses an integer constant.
A GUIElement representing an in-game object.
static GUICommand parseAccountLogin(@Nullable final AbstractGUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds an "ACCOUNT_LOGIN" command.
CommandParser(@NotNull final Dialogs dialogs, @NotNull final FloorView floorView, @NotNull final JXCSkinCache< AbstractGUIElement > definedGUIElements)
Creates a new instance.
Utility class for parsing string parameters into values.
A GUICommand which toggles the visibility of a dialog.
A GUICommand which closes a Gui.
static GUICommand parseDisconnect(@Nullable final GUIElement element, @NotNull final GuiStateManager guiStateManager)
Parses and builds a "DISCONNECT" command.
static GUICommand parseGuiStart(@Nullable final GUIElement element, @NotNull final GuiStateManager guiStateManager)
Parses and builds a "GUI_START" command.
static GUICommand parseQuit(@Nullable final GUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds a "QUIT" command.
A GUICommand sending a character creation request.
Interface defining an abstract GUI element.
A GUICommand which executes a Crossfire command.
Manages macro expansion in command strings.
A GUIElement that can be set to active or inactive.
final JXCSkinCache< AbstractGUIElement > definedGUIElements
The defined GUI elements.
static GUICommand parseScroll(@NotNull final Args args, @Nullable final GUIElement element, final boolean isScroll)
Parses and builds a "SCROLL" or "SCROLL_NEVER command.
A GUICommand sending a request to link a character to an account.
static GUICommand parseGuiExecuteElement(@Nullable final GUIElement element)
Parses and builds a "GUI_EXECUTE_ELEMENT" command.
A GUICommand which shows a target GUIElement.
static GUICommand parseAccountPlay(@Nullable final AbstractGUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds an "ACCOUNT_PLAY" command.
A GUIList instance that displays GUIItemItem instances.
static boolean parseBoolean(@NotNull final String str)
Parses a boolean constant.
Interface that defines callback functions needed by commands.
final Dialogs dialogs
The Dialogs instance to use.
static GUICommand parseConnect(@Nullable final GUIElement element, @NotNull final GuiStateManager guiStateManager)
Parses and builds a "CONNECT" command.
A GUICommand which toggles the visibility of a target GUIElement.
A GUICommand which quite the client.
A GUICommand which does nothing.
A GUICommand sending an account password change request.
A GUICommand for selecting or deselecting a GUIElement.
static GUICommand parseHide(@Nullable final Component element)
Parses and builds a "HIDE" command.
Implements a cache for elements identified by name.
Utility class for parsing strings into numbers.
Exception thrown if a skin related problem occurs.
static GUICommand parseToggle(@Nullable final Component element)
Parses and builds a "TOGGLE" command.
A GUICommand that executes a command on the selected item of a GUIItemList.
static GUICommand parseAccountLink(@Nullable final AbstractGUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds an "ACCOUNT_LINK" command.
Abstract base class for GUI elements to be shown in Guis.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
static GUICommand parseScrollReset(@Nullable final GUIElement element)
Parses and builds a "SCROLL_RESET" command.
Maintains the pending (ncom) commands sent to the server.
A GUICommand which hides a target GUIElement.
A GUICommand sending an account creation request.
A GUICommand sending a play character request to the server.
static GUICommand parseAccountCreate(@Nullable final AbstractGUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds an "ACCOUNT_CREATE" command.
A GUICommand which disconnects from the Crossfire server.
static GUICommand parseScrollList(@NotNull final Args args, @Nullable final GUIElement element)
Parses and builds a "SCROLL_LIST" command.
static GUICommand parseAccountCreateCharacter(@Nullable final AbstractGUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds an "ACCOUNT_CREATE_CHARACTER" command.
Parser for creating GUICommand instances from string representations.
static String parseText(@NotNull final Args args, @NotNull final LineNumberReader lnr)
Concatenates trailing arguments into a string.
A GUIElement that displays a list of entries.
GUICommand parseCommandArgs(@NotNull final Args args, @Nullable final AbstractGUIElement element, @NotNull final String command, @NotNull final GuiStateManager guiStateManager, @NotNull final CommandExecutor commandExecutor, @NotNull final LineNumberReader lnr, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final CommandCallback commandCallback, @NotNull final Macros macros)
Parses and builds command arguments.
GUICommand parseDialogToggle(@NotNull final Args args, @Nullable final GUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds a "DIALOG_TOGGLE" command.
Maintains a set of Gui instances representing dialog windows.
T lookup(@NotNull final String name)
Looks up an element by name.
static GUICommand parseAccountPassword(@Nullable final AbstractGUIElement element, @NotNull final CommandCallback commandCallback)
Parses and builds an "ACCOUNT_PASSWORD" command.
Abstract base class for text input fields.
Provides a view to all items comprising the current floor view.
static GUICommand parseGuiMeta(@Nullable final GUIElement element, @NotNull final GuiStateManager guiStateManager)
Parses and builds a "GUI_META" command.