summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-04 23:55:09 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-04 23:55:09 +0200
commit966be40441f358354055819c6eed1420f18a0792 (patch)
tree9fb632a8f7bd1b662a52891908befc630115dcb5 /src
parent6cacaa3d7f55d91d8b7ca178f8595cc6c6b4383d (diff)
downloadmana-966be40441f358354055819c6eed1420f18a0792.tar.gz
mana-966be40441f358354055819c6eed1420f18a0792.tar.bz2
mana-966be40441f358354055819c6eed1420f18a0792.tar.xz
mana-966be40441f358354055819c6eed1420f18a0792.zip
Removed the no longer used EmoteContainer class
This code moved into EmotePopup.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/emotecontainer.cpp167
-rw-r--r--src/gui/emotecontainer.h136
4 files changed, 0 insertions, 307 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d5f8c9a7..87b300bb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -126,8 +126,6 @@ SET(SRCS
gui/confirmdialog.h
gui/debugwindow.cpp
gui/debugwindow.h
- gui/emotecontainer.cpp
- gui/emotecontainer.h
gui/emotepopup.cpp
gui/emotepopup.h
gui/emoteshortcutcontainer.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 0eedc018..761599d1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -79,8 +79,6 @@ tmw_SOURCES = gui/widgets/avatar.cpp \
gui/confirmdialog.h \
gui/debugwindow.cpp \
gui/debugwindow.h \
- gui/emotecontainer.cpp \
- gui/emotecontainer.h \
gui/emotepopup.cpp \
gui/emotepopup.h \
gui/emoteshortcutcontainer.cpp \
diff --git a/src/gui/emotecontainer.cpp b/src/gui/emotecontainer.cpp
deleted file mode 100644
index 0eee5434..00000000
--- a/src/gui/emotecontainer.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Extended support for activating emotes
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The Mana World.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gui/emotecontainer.h"
-
-#include "animatedsprite.h"
-#include "configuration.h"
-#include "emoteshortcut.h"
-#include "graphics.h"
-#include "localplayer.h"
-#include "log.h"
-
-#include "resources/emotedb.h"
-#include "resources/image.h"
-#include "resources/iteminfo.h"
-#include "resources/resourcemanager.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include <guichan/mouseinput.hpp>
-#include <guichan/selectionlistener.hpp>
-
-const int EmoteContainer::gridWidth = 34; // emote icon width + 4
-const int EmoteContainer::gridHeight = 36; // emote icon height + 4
-
-static const int NO_EMOTE = -1;
-
-EmoteContainer::EmoteContainer():
- mSelectedEmoteIndex(NO_EMOTE)
-{
- ResourceManager *resman = ResourceManager::getInstance();
-
- // Setup emote sprites
- for (int i = 0; i <= EmoteDB::getLast(); i++)
- {
- mEmoteImg.push_back(EmoteDB::getAnimation(i));
- }
-
- mSelImg = resman->getImage("graphics/gui/selection.png");
- if (!mSelImg)
- logger->error(_("Unable to load selection.png"));
-
- mSelImg->setAlpha(config.getValue("guialpha", 0.8));
-
- mMaxEmote = EmoteDB::getLast() + 1;
-
- addMouseListener(this);
- addWidgetListener(this);
-}
-
-EmoteContainer::~EmoteContainer()
-{
- mSelImg->decRef();
-}
-
-void EmoteContainer::draw(gcn::Graphics *graphics)
-{
- int columns = getWidth() / gridWidth;
-
- // Have at least 1 column
- if (columns < 1)
- columns = 1;
-
- for (int i = 0; i < mMaxEmote ; i++)
- {
- const int emoteX = ((i) % columns) * gridWidth;
- const int emoteY = ((i) / columns) * gridHeight;
-
- // Draw selection image below selected item
- if (mSelectedEmoteIndex == i)
- {
- static_cast<Graphics*>(graphics)->drawImage(
- mSelImg, emoteX, emoteY + 4);
- }
-
- // Draw emote icon
- mEmoteImg[i]->draw(static_cast<Graphics*>(graphics), emoteX, emoteY);
- }
-}
-
-void EmoteContainer::widgetResized(const gcn::Event &event)
-{
- recalculateHeight();
-}
-
-void EmoteContainer::recalculateHeight()
-{
- int cols = getWidth() / gridWidth;
-
- if (cols < 1)
- cols = 1;
-
- const int rows = (mMaxEmote / cols) + (mMaxEmote % cols > 0 ? 1 : 0);
- const int height = rows * gridHeight + 8;
- if (height != getHeight())
- setHeight(height);
-}
-
-int EmoteContainer::getSelectedEmote()
-{
- if (mSelectedEmoteIndex == NO_EMOTE)
- return 0;
-
- return 1 + mSelectedEmoteIndex;
-}
-
-void EmoteContainer::selectNone()
-{
- setSelectedEmoteIndex(NO_EMOTE);
-}
-
-void EmoteContainer::setSelectedEmoteIndex(int index)
-{
- if (index < 0 || index >= mMaxEmote )
- mSelectedEmoteIndex = NO_EMOTE;
- else
- mSelectedEmoteIndex = index;
-}
-
-void EmoteContainer::distributeValueChangedEvent()
-{
- gcn::SelectionEvent event(this);
- std::list<gcn::SelectionListener*>::iterator i_end = mListeners.end();
- std::list<gcn::SelectionListener*>::iterator i;
-
- for (i = mListeners.begin(); i != i_end; ++i)
- {
- (*i)->valueChanged(event);
- }
-}
-
-void EmoteContainer::mousePressed(gcn::MouseEvent &event)
-{
- int button = event.getButton();
- if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT)
- {
- int columns = getWidth() / gridWidth;
- int mx = event.getX();
- int my = event.getY();
- int index = mx / gridWidth + ((my / gridHeight) * columns);
- if (index < mMaxEmote)
- {
- setSelectedEmoteIndex(index);
- emoteShortcut->setEmoteSelected(index + 1);
- }
- }
-}
diff --git a/src/gui/emotecontainer.h b/src/gui/emotecontainer.h
deleted file mode 100644
index db0fd6dd..00000000
--- a/src/gui/emotecontainer.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Extended support for activating emotes
- * Copyright (C) 2009 Aethyra Development Team
- *
- * This file is part of The Mana World.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef EMOTECONTAINER_H
-#define EMOTECONTAINER_H
-
-#include <list>
-#include <vector>
-
-#include <guichan/mouselistener.hpp>
-#include <guichan/widget.hpp>
-#include <guichan/widgetlistener.hpp>
-
-class AnimatedSprite;
-class Image;
-
-namespace gcn {
- class SelectionListener;
-}
-
-/**
- * An emote container. Used to show emotes in inventory and trade dialog.
- *
- * \ingroup GUI
- */
-class EmoteContainer : public gcn::Widget,
- public gcn::MouseListener,
- public gcn::WidgetListener
-{
- public:
- /**
- * Constructor. Initializes the graphic.
- */
- EmoteContainer();
-
- /**
- * Destructor.
- */
- virtual ~EmoteContainer();
-
- /**
- * Draws the emotes.
- */
- void draw(gcn::Graphics *graphics);
-
- /**
- * Called whenever the widget changes size.
- */
- void widgetResized(const gcn::Event &event);
-
- /**
- * Handles mouse click.
- */
- void mousePressed(gcn::MouseEvent &event);
-
- /**
- * Returns the selected emote.
- */
- int getSelectedEmote();
-
- /**
- * Sets selected emote to NULL.
- */
- void selectNone();
-
- /**
- * 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 currently selected emote. Invalid (e.g., negative) indices
- * set `no emotr'.
- */
- void setSelectedEmoteIndex(int index);
-
- /**
- * Find the current emote index by the most recently used emote ID
- */
- void refindSelectedEmote();
-
- /**
- * Determine and set the height of the container.
- */
- void recalculateHeight();
-
- /**
- * Sends out selection events to the list of selection listeners.
- */
- void distributeValueChangedEvent();
-
- std::vector<const AnimatedSprite*> mEmoteImg;
- Image *mSelImg;
- int mSelectedEmoteIndex;
-
- int mMaxEmote;
-
- std::list<gcn::SelectionListener*> mListeners;
-
- static const int gridWidth;
- static const int gridHeight;
-};
-
-#endif