summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-06 14:49:47 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-06 14:49:47 +0300
commitc649cf883480071c9b93909c4ea4ee5ec98155b2 (patch)
tree71022fd2db59c643c19c78c5524ffcd038e35a7f /src/gui
parent4cab6fc78e19799f223d951d5ccc9afb303b65f2 (diff)
downloadplus-c649cf883480071c9b93909c4ea4ee5ec98155b2.tar.gz
plus-c649cf883480071c9b93909c4ea4ee5ec98155b2.tar.bz2
plus-c649cf883480071c9b93909c4ea4ee5ec98155b2.tar.xz
plus-c649cf883480071c9b93909c4ea4ee5ec98155b2.zip
Remove some duplicate code.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popups/popupmenu.cpp51
-rw-r--r--src/gui/popups/popupmenu.h2
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp22
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp28
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp24
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp30
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp23
7 files changed, 55 insertions, 125 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 00cae3ee3..5d0f32f19 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -2521,6 +2521,25 @@ void PopupMenu::showPopup(int x, int y)
requestMoveToTop();
}
+void PopupMenu::addNormalRelations()
+{
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: add player to disregarded list
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: add player to ignore list
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: add player to black list
+ mBrowserBox->addRow("blacklist", _("Black list"));
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: add player to enemy list
+ mBrowserBox->addRow("enemy", _("Set as enemy"));
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: add player to erased list
+ mBrowserBox->addRow("erase", _("Erase"));
+}
+
void PopupMenu::addPlayerRelation(const std::string &name)
{
switch (player_relations.getRelation(name))
@@ -2529,39 +2548,11 @@ void PopupMenu::addPlayerRelation(const std::string &name)
// TRANSLATORS: popup menu item
// TRANSLATORS: add player to friends list
mBrowserBox->addRow("friend", _("Be friend"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to disregarded list
- mBrowserBox->addRow("disregard", _("Disregard"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to ignore list
- mBrowserBox->addRow("ignore", _("Ignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to black list
- mBrowserBox->addRow("blacklist", _("Black list"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to enemy list
- mBrowserBox->addRow("enemy", _("Set as enemy"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to erased list
- mBrowserBox->addRow("erase", _("Erase"));
+ addNormalRelations();
break;
case PlayerRelation::FRIEND:
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to disregarded list
- mBrowserBox->addRow("disregard", _("Disregard"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to ignore list
- mBrowserBox->addRow("ignore", _("Ignore"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to black list
- mBrowserBox->addRow("blacklist", _("Black list"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to enemy list
- mBrowserBox->addRow("enemy", _("Set as enemy"));
- // TRANSLATORS: popup menu item
- // TRANSLATORS: add player to erased list
- mBrowserBox->addRow("erase", _("Erase"));
+ addNormalRelations();
break;
case PlayerRelation::BLACKLISTED:
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index 72c16ce50..69ca3c17b 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -170,6 +170,8 @@ class PopupMenu final : public Popup, public LinkHandler
void addGmCommands();
+ void addNormalRelations();
+
void showGMPopup();
BrowserBox *mBrowserBox;
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 087f4b372..f1434aa23 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -54,36 +54,14 @@ DropShortcutContainer::DropShortcutContainer(Widget2 *const widget) :
{
mItemPopup->postInit();
- addMouseListener(this);
- addWidgetListener(this);
-
- mBackgroundImg = Theme::getImageFromThemeXml(
- "item_shortcut_background.xml", "background.xml");
if (dropShortcut)
mMaxItems = dropShortcut->getItemCount();
else
mMaxItems = 0;
-
- if (mBackgroundImg)
- {
- mBackgroundImg->setAlpha(settings.guiAlpha);
- mBoxHeight = mBackgroundImg->getHeight();
- mBoxWidth = mBackgroundImg->getWidth();
- }
- else
- {
- mBoxHeight = 1;
- mBoxWidth = 1;
- }
}
DropShortcutContainer::~DropShortcutContainer()
{
- if (mBackgroundImg)
- {
- mBackgroundImg->decRef();
- mBackgroundImg = nullptr;
- }
delete2(mItemPopup);
}
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 85e07e2b7..0d802034e 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -39,6 +39,7 @@
#include "resources/db/emotedb.h"
#include "utils/stringutils.h"
+#include "utils/delete2.h"
#include "debug.h"
@@ -53,13 +54,6 @@ EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *const widget) :
{
mEmotePopup->postInit();
- addMouseListener(this);
- addWidgetListener(this);
-
- mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE);
- mBackgroundImg = Theme::getImageFromThemeXml(
- "item_shortcut_background.xml", "background.xml");
-
if (mBackgroundImg)
mBackgroundImg->setAlpha(settings.guiAlpha);
@@ -72,29 +66,11 @@ EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *const widget) :
}
mMaxItems = MAX_ITEMS;
-
- if (mBackgroundImg)
- {
- mBoxHeight = mBackgroundImg->getHeight();
- mBoxWidth = mBackgroundImg->getWidth();
- }
- else
- {
- mBoxHeight = 1;
- mBoxWidth = 1;
- }
- mForegroundColor = getThemeColor(Theme::TEXT);
}
EmoteShortcutContainer::~EmoteShortcutContainer()
{
- delete mEmotePopup;
-
- if (mBackgroundImg)
- {
- mBackgroundImg->decRef();
- mBackgroundImg = nullptr;
- }
+ delete2(mEmotePopup);
}
void EmoteShortcutContainer::setWidget2(const Widget2 *const widget)
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 670807ed5..51a1cef13 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -68,38 +68,14 @@ ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
mItemPopup->postInit();
mSpellPopup->postInit();
- addMouseListener(this);
- addWidgetListener(this);
-
- mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE);
- mBackgroundImg = Theme::getImageFromThemeXml(
- "item_shortcut_background.xml", "background.xml");
if (itemShortcut[mNumber])
mMaxItems = itemShortcut[mNumber]->getItemCount();
else
mMaxItems = 0;
-
- if (mBackgroundImg)
- {
- mBackgroundImg->setAlpha(settings.guiAlpha);
- mBoxHeight = mBackgroundImg->getHeight();
- mBoxWidth = mBackgroundImg->getWidth();
- }
- else
- {
- mBoxHeight = 1;
- mBoxWidth = 1;
- }
- mForegroundColor = getThemeColor(Theme::TEXT);
}
ItemShortcutContainer::~ItemShortcutContainer()
{
- if (mBackgroundImg)
- {
- mBackgroundImg->decRef();
- mBackgroundImg = nullptr;
- }
delete2(mItemPopup);
delete2(mSpellPopup);
}
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index e789c863d..313e37262 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -23,9 +23,12 @@
#include "gui/widgets/shortcutcontainer.h"
#include "graphicsvertexes.h"
+#include "settings.h"
#include "gui/gui.h"
+#include "resources/image.h"
+
#include "utils/delete2.h"
#include "debug.h"
@@ -45,10 +48,37 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
mVertexes(new ImageCollection)
{
mAllowLogic = false;
+
+ addMouseListener(this);
+ addWidgetListener(this);
+
+ mForegroundColor = getThemeColor(Theme::TEXT);
+ mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE);
+
+ mBackgroundImg = Theme::getImageFromThemeXml(
+ "item_shortcut_background.xml", "background.xml");
+
+ if (mBackgroundImg)
+ {
+ mBackgroundImg->setAlpha(settings.guiAlpha);
+ mBoxHeight = mBackgroundImg->getHeight();
+ mBoxWidth = mBackgroundImg->getWidth();
+ }
+ else
+ {
+ mBoxHeight = 1;
+ mBoxWidth = 1;
+ }
}
ShortcutContainer::~ShortcutContainer()
{
+ if (mBackgroundImg)
+ {
+ mBackgroundImg->decRef();
+ mBackgroundImg = nullptr;
+ }
+
if (gui)
gui->removeDragged(this);
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 014fa4354..08e22ee98 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -50,37 +50,14 @@ SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
{
mSpellPopup->postInit();
- addMouseListener(this);
- addWidgetListener(this);
-
- mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE);
-
- mBackgroundImg = Theme::getImageFromThemeXml(
- "item_shortcut_background.xml", "background.xml");
if (spellShortcut)
mMaxItems = spellShortcut->getSpellsCount();
else
mMaxItems = 0;
-
- if (mBackgroundImg)
- {
- mBackgroundImg->setAlpha(settings.guiAlpha);
- mBoxHeight = mBackgroundImg->getHeight();
- mBoxWidth = mBackgroundImg->getWidth();
- }
- else
- {
- mBoxHeight = 1;
- mBoxWidth = 1;
- }
- mForegroundColor = getThemeColor(Theme::TEXT);
}
SpellShortcutContainer::~SpellShortcutContainer()
{
- if (mBackgroundImg)
- mBackgroundImg->decRef();
- mBackgroundImg = nullptr;
delete2(mSpellPopup);
}