summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-12 15:41:10 -0700
committerIra Rice <irarice@gmail.com>2009-01-12 15:41:10 -0700
commit7f8f7bcd329e62d240914686b01a9cd68624309c (patch)
tree1256aff76fa3f81b62724e73197eb94d231d9045 /src
parentfc1539e019b6d916d1470ddf1f31997044af8396 (diff)
downloadmana-client-7f8f7bcd329e62d240914686b01a9cd68624309c.tar.gz
mana-client-7f8f7bcd329e62d240914686b01a9cd68624309c.tar.bz2
mana-client-7f8f7bcd329e62d240914686b01a9cd68624309c.tar.xz
mana-client-7f8f7bcd329e62d240914686b01a9cd68624309c.zip
Some rather pedantic changes. Unified all naming for emoticons in the
code so that only one term is used everywhere (to simplify maintainability), as well as corrected several variable names and comments where there was copy/pasted code, but it wasn't corrected. Also moved emote shortcuts back to where they were originally, to reduce player confusion when the next build comes around. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am16
-rw-r--r--src/emoteshortcut.cpp77
-rw-r--r--src/emoteshortcut.h125
-rw-r--r--src/game.cpp46
-rw-r--r--src/gui/emotecontainer.cpp (renamed from src/gui/smileycontainer.cpp)81
-rw-r--r--src/gui/emotecontainer.h (renamed from src/gui/smileycontainer.h)37
-rw-r--r--src/gui/emoteshortcutcontainer.cpp192
-rw-r--r--src/gui/emoteshortcutcontainer.h (renamed from src/gui/smileyshortcutcontainer.h)38
-rw-r--r--src/gui/emotewindow.cpp (renamed from src/gui/smileywindow.cpp)34
-rw-r--r--src/gui/emotewindow.h (renamed from src/gui/smileywindow.h)33
-rw-r--r--src/gui/itemshortcutcontainer.cpp6
-rw-r--r--src/gui/menuwindow.cpp4
-rw-r--r--src/gui/setup.cpp8
-rw-r--r--src/gui/setup.h3
-rw-r--r--src/gui/shortcutcontainer.cpp9
-rw-r--r--src/gui/shortcutcontainer.h9
-rw-r--r--src/gui/shortcutwindow.h2
-rw-r--r--src/gui/smileyshortcutcontainer.cpp179
-rw-r--r--src/itemshortcut.h2
-rw-r--r--src/keyboardconfig.cpp52
-rw-r--r--src/keyboardconfig.h40
-rw-r--r--src/main.cpp8
-rw-r--r--src/smileyshortcut.cpp76
-rw-r--r--src/smileyshortcut.h127
24 files changed, 607 insertions, 597 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e189b793..96be8465 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,12 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \
gui/connection.h \
gui/debugwindow.cpp \
gui/debugwindow.h \
+ gui/emotecontainer.cpp \
+ gui/emotecontainer.h \
+ gui/emoteshortcutcontainer.cpp \
+ gui/emoteshortcutcontainer.h \
+ gui/emotewindow.cpp \
+ gui/emotewindow.h \
gui/equipmentwindow.cpp \
gui/equipmentwindow.h \
gui/focushandler.cpp \
@@ -117,12 +123,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \
gui/skill.h \
gui/slider.cpp \
gui/slider.h \
- gui/smileycontainer.cpp \
- gui/smileycontainer.h \
- gui/smileyshortcutcontainer.cpp \
- gui/smileyshortcutcontainer.h \
- gui/smileywindow.cpp \
- gui/smileywindow.h \
gui/speechbubble.cpp \
gui/speechbubble.h \
gui/status.cpp \
@@ -252,6 +252,8 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \
configuration.h \
effectmanager.cpp \
effectmanager.h \
+ emoteshortcut.cpp \
+ emoteshortcut.h \
engine.cpp \
engine.h \
equipment.cpp \
@@ -272,8 +274,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \
inventory.h \
item.cpp \
item.h \
- smileyshortcut.cpp \
- smileyshortcut.h \
itemshortcut.cpp \
itemshortcut.h \
joystick.cpp \
diff --git a/src/emoteshortcut.cpp b/src/emoteshortcut.cpp
new file mode 100644
index 00000000..66989d44
--- /dev/null
+++ b/src/emoteshortcut.cpp
@@ -0,0 +1,77 @@
+/*
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
+ *
+ * This file is part of Aethyra.
+ *
+ * Aethyra 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
+ * any later version.
+ *
+ * Aethyra 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 Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "emoteshortcut.h"
+
+#include "configuration.h"
+#include "localplayer.h"
+
+#include "utils/tostring.h"
+
+EmoteShortcut::EmoteShortcut *emoteShortcut;
+
+EmoteShortcut::EmoteShortcut():
+ mEmoteSelected(0)
+{
+ for (int i = 0; i < SHORTCUT_EMOTES; i++)
+ {
+ mEmotes[i] = i + 1;
+ }
+ load();
+}
+
+EmoteShortcut::~EmoteShortcut()
+{
+ save();
+}
+
+void EmoteShortcut::load()
+{
+ for (int i = 0; i < SHORTCUT_EMOTES; i++)
+ {
+ int emoteId = (int) config.getValue("emoteshortcut" + toString(i), i + 1);
+
+ if (emoteId)
+ {
+ mEmotes[i] = emoteId;
+ }
+ }
+}
+
+void EmoteShortcut::save()
+{
+ for (int i = 0; i < SHORTCUT_EMOTES; i++)
+ {
+ const int emoteId = mEmotes[i] ? mEmotes[i] : 0;
+ config.setValue("emoteshortcut" + toString(i), emoteId);
+ }
+}
+
+void EmoteShortcut::useEmote(int index)
+{
+ if ((index > 0) && (index <= SHORTCUT_EMOTES))
+ {
+ if (mEmotes[index - 1] > 0)
+ {
+ player_node->emote(mEmotes[index - 1]);
+ }
+ }
+}
diff --git a/src/emoteshortcut.h b/src/emoteshortcut.h
new file mode 100644
index 00000000..14162f73
--- /dev/null
+++ b/src/emoteshortcut.h
@@ -0,0 +1,125 @@
+/*
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
+ *
+ * This file is part of Aethyra.
+ *
+ * Aethyra 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
+ * any later version.
+ *
+ * Aethyra 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 Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _AETHYRA_EMOTESHORTCUT_H__
+#define _AETHYRA_EMOTESHORTCUT_H__
+
+#define SHORTCUT_EMOTES 12
+
+/**
+ * The class which keeps track of the emote shortcuts.
+ */
+class EmoteShortcut
+{
+ public:
+ /**
+ * Constructor.
+ */
+ EmoteShortcut();
+
+ /**
+ * Destructor.
+ */
+ ~EmoteShortcut();
+
+ /**
+ * Load the configuration information.
+ */
+ void load();
+
+ /**
+ * Returns the shortcut Emote ID specified by the index.
+ *
+ * @param index Index of the shortcut Emote.
+ */
+ int getEmote(int index) const
+ { return mEmotes[index]; }
+
+ /**
+ * Returns the amount of shortcut Emotes.
+ */
+ int getEmoteCount() const
+ { return SHORTCUT_EMOTES; }
+
+ /**
+ * Returns the emote ID that is currently selected.
+ */
+ int getEmoteSelected() const
+ { return mEmoteSelected; }
+
+ /**
+ * Adds the selected emote ID to the emotes specified by the index.
+ *
+ * @param index Index of the emotes.
+ */
+ void setEmote(int index)
+ { mEmotes[index] = mEmoteSelected; }
+
+ /**
+ * Adds a emoticon to the emotes store specified by the index.
+ *
+ * @param index Index of the emote.
+ * @param emoteId ID of the emote.
+ */
+ void setEmotes(int index, int emoteId)
+ { mEmotes[index] = emoteId; }
+
+ /**
+ * Set the Emote that is selected.
+ *
+ * @param emoteId The ID of the emote that is to be assigned.
+ */
+ void setEmoteSelected(int emoteId)
+ { mEmoteSelected = emoteId; }
+
+ /**
+ * A flag to check if the Emote is selected.
+ */
+ bool isEmoteSelected()
+ { return mEmoteSelected; }
+
+ /**
+ * Remove a Emote from the shortcut.
+ */
+ void removeEmote(int index)
+ { mEmotes[index] = 0; }
+
+ /**
+ * Try to use the Emote specified by the index.
+ *
+ * @param index Index of the emote shortcut.
+ */
+ void useEmote(int index);
+
+ private:
+ /**
+ * Save the configuration information.
+ */
+ void save();
+
+ int mEmotes[SHORTCUT_EMOTES]; /**< The emote stored. */
+ int mEmoteSelected; /**< The emote held by cursor. */
+
+};
+
+extern EmoteShortcut *emoteShortcut;
+
+#endif
diff --git a/src/game.cpp b/src/game.cpp
index 18169cd0..753d7afa 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -35,7 +35,6 @@
#include "flooritemmanager.h"
#include "graphics.h"
#include "itemshortcut.h"
-#include "smileyshortcut.h"
#include "joystick.h"
#include "keyboardconfig.h"
#include "localplayer.h"
@@ -49,15 +48,16 @@
#include "gui/chat.h"
#include "gui/confirm_dialog.h"
#include "gui/debugwindow.h"
+#include "gui/emoteshortcut.h"
+#include "gui/emoteshortcutcontainer.h"
+#include "gui/emotewindow.h"
#include "gui/equipmentwindow.h"
#include "gui/gui.h"
#include "gui/help.h"
#include "gui/inventorywindow.h"
-#include "gui/smileywindow.h"
#include "gui/shortcutwindow.h"
#include "gui/shortcutcontainer.h"
#include "gui/itemshortcutcontainer.h"
-#include "gui/smileyshortcutcontainer.h"
#include "gui/menuwindow.h"
#include "gui/minimap.h"
#include "gui/ministatus.h"
@@ -118,7 +118,7 @@ BuyDialog *buyDialog;
SellDialog *sellDialog;
BuySellDialog *buySellDialog;
InventoryWindow *inventoryWindow;
-SmileyWindow *smileyWindow;
+EmoteWindow *emoteWindow;
NpcListDialog *npcListDialog;
NpcTextDialog *npcTextDialog;
SkillDialog *skillDialog;
@@ -129,7 +129,7 @@ TradeWindow *tradeWindow;
HelpWindow *helpWindow;
DebugWindow *debugWindow;
ShortcutWindow *itemShortcutWindow;
-ShortcutWindow *smileyShortcutWindow;
+ShortcutWindow *emoteShortcutWindow;
BeingManager *beingManager = NULL;
FloorItemManager *floorItemManager = NULL;
@@ -202,7 +202,7 @@ void createGuiWindows(Network *network)
sellDialog = new SellDialog(network);
buySellDialog = new BuySellDialog();
inventoryWindow = new InventoryWindow();
- smileyWindow = new SmileyWindow();
+ emoteWindow = new EmoteWindow();
npcTextDialog = new NpcTextDialog();
npcListDialog = new NpcListDialog();
skillDialog = new SkillDialog();
@@ -213,7 +213,7 @@ void createGuiWindows(Network *network)
helpWindow = new HelpWindow();
debugWindow = new DebugWindow();
itemShortcutWindow = new ShortcutWindow("ItemShortcut",new ItemShortcutContainer);
- smileyShortcutWindow = new ShortcutWindow("SmileyShortcut",new SmileyShortcutContainer);
+ emoteShortcutWindow = new ShortcutWindow("emoteShortcut",new EmoteShortcutContainer);
// Set initial window visibility
chatWindow->setVisible((bool) config.getValue(
@@ -227,8 +227,8 @@ void createGuiWindows(Network *network)
menuWindow->getWindowName() + "Visible", true));
itemShortcutWindow->setVisible((bool) config.getValue(
itemShortcutWindow->getWindowName() + "Visible", true));
- smileyShortcutWindow->setVisible((bool) config.getValue(
- smileyShortcutWindow->getWindowName() + "Visible", true));
+ emoteShortcutWindow->setVisible((bool) config.getValue(
+ emoteShortcutWindow->getWindowName() + "Visible", true));
if (config.getValue("logToChat", 0))
{
@@ -250,7 +250,7 @@ void destroyGuiWindows()
delete sellDialog;
delete buySellDialog;
delete inventoryWindow;
- delete smileyWindow;
+ delete emoteWindow;
delete npcListDialog;
delete npcTextDialog;
delete skillDialog;
@@ -261,7 +261,7 @@ void destroyGuiWindows()
delete helpWindow;
delete debugWindow;
delete itemShortcutWindow;
- delete smileyShortcutWindow;
+ delete emoteShortcutWindow;
}
Game::Game(Network *network):
@@ -545,14 +545,14 @@ void Game::handleInput()
}
}
- // Smilie
- if (keyboard.isKeyActive(keyboard.KEY_SMILIE))
+ // Mode switch to emotes
+ if (keyboard.isKeyActive(keyboard.KEY_EMOTE))
{
// Emotions
- int emotion = keyboard.getKeySmilieOffset(event.key.keysym.sym);
+ int emotion = keyboard.getKeyEmoteOffset(event.key.keysym.sym);
if (emotion)
{
- smileyShortcut->useSmiley(emotion);
+ emoteShortcut->useEmote(emotion);
used = true;
return;
}
@@ -655,13 +655,13 @@ void Game::handleInput()
if (!tradeWindow->isVisible())
{
// Checks if any item shortcut is pressed.
- for (int i = KeyboardConfig::KEY_SHORTCUT_0;
- i <= KeyboardConfig::KEY_SHORTCUT_9;
+ for (int i = KeyboardConfig::KEY_SHORTCUT_1;
+ i <= KeyboardConfig::KEY_SHORTCUT_12;
i++)
{
if (tKey == i && !used) {
itemShortcut->useItem(
- i - KeyboardConfig::KEY_SHORTCUT_0);
+ i - KeyboardConfig::KEY_SHORTCUT_1);
break;
}
}
@@ -708,7 +708,7 @@ void Game::handleInput()
{
statusWindow->setVisible(false);
inventoryWindow->setVisible(false);
- smileyWindow->setVisible(false);
+ emoteWindow->setVisible(false);
skillDialog->setVisible(false);
setupWindow->setVisible(false);
equipmentWindow->setVisible(false);
@@ -745,11 +745,11 @@ void Game::handleInput()
case KeyboardConfig::KEY_WINDOW_DEBUG:
requestedWindow = debugWindow;
break;
- case KeyboardConfig::KEY_WINDOW_ALLSMILEY:
- requestedWindow = smileyWindow;
+ case KeyboardConfig::KEY_WINDOW_EMOTE:
+ requestedWindow = emoteWindow;
break;
- case KeyboardConfig::KEY_WINDOW_SMILEY_SHORTCUT:
- requestedWindow = smileyShortcutWindow;
+ case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT:
+ requestedWindow = emoteShortcutWindow;
break;
}
}
diff --git a/src/gui/smileycontainer.cpp b/src/gui/emotecontainer.cpp
index f8f57c45..c3e20c41 100644
--- a/src/gui/smileycontainer.cpp
+++ b/src/gui/emotecontainer.cpp
@@ -1,33 +1,33 @@
/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
*
- * This file is part of The Mana World.
+ * This file is part of Aethyra.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * Aethyra 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
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * Aethyra 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "smileycontainer.h"
-
#include <guichan/mouseinput.hpp>
#include <guichan/selectionlistener.hpp>
+#include "emotecontainer.h"
+#include "emoteshortcut.h"
+
#include "../configuration.h"
#include "../graphics.h"
#include "../log.h"
-#include "../smileyshortcut.h"
#include "../resources/image.h"
#include "../resources/iteminfo.h"
@@ -36,45 +36,45 @@
#include "../utils/gettext.h"
#include "../utils/tostring.h"
-const int SmileyContainer::gridWidth = 34; // emote icon width + 4
-const int SmileyContainer::gridHeight = 36; // emote icon height + 4
+const int EmoteContainer::gridWidth = 34; // emote icon width + 4
+const int EmoteContainer::gridHeight = 36; // emote icon height + 4
static const int NO_EMOTE = -1;
-SmileyContainer::SmileyContainer():
+EmoteContainer::EmoteContainer():
mSelectedEmoteIndex(NO_EMOTE)
{
ResourceManager *resman = ResourceManager::getInstance();
- mSmileyImg = resman->getImageSet("graphics/sprites/emotions.png", 30, 32);
- if (!mSmileyImg) logger->error(_("Unable to load emotions"));
+ mEmoteImg = resman->getImageSet("graphics/sprites/emotions.png", 30, 32);
+ if (!mEmoteImg) logger->error(_("Unable to load emotions"));
mSelImg = resman->getImage("graphics/gui/selection.png");
if (!mSelImg) logger->error(_("Unable to load selection.png"));
mSelImg->setAlpha(config.getValue("guialpha", 0.8));
- mMaxSmiley = mSmileyImg->size();
+ mMaxEmote = mEmoteImg->size();
addMouseListener(this);
addWidgetListener(this);
}
-SmileyContainer::~SmileyContainer()
+EmoteContainer::~EmoteContainer()
{
- if (mSmileyImg)
+ if (mEmoteImg)
{
- mSmileyImg->decRef();
- mSmileyImg=NULL;
+ mEmoteImg->decRef();
+ mEmoteImg = NULL;
}
if (!mSelImg)
{
mSelImg->decRef();
- mSelImg=NULL;
+ mSelImg = NULL;
}
}
-void SmileyContainer::draw(gcn::Graphics *graphics)
+void EmoteContainer::draw(gcn::Graphics *graphics)
{
int columns = getWidth() / gridWidth;
@@ -84,65 +84,64 @@ void SmileyContainer::draw(gcn::Graphics *graphics)
columns = 1;
}
- for (int i = 0; i < mMaxSmiley ; i++)
+ for (int i = 0; i < mMaxEmote ; i++)
{
- int itemX = ((i) % columns) * gridWidth;
- int itemY = ((i) / columns) * gridHeight;
+ int emoteX = ((i) % columns) * gridWidth;
+ int emoteY = ((i) / columns) * gridHeight;
-
- // Draw item icon
+ // Draw emote icon
static_cast<Graphics*>(graphics)->drawImage(
- mSmileyImg->get(i), itemX, itemY);
+ mEmoteImg->get(i), emoteX, emoteY);
// Draw selection image below selected item
if (mSelectedEmoteIndex == i)
{
static_cast<Graphics*>(graphics)->drawImage(
- mSelImg, itemX, itemY);
+ mSelImg, emoteX, emoteY);
}
}
}
-void SmileyContainer::widgetResized(const gcn::Event &event)
+void EmoteContainer::widgetResized(const gcn::Event &event)
{
recalculateHeight();
}
-void SmileyContainer::recalculateHeight()
+void EmoteContainer::recalculateHeight()
{
int cols = getWidth() / gridWidth;
if (cols < 1)
cols = 1;
- const int rows = (mMaxSmiley / cols) + (mMaxSmiley % cols > 0 ? 1 : 0);
+ const int rows = (mMaxEmote / cols) + (mMaxEmote % cols > 0 ? 1 : 0);
const int height = rows * gridHeight + 8;
if (height != getHeight())
setHeight(height);
}
-int SmileyContainer::getSelectedSmiley()
+int EmoteContainer::getSelectedEmote()
{
if (mSelectedEmoteIndex == NO_EMOTE)
return 0;
- return 1+mSelectedEmoteIndex;
+ return 1 + mSelectedEmoteIndex;
}
-void SmileyContainer::selectNone()
+void EmoteContainer::selectNone()
{
setSelectedEmoteIndex(NO_EMOTE);
}
-void SmileyContainer::setSelectedEmoteIndex(int index)
+void EmoteContainer::setSelectedEmoteIndex(int index)
{
- if (index < 0 || index >= mMaxSmiley )
+ if (index < 0 || index >= mMaxEmote )
mSelectedEmoteIndex = NO_EMOTE;
else
mSelectedEmoteIndex = index;
}
-void SmileyContainer::distributeValueChangedEvent()
+void EmoteContainer::distributeValueChangedEvent()
{
gcn::SelectionEvent event(this);
std::list<gcn::SelectionListener*>::iterator i_end = mListeners.end();
@@ -154,7 +153,7 @@ void SmileyContainer::distributeValueChangedEvent()
}
}
-void SmileyContainer::mousePressed(gcn::MouseEvent &event)
+void EmoteContainer::mousePressed(gcn::MouseEvent &event)
{
int button = event.getButton();
if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT)
@@ -163,10 +162,10 @@ void SmileyContainer::mousePressed(gcn::MouseEvent &event)
int mx = event.getX();
int my = event.getY();
int index = mx / gridWidth + ((my / gridHeight) * columns);
- if (index <mMaxSmiley)
+ if (index < mMaxEmote)
{
setSelectedEmoteIndex(index);
- smileyShortcut->setSmileySelected(index+1);
+ emoteShortcut->setEmoteSelected(index + 1);
}
}
}
diff --git a/src/gui/smileycontainer.h b/src/gui/emotecontainer.h
index 88ca0b48..f5922a9c 100644
--- a/src/gui/smileycontainer.h
+++ b/src/gui/emotecontainer.h
@@ -1,26 +1,26 @@
/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
*
- * This file is part of The Mana World.
+ * This file is part of Aethyra.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * Aethyra 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
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * Aethyra 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_SMILEYCONTAINER_H__
-#define _TMW_SMILEYCONTAINER_H__
+#ifndef _AETHYRA_EMOTECONTAINER_H__
+#define _AETHYRA_EMOTECONTAINER_H__
#include <list>
@@ -28,9 +28,10 @@
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../resources/imageset.h"
#include "../guichanfwd.h"
+#include "../resources/imageset.h"
+
class Image;
class Inventory;
class Emote;
@@ -44,20 +45,20 @@ namespace gcn {
*
* \ingroup GUI
*/
-class SmileyContainer : public gcn::Widget,
- public gcn::MouseListener,
- public gcn::WidgetListener
+class EmoteContainer : public gcn::Widget,
+ public gcn::MouseListener,
+ public gcn::WidgetListener
{
public:
/**
* Constructor. Initializes the graphic.
*/
- SmileyContainer();
+ EmoteContainer();
/**
* Destructor.
*/
- virtual ~SmileyContainer();
+ virtual ~EmoteContainer();
/**
* Draws the items.
@@ -77,7 +78,7 @@ class SmileyContainer : public gcn::Widget,
/**
* Returns the selected item.
*/
- int getSelectedSmiley();
+ int getSelectedEmote();
/**
* Sets selected item to NULL.
@@ -124,11 +125,11 @@ class SmileyContainer : public gcn::Widget,
*/
void distributeValueChangedEvent(void);
- ImageSet *mSmileyImg;
+ ImageSet *mEmoteImg;
Image *mSelImg;
int mSelectedEmoteIndex;
- int mMaxSmiley;
+ int mMaxEmote;
std::list<gcn::SelectionListener*> mListeners;
diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp
new file mode 100644
index 00000000..5e984dd5
--- /dev/null
+++ b/src/gui/emoteshortcutcontainer.cpp
@@ -0,0 +1,192 @@
+/*
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
+ *
+ * This file is part of Aethyra.
+ *
+ * Aethyra 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
+ * any later version.
+ *
+ * Aethyra 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 Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "emoteshortcutcontainer.h"
+
+#include "../emoteshortcut.h"
+#include "../graphics.h"
+#include "../inventory.h"
+#include "../item.h"
+#include "../itemshortcut.h"
+#include "../keyboardconfig.h"
+#include "../localplayer.h"
+#include "../log.h"
+
+#include "../resources/image.h"
+#include "../resources/resourcemanager.h"
+
+#include "../utils/gettext.h"
+#include "../utils/tostring.h"
+
+EmoteShortcutContainer::EmoteShortcutContainer():
+ mEmoteClicked(false),
+ mEmoteMoved(0)
+{
+ mGridWidth = 1,
+ mGridHeight = 1,
+ addMouseListener(this);
+ addWidgetListener(this);
+
+ ResourceManager *resman = ResourceManager::getInstance();
+
+ mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png");
+ mEmoteImg = resman->getImageSet("graphics/sprites/emotions.png", 30, 32);
+ if (!mEmoteImg) logger->error(_("Unable to load emotions"));
+
+ mMaxItems = emoteShortcut->getEmoteCount();
+
+ mBoxHeight = mBackgroundImg->getHeight();
+ mBoxWidth = mBackgroundImg->getWidth();
+}
+
+EmoteShortcutContainer::~EmoteShortcutContainer()
+{
+ mBackgroundImg->decRef();
+ if (mEmoteImg)
+ {
+ mEmoteImg->decRef();
+ mEmoteImg=NULL;
+ }
+}
+
+void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
+{
+ Graphics *g = static_cast<Graphics*>(graphics);
+
+ //graphics->setFont(getFont());
+
+ for (int i = 0; i < mMaxItems; i++)
+ {
+ const int emoteX = (i % mGridWidth) * mBoxWidth;
+ const int emoteY = (i / mGridWidth) * mBoxHeight;
+
+ g->drawImage(mBackgroundImg, emoteX, emoteY);
+
+ // Draw emote keyboard shortcut.
+ const char *key = SDL_GetKeyName(
+ (SDLKey) keyboard.getKeyValue(keyboard.KEY_EMOTE_1 + i));
+ graphics->setColor(0x000000);
+ g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT);
+
+ if (emoteShortcut->getEmote(i))
+ {
+ static_cast<Graphics*>(graphics)->drawImage(
+ mEmoteImg->get(emoteShortcut->getEmote(i) - 1), emoteX + 2, emoteY + 10);
+ }
+
+ }
+ if (mEmoteMoved)
+ {
+ // Draw the emote image being dragged by the cursor.
+ Image* image = mEmoteImg->get(mEmoteMoved-1);
+ if (image)
+ {
+ const int tPosX = mCursorPosX - (image->getWidth() / 2);
+ const int tPosY = mCursorPosY - (image->getHeight() / 2);
+
+ g->drawImage(image, tPosX, tPosY);
+ }
+ }
+}
+
+void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event)
+{
+ if (event.getButton() == gcn::MouseEvent::LEFT)
+ {
+ if (!mEmoteMoved && mEmoteClicked)
+ {
+ const int index = getIndexFromGrid(event.getX(), event.getY());
+ const int emoteId = emoteShortcut->getEmote(index);
+
+ if (index == -1)
+ {
+ return;
+ }
+
+ if (emoteId)
+ {
+ mEmoteMoved = emoteId;
+ emoteShortcut->removeEmote(index);
+ }
+ }
+ if (mEmoteMoved)
+ {
+ mCursorPosX = event.getX();
+ mCursorPosY = event.getY();
+ }
+ }
+}
+
+void EmoteShortcutContainer::mousePressed(gcn::MouseEvent &event)
+{
+ const int index = getIndexFromGrid(event.getX(), event.getY());
+
+ if (index == -1)
+ {
+ return;
+ }
+
+ // Stores the selected emote if there is one.
+ if (emoteShortcut->isEmoteSelected())
+ {
+ emoteShortcut->setEmote(index);
+ emoteShortcut->setEmoteSelected(0);
+ }
+ else if (emoteShortcut->getEmote(index))
+ {
+ mEmoteClicked = true;
+ }
+}
+
+void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event)
+{
+ if (event.getButton() == gcn::MouseEvent::LEFT)
+ {
+ const int index = getIndexFromGrid(event.getX(), event.getY());
+
+ if (emoteShortcut->isEmoteSelected())
+ {
+ emoteShortcut->setEmoteSelected(0);
+ }
+
+ if (index == -1)
+ {
+ mEmoteMoved = 0;
+ return;
+ }
+
+ if (mEmoteMoved)
+ {
+ emoteShortcut->setEmotes(index, mEmoteMoved);
+ mEmoteMoved = 0;
+ }
+ else if (emoteShortcut->getEmote(index) && mEmoteClicked)
+ {
+ emoteShortcut->useEmote(index + 1);
+ }
+
+ if (mEmoteClicked)
+ {
+ mEmoteClicked = false;
+ }
+ }
+}
+
diff --git a/src/gui/smileyshortcutcontainer.h b/src/gui/emoteshortcutcontainer.h
index 55df6124..5b3f61cd 100644
--- a/src/gui/smileyshortcutcontainer.h
+++ b/src/gui/emoteshortcutcontainer.h
@@ -1,56 +1,56 @@
/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
*
- * This file is part of The Mana World.
+ * This file is part of Aethyra.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * Aethyra 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
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * Aethyra 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_SMILEYSHORTCUTCONTAINER_H__
-#define _TMW_SMILEYSHORTCUTCONTAINER_H__
+#ifndef _AETHYRA_EMOTESHORTCUTCONTAINER_H__
+#define _AETHYRA_EMOTESHORTCUTCONTAINER_H__
#include <guichan/mouselistener.hpp>
#include <guichan/widget.hpp>
#include <guichan/widgetlistener.hpp>
-#include "../resources/imageset.h"
+#include "shortcutcontainer.h"
+
#include "../guichanfwd.h"
-#include "shortcutcontainer.h"
+#include "../resources/imageset.h"
class Image;
-class Item;
/**
- * A smiley shortcut container. Used to quickly use items.
+ * An emote shortcut container. Used to quickly use emoticons.
*
* \ingroup GUI
*/
-class SmileyShortcutContainer : public ShortcutContainer
+class EmoteShortcutContainer : public ShortcutContainer
{
public:
/**
* Constructor. Initializes the graphic.
*/
- SmileyShortcutContainer();
+ EmoteShortcutContainer();
/**
* Destructor.
*/
- virtual ~SmileyShortcutContainer();
+ virtual ~EmoteShortcutContainer();
/**
* Draws the items.
@@ -73,10 +73,10 @@ class SmileyShortcutContainer : public ShortcutContainer
void mouseReleased(gcn::MouseEvent &event);
private:
- ImageSet *mSmileyImg;
+ ImageSet *mEmoteImg;
- bool mSmileyClicked;
- int mSmileyMoved;
+ bool mEmoteClicked;
+ int mEmoteMoved;
};
#endif
diff --git a/src/gui/smileywindow.cpp b/src/gui/emotewindow.cpp
index e3e821ff..af9648ef 100644
--- a/src/gui/smileywindow.cpp
+++ b/src/gui/emotewindow.cpp
@@ -1,22 +1,22 @@
/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
*
- * This file is part of The Mana World.
+ * This file is part of Aethyra.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * Aethyra 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
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * Aethyra 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string>
@@ -25,8 +25,8 @@
#include "button.h"
#include "gui.h"
-#include "smileywindow.h"
-#include "smileycontainer.h"
+#include "emotewindow.h"
+#include "emotecontainer.h"
#include "scrollarea.h"
#include "../localplayer.h"
@@ -34,7 +34,7 @@
#include "../utils/gettext.h"
#include "../utils/tostring.h"
-SmileyWindow::SmileyWindow():
+EmoteWindow::EmoteWindow():
Window(_("Emote"))
{
setWindowName(_("Emote"));
@@ -45,7 +45,7 @@ SmileyWindow::SmileyWindow():
mUseButton = new Button(_("Use"), "use", this);
- mEmotes = new SmileyContainer();
+ mEmotes = new EmoteContainer();
mEmotes->addSelectionListener(this);
mInvenScroll = new ScrollArea(mEmotes);
@@ -61,9 +61,9 @@ SmileyWindow::SmileyWindow():
loadWindowState();
}
-void SmileyWindow::action(const gcn::ActionEvent &event)
+void EmoteWindow::action(const gcn::ActionEvent &event)
{
- int emote = mEmotes->getSelectedSmiley();
+ int emote = mEmotes->getSelectedEmote();
if (!emote)
return;
@@ -72,7 +72,7 @@ void SmileyWindow::action(const gcn::ActionEvent &event)
}
-void SmileyWindow::draw()
+void EmoteWindow::draw()
{
const gcn::Rectangle &area = getChildrenArea();
const int width = area.width;
@@ -86,14 +86,14 @@ void SmileyWindow::draw()
setMinHeight(130);
}
-void SmileyWindow::widgetResized(const gcn::Event &event)
+void EmoteWindow::widgetResized(const gcn::Event &event)
{
Window::widgetResized(event);
draw();
}
-int SmileyWindow::getSelectedSmiley() const
+int EmoteWindow::getSelectedEmote() const
{
- return mEmotes->getSelectedSmiley();
+ return mEmotes->getSelectedEmote();
}
diff --git a/src/gui/smileywindow.h b/src/gui/emotewindow.h
index db27fcbd..a382e37d 100644
--- a/src/gui/smileywindow.h
+++ b/src/gui/emotewindow.h
@@ -1,26 +1,26 @@
/*
- * The Mana World
- * Copyright 2004 The Mana World Development Team
+ * Aethyra
+ * Copyright 2009 Aethyra Development Team
*
- * This file is part of The Mana World.
+ * This file is part of Aethyra.
*
- * The Mana World is free software; you can redistribute it and/or modify
+ * Aethyra 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
* any later version.
*
- * The Mana World is distributed in the hope that it will be useful,
+ * Aethyra 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with Aethyra; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _TMW_SMILEYWINDOW_H
-#define _TMW_SMILEYWINDOW_H
+#ifndef _AETHYRA_EMOTEWINDOW_H
+#define _AETHYRA_EMOTEWINDOW_H
#include <guichan/actionlistener.hpp>
#include <guichan/selectionlistener.hpp>
@@ -30,22 +30,21 @@
#include "../guichanfwd.h"
-class Item;
-class SmileyContainer;
+class EmoteContainer;
/**
- * smiley dialog.
+ * Emote dialog.
*
* \ingroup Interface
*/
-class SmileyWindow : public Window, gcn::ActionListener,
+class EmoteWindow : public Window, gcn::ActionListener,
gcn::SelectionListener
{
public:
/**
* Constructor.
*/
- SmileyWindow();
+ EmoteWindow();
/**
* Called when receiving actions from the widgets.
@@ -55,7 +54,7 @@ class SmileyWindow : public Window, gcn::ActionListener,
/**
* Returns the selected item.
*/
- int getSelectedSmiley() const;
+ int getSelectedEmote() const;
/**
* Updates window drawing.
@@ -69,12 +68,12 @@ class SmileyWindow : public Window, gcn::ActionListener,
private:
- SmileyContainer *mEmotes;
+ EmoteContainer *mEmotes;
gcn::Button *mUseButton;
gcn::ScrollArea *mInvenScroll;
};
-extern SmileyWindow *smileyWindow;
+extern EmoteWindow *emoteWindow;
#endif
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index b576e843..7e2eeac0 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -50,8 +50,8 @@ ItemShortcutContainer::ItemShortcutContainer():
mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
- mBoxHeight = 42;
- mBoxWidth = 36;
+ mBoxHeight = mBackgroundImg->getHeight();
+ mBoxWidth = mBackgroundImg->getWidth();
}
ItemShortcutContainer::~ItemShortcutContainer()
@@ -89,7 +89,7 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics)
// Draw item keyboard shortcut.
const char *key = SDL_GetKeyName(
- (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_0 + i));
+ (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i));
graphics->setColor(0x000000);
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp
index 99eaca34..2a175a61 100644
--- a/src/gui/menuwindow.cpp
+++ b/src/gui/menuwindow.cpp
@@ -33,7 +33,7 @@ extern Window *chatWindow;
extern Window *equipmentWindow;
extern Window *inventoryWindow;
extern Window *itemShortcutWindow;
-extern Window *smileyWindow;
+extern Window *emoteWindow;
extern Window *setupWindow;
extern Window *skillDialog;
extern Window *statusWindow;
@@ -120,7 +120,7 @@ void MenuWindowListener::action(const gcn::ActionEvent &event)
}
else if (event.getId() == _("Emote"))
{
- window = smileyWindow;
+ window = emoteWindow;
}
else if (event.getId() == _("Setup"))
{
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index bcffbae0..66f15f03 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -43,8 +43,8 @@ extern Window *minimap;
extern Window *skillDialog;
extern Window *statusWindow;
extern Window *itemShortcutWindow;
-extern Window *smileyShortcutWindow;
-extern Window *smileyWindow;
+extern Window *emoteShortcutWindow;
+extern Window *emoteWindow;
extern Window *tradeWindow;
Setup::Setup():
@@ -138,8 +138,8 @@ void Setup::action(const gcn::ActionEvent &event)
helpWindow->resetToDefaultSize();
skillDialog->resetToDefaultSize();
itemShortcutWindow->resetToDefaultSize();
- smileyShortcutWindow->resetToDefaultSize();
- smileyWindow->resetToDefaultSize();
+ emoteShortcutWindow->resetToDefaultSize();
+ emoteWindow->resetToDefaultSize();
tradeWindow->resetToDefaultSize();
}
}
diff --git a/src/gui/setup.h b/src/gui/setup.h
index fd200f4c..1ad93cac 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -53,8 +53,7 @@ class Setup : public Window, public gcn::ActionListener
/**
* Event handling method.
*/
- void
- action(const gcn::ActionEvent &event);
+ void action(const gcn::ActionEvent &event);
private:
std::list<SetupTab*> mTabs;
diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp
index 32d7c6af..88d9bb22 100644
--- a/src/gui/shortcutcontainer.cpp
+++ b/src/gui/shortcutcontainer.cpp
@@ -43,7 +43,8 @@ ShortcutContainer::ShortcutContainer():
void ShortcutContainer::widgetResized(const gcn::Event &event)
{
mGridWidth = getWidth() / mBoxWidth;
- if (mGridWidth < 1) {
+ if (mGridWidth < 1)
+ {
mGridWidth = 1;
}
@@ -51,7 +52,8 @@ void ShortcutContainer::widgetResized(const gcn::Event &event)
(mMaxItems % mGridWidth > 0 ? 1 : 0)) * mBoxHeight);
mGridHeight = getHeight() / mBoxHeight;
- if (mGridHeight < 1) {
+ if (mGridHeight < 1)
+ {
mGridHeight = 1;
}
}
@@ -61,7 +63,8 @@ ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const
{
const gcn::Rectangle tRect = gcn::Rectangle(
0, 0, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight);
- if (!tRect.isPointInRect(pointX, pointY)) {
+ if (!tRect.isPointInRect(pointX, pointY))
+ {
return -1;
}
const int index = ((pointY / mBoxHeight) * mGridWidth) +
diff --git a/src/gui/shortcutcontainer.h b/src/gui/shortcutcontainer.h
index ebc0a9fc..9d0584d3 100644
--- a/src/gui/shortcutcontainer.h
+++ b/src/gui/shortcutcontainer.h
@@ -29,7 +29,6 @@
#include "../guichanfwd.h"
class Image;
-class Item;
/**
* An item shortcut container. Used to quickly use items.
@@ -54,7 +53,7 @@ class ShortcutContainer : public gcn::Widget,
/**
* Draws the items.
*/
- virtual void draw(gcn::Graphics *graphics)=0;
+ virtual void draw(gcn::Graphics *graphics) = 0;
/**
* Invoked when a widget changes its size. This is used to determine
@@ -65,17 +64,17 @@ class ShortcutContainer : public gcn::Widget,
/**
* Handles mouse when dragged.
*/
- virtual void mouseDragged(gcn::MouseEvent &event)=0;
+ virtual void mouseDragged(gcn::MouseEvent &event) = 0;
/**
* Handles mouse when pressed.
*/
- virtual void mousePressed(gcn::MouseEvent &event)=0;
+ virtual void mousePressed(gcn::MouseEvent &event) = 0;
/**
* Handles mouse release.
*/
- virtual void mouseReleased(gcn::MouseEvent &event)=0;
+ virtual void mouseReleased(gcn::MouseEvent &event) = 0;
virtual int getMaxItems()
{ return mMaxItems; }
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index b5a23c2c..9ac1a52a 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -60,6 +60,6 @@ class ShortcutWindow : public Window
};
extern ShortcutWindow *itemShortcutWindow;
-extern ShortcutWindow *smileyShortcutWindow;
+extern ShortcutWindow *emoteShortcutWindow;
#endif
diff --git a/src/gui/smileyshortcutcontainer.cpp b/src/gui/smileyshortcutcontainer.cpp
deleted file mode 100644
index c3cd056d..00000000
--- a/src/gui/smileyshortcutcontainer.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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
- * any later version.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "smileyshortcutcontainer.h"
-
-#include "../graphics.h"
-#include "../inventory.h"
-#include "../item.h"
-#include "../itemshortcut.h"
-#include "../smileyshortcut.h"
-#include "../keyboardconfig.h"
-#include "../localplayer.h"
-#include "../log.h"
-
-
-#include "../resources/image.h"
-#include "../resources/resourcemanager.h"
-
-#include "../utils/gettext.h"
-#include "../utils/tostring.h"
-
-SmileyShortcutContainer::SmileyShortcutContainer():
- mSmileyClicked(false),
- mSmileyMoved(0)
-{
- mGridWidth = 1,
- mGridHeight = 1,
- addMouseListener(this);
- addWidgetListener(this);
-
- ResourceManager *resman = ResourceManager::getInstance();
-
- mBackgroundImg = resman->getImage("graphics/gui/item_shortcut_bgr.png");
- mSmileyImg = resman->getImageSet("graphics/sprites/emotions.png", 30, 32);
- if (!mSmileyImg) logger->error(_("Unable to load emotions"));
-
- mMaxItems = smileyShortcut->getSmileyCount();
-
- mBoxHeight = 42;
- mBoxWidth = 36;
-}
-
-SmileyShortcutContainer::~SmileyShortcutContainer()
-{
- mBackgroundImg->decRef();
- if (mSmileyImg)
- {
- mSmileyImg->decRef();
- mSmileyImg=NULL;
- }
-
-}
-
-void
-SmileyShortcutContainer::draw(gcn::Graphics *graphics)
-{
- Graphics *g = static_cast<Graphics*>(graphics);
-
- graphics->setFont(getFont());
-
- for (int i = 0; i < mMaxItems; i++)
- {
- const int itemX = (i % mGridWidth) * mBoxWidth;
- const int itemY = (i / mGridWidth) * mBoxHeight;
-
- g->drawImage(mBackgroundImg, itemX, itemY);
-
- // Draw item keyboard shortcut.
- const char *key = SDL_GetKeyName(
- (SDLKey) keyboard.getKeyValue(keyboard.KEY_SMILEY_1 + i));
- graphics->setColor(0x000000);
- g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
- if (smileyShortcut->getSmiley(i))
- {
- static_cast<Graphics*>(graphics)->drawImage(
- mSmileyImg->get(smileyShortcut->getSmiley(i)-1), itemX+2, itemY+10);
- }
-
- }
- if (mSmileyMoved)
- {
- // Draw the item image being dragged by the cursor.
- Image* image = mSmileyImg->get(mSmileyMoved-1);
- if (image)
- {
- const int tPosX = mCursorPosX - (image->getWidth() / 2);
- const int tPosY = mCursorPosY - (image->getHeight() / 2);
-
- g->drawImage(image, tPosX, tPosY);
- }
- }
-}
-
-void
-SmileyShortcutContainer::mouseDragged(gcn::MouseEvent &event)
-{
- if (event.getButton() == gcn::MouseEvent::LEFT) {
- if (!mSmileyMoved && mSmileyClicked) {
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1) {
- return;
- }
- const int smileyId = smileyShortcut->getSmiley(index);
- if (smileyId)
- {
- mSmileyMoved = smileyId;
- smileyShortcut->removeSmiley(index);
- }
- }
- if (mSmileyMoved) {
- mCursorPosX = event.getX();
- mCursorPosY = event.getY();
- }
- }
-}
-
-void
-SmileyShortcutContainer::mousePressed(gcn::MouseEvent &event)
-{
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1) {
- return;
- }
- // Stores the selected item if theirs one.
- if (smileyShortcut->isSmileySelected()) {
- smileyShortcut->setSmiley(index);
- smileyShortcut->setSmileySelected(0);
- }
- else if (smileyShortcut->getSmiley(index)) {
- mSmileyClicked = true;
- }
-}
-
-void
-SmileyShortcutContainer::mouseReleased(gcn::MouseEvent &event)
-{
- if (event.getButton() == gcn::MouseEvent::LEFT)
- {
- if (smileyShortcut->isSmileySelected())
- {
- smileyShortcut->setSmileySelected(0);
- }
- const int index = getIndexFromGrid(event.getX(), event.getY());
- if (index == -1) {
- mSmileyMoved = 0;
- return;
- }
- if (mSmileyMoved) {
- smileyShortcut->setSmileys(index, mSmileyMoved);
- mSmileyMoved = 0;
- }
- else if (smileyShortcut->getSmiley(index) && mSmileyClicked)
- {
- smileyShortcut->useSmiley(index+1);
- }
- if (mSmileyClicked) {
- mSmileyClicked = false;
- }
- }
-}
-
diff --git a/src/itemshortcut.h b/src/itemshortcut.h
index a0c52468..57800d96 100644
--- a/src/itemshortcut.h
+++ b/src/itemshortcut.h
@@ -22,7 +22,7 @@
#ifndef _TMW_ITEMSHORTCUT_H__
#define _TMW_ITEMSHORTCUT_H__
-#define SHORTCUT_ITEMS 10
+#define SHORTCUT_ITEMS 12
class Item;
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 0923f331..932f6ad2 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -50,7 +50,6 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyPickup", SDLK_z, "Pickup"},
{"keyHideWindows", SDLK_h, "Hide Windows"},
{"keyBeingSit", SDLK_s, "Sit"},
- {"keyShortcut0", SDLK_0, "Item Shortcut 0"},
{"keyShortcut1", SDLK_1, "Item Shortcut 1"},
{"keyShortcut2", SDLK_2, "Item Shortcut 2"},
{"keyShortcut3", SDLK_3, "Item Shortcut 3"},
@@ -60,6 +59,9 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyShortcut7", SDLK_7, "Item Shortcut 7"},
{"keyShortcut8", SDLK_8, "Item Shortcut 8"},
{"keyShortcut9", SDLK_9, "Item Shortcut 9"},
+ {"keyShortcut10", SDLK_0, "Item Shortcut 10"},
+ {"keyShortcut11", SDLK_MINUS, "Item Shortcut 11"},
+ {"keyShortcut12", SDLK_EQUALS, "Item Shortcut 12"},
{"keyWindowStatus", SDLK_F2, "Status Window"},
{"keyWindowInventory", SDLK_F3, "Inventory Window"},
{"keyWindowEquipment", SDLK_F4, "Equipment WIndow"},
@@ -69,20 +71,20 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyWindowShortcut", SDLK_F8, "Item Shortcut Window"},
{"keyWindowSetup", SDLK_F9, "Setup Window"},
{"keyWindowDebug", SDLK_F10, "Debug Window"},
- {"keyWindowSmileyList", SDLK_F11, "Smiley List Window"},
- {"keyWindowSmileyBar", SDLK_F12, "Smiley Shortcut Window"},
- {"keySmileyShortcut1", SDLK_KP1, "Smiley Shortcut 1"},
- {"keySmileyShortcut2", SDLK_KP2, "Smiley Shortcut 2"},
- {"keySmileyShortcut3", SDLK_KP3, "Smiley Shortcut 3"},
- {"keySmileyShortcut4", SDLK_KP4, "Smiley Shortcut 4"},
- {"keySmileyShortcut5", SDLK_KP5, "Smiley Shortcut 5"},
- {"keySmileyShortcut6", SDLK_KP6, "Smiley Shortcut 6"},
- {"keySmileyShortcut7", SDLK_KP7, "Smiley Shortcut 7"},
- {"keySmileyShortcut8", SDLK_KP8, "Smiley Shortcut 8"},
- {"keySmileyShortcut9", SDLK_KP9, "Smiley Shortcut 9"},
- {"keySmileyShortcut10", SDLK_KP0, "Smiley Shortcut 10"},
- {"keySmileyShortcut11", SDLK_KP_DIVIDE, "Smiley Shortcut 11"},
- {"keySmileyShortcut12", SDLK_KP_MULTIPLY, "Smiley Shortcut 12"}
+ {"keyWindowEmote", SDLK_F11, "Emote Window"},
+ {"keyWindowEmoteBar", SDLK_F12, "Emote Shortcut Window"},
+ {"keyEmoteShortcut1", SDLK_1, "Emote Shortcut 1"},
+ {"keyEmoteShortcut2", SDLK_2, "Emote Shortcut 2"},
+ {"keyEmoteShortcut3", SDLK_3, "Emote Shortcut 3"},
+ {"keyEmoteShortcut4", SDLK_4, "Emote Shortcut 4"},
+ {"keyEmoteShortcut5", SDLK_5, "Emote Shortcut 5"},
+ {"keyEmoteShortcut6", SDLK_6, "Emote Shortcut 6"},
+ {"keyEmoteShortcut7", SDLK_7, "Emote Shortcut 7"},
+ {"keyEmoteShortcut8", SDLK_8, "Emote Shortcut 8"},
+ {"keyEmoteShortcut9", SDLK_9, "Emote Shortcut 9"},
+ {"keyEmoteShortcut10", SDLK_0, "Emote Shortcut 10"},
+ {"keyEmoteShortcut11", SDLK_MINUS, "Emote Shortcut 11"},
+ {"keyEmoteShortcut12", SDLK_EQUALS, "Emote Shortcut 12"}
};
void KeyboardConfig::init()
@@ -134,16 +136,11 @@ bool KeyboardConfig::hasConflicts()
*/
for (i = 0; i < KEY_TOTAL; i++)
{
- for (j = i,j++; j < KEY_TOTAL; j++)
+ for (j = i, j++; j < KEY_TOTAL; j++)
{
-/**
- * KEY_SMILEY_* are separated from other keys, duplicate in different
- * area is allowed, but not in same area (of course)
- * (i.e.: not two identical key for smiley, not two identical for other;
- * but same key for a smiley and a not-smiley is ok)
- *
- */
- if (!((i<KEY_SMILEY_1)&&(j>=KEY_SMILEY_1))
+ // Allow for item shortcut and emote keys to overlap, but no other keys
+ if (!(((i >= KEY_SHORTCUT_1) && (i <= KEY_SHORTCUT_12)) &&
+ ((j >= KEY_EMOTE_1) && (j <= KEY_EMOTE_12)))
&& mKey[i].value == mKey[j].value
)
{
@@ -171,13 +168,14 @@ int KeyboardConfig::getKeyIndex(int keyValue) const
return KEY_NO_VALUE;
}
-int KeyboardConfig::getKeySmilieOffset(int keyValue) const
+
+int KeyboardConfig::getKeyEmoteOffset(int keyValue) const
{
- for (int i = KEY_SMILEY_1; i <= KEY_SMILEY_12; i++)
+ for (int i = KEY_EMOTE_1; i <= KEY_EMOTE_12; i++)
{
if(keyValue == mKey[i].value)
{
- return 1+i-KEY_SMILEY_1;
+ return 1 + i - KEY_EMOTE_1;
}
}
return 0;
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index f6439795..716f9a17 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -103,9 +103,9 @@ class KeyboardConfig
int getKeyIndex(int keyValue) const;
/**
- * Get the key function index for smiley by providing the offset value.
+ * Get the key function index for an emote by providing the offset value.
*/
- int getKeySmilieOffset(int keyValue) const;
+ int getKeyEmoteOffset(int keyValue) const;
/**
* Set the enable flag, which will stop the user from doing actions.
@@ -147,8 +147,6 @@ class KeyboardConfig
* KEY_TOTAL should always be last (used as a conditional in loops).
* The key assignment view gets arranged according to the order of
* these values.
- *
- * KEY_SMILEY_* must be also at the end (just before KEY_TOTAL)
*/
enum KeyAction {
KEY_NO_VALUE = -1,
@@ -157,7 +155,7 @@ class KeyboardConfig
KEY_MOVE_LEFT,
KEY_MOVE_RIGHT,
KEY_ATTACK,
- KEY_SMILIE,
+ KEY_EMOTE,
KEY_TALK,
KEY_TARGET,
KEY_TARGET_CLOSEST,
@@ -166,7 +164,6 @@ class KeyboardConfig
KEY_PICKUP,
KEY_HIDE_WINDOWS,
KEY_SIT,
- KEY_SHORTCUT_0,
KEY_SHORTCUT_1,
KEY_SHORTCUT_2,
KEY_SHORTCUT_3,
@@ -176,6 +173,9 @@ class KeyboardConfig
KEY_SHORTCUT_7,
KEY_SHORTCUT_8,
KEY_SHORTCUT_9,
+ KEY_SHORTCUT_10,
+ KEY_SHORTCUT_11,
+ KEY_SHORTCUT_12,
KEY_WINDOW_STATUS,
KEY_WINDOW_INVENTORY,
KEY_WINDOW_EQUIPMENT,
@@ -185,20 +185,20 @@ class KeyboardConfig
KEY_WINDOW_SHORTCUT,
KEY_WINDOW_SETUP,
KEY_WINDOW_DEBUG,
- KEY_WINDOW_ALLSMILEY,
- KEY_WINDOW_SMILEY_SHORTCUT,
- KEY_SMILEY_1,
- KEY_SMILEY_2,
- KEY_SMILEY_3,
- KEY_SMILEY_4,
- KEY_SMILEY_5,
- KEY_SMILEY_6,
- KEY_SMILEY_7,
- KEY_SMILEY_8,
- KEY_SMILEY_9,
- KEY_SMILEY_10,
- KEY_SMILEY_11,
- KEY_SMILEY_12,
+ KEY_WINDOW_EMOTE,
+ KEY_WINDOW_EMOTE_SHORTCUT,
+ KEY_EMOTE_1,
+ KEY_EMOTE_2,
+ KEY_EMOTE_3,
+ KEY_EMOTE_4,
+ KEY_EMOTE_5,
+ KEY_EMOTE_6,
+ KEY_EMOTE_7,
+ KEY_EMOTE_8,
+ KEY_EMOTE_9,
+ KEY_EMOTE_10,
+ KEY_EMOTE_11,
+ KEY_EMOTE_12,
KEY_TOTAL
};
diff --git a/src/main.cpp b/src/main.cpp
index d9ebaefa..3cf8611d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -40,7 +40,6 @@
#include "game.h"
#include "graphics.h"
#include "itemshortcut.h"
-#include "smileyshortcut.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "lockedarray.h"
@@ -57,6 +56,7 @@
#include "gui/char_server.h"
#include "gui/char_select.h"
#include "gui/colour.h"
+#include "gui/emoteshortcut.h"
#include "gui/gui.h"
#include "gui/login.h"
#include "gui/ok_dialog.h"
@@ -403,8 +403,8 @@ void init_engine(const Options &options)
// Initialize the item shortcuts.
itemShortcut = new ItemShortcut();
- // Initialize the smiley shortcuts.
- smileyShortcut = new SmileyShortcut();
+ // Initialize the emote shortcuts.
+ emoteShortcut = new EmoteShortcut();
gui = new Gui(graphics);
state = LOGIN_STATE; /**< Initial game state */
@@ -438,7 +438,7 @@ void exit_engine()
// Before config.write() since it writes the shortcuts to the config
delete itemShortcut;
- delete smileyShortcut;
+ delete emoteShortcut;
config.write();
diff --git a/src/smileyshortcut.cpp b/src/smileyshortcut.cpp
deleted file mode 100644
index adc7d9c3..00000000
--- a/src/smileyshortcut.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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
- * any later version.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "configuration.h"
-#include "smileyshortcut.h"
-#include "localplayer.h"
-
-#include "utils/tostring.h"
-
-SmileyShortcut::SmileyShortcut *smileyShortcut;
-
-SmileyShortcut::SmileyShortcut():
- mSmileySelected(0)
-{
- for (int i = 0; i < SHORTCUT_SMILEYS; i++)
- {
- mSmileys[i] = i+1;
- }
- load();
-}
-
-SmileyShortcut::~SmileyShortcut()
-{
- save();
-}
-
-void SmileyShortcut::load()
-{
- for (int i = 0; i < SHORTCUT_SMILEYS; i++)
- {
- int smileyId = (int) config.getValue("Smileyshortcut" + toString(i), i+1);
-
- if (smileyId)
- {
- mSmileys[i] = smileyId;
- }
- }
-}
-
-void SmileyShortcut::save()
-{
- for (int i = 0; i < SHORTCUT_SMILEYS; i++)
- {
- const int smileyId = mSmileys[i] ? mSmileys[i] : 0;
- config.setValue("Smileyshortcut" + toString(i), smileyId);
- }
-}
-
-void SmileyShortcut::useSmiley(int index)
-{
- if ((index>0)&&(index<=SHORTCUT_SMILEYS))
- {
- if (mSmileys[index-1]>0)
- {
- player_node->emote(mSmileys[index-1]);
- }
- }
-}
diff --git a/src/smileyshortcut.h b/src/smileyshortcut.h
deleted file mode 100644
index c4fb9280..00000000
--- a/src/smileyshortcut.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * The Mana World
- * Copyright 2007 The Mana World Development Team
- *
- * This file is part of The Mana World.
- *
- * The Mana World 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
- * any later version.
- *
- * The Mana World 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 The Mana World; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _TMW_SMILEYSHORTCUT_H__
-#define _TMW_SMILEYSHORTCUT_H__
-
-#define SHORTCUT_SMILEYS 12
-
-class Item;
-
-/**
- * The class which keeps track of the item shortcuts.
- */
-class SmileyShortcut
-{
- public:
- /**
- * Constructor.
- */
- SmileyShortcut();
-
- /**
- * Destructor.
- */
- ~SmileyShortcut();
-
- /**
- * Load the configuration information.
- */
- void load();
-
- /**
- * Returns the shortcut smiley ID specified by the index.
- *
- * @param index Index of the shortcut smiley.
- */
- int getSmiley(int index) const
- { return mSmileys[index]; }
-
- /**
- * Returns the amount of shortcut smileys.
- */
- int getSmileyCount() const
- { return SHORTCUT_SMILEYS; }
-
- /**
- * Returns the item ID that is currently selected.
- */
- int getSmileySelected() const
- { return mSmileySelected; }
-
- /**
- * Adds the selected item ID to the items specified by the index.
- *
- * @param index Index of the items.
- */
- void setSmiley(int index)
- { mSmileys[index] = mSmileySelected; }
-
- /**
- * Adds a smiley to the smileys store specified by the index.
- *
- * @param index Index of the smiley.
- * @param smileyId ID of the smiley.
- */
- void setSmileys(int index, int smileyId)
- { mSmileys[index] = smileyId; }
-
- /**
- * Set the smiley that is selected.
- *
- * @param smileyId The ID of the smiley that is to be assigned.
- */
- void setSmileySelected(int smileyId)
- { mSmileySelected = smileyId; }
-
- /**
- * A flag to check if the smiley is selected.
- */
- bool isSmileySelected()
- { return mSmileySelected; }
-
- /**
- * Remove a smiley from the shortcut.
- */
- void removeSmiley(int index)
- { mSmileys[index] = 0; }
-
- /**
- * Try to use the smiley specified by the index.
- *
- * @param index Index of the smiley shortcut.
- */
- void useSmiley(int index);
-
- private:
- /**
- * Save the configuration information.
- */
- void save();
-
- int mSmileys[SHORTCUT_SMILEYS]; /**< The smiley stored. */
- int mSmileySelected; /**< The smiley held by cursor. */
-
-};
-
-extern SmileyShortcut *smileyShortcut;
-
-#endif