|
From: Crossfire C. r. messages.
<cro...@li...> - 2009-05-23 21:03:18
|
Revision: 11712
http://crossfire.svn.sourceforge.net/crossfire/?rev=11712&view=rev
Author: akirschbaum
Date: 2009-05-23 21:03:09 +0000 (Sat, 23 May 2009)
Log Message:
-----------
Add 'R' keybinding: reply to last player that has sent a /tell command.
Modified Paths:
--------------
jxclient/trunk/ChangeLog
jxclient/trunk/skins/prelude/global.skin
jxclient/trunk/skins/ragnorok/global.skin
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/BindCommand.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Commands.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ActivateCommandInputCommand.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ExecuteCommandCommand.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/GUICommandFactory.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/Gui.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/GuiFactory.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/keybindings/KeyBindings.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/MessageTypes.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/CommandParser.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/DefaultJXCSkin.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/JXCSkinLoader.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/GuiManager.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/JXCWindow.java
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/KeybindingsManager.java
Added Paths:
-----------
jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Macros.java
Modified: jxclient/trunk/ChangeLog
===================================================================
--- jxclient/trunk/ChangeLog 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/ChangeLog 2009-05-23 21:03:09 UTC (rev 11712)
@@ -1,3 +1,7 @@
+2009-05-23 Andreas Kirschbaum
+
+ * Add 'R' keybinding: reply to last player that has sent a /tell command.
+
2009-05-21 Andreas Kirschbaum
* Fix display issues when the character is running.
Modified: jxclient/trunk/skins/prelude/global.skin
===================================================================
--- jxclient/trunk/skins/prelude/global.skin 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/skins/prelude/global.skin 2009-05-23 21:03:09 UTC (rev 11712)
@@ -55,6 +55,7 @@
key code F11 0 exec command_shortcutA
key code F12 0 exec command_shortcutB
+key char 82 -e tell <<reply_to>> -
key char 97 apply
key char 100 use_skill disarm traps
key char 101 examine
Modified: jxclient/trunk/skins/ragnorok/global.skin
===================================================================
--- jxclient/trunk/skins/ragnorok/global.skin 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/skins/ragnorok/global.skin 2009-05-23 21:03:09 UTC (rev 11712)
@@ -89,6 +89,7 @@
key code F9 0 exec command_map
key code F10 0 exec command_setup
+key char 82 -e tell <<reply_to>> -
key char 97 apply
key char 100 use_skill disarm traps
key char 101 examine
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/BindCommand.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/BindCommand.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/BindCommand.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -49,6 +49,11 @@
private final GuiManager guiManager;
/**
+ * The {@link Macros} instance to use.
+ */
+ private Macros macros;
+
+ /**
* Create a new instance.
*
* @param window The window to execute in.
@@ -58,13 +63,16 @@
* @param commands the commands instance for executing commands
*
* @param guiManager the gui manager to use
+ *
+ * @param macros the macros instance to use
*/
- protected BindCommand(final JXCWindow window, final CrossfireServerConnection crossfireServerConnection, final Commands commands, final GuiManager guiManager)
+ protected BindCommand(final JXCWindow window, final CrossfireServerConnection crossfireServerConnection, final Commands commands, final GuiManager guiManager, final Macros macros)
{
super(crossfireServerConnection);
this.window = window;
this.commands = commands;
this.guiManager = guiManager;
+ this.macros = macros;
}
/** {@inheritDoc} */
@@ -103,7 +111,7 @@
}
final GUICommandList commandList2 = new GUICommandList(GUICommandList.CommandType.AND);
- commandList2.add(GUICommandFactory.createCommand(commandList, guiManager, commands));
+ commandList2.add(GUICommandFactory.createCommand(commandList, guiManager, commands, macros));
if (!window.createKeyBinding(perCharacterBinding, commandList2))
{
drawInfoError("Cannot use bind -c since no character is logged in.");
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Commands.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Commands.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Commands.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -57,11 +57,12 @@
* @param scriptManager the script manager instance
* @param optionManager the option manager instance
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
*/
- public Commands(final JXCWindow window, final JXCWindowRenderer windowRenderer, final CommandQueue commandQueue, final CrossfireServerConnection crossfireServerConnection, final ScriptManager scriptManager, final OptionManager optionManager, final GuiManager guiManager)
+ public Commands(final JXCWindow window, final JXCWindowRenderer windowRenderer, final CommandQueue commandQueue, final CrossfireServerConnection crossfireServerConnection, final ScriptManager scriptManager, final OptionManager optionManager, final GuiManager guiManager, final Macros macros)
{
this.commandQueue = commandQueue;
- commands.put("bind", new BindCommand(window, crossfireServerConnection, this, guiManager));
+ commands.put("bind", new BindCommand(window, crossfireServerConnection, this, guiManager, macros));
commands.put("unbind", new UnbindCommand(window, crossfireServerConnection));
commands.put("screenshot", new ScreenshotCommand(window, windowRenderer, crossfireServerConnection));
commands.put("script", new ScriptCommand(scriptManager, crossfireServerConnection));
Added: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Macros.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Macros.java (rev 0)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Macros.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -0,0 +1,144 @@
+//
+// This file is part of JXClient, the Fullscreen Java Crossfire Client.
+//
+// JXClient is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// JXClient is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with JXClient; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+// JXClient is (C)2005 by Yann Chachkoff.
+//
+package com.realtime.crossfire.jxclient.commands;
+
+import com.realtime.crossfire.jxclient.server.CrossfireDrawextinfoListener;
+import com.realtime.crossfire.jxclient.server.CrossfireServerConnection;
+import com.realtime.crossfire.jxclient.server.MessageTypes;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Manages macro expansion in command strings.
+ * @author Andreas Kirschbaum
+ */
+public class Macros
+{
+ /**
+ * The "reply_to" macro name.
+ */
+ private static final String REPLY_TO = "reply_to";
+
+ /**
+ * The {@link Pattern} matching macro names.
+ */
+ private final Pattern macroPattern = Pattern.compile("<<([a-z_]+)>>");
+
+ /**
+ * The macro expansions. Maps macro name to macro expansion.
+ */
+ private final Map<String, String> expansions = new HashMap<String, String>();
+
+ /**
+ * The {@link CrossfireDrawextinfoListener} for tracking tells.
+ */
+ private final CrossfireDrawextinfoListener crossfireDrawextinfoListener = new CrossfireDrawextinfoListener()
+ {
+ /** {@inheritDoc} */
+ @Override
+ public void commandDrawextinfoReceived(final int color, final int type, final int subtype, final String message)
+ {
+ switch (type)
+ {
+ case MessageTypes.MSG_TYPE_BOOK:
+ case MessageTypes.MSG_TYPE_CARD:
+ case MessageTypes.MSG_TYPE_PAPER:
+ case MessageTypes.MSG_TYPE_SIGN:
+ case MessageTypes.MSG_TYPE_MONUMENT:
+ case MessageTypes.MSG_TYPE_DIALOG:
+ case MessageTypes.MSG_TYPE_MOTD:
+ case MessageTypes.MSG_TYPE_ADMIN:
+ case MessageTypes.MSG_TYPE_SHOP:
+ case MessageTypes.MSG_TYPE_COMMAND:
+ case MessageTypes.MSG_TYPE_ATTRIBUTE:
+ case MessageTypes.MSG_TYPE_SKILL:
+ case MessageTypes.MSG_TYPE_APPLY:
+ case MessageTypes.MSG_TYPE_ATTACK:
+ break;
+
+ case MessageTypes.MSG_TYPE_COMMUNICATION:
+ if (subtype == MessageTypes.MSG_TYPE_COMMUNICATION_TELL)
+ {
+ final int index = message.indexOf(" tells you:");
+ if (index != -1)
+ {
+ final String name = message.substring(0, index);
+ expansions.put(REPLY_TO, name);
+ }
+ }
+ break;
+
+ case MessageTypes.MSG_TYPE_SPELL:
+ case MessageTypes.MSG_TYPE_ITEM:
+ case MessageTypes.MSG_TYPE_MISC:
+ case MessageTypes.MSG_TYPE_VICTIM:
+ default:
+ break;
+ }
+ }
+ };
+
+ /**
+ * Creates a new instance.
+ * @param crossfireServerConnection the crossfire server connection to
+ * track
+ */
+ public Macros(final CrossfireServerConnection crossfireServerConnection)
+ {
+ expansions.put(REPLY_TO, "");
+ crossfireServerConnection.addCrossfireDrawextinfoListener(crossfireDrawextinfoListener);
+ }
+
+ /**
+ * Expands all macro references.
+ * @param string the string to expand
+ * @return the expanded string
+ */
+ public String expandMacros(final String string)
+ {
+ StringBuilder result = null;
+ int index = 0;
+ final Matcher macroMatcher = macroPattern.matcher(string);
+ while (macroMatcher.find())
+ {
+ if (result == null)
+ {
+ result = new StringBuilder();
+ }
+
+ final String name = macroMatcher.group(1);
+ String expansion = expansions.get(name);
+ if (expansion == null)
+ {
+ expansion = macroMatcher.group(); // do not expand unknown macro names
+ }
+ result.append(string.substring(index, macroMatcher.start()));
+ result.append(expansion);
+ index = macroMatcher.end();
+ }
+ if (result != null)
+ {
+ result.append(string.substring(index, string.length()));
+ }
+ return result == null ? string : result.toString();
+ }
+}
Property changes on: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/commands/Macros.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ LF
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ActivateCommandInputCommand.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ActivateCommandInputCommand.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ActivateCommandInputCommand.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -19,6 +19,7 @@
//
package com.realtime.crossfire.jxclient.gui.commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.window.GuiManager;
/**
@@ -36,14 +37,21 @@
private final String commandText;
/**
+ * The {@link Macros} instance to use.
+ */
+ private final Macros macros;
+
+ /**
* Creates a new instance.
* @param commandText the command text to set
* @param guiManager the gui manager to affect
+ * @param macros the macros instance to use
*/
- public ActivateCommandInputCommand(final String commandText, final GuiManager guiManager)
+ public ActivateCommandInputCommand(final String commandText, final GuiManager guiManager, final Macros macros)
{
this.commandText = commandText;
this.guiManager = guiManager;
+ this.macros = macros;
}
/** {@inheritDoc} */
@@ -57,7 +65,7 @@
@Override
public void execute()
{
- guiManager.activateCommandInput(commandText);
+ guiManager.activateCommandInput(macros.expandMacros(commandText));
}
/**
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ExecuteCommandCommand.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ExecuteCommandCommand.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/ExecuteCommandCommand.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.gui.commands;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
/**
* A {@link GUICommand} which executes a Crossfire command.
@@ -34,14 +35,21 @@
private final String command;
/**
+ * The {@link Macros} instance to use.
+ */
+ private final Macros macros;
+
+ /**
* Creates a new instance.
* @param commands the commands instance for executing the command
* @param command the command to execute
+ * @param macros the macros instance to use
*/
- public ExecuteCommandCommand(final Commands commands, final String command)
+ public ExecuteCommandCommand(final Commands commands, final String command, final Macros macros)
{
this.commands = commands;
this.command = command;
+ this.macros = macros;
}
/** {@inheritDoc} */
@@ -55,7 +63,7 @@
@Override
public void execute()
{
- commands.executeCommand(command);
+ commands.executeCommand(macros.expandMacros(command));
}
/**
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/GUICommandFactory.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/GUICommandFactory.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/commands/GUICommandFactory.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.gui.commands;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.util.StringUtils;
import com.realtime.crossfire.jxclient.window.GuiManager;
import java.util.regex.Pattern;
@@ -52,11 +53,12 @@
* @param encodedCommandString the command string representation
* @param guiManager the gui manager to use
* @param commands the commands instance to use
+ * @param macros the macros instance to use
* @return the new command instance
*/
- public static GUICommand createCommandDecode(final String encodedCommandString, final GuiManager guiManager, final Commands commands)
+ public static GUICommand createCommandDecode(final String encodedCommandString, final GuiManager guiManager, final Commands commands, final Macros macros)
{
- return createCommand(decode(encodedCommandString), guiManager, commands);
+ return createCommand(decode(encodedCommandString), guiManager, commands, macros);
}
/**
@@ -64,21 +66,22 @@
* @param commandString the command string representation
* @param guiManager the gui manager to use
* @param commands the commands instance to use
+ * @param macros the macros instance to use
* @return the new command instance
*/
- public static GUICommand createCommand(final String commandString, final GuiManager guiManager, final Commands commands)
+ public static GUICommand createCommand(final String commandString, final GuiManager guiManager, final Commands commands, final Macros macros)
{
if (commandString.equals("-e"))
{
- return new ActivateCommandInputCommand("", guiManager);
+ return new ActivateCommandInputCommand("", guiManager, macros);
}
else if (commandString.startsWith("-e "))
{
- return new ActivateCommandInputCommand(StringUtils.trimLeading(commandString.substring(3)), guiManager);
+ return new ActivateCommandInputCommand(StringUtils.trimLeading(commandString.substring(3)), guiManager, macros);
}
else
{
- return new ExecuteCommandCommand(commands, commandString);
+ return new ExecuteCommandCommand(commands, commandString, macros);
}
}
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/Gui.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/Gui.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/Gui.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.gui.gui;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.gui.button.AbstractButton;
import com.realtime.crossfire.jxclient.gui.keybindings.KeyBindings;
import com.realtime.crossfire.jxclient.gui.textinput.GUIText;
@@ -130,11 +131,12 @@
* <code>null</code> otherwise
* @param commands the commands instance for executing commands
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
*/
- public Gui(final MouseTracker mouseTracker, final Commands commands, final GuiManager guiManager)
+ public Gui(final MouseTracker mouseTracker, final Commands commands, final GuiManager guiManager, final Macros macros)
{
this.mouseTracker = mouseTracker;
- keyBindings = new KeyBindings(null, commands, guiManager);
+ keyBindings = new KeyBindings(null, commands, guiManager, macros);
}
/**
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/GuiFactory.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/GuiFactory.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/gui/GuiFactory.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.gui.gui;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.window.GuiManager;
import com.realtime.crossfire.jxclient.window.MouseTracker;
@@ -45,17 +46,24 @@
private final GuiManager guiManager;
/**
+ * The {@link Macros} instance to use.
+ */
+ private final Macros macros;
+
+ /**
* Creates a new instance.
* @param mouseTracker the mouse tracker when in debug GUI mode or
* <code>null</code> otherwise
* @param commands the commands instance for executing commands
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
*/
- public GuiFactory(final MouseTracker mouseTracker, final Commands commands, final GuiManager guiManager)
+ public GuiFactory(final MouseTracker mouseTracker, final Commands commands, final GuiManager guiManager, final Macros macros)
{
this.mouseTracker = mouseTracker;
this.commands = commands;
this.guiManager = guiManager;
+ this.macros = macros;
}
/**
@@ -64,6 +72,6 @@
*/
public Gui newGui()
{
- return new Gui(mouseTracker, commands, guiManager);
+ return new Gui(mouseTracker, commands, guiManager, macros);
}
}
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/keybindings/KeyBindings.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/keybindings/KeyBindings.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/gui/keybindings/KeyBindings.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -21,6 +21,7 @@
package com.realtime.crossfire.jxclient.gui.keybindings;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.gui.commands.GUICommandFactory;
import com.realtime.crossfire.jxclient.window.GUICommandList;
import com.realtime.crossfire.jxclient.window.GuiManager;
@@ -54,6 +55,11 @@
private final GuiManager guiManager;
/**
+ * The {@link Macros} instance to use.
+ */
+ private Macros macros;
+
+ /**
* The active key bindings.
*/
private final Set<KeyBinding> keybindings = new HashSet<KeyBinding>();
@@ -80,12 +86,14 @@
* save
* @param commands the commands instance for executing commands
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
*/
- public KeyBindings(final File file, final Commands commands, final GuiManager guiManager)
+ public KeyBindings(final File file, final Commands commands, final GuiManager guiManager, final Macros macros)
{
this.file = file;
this.commands = commands;
this.guiManager = guiManager;
+ this.macros = macros;
}
/**
@@ -375,7 +383,7 @@
{
final char keyChar = (char)Integer.parseInt(tmp[0]);
final GUICommandList commandList = new GUICommandList(GUICommandList.CommandType.AND);
- commandList.add(GUICommandFactory.createCommandDecode(tmp[1], guiManager, commands));
+ commandList.add(GUICommandFactory.createCommandDecode(tmp[1], guiManager, commands, macros));
addKeyBindingAsKeyChar(keyChar, commandList, isDefault);
}
catch (final NumberFormatException ex)
@@ -417,7 +425,7 @@
}
final GUICommandList commandList = new GUICommandList(GUICommandList.CommandType.AND);
- commandList.add(GUICommandFactory.createCommandDecode(tmp[2], guiManager, commands));
+ commandList.add(GUICommandFactory.createCommandDecode(tmp[2], guiManager, commands, macros));
addKeyBindingAsKeyCode(keyCode, modifiers, commandList, isDefault);
}
else
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/MessageTypes.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/MessageTypes.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/server/MessageTypes.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -81,6 +81,15 @@
public static final int MSG_TYPE_BOOK_SPELL_SORCERER = 11;
public static final int MSG_TYPE_BOOK_SPELL_SUMMONER = 12;
+ public static final int MSG_TYPE_COMMUNICATION_RANDOM = 1; // random event (coin toss)
+ public static final int MSG_TYPE_COMMUNICATION_SAY = 2; // player says something
+ public static final int MSG_TYPE_COMMUNICATION_ME = 3; // player me's a message
+ public static final int MSG_TYPE_COMMUNICATION_TELL = 4; // player tells something
+ public static final int MSG_TYPE_COMMUNICATION_EMOTE = 5; // player emotes
+ public static final int MSG_TYPE_COMMUNICATION_PARTY = 6; // party message
+ public static final int MSG_TYPE_COMMUNICATION_SHOUT = 7; // shout message
+ public static final int MSG_TYPE_COMMUNICATION_chat = 8; // chat message
+
/**
* Private constructor to prevent instantiation.
*/
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/CommandParser.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/CommandParser.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/CommandParser.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.skin;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.gui.commands.ConnectCommand;
import com.realtime.crossfire.jxclient.gui.commands.DialogCloseCommand;
import com.realtime.crossfire.jxclient.gui.commands.DialogOpenCommand;
@@ -112,11 +113,12 @@
* @param commandQueue the command queue for executing commands
* @param crossfireServerConnection the server connection to use
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
* @return the command arguments
* @throws IOException if a syntax error occurs
* @throws JXCSkinException if an element cannot be found
*/
- public GUICommand parseCommandArgs(final String[] args, final int argc, final GUIElement element, final String command, final JXCWindow window, final Commands commands, final LineNumberReader lnr, final CommandQueue commandQueue, final CrossfireServerConnection crossfireServerConnection, final GuiManager guiManager) throws IOException, JXCSkinException
+ public GUICommand parseCommandArgs(final String[] args, final int argc, final GUIElement element, final String command, final JXCWindow window, final Commands commands, final LineNumberReader lnr, final CommandQueue commandQueue, final CrossfireServerConnection crossfireServerConnection, final GuiManager guiManager, final Macros macros) throws IOException, JXCSkinException
{
if (command.equals("SHOW"))
{
@@ -253,7 +255,7 @@
}
final String commandString = ParseUtils.parseText(args, argc, lnr);
- return new ExecuteCommandCommand(commands, commandString);
+ return new ExecuteCommandCommand(commands, commandString, macros);
}
else if (command.equals("EXEC_SELECTION"))
{
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/DefaultJXCSkin.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/DefaultJXCSkin.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/DefaultJXCSkin.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.skin;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.experience.ExperienceTable;
import com.realtime.crossfire.jxclient.gui.gauge.GaugeUpdater;
import com.realtime.crossfire.jxclient.gui.gui.GUIElement;
@@ -383,13 +384,14 @@
* @param commandQueue the command queue for executing commands
* @param crossfireServerConnection the server connection to use
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
* @throws IOException if a syntax error occurs
* @throws JXCSkinException if an element cannot be found
*/
- public void addCommand(final String listName, final String[] args, final int argc, final GUIElement element, final String command, final JXCWindow window, final Commands commands, final LineNumberReader lnr, final CommandQueue commandQueue, final CrossfireServerConnection crossfireServerConnection, final GuiManager guiManager ) throws IOException, JXCSkinException
+ public void addCommand(final String listName, final String[] args, final int argc, final GUIElement element, final String command, final JXCWindow window, final Commands commands, final LineNumberReader lnr, final CommandQueue commandQueue, final CrossfireServerConnection crossfireServerConnection, final GuiManager guiManager, final Macros macros) throws IOException, JXCSkinException
{
final GUICommandList commandList = getCommandList(listName);
- commandList.add(commandParser.parseCommandArgs(args, argc, element, command, window, commands, lnr, commandQueue, crossfireServerConnection, guiManager));
+ commandList.add(commandParser.parseCommandArgs(args, argc, element, command, window, commands, lnr, commandQueue, crossfireServerConnection, guiManager, macros));
}
/** {@inheritDoc} */
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/JXCSkinLoader.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/JXCSkinLoader.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/skin/JXCSkinLoader.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.skin;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.experience.ExperienceTable;
import com.realtime.crossfire.jxclient.faces.FacesManager;
import com.realtime.crossfire.jxclient.gui.GUIMagicMap;
@@ -247,10 +248,11 @@
* @param currentSpellManager the current spell manager to use
* @param guiManager the gui manager to use
* @param debugGui whether gui debugging is active
+ * @param macros the macros instance to use
* @return the loaded skin
* @throws JXCSkinException if the skin cannot be loaded
*/
- public JXCSkin load(final JXCSkinSource skinSource, final CrossfireServerConnection crossfireServerConnection, final JXCWindow window, final TooltipManager tooltipManager, final JXCWindowRenderer windowRenderer, final MouseTracker mouseTracker, final MetaserverModel metaserverModel, final CommandQueue commandQueue, final Resolution resolution, final Shortcuts shortcuts, final Commands commands, final CurrentSpellManager currentSpellManager, final GuiManager guiManager, final boolean debugGui) throws JXCSkinException
+ public JXCSkin load(final JXCSkinSource skinSource, final CrossfireServerConnection crossfireServerConnection, final JXCWindow window, final TooltipManager tooltipManager, final JXCWindowRenderer windowRenderer, final MouseTracker mouseTracker, final MetaserverModel metaserverModel, final CommandQueue commandQueue, final Resolution resolution, final Shortcuts shortcuts, final Commands commands, final CurrentSpellManager currentSpellManager, final GuiManager guiManager, final boolean debugGui, final Macros macros) throws JXCSkinException
{
imageParser = new ImageParser(skinSource);
fontParser = new FontParser(skinSource);
@@ -301,7 +303,7 @@
}
expressionParser = new ExpressionParser(selectedResolution);
- final GuiFactory guiFactory = new GuiFactory(debugGui ? mouseTracker : null, commands, guiManager);
+ final GuiFactory guiFactory = new GuiFactory(debugGui ? mouseTracker : null, commands, guiManager, macros);
skin = new DefaultJXCSkin(defaultKeyBindings, optionManager, stats, itemsManager, experienceTable, skillSet, expressionParser, selectedResolution, guiFactory);
JXCSkin skinToDetach = skin;
try
@@ -323,7 +325,7 @@
checkBoxFactory = null;
try
{
- load(skinSource, "global", crossfireServerConnection, window, tooltipManager, windowRenderer, metaserverModel, commandQueue, null, shortcuts, commands, currentSpellManager, guiManager);
+ load(skinSource, "global", crossfireServerConnection, window, tooltipManager, windowRenderer, metaserverModel, commandQueue, null, shortcuts, commands, currentSpellManager, guiManager, macros);
for (;;)
{
final String name = skin.getDialogToLoad();
@@ -332,7 +334,7 @@
break;
}
final Gui gui = skin.getDialog(name);
- load(skinSource, name, crossfireServerConnection, window, tooltipManager, windowRenderer, metaserverModel, commandQueue, gui, shortcuts, commands, currentSpellManager, guiManager);
+ load(skinSource, name, crossfireServerConnection, window, tooltipManager, windowRenderer, metaserverModel, commandQueue, gui, shortcuts, commands, currentSpellManager, guiManager, macros);
gui.setStateChanged(false);
}
}
@@ -378,9 +380,10 @@
* @param commands the commands instance for executing commands
* @param currentSpellManager the current spell manager to use
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
* @throws JXCSkinException if the file cannot be loaded
*/
- private void load(final JXCSkinSource skinSource, final String dialogName, final CrossfireServerConnection server, final JXCWindow window, final TooltipManager tooltipManager, final JXCWindowRenderer windowRenderer, final MetaserverModel metaserverModel, final CommandQueue commandQueue, final Gui gui, final Shortcuts shortcuts, final Commands commands, final CurrentSpellManager currentSpellManager, final GuiManager guiManager) throws JXCSkinException
+ private void load(final JXCSkinSource skinSource, final String dialogName, final CrossfireServerConnection server, final JXCWindow window, final TooltipManager tooltipManager, final JXCWindowRenderer windowRenderer, final MetaserverModel metaserverModel, final CommandQueue commandQueue, final Gui gui, final Shortcuts shortcuts, final Commands commands, final CurrentSpellManager currentSpellManager, final GuiManager guiManager, final Macros macros) throws JXCSkinException
{
String resourceName = dialogName+"@"+skin.getSelectedResolution()+".skin";
@@ -399,7 +402,7 @@
}
try
{
- load(skinSource, dialogName, resourceName, inputStream, server, window, tooltipManager, windowRenderer, metaserverModel, commandQueue, gui, shortcuts, commands, currentSpellManager, guiManager);
+ load(skinSource, dialogName, resourceName, inputStream, server, window, tooltipManager, windowRenderer, metaserverModel, commandQueue, gui, shortcuts, commands, currentSpellManager, guiManager, macros);
}
finally
{
@@ -438,9 +441,10 @@
* @param commands the commands instance for executing commands
* @param currentSpellManager the current spell manager to use
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
* @throws JXCSkinException if the file cannot be loaded
*/
- private void load(final JXCSkinSource skinSource, final String dialogName, final String resourceName, final InputStream inputStream, final CrossfireServerConnection server, final JXCWindow window, final TooltipManager tooltipManager, final JXCWindowRenderer windowRenderer, final MetaserverModel metaserverModel, final CommandQueue commandQueue, final Gui gui, final Shortcuts shortcuts, final Commands commands, final CurrentSpellManager currentSpellManager, final GuiManager guiManager) throws JXCSkinException
+ private void load(final JXCSkinSource skinSource, final String dialogName, final String resourceName, final InputStream inputStream, final CrossfireServerConnection server, final JXCWindow window, final TooltipManager tooltipManager, final JXCWindowRenderer windowRenderer, final MetaserverModel metaserverModel, final CommandQueue commandQueue, final Gui gui, final Shortcuts shortcuts, final Commands commands, final CurrentSpellManager currentSpellManager, final GuiManager guiManager, final Macros macros) throws JXCSkinException
{
final List<GUIElement> addedElements = new ArrayList<GUIElement>();
boolean addedElementsContainsWildcard = false;
@@ -494,11 +498,11 @@
}
else if (args[0].equals("commandlist"))
{
- parseCommandList(args, window, lnr, commands, commandQueue, server, guiManager);
+ parseCommandList(args, window, lnr, commands, commandQueue, server, guiManager, macros);
}
else if (args[0].equals("commandlist_add"))
{
- parseCommandListAdd(args, window, lnr, commands, commandQueue, server, guiManager);
+ parseCommandListAdd(args, window, lnr, commands, commandQueue, server, guiManager, macros);
}
else if (gui != null && args[0].equals("command_text"))
{
@@ -837,7 +841,7 @@
* @throws IOException if the command cannot be parsed
* @throws JXCSkinException if the command cannot be parsed
*/
- private void parseCommandList(final String[] args, final JXCWindow window, final LineNumberReader lnr, final Commands commands, final CommandQueue commandQueue, final CrossfireServerConnection server, final GuiManager guiManager) throws IOException, JXCSkinException
+ private void parseCommandList(final String[] args, final JXCWindow window, final LineNumberReader lnr, final Commands commands, final CommandQueue commandQueue, final CrossfireServerConnection server, final GuiManager guiManager, final Macros macros) throws IOException, JXCSkinException
{
if (args.length != 3 && args.length < 5)
{
@@ -850,7 +854,7 @@
if (args.length >= 5)
{
final GUIElement element = args[3].equals("null") ? null : skin.lookupGuiElement(args[3]);
- skin.addCommand(commandListName, args, 5, element, args[4], window, commands, lnr, commandQueue, server, guiManager);
+ skin.addCommand(commandListName, args, 5, element, args[4], window, commands, lnr, commandQueue, server, guiManager, macros);
}
}
@@ -863,10 +867,11 @@
* @param commandQueue the command queue to use
* @param server the server to use
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
* @throws IOException if the command cannot be parsed
* @throws JXCSkinException if the command cannot be parsed
*/
- private void parseCommandListAdd(final String[] args, final JXCWindow window, final LineNumberReader lnr, final Commands commands, final CommandQueue commandQueue, final CrossfireServerConnection server, final GuiManager guiManager) throws IOException, JXCSkinException
+ private void parseCommandListAdd(final String[] args, final JXCWindow window, final LineNumberReader lnr, final Commands commands, final CommandQueue commandQueue, final CrossfireServerConnection server, final GuiManager guiManager, final Macros macros) throws IOException, JXCSkinException
{
if (args.length < 4)
{
@@ -874,7 +879,7 @@
}
final GUIElement element = args[2].equals("null") ? null : skin.lookupGuiElement(args[2]);
- skin.addCommand(args[1], args, 4, element, args[3], window, commands, lnr, commandQueue, server, guiManager);
+ skin.addCommand(args[1], args, 4, element, args[3], window, commands, lnr, commandQueue, server, guiManager, macros);
}
/**
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/GuiManager.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/GuiManager.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/GuiManager.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -1,6 +1,7 @@
package com.realtime.crossfire.jxclient.window;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.gui.gui.Gui;
import com.realtime.crossfire.jxclient.gui.gui.GuiFactory;
import com.realtime.crossfire.jxclient.gui.gui.TooltipManager;
@@ -130,6 +131,11 @@
private final CrossfireServerConnection server;
/**
+ * The {@link Macros} instance to use.
+ */
+ private final Macros macros;
+
+ /**
* Called periodically to update the display contents.
*/
private final ActionListener actionListener = new ActionListener()
@@ -298,7 +304,7 @@
* @param settings the settings to use
* @param server the crossfire server connection to monitor
*/
- public GuiManager(final JXCWindow window, final boolean debugGui, final Object semaphoreDrawing, final Object semaphoreRedraw, final TooltipManager tooltipManager, final Settings settings, final CrossfireServerConnection server)
+ public GuiManager(final JXCWindow window, final boolean debugGui, final Object semaphoreDrawing, final Object semaphoreRedraw, final TooltipManager tooltipManager, final Settings settings, final CrossfireServerConnection server, final Macros macros)
{
this.debugGui = debugGui;
this.semaphoreDrawing = semaphoreDrawing;
@@ -306,6 +312,7 @@
this.tooltipManager = tooltipManager;
this.settings = settings;
this.server = server;
+ this.macros = macros;
mouseTracker = new MouseTracker(debugGui);
windowRenderer = new JXCWindowRenderer(window, mouseTracker, semaphoreRedraw, server);
window.addConnectionStateListener(guiStateListener);
@@ -315,8 +322,8 @@
@Deprecated
public void init(final ScriptManager scriptManager, final CommandQueue commandQueue, final CrossfireServerConnection server, final OptionManager optionManager)
{
- commands = new Commands(window, windowRenderer, commandQueue, server, scriptManager, optionManager, this);
- guiFactory = new GuiFactory(debugGui ? mouseTracker : null, commands, this);
+ commands = new Commands(window, windowRenderer, commandQueue, server, scriptManager, optionManager, this, macros);
+ guiFactory = new GuiFactory(debugGui ? mouseTracker : null, commands, this, macros);
windowRenderer.setCurrentGui(guiFactory.newGui());
queryDialog = guiFactory.newGui();
keybindDialog = guiFactory.newGui();
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/JXCWindow.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/JXCWindow.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/JXCWindow.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.window;
import com.realtime.crossfire.jxclient.animations.Animations;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.experience.ExperienceTable;
import com.realtime.crossfire.jxclient.faces.FaceCache;
import com.realtime.crossfire.jxclient.faces.FacesManager;
@@ -214,6 +215,11 @@
private final Object semaphoreStatus = new Object();
/**
+ * The {@link Macros} instance.
+ */
+ private final Macros macros;
+
+ /**
* The {@link WindowFocusListener} registered for this window. It resets
* the keyboard modifier state when the window loses the focus. The idea is
* to prevent the following: user switches from jxclient to another window
@@ -484,6 +490,7 @@
this.optionManager = optionManager;
this.metaserverModel = metaserverModel;
this.resolution = resolution;
+ macros = new Macros(server);
final FaceCache faceCache = new FaceCache(server);
experienceTable = new ExperienceTable(server);
skillSet = new SkillSet(server, this);
@@ -496,10 +503,10 @@
new PoisonWatcher(stats, server);
new ActiveSkillWatcher(stats, server);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
- guiManager = new GuiManager(this, debugGui, semaphoreDrawing, semaphoreRedraw, new TooltipManager(this), settings, server);
+ guiManager = new GuiManager(this, debugGui, semaphoreDrawing, semaphoreRedraw, new TooltipManager(this), settings, server, macros);
final ScriptManager scriptManager = new ScriptManager(commandQueue, server, stats, itemsManager, spellsManager, mapUpdater, skillSet);
guiManager.init(scriptManager, commandQueue, server, optionManager);
- keybindingsManager = new KeybindingsManager(guiManager.getCommands(), guiManager);
+ keybindingsManager = new KeybindingsManager(guiManager.getCommands(), guiManager, macros);
shortcutsManager = new ShortcutsManager(commandQueue, spellsManager);
keyHandler = new KeyHandler(debugKeyboard, keybindingsManager, commandQueue, guiManager.getWindowRenderer(), keyHandlerListener);
try
@@ -693,7 +700,7 @@
{
// check for skin in directory
final File dir = new File(skinName);
- final KeyBindings defaultKeyBindings = new KeyBindings(null, guiManager.getCommands(), guiManager);
+ final KeyBindings defaultKeyBindings = new KeyBindings(null, guiManager.getCommands(), guiManager, macros);
final JXCSkinSource skinSource;
if (dir.exists() && dir.isDirectory())
{
@@ -705,7 +712,7 @@
skinSource = new JXCSkinClassSource("com/realtime/crossfire/jxclient/skins/"+skinName);
}
final JXCSkinLoader newSkin = new JXCSkinLoader(itemsManager, spellsManager, facesManager, stats, mapUpdater, defaultKeyBindings, optionManager, experienceTable, skillSet);
- return newSkin.load(skinSource, server, this, guiManager.getTooltipManager(), guiManager.getWindowRenderer(), guiManager.mouseTracker, metaserverModel, commandQueue, resolution, shortcutsManager.getShortcuts(), guiManager.getCommands(), currentSpellManager, guiManager, debugGui);
+ return newSkin.load(skinSource, server, this, guiManager.getTooltipManager(), guiManager.getWindowRenderer(), guiManager.mouseTracker, metaserverModel, commandQueue, resolution, shortcutsManager.getShortcuts(), guiManager.getCommands(), currentSpellManager, guiManager, debugGui, macros);
}
/**
Modified: jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/KeybindingsManager.java
===================================================================
--- jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/KeybindingsManager.java 2009-05-23 19:18:19 UTC (rev 11711)
+++ jxclient/trunk/src/jxclient/com/realtime/crossfire/jxclient/window/KeybindingsManager.java 2009-05-23 21:03:09 UTC (rev 11712)
@@ -20,6 +20,7 @@
package com.realtime.crossfire.jxclient.window;
import com.realtime.crossfire.jxclient.commands.Commands;
+import com.realtime.crossfire.jxclient.commands.Macros;
import com.realtime.crossfire.jxclient.gui.keybindings.KeyBindingState;
import com.realtime.crossfire.jxclient.gui.keybindings.KeyBindings;
import com.realtime.crossfire.jxclient.settings.Filenames;
@@ -43,6 +44,11 @@
private final GuiManager guiManager;
/**
+ * The {@link Macros} instance to use.
+ */
+ private final Macros macros;
+
+ /**
* The global key bindings.
*/
private final KeyBindings keyBindings;
@@ -63,12 +69,14 @@
* Creates a new instance.
* @param commands the commands instance to use
* @param guiManager the gui manager to use
+ * @param macros the macros instance to use
*/
- public KeybindingsManager(final Commands commands, final GuiManager guiManager)
+ public KeybindingsManager(final Commands commands, final GuiManager guiManager, final Macros macros)
{
this.commands = commands;
this.guiManager = guiManager;
- keyBindings = new KeyBindings(Filenames.getKeybindingsFile(null, null), commands, guiManager);
+ this.macros = macros;
+ keyBindings = new KeyBindings(Filenames.getKeybindingsFile(null, null), commands, guiManager, macros);
}
/**
@@ -142,7 +150,7 @@
*/
public void loadPerCharacterBindings(final String hostname, final String character)
{
- characterKeyBindings = new KeyBindings(Filenames.getKeybindingsFile(hostname, character), commands, guiManager);
+ characterKeyBindings = new KeyBindings(Filenames.getKeybindingsFile(hostname, character), commands, guiManager, macros);
try
{
characterKeyBindings.loadKeyBindings();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|