summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/emotepopup.cpp223
-rw-r--r--src/gui/emotepopup.h122
-rw-r--r--src/gui/windowmenu.cpp48
-rw-r--r--src/gui/windowmenu.h4
6 files changed, 7 insertions, 394 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b22bde560..7fe4630b3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -247,8 +247,6 @@ SET(SRCS
gui/didyouknowwindow.h
gui/editserverdialog.cpp
gui/editserverdialog.h
- gui/emotepopup.cpp
- gui/emotepopup.h
gui/equipmentwindow.cpp
gui/equipmentwindow.h
gui/focushandler.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 7e6b6caa9..00a136b4a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -256,8 +256,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/didyouknowwindow.h \
gui/editserverdialog.cpp \
gui/editserverdialog.h \
- gui/emotepopup.cpp \
- gui/emotepopup.h \
gui/equipmentwindow.cpp \
gui/equipmentwindow.h \
gui/focushandler.cpp \
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
deleted file mode 100644
index 33ecc037f..000000000
--- a/src/gui/emotepopup.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Extended support for activating emotes
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2012 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program 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.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/emotepopup.h"
-
-#include "animatedsprite.h"
-#include "configuration.h"
-#include "emoteshortcut.h"
-#include "graphics.h"
-#include "localplayer.h"
-#include "logger.h"
-
-#include "gui/theme.h"
-
-#include "resources/emotedb.h"
-#include "resources/image.h"
-#include "resources/iteminfo.h"
-
-#include "utils/dtor.h"
-
-#include <guichan/mouseinput.hpp>
-#include <guichan/selectionlistener.hpp>
-
-#include "debug.h"
-
-const int EmotePopup::gridWidth = 34; // emote icon width + 4
-const int EmotePopup::gridHeight = 36; // emote icon height + 4
-
-static const int MAX_COLUMNS = 6;
-
-EmotePopup::EmotePopup() :
- Popup("EmotePopup", "emotepopup.xml"),
- mSelectedEmoteIndex(-1),
- mHoveredEmoteIndex(-1),
- mRowCount(1),
- mColumnCount(1)
-{
- // Setup emote sprites
- for (int i = 0; i <= EmoteDB::getLast(); ++i)
- {
- const AnimatedSprite *sprite = EmoteDB::getAnimation(i, true);
- if (sprite)
- mEmotes.push_back(sprite);
- }
-
- mSelectionImage = Theme::getImageFromThemeXml("emote_selection.xml");
- if (!mSelectionImage)
- logger->log1("Error: Unable to load selection.png");
-
- if (mSelectionImage)
- mSelectionImage->setAlpha(Client::getGuiAlpha());
-
- addMouseListener(this);
- recalculateSize();
- setVisible(true);
-}
-
-EmotePopup::~EmotePopup()
-{
- if (mSelectionImage)
- {
- mSelectionImage->decRef();
- mSelectionImage = nullptr;
- }
-}
-
-void EmotePopup::draw(gcn::Graphics *graphics)
-{
- Popup::draw(graphics);
-
- if (!mColumnCount)
- return;
-
- const unsigned int emoteCount = static_cast<unsigned>(mEmotes.size());
- const unsigned int emotesLeft
- = static_cast<unsigned>(mEmotes.size() % mColumnCount);
-
- for (unsigned int i = 0; i < emoteCount ; i++)
- {
- int row = i / mColumnCount;
- int column = i % mColumnCount;
-
- unsigned int emoteX = 4 + column * gridWidth;
- unsigned int emoteY = 4 + row * gridHeight;
-
- // Center the last row when there are less emotes than columns
- if (emotesLeft > 0 && row == mRowCount - 1)
- emoteX += (mColumnCount - emotesLeft) * gridWidth / 2;
-
- // Draw selection image below hovered item
- if (mSelectionImage && static_cast<int>(i) == mHoveredEmoteIndex)
- {
- static_cast<Graphics*>(graphics)->drawImage(
- mSelectionImage, emoteX, emoteY + 4);
- }
-
- // Draw emote icon
- if (mEmotes[i])
- mEmotes[i]->draw(static_cast<Graphics*>(graphics), emoteX, emoteY);
- }
-}
-
-void EmotePopup::mousePressed(gcn::MouseEvent &event)
-{
- if (event.getButton() != gcn::MouseEvent::LEFT)
- return;
-
- const int index = getIndexAt(event.getX(), event.getY());
- if (index != -1)
- {
- setSelectedEmoteIndex(index);
- if (emoteShortcut)
- {
- emoteShortcut->setEmoteSelected(
- static_cast<unsigned char>(index + 1));
- }
- }
-}
-
-void EmotePopup::mouseMoved(gcn::MouseEvent &event)
-{
- Popup::mouseMoved(event);
-
- mHoveredEmoteIndex = getIndexAt(event.getX(), event.getY());
-}
-
-int EmotePopup::getSelectedEmote() const
-{
- return 1 + mSelectedEmoteIndex;
-}
-
-void EmotePopup::setSelectedEmoteIndex(int index)
-{
- if (index == mSelectedEmoteIndex)
- return;
-
- mSelectedEmoteIndex = index;
- distributeValueChangedEvent();
-}
-
-int EmotePopup::getIndexAt(int x, int y) const
-{
- if (!gridWidth || !gridHeight)
- return -1;
-
- const unsigned int emotesLeft
- = static_cast<unsigned>(mEmotes.size() % mColumnCount);
- const unsigned int row = y / gridHeight;
- unsigned int column;
-
- // Take into account that the last row is centered
- if (emotesLeft > 0 && static_cast<signed>(row) == mRowCount - 1)
- {
- int unsigned emotesMissing = mColumnCount - emotesLeft;
- column = std::min((x - emotesMissing * gridWidth / 2) / gridWidth,
- emotesLeft - 1);
- }
- else
- {
- column = std::min(x / gridWidth, mColumnCount - 1);
- }
-
- int unsigned index = column + (row * mColumnCount);
-
- if (index < mEmotes.size())
- return index;
-
- return -1;
-}
-
-void EmotePopup::recalculateSize()
-{
- const unsigned emoteCount = static_cast<unsigned>(mEmotes.size());
-
- mRowCount = emoteCount / MAX_COLUMNS;
- if (emoteCount % MAX_COLUMNS > 0)
- ++mRowCount;
-
- if (mRowCount)
- {
- mColumnCount = emoteCount / mRowCount;
- if (emoteCount % mRowCount > 0)
- ++ mColumnCount;
- }
- else
- {
- mColumnCount = 1;
- }
-
- setContentSize(mColumnCount * gridWidth, mRowCount * gridHeight);
-}
-
-void EmotePopup::distributeValueChangedEvent()
-{
- gcn::SelectionEvent event(this);
-
- for (Listeners::const_iterator i = mListeners.begin(),
- i_end = mListeners.end(); i != i_end; ++i)
- {
- if (*i)
- (*i)->valueChanged(event);
- }
-}
diff --git a/src/gui/emotepopup.h b/src/gui/emotepopup.h
deleted file mode 100644
index 453c4e669..000000000
--- a/src/gui/emotepopup.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Extended support for activating emotes
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2012 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program 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.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef EMOTEPOPUP_H
-#define EMOTEPOPUP_H
-
-#include "gui/widgets/popup.h"
-
-#include <guichan/mouselistener.hpp>
-
-#include <list>
-#include <vector>
-
-class AnimatedSprite;
-class Image;
-
-namespace gcn
-{
- class SelectionListener;
-}
-
-/**
- * An emote popup. Used to activate emotes and assign them to shortcuts.
- *
- * \ingroup GUI
- */
-class EmotePopup : public Popup
-{
- public:
- /**
- * Constructor. Initializes the graphic.
- */
- EmotePopup();
-
- virtual ~EmotePopup();
-
- /**
- * Draws the emotes.
- */
- void draw(gcn::Graphics *graphics);
-
- void mousePressed(gcn::MouseEvent &event);
- void mouseMoved(gcn::MouseEvent &event);
-
- /**
- * Returns the selected emote.
- */
- int getSelectedEmote() const;
-
- /**
- * Adds a listener to the list that's notified each time a change to
- * the selection occurs.
- */
- void addSelectionListener(gcn::SelectionListener *listener)
- { mListeners.push_back(listener); }
-
- /**
- * Removes a listener from the list that's notified each time a change
- * to the selection occurs.
- */
- void removeSelectionListener(gcn::SelectionListener *listener)
- { mListeners.remove(listener); }
-
- private:
- /**
- * Sets the index of the currently selected emote.
- */
- void setSelectedEmoteIndex(int index);
-
- /**
- * Returns the index at the specified coordinates. Returns -1 when
- * there is no valid index.
- */
- int getIndexAt(int x, int y) const;
-
- /**
- * Determine and set the size of the container.
- */
- void recalculateSize();
-
- /**
- * Sends out selection events to the list of selection listeners.
- */
- void distributeValueChangedEvent();
-
- std::vector<const AnimatedSprite*> mEmotes;
- Image *mSelectionImage;
- int mSelectedEmoteIndex;
- int mHoveredEmoteIndex;
-
- int mRowCount;
- int mColumnCount;
-
- typedef std::list<gcn::SelectionListener*> Listeners;
-
- Listeners mListeners;
-
- static const int gridWidth;
- static const int gridHeight;
-};
-
-#endif
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 7ecb8e2fa..37490eea7 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -28,7 +28,6 @@
#include "keyboardconfig.h"
#include "gui/didyouknowwindow.h"
-#include "gui/emotepopup.h"
#include "gui/skilldialog.h"
#ifdef MANASERV_SUPPORT
#include "gui/specialswindow.h"
@@ -48,6 +47,7 @@
#include "debug.h"
+extern Window *emoteShortcutWindow;
extern Window *equipmentWindow;
extern Window *inventoryWindow;
extern Window *itemShortcutWindow;
@@ -60,8 +60,7 @@ extern Window *spellShortcutWindow;
extern Window *botCheckerWindow;
extern Window *socialWindow;
-WindowMenu::WindowMenu():
- mEmotePopup(nullptr),
+WindowMenu::WindowMenu() :
mHaveMouse(false),
mAutoHide(1)
{
@@ -148,32 +147,7 @@ void WindowMenu::action(const gcn::ActionEvent &event)
if (event.getId() == ":-)")
{
- if (!mEmotePopup)
- {
- const gcn::Widget *s = event.getSource();
- if (s)
- {
- const gcn::Rectangle &r = s->getDimension();
- const int parentX = s->getParent()->getX();
-
- mEmotePopup = new EmotePopup;
- const int offset = (r.width - mEmotePopup->getWidth()) / 2;
- mEmotePopup->setPosition(parentX + r.x + offset,
- r.y + r.height + 5);
-
- mEmotePopup->addSelectionListener(this);
- }
- else
- {
- mEmotePopup = nullptr;
- }
- }
- else
- {
- if (windowContainer)
- windowContainer->scheduleDelete(mEmotePopup);
- mEmotePopup = nullptr;
- }
+ window = emoteShortcutWindow;
}
else if (event.getId() == "STA")
{
@@ -242,19 +216,9 @@ void WindowMenu::action(const gcn::ActionEvent &event)
}
}
-void WindowMenu::valueChanged(const gcn::SelectionEvent &event)
-{
- if (event.getSource() == mEmotePopup)
- {
- int emote = mEmotePopup->getSelectedEmote();
- if (emote && emoteShortcut)
- emoteShortcut->useEmote(emote);
-
- if (windowContainer)
- windowContainer->scheduleDelete(mEmotePopup);
- mEmotePopup = nullptr;
- }
-}
+//void WindowMenu::valueChanged(const gcn::SelectionEvent &event)
+//{
+//}
void WindowMenu::addButton(const char* text, std::string description,
int &x, int &h, int key, bool visible)
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
index 01d4e4361..e1c78e5f8 100644
--- a/src/gui/windowmenu.h
+++ b/src/gui/windowmenu.h
@@ -36,7 +36,6 @@
#include <map>
#include <vector>
-class EmotePopup;
class TextPopup;
/**
@@ -58,7 +57,7 @@ class WindowMenu : public Container,
void action(const gcn::ActionEvent &event);
- void valueChanged(const gcn::SelectionEvent &event);
+// void valueChanged(const gcn::SelectionEvent &event);
void mousePressed(gcn::MouseEvent &event);
@@ -88,7 +87,6 @@ class WindowMenu : public Container,
void updateButtons();
- EmotePopup *mEmotePopup;
TextPopup *mTextPopup;
std::vector <gcn::Button*> mButtons;
std::map <std::string, gcn::Button*> mButtonNames;