summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-18 22:05:19 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-18 22:05:19 +0300
commit9f2993aaa89a4a837455e78a4e00826a779b036c (patch)
treec36c593f320c9590a04b0791d1239ae4ebb94f57
parent215ce3e68738159ec98056874a4ad86e451418d0 (diff)
downloadmanaplus-9f2993aaa89a4a837455e78a4e00826a779b036c.tar.gz
manaplus-9f2993aaa89a4a837455e78a4e00826a779b036c.tar.bz2
manaplus-9f2993aaa89a4a837455e78a4e00826a779b036c.tar.xz
manaplus-9f2993aaa89a4a837455e78a4e00826a779b036c.zip
Add baic menu into social window menu button.
Allow create/leave party or guild.
-rw-r--r--src/actions/chat.cpp16
-rw-r--r--src/gui/popups/popupmenu.cpp98
-rw-r--r--src/gui/popups/popupmenu.h16
-rw-r--r--src/gui/widgets/tabs/socialattacktab.h1
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h1
-rw-r--r--src/gui/widgets/tabs/socialguildtab.h1
-rw-r--r--src/gui/widgets/tabs/socialguildtab2.h1
-rw-r--r--src/gui/widgets/tabs/socialnavigationtab.h1
-rw-r--r--src/gui/widgets/tabs/socialpartytab.h1
-rw-r--r--src/gui/widgets/tabs/socialpickuptab.h1
-rw-r--r--src/gui/widgets/tabs/socialplayerstab.h1
-rw-r--r--src/gui/widgets/tabs/socialtab.h13
-rw-r--r--src/gui/windows/socialwindow.cpp47
-rw-r--r--src/gui/windows/socialwindow.h8
14 files changed, 191 insertions, 15 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp
index add653cb0..3bf231d7c 100644
--- a/src/actions/chat.cpp
+++ b/src/actions/chat.cpp
@@ -30,6 +30,8 @@
#include "gui/windows/chatwindow.h"
+#include "listeners/inputactionreplaylistener.h"
+
#include "net/charserverhandler.h"
#include "net/chathandler.h"
#include "net/guildhandler.h"
@@ -336,9 +338,10 @@ impHandler(createParty)
if (event.args.empty())
{
- // TRANSLATORS: create party message
- event.tab->chatLog(_("Party name is missing."),
- ChatMsgType::BY_SERVER);
+ // TRANSLATORS: dialog header
+ inputActionReplayListener.openDialog(_("Create party"),
+ "",
+ InputAction::CREATE_PARTY);
}
else
{
@@ -359,9 +362,10 @@ impHandler(createGuild)
if (event.args.empty())
{
- // TRANSLATORS: create guild message
- event.tab->chatLog(_("Guild name is missing."),
- ChatMsgType::BY_SERVER);
+ // TRANSLATORS: dialog header
+ inputActionReplayListener.openDialog(_("Create guild"),
+ "",
+ InputAction::CREATE_GUILD);
}
else
{
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index fc3a52a77..0630e7844 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -3390,6 +3390,103 @@ void PopupMenu::showAdoptCommands()
mBrowserBox->addRow("/adoptchild 'NAME'", _("Adopt child"));
}
+void PopupMenu::addSocialMenu()
+{
+ mBrowserBox->clearRows();
+ setMousePos();
+ const Party *const party = localPlayer->getParty();
+ if (party)
+ {
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: leave party
+ mBrowserBox->addRow("/leaveparty", _("Leave party"));
+ }
+ else
+ {
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: create party
+ mBrowserBox->addRow("/createparty", _("Create party"));
+ }
+ const Guild *const guild = localPlayer->getGuild();
+ if (!guild)
+ {
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: create guild
+ mBrowserBox->addRow("/createguild", _("Create guild"));
+ }
+ mBrowserBox->addRow("##3---");
+}
+
+void PopupMenu::showPartyPopup()
+{
+ addSocialMenu();
+
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
+void PopupMenu::showGuildPopup()
+{
+ addSocialMenu();
+
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
+void PopupMenu::showAttackPopup()
+{
+ addSocialMenu();
+
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
+void PopupMenu::showNavigationPopup()
+{
+ addSocialMenu();
+
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
+void PopupMenu::showPickupPopup()
+{
+ addSocialMenu();
+
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
+void PopupMenu::showPlayersPopup()
+{
+ addSocialMenu();
+
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
+void PopupMenu::showFriendsPopup()
+{
+ addSocialMenu();
+
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
void PopupMenu::moveUp()
{
mBrowserBox->moveSelectionUp();
@@ -3402,5 +3499,6 @@ void PopupMenu::moveDown()
void PopupMenu::select()
{
+
mBrowserBox->selectSelection();
}
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index 7bd4c085e..9ea2c33b7 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -174,6 +174,20 @@ class PopupMenu final : public Popup, public LinkHandler
void showEmoteType();
+ void showPartyPopup();
+
+ void showGuildPopup();
+
+ void showAttackPopup();
+
+ void showNavigationPopup();
+
+ void showPickupPopup();
+
+ void showPlayersPopup();
+
+ void showFriendsPopup();
+
/**
* Handles link action.
*/
@@ -250,6 +264,8 @@ class PopupMenu final : public Popup, public LinkHandler
void showAdoptCommands();
+ void addSocialMenu();
+
bool addBeingMenu();
BrowserBox *mBrowserBox A_NONNULLPOINTER;
diff --git a/src/gui/widgets/tabs/socialattacktab.h b/src/gui/widgets/tabs/socialattacktab.h
index 31cafd1ff..d83df7d14 100644
--- a/src/gui/widgets/tabs/socialattacktab.h
+++ b/src/gui/widgets/tabs/socialattacktab.h
@@ -47,6 +47,7 @@ class SocialAttackTab final : public SocialTab
// TRANSLATORS: Attack filter tab name in social window.
// TRANSLATORS: Should be small
setCaption(_("Atk"));
+ mMenuAction = "attack";
}
A_DELETE_COPY(SocialAttackTab)
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
index b53138e10..12ea761d3 100644
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ b/src/gui/widgets/tabs/socialfriendstab.h
@@ -52,6 +52,7 @@ class SocialFriendsTab final : public SocialTab
getPlayersAvatars();
setCaption(name);
+ mMenuAction = "friends";
}
A_DELETE_COPY(SocialFriendsTab)
diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h
index 942ce9d59..3ea77d529 100644
--- a/src/gui/widgets/tabs/socialguildtab.h
+++ b/src/gui/widgets/tabs/socialguildtab.h
@@ -59,6 +59,7 @@ class SocialGuildTab final : public SocialTab,
ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE));
createControls(guild, showBackground);
+ mMenuAction = "guild";
}
A_DELETE_COPY(SocialGuildTab)
diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h
index c216c6d36..cc887cd32 100644
--- a/src/gui/widgets/tabs/socialguildtab2.h
+++ b/src/gui/widgets/tabs/socialguildtab2.h
@@ -59,6 +59,7 @@ class SocialGuildTab2 final : public SocialTab,
ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE));
createControls(guild, showBackground);
+ mMenuAction = "guild";
}
A_DELETE_COPY(SocialGuildTab2)
diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h
index e673c689b..839e2cc3e 100644
--- a/src/gui/widgets/tabs/socialnavigationtab.h
+++ b/src/gui/widgets/tabs/socialnavigationtab.h
@@ -58,6 +58,7 @@ class SocialNavigationTab final : public SocialTab
// TRANSLATORS: Navigation tab name in social window.
// TRANSLATORS: Should be small
setCaption(_("Nav"));
+ mMenuAction = "navigation";
}
A_DELETE_COPY(SocialNavigationTab)
diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h
index d38328728..00a66a9b9 100644
--- a/src/gui/widgets/tabs/socialpartytab.h
+++ b/src/gui/widgets/tabs/socialpartytab.h
@@ -61,6 +61,7 @@ class SocialPartyTab final : public SocialTab,
ThemeColorId::PARTY_SOCIAL_TAB_SELECTED_OUTLINE));
createControls(party, showBackground);
+ mMenuAction = "party";
}
A_DELETE_COPY(SocialPartyTab)
diff --git a/src/gui/widgets/tabs/socialpickuptab.h b/src/gui/widgets/tabs/socialpickuptab.h
index 7c0c6fd35..fab754ec8 100644
--- a/src/gui/widgets/tabs/socialpickuptab.h
+++ b/src/gui/widgets/tabs/socialpickuptab.h
@@ -47,6 +47,7 @@ class SocialPickupTab final : public SocialTab
// TRANSLATORS: Pickup filter tab name in social window.
// TRANSLATORS: Should be small
setCaption(_("Pik"));
+ mMenuAction = "pickup";
}
A_DELETE_COPY(SocialPickupTab)
diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h
index 50d86e33c..fcd01b6a3 100644
--- a/src/gui/widgets/tabs/socialplayerstab.h
+++ b/src/gui/widgets/tabs/socialplayerstab.h
@@ -52,6 +52,7 @@ class SocialPlayersTab final : public SocialTab
getPlayersAvatars();
setCaption(name);
+ mMenuAction = "players";
}
A_DELETE_COPY(SocialPlayersTab)
diff --git a/src/gui/widgets/tabs/socialtab.h b/src/gui/widgets/tabs/socialtab.h
index dfd6ad828..9d8469321 100644
--- a/src/gui/widgets/tabs/socialtab.h
+++ b/src/gui/widgets/tabs/socialtab.h
@@ -80,7 +80,8 @@ class SocialTab notfinal : public Tab
mConfirmDialog(nullptr),
mScroll(nullptr),
mList(nullptr),
- mCounterString()
+ mCounterString(),
+ mMenuAction("menu")
{
}
@@ -116,12 +117,19 @@ class SocialTab notfinal : public Tab
void setCurrent() override final
{
updateCounter();
+ updateMenu();
}
void updateCounter() const
{
if (socialWindow)
- socialWindow->setCounter(this, mCounterString);
+ socialWindow->updateCounter(this, mCounterString);
+ }
+
+ void updateMenu() const
+ {
+ if (socialWindow)
+ socialWindow->updateMenu(this, mMenuAction);
}
TextDialog *mInviteDialog;
@@ -129,6 +137,7 @@ class SocialTab notfinal : public Tab
ScrollArea *mScroll;
AvatarListBox *mList;
std::string mCounterString;
+ std::string mMenuAction;
};
#endif // GUI_WIDGETS_TABS_SOCIALTAB_H
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 2d53536bd..52507a422 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -21,6 +21,8 @@
#include "gui/windows/socialwindow.h"
+#include "gui/popups/popupmenu.h"
+
#include "gui/windows/okdialog.h"
#include "gui/windows/setupwindow.h"
@@ -70,7 +72,7 @@ SocialWindow::SocialWindow() :
mFriends(new SocialFriendsTab(this, _("F"),
getOptionBool("showtabbackground"))),
// TRANSLATORS: social window button
- mCreateButton(new Button(this, _("Create"), "create", this)),
+ mMenuButton(new Button(this, _("Menu"), "menu", this)),
mCountLabel(new Label(this, "1000 / 1000")),
mTabs(CREATEWIDGETR(TabbedArea, this)),
mMap(nullptr),
@@ -98,7 +100,7 @@ void SocialWindow::postInit()
if (setupWindow)
setupWindow->registerWindowForReset(this);
- place(0, 0, mCreateButton);
+ place(0, 0, mMenuButton);
place(0, 1, mCountLabel);
place(0, 2, mTabs, 2, 4);
@@ -322,6 +324,34 @@ void SocialWindow::action(const ActionEvent &event)
mGuildInvited = 0;
mGuildAcceptDialog = nullptr;
}
+ else if (eventId == "party")
+ {
+ popupMenu->showPartyPopup();
+ }
+ else if (eventId == "guild")
+ {
+ popupMenu->showGuildPopup();
+ }
+ else if (eventId == "attack")
+ {
+ popupMenu->showAttackPopup();
+ }
+ else if (eventId == "friends")
+ {
+ popupMenu->showFriendsPopup();
+ }
+ else if (eventId == "navigation")
+ {
+ popupMenu->showNavigationPopup();
+ }
+ else if (eventId == "pickup")
+ {
+ popupMenu->showPickupPopup();
+ }
+ else if (eventId == "players")
+ {
+ popupMenu->showPlayersPopup();
+ }
}
void SocialWindow::showGuildInvite(const std::string &restrict guildName,
@@ -560,16 +590,23 @@ void SocialWindow::widgetResized(const Event &event)
mTabs->adjustSize();
}
-void SocialWindow::setCounter(const SocialTab *const tab,
- const std::string &str)
+void SocialWindow::updateCounter(const SocialTab *const tab,
+ const std::string &counter)
{
if (mTabs->getSelectedTab() == tab)
{
- mCountLabel->setCaption(str);
+ mCountLabel->setCaption(counter);
mCountLabel->adjustSize();
}
}
+void SocialWindow::updateMenu(const SocialTab *const tab,
+ const std::string &menu)
+{
+ if (mTabs->getSelectedTab() == tab)
+ mMenuButton->setActionEventId(menu);
+}
+
void SocialWindow::updateGuildCounter(const int online, const int total)
{
if (!localPlayer)
diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h
index b2bd1409f..4c2f82068 100644
--- a/src/gui/windows/socialwindow.h
+++ b/src/gui/windows/socialwindow.h
@@ -117,7 +117,11 @@ class SocialWindow final : public Window,
void widgetResized(const Event &event) override final;
- void setCounter(const SocialTab *const tab, const std::string &str);
+ void updateCounter(const SocialTab *const tab,
+ const std::string &count);
+
+ void updateMenu(const SocialTab *const tab,
+ const std::string &menu);
void updateGuildCounter(const int online = 0, const int total = 0);
@@ -151,7 +155,7 @@ class SocialWindow final : public Window,
SocialTab *mNavigation A_NONNULLPOINTER;
SocialTab *mFriends A_NONNULLPOINTER;
- Button *mCreateButton A_NONNULLPOINTER;
+ Button *mMenuButton A_NONNULLPOINTER;
Label *mCountLabel A_NONNULLPOINTER;
TabbedArea *mTabs A_NONNULLPOINTER;
Map *mMap;