From 12bf548533867a2eb3a1c354b778ef7f9157322a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 26 Aug 2011 16:57:05 +0300 Subject: Basic support for guild bot integration. Not working context menu actions, chat commands, auto complete. --- src/gui/socialwindow.cpp | 111 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 2 deletions(-) (limited to 'src/gui/socialwindow.cpp') diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index e3aa69b30..aa26fa051 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -206,6 +206,109 @@ private: Guild *mGuild; }; +class GuildTab2 : public SocialTab, public gcn::ActionListener +{ +public: + GuildTab2(Guild *guild): + mGuild(guild) + { + setCaption(_("Guild")); + + setTabColor(&Theme::getThemeColor(Theme::GUILD_SOCIAL_TAB)); + + mList = new AvatarListBox(guild); + mScroll = new ScrollArea(mList); + + mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); + mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); + } + + ~GuildTab2() + { + delete mList; + mList = 0; + delete mScroll; + mScroll = 0; + } + + void action(const gcn::ActionEvent &event) + { +/* + if (event.getId() == "do invite") + { + std::string name = mInviteDialog->getText(); + Net::getGuildHandler()->invite(mGuild->getId(), name); + + if (localChatTab) + { + localChatTab->chatLog(strprintf( + _("Invited user %s to guild %s."), + name.c_str(), mGuild->getName().c_str()), BY_SERVER); + } + mInviteDialog = 0; + } + else if (event.getId() == "~do invite") + { + mInviteDialog = 0; + } + else if (event.getId() == "yes") + { + Net::getGuildHandler()->leave(mGuild->getId()); + if (localChatTab) + { + localChatTab->chatLog(strprintf(_("Guild %s quit requested."), + mGuild->getName().c_str()), BY_SERVER); + } + mConfirmDialog = 0; + } + else if (event.getId() == "~yes") + { + mConfirmDialog = 0; + } +*/ + } + + void updateList() + { + } + + void updateAvatar(std::string name A_UNUSED) + { + } + + void resetDamage(std::string name A_UNUSED) + { + } + +protected: + void invite() + { +/* + mInviteDialog = new TextDialog(_("Member Invite to Guild"), + strprintf(_("Who would you like to invite to guild %s?"), + mGuild->getName().c_str()), + socialWindow); + mInviteDialog->setActionEventId("do invite"); + mInviteDialog->addActionListener(this); +*/ + } + + void leave() + { +/* + mConfirmDialog = new ConfirmDialog(_("Leave Guild?"), + strprintf(_("Are you sure you want to leave guild %s?"), + mGuild->getName().c_str()), + socialWindow); + + mConfirmDialog->addActionListener(this); +*/ + } + +private: + Guild *mGuild; +}; + class PartyTab : public SocialTab, public gcn::ActionListener { public: @@ -1106,9 +1209,13 @@ bool SocialWindow::addTab(Guild *guild) if (mGuilds.find(guild) != mGuilds.end()) return false; - GuildTab *tab = new GuildTab(guild); - mGuilds[guild] = tab; + SocialTab *tab = 0; + if (guild->getServerGuild()) + tab = new GuildTab(guild); + else + tab = new GuildTab2(guild); + mGuilds[guild] = tab; mTabs->addTab(tab, tab->mScroll); updateButtons(); -- cgit v1.2.3-70-g09d2 From 2dc730f9aba84fc9fe684fd2af9864df97580502 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 28 Aug 2011 02:48:00 +0300 Subject: Fix possible conflicts between class names GuildTab, PartyTab and other. --- manaplus.cbp | 4 +- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/gui/socialwindow.cpp | 56 ++++++++--------- src/gui/widgets/guildchattab.cpp | 127 +++++++++++++++++++++++++++++++++++++++ src/gui/widgets/guildchattab.h | 52 ++++++++++++++++ src/gui/widgets/guildtab.cpp | 127 --------------------------------------- src/gui/widgets/guildtab.h | 52 ---------------- src/guildmanager.cpp | 4 +- src/guildmanager.h | 4 +- 10 files changed, 217 insertions(+), 217 deletions(-) create mode 100644 src/gui/widgets/guildchattab.cpp create mode 100644 src/gui/widgets/guildchattab.h delete mode 100644 src/gui/widgets/guildtab.cpp delete mode 100644 src/gui/widgets/guildtab.h (limited to 'src/gui/socialwindow.cpp') diff --git a/manaplus.cbp b/manaplus.cbp index d05cccd3b..992915467 100644 --- a/manaplus.cbp +++ b/manaplus.cbp @@ -310,8 +310,8 @@ - - + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7f59135b8..49b41f906 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -137,8 +137,8 @@ SET(SRCS gui/widgets/emoteshortcutcontainer.h gui/widgets/flowcontainer.cpp gui/widgets/flowcontainer.h - gui/widgets/guildtab.cpp - gui/widgets/guildtab.h + gui/widgets/guildchattab.cpp + gui/widgets/guildchattab.h gui/widgets/horizontcontainer.cpp gui/widgets/horizontcontainer.h gui/widgets/icon.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 7d0c1634b..ca6dd6bc2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -140,8 +140,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/emoteshortcutcontainer.h \ gui/widgets/flowcontainer.cpp \ gui/widgets/flowcontainer.h \ - gui/widgets/guildtab.cpp \ - gui/widgets/guildtab.h \ + gui/widgets/guildchattab.cpp \ + gui/widgets/guildchattab.h \ gui/widgets/horizontcontainer.cpp \ gui/widgets/horizontcontainer.h \ gui/widgets/icon.cpp \ diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index aa26fa051..b517911ba 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -108,10 +108,10 @@ protected: AvatarListBox *mList; }; -class GuildTab : public SocialTab, public gcn::ActionListener +class SocialGuildTab : public SocialTab, public gcn::ActionListener { public: - GuildTab(Guild *guild): + SocialGuildTab(Guild *guild): mGuild(guild) { setCaption(_("Guild")); @@ -125,7 +125,7 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); } - ~GuildTab() + ~SocialGuildTab() { delete mList; mList = 0; @@ -206,10 +206,10 @@ private: Guild *mGuild; }; -class GuildTab2 : public SocialTab, public gcn::ActionListener +class SocialGuildTab2 : public SocialTab, public gcn::ActionListener { public: - GuildTab2(Guild *guild): + SocialGuildTab2(Guild *guild): mGuild(guild) { setCaption(_("Guild")); @@ -223,7 +223,7 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); } - ~GuildTab2() + ~SocialGuildTab2() { delete mList; mList = 0; @@ -309,10 +309,10 @@ private: Guild *mGuild; }; -class PartyTab : public SocialTab, public gcn::ActionListener +class SocialPartyTab : public SocialTab, public gcn::ActionListener { public: - PartyTab(Party *party): + SocialPartyTab(Party *party): mParty(party) { setCaption(_("Party")); @@ -326,7 +326,7 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); } - ~PartyTab() + ~SocialPartyTab() { delete mList; mList = 0; @@ -443,10 +443,10 @@ public: std::vector mMembers; }; -class PlayersTab : public SocialTab +class SocialPlayersTab : public SocialTab { public: - PlayersTab(std::string name) + SocialPlayersTab(std::string name) { mBeings = new BeingsListModal(); @@ -461,7 +461,7 @@ public: setCaption(name); } - ~PlayersTab() + ~SocialPlayersTab() { delete mList; mList = 0; @@ -608,10 +608,10 @@ private: }; -class NavigationTab : public SocialTab +class SocialNavigationTab : public SocialTab { public: - NavigationTab() + SocialNavigationTab() { mBeings = new BeingsListModal(); @@ -625,7 +625,7 @@ public: } - ~NavigationTab() + ~SocialNavigationTab() { delete mList; mList = 0; @@ -886,10 +886,10 @@ protected: }; -class AttackTab : public SocialTab +class SocialAttackTab : public SocialTab { public: - AttackTab() + SocialAttackTab() { mBeings = new BeingsListModal(); @@ -902,7 +902,7 @@ public: setCaption(_("Atk")); } - ~AttackTab() + ~SocialAttackTab() { delete mList; mList = 0; @@ -1149,15 +1149,15 @@ SocialWindow::SocialWindow() : loadWindowState(); - mPlayers = new PlayersTab("P"); + mPlayers = new SocialPlayersTab("P"); mTabs->addTab(mPlayers, mPlayers->mScroll); - mNavigation = new NavigationTab(); + mNavigation = new SocialNavigationTab(); mTabs->addTab(mNavigation, mNavigation->mScroll); if (config.getBoolValue("enableAttackFilter")) { - mAttackFilter = new AttackTab(); + mAttackFilter = new SocialAttackTab(); mTabs->addTab(mAttackFilter, mAttackFilter->mScroll); } else @@ -1211,9 +1211,9 @@ bool SocialWindow::addTab(Guild *guild) SocialTab *tab = 0; if (guild->getServerGuild()) - tab = new GuildTab(guild); + tab = new SocialGuildTab(guild); else - tab = new GuildTab2(guild); + tab = new SocialGuildTab2(guild); mGuilds[guild] = tab; mTabs->addTab(tab, tab->mScroll); @@ -1243,7 +1243,7 @@ bool SocialWindow::addTab(Party *party) if (mParties.find(party) != mParties.end()) return false; - PartyTab *tab = new PartyTab(party); + SocialPartyTab *tab = new SocialPartyTab(party); mParties[party] = tab; mTabs->addTab(tab, tab->mScroll); @@ -1556,7 +1556,7 @@ void SocialWindow::updatePortals() void SocialWindow::updatePortalNames() { if (mNavigation) - static_cast(mNavigation)->updateNames(); + static_cast(mNavigation)->updateNames(); } void SocialWindow::selectPortal(unsigned num) @@ -1568,7 +1568,7 @@ void SocialWindow::selectPortal(unsigned num) int SocialWindow::getPortalIndex(int x, int y) { if (mNavigation) - return static_cast(mNavigation)->getPortalIndex(x, y); + return static_cast(mNavigation)->getPortalIndex(x, y); else return -1; } @@ -1576,13 +1576,13 @@ int SocialWindow::getPortalIndex(int x, int y) void SocialWindow::addPortal(int x, int y) { if (mNavigation) - static_cast(mNavigation)->addPortal(x, y); + static_cast(mNavigation)->addPortal(x, y); } void SocialWindow::removePortal(int x, int y) { if (mNavigation) - static_cast(mNavigation)->removePortal(x, y); + static_cast(mNavigation)->removePortal(x, y); } void SocialWindow::nextTab() diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp new file mode 100644 index 000000000..0d40506dd --- /dev/null +++ b/src/gui/widgets/guildchattab.cpp @@ -0,0 +1,127 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011 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 . + */ + +#include "gui/widgets/guildchattab.h" + +#include "chatlogger.h" +#include "commandhandler.h" +#include "guild.h" +#include "guildmanager.h" +#include "localplayer.h" + +#include "gui/theme.h" + +#include "resources/iteminfo.h" +#include "resources/itemdb.h" + +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" + +#include "debug.h" + +GuildChatTab::GuildChatTab() : + ChatTab(_("Guild")) +{ + setTabColor(&Theme::getThemeColor(Theme::GUILD_CHAT_TAB)); +} + +GuildChatTab::~GuildChatTab() +{ +} + +bool GuildChatTab::handleCommand(const std::string &type, const std::string &args) +{ + if (type == "help") + { + if (args == "invite") + { + chatLog(_("Command: /invite ")); + chatLog(_("This command invites to the guild you're in.")); + chatLog(_("If the has spaces in it, enclose it in " + "double quotes (\").")); + } + else if (args == "leave") + { + chatLog(_("Command: /leave")); + chatLog(_("This command causes the player to leave the guild.")); + } + else + return false; + } + else if (type == "invite" && guildManager) + { + guildManager->invite(args); + } + else if (type == "leave" && guildManager) + { + guildManager->leave(); + } + else if (type == "kick" && guildManager) + { + guildManager->kick(args); + } + else if (type == "notice" && guildManager) + { + guildManager->notice(args); + } + else + { + return false; + } + + return true; +} + +void GuildChatTab::handleInput(const std::string &msg) +{ + if (!guildManager) + return; + + if (chatWindow) + guildManager->chat(chatWindow->doReplace(msg)); + else + guildManager->chat(msg); +} + +void GuildChatTab::showHelp() +{ + chatLog(_("/help > Display this help.")); + chatLog(_("/invite > Invite a player to your guild")); + chatLog(_("/leave > Leave the guild you are in")); + chatLog(_("/kick > Kick some one from the guild you are in")); +} + +void GuildChatTab::getAutoCompleteList(std::vector &names) const +{ + if (!guildManager) + return; + + guildManager->getNames(names); + names.push_back("/notice "); +} + +void GuildChatTab::saveToLogFile(std::string &msg) +{ + if (chatLogger) + chatLogger->log("#Guild", msg); +} diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h new file mode 100644 index 000000000..4f5ee3a8e --- /dev/null +++ b/src/gui/widgets/guildchattab.h @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011 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 . + */ + +#ifndef GUI_GUILDTAB_H +#define GUI_GUILDTAB_H + +#include "gui/widgets/chattab.h" + +/** + * A tab for a guild chat channel. + */ +class GuildChatTab : public ChatTab +{ + public: + GuildChatTab(); + + ~GuildChatTab(); + + bool handleCommand(const std::string &type, const std::string &args); + + void showHelp(); + + void saveToLogFile(std::string &msg); + + int getType() const { return ChatTab::TAB_GUILD; } + + protected: + void handleInput(const std::string &msg); + + void getAutoCompleteList(std::vector &names) const; +}; + +#endif diff --git a/src/gui/widgets/guildtab.cpp b/src/gui/widgets/guildtab.cpp deleted file mode 100644 index f4288e228..000000000 --- a/src/gui/widgets/guildtab.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 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 . - */ - -#include "gui/widgets/guildtab.h" - -#include "chatlogger.h" -#include "commandhandler.h" -#include "guild.h" -#include "guildmanager.h" -#include "localplayer.h" - -#include "gui/theme.h" - -#include "resources/iteminfo.h" -#include "resources/itemdb.h" - -#include "utils/dtor.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "debug.h" - -GuildTab::GuildTab() : - ChatTab(_("Guild")) -{ - setTabColor(&Theme::getThemeColor(Theme::GUILD_CHAT_TAB)); -} - -GuildTab::~GuildTab() -{ -} - -bool GuildTab::handleCommand(const std::string &type, const std::string &args) -{ - if (type == "help") - { - if (args == "invite") - { - chatLog(_("Command: /invite ")); - chatLog(_("This command invites to the guild you're in.")); - chatLog(_("If the has spaces in it, enclose it in " - "double quotes (\").")); - } - else if (args == "leave") - { - chatLog(_("Command: /leave")); - chatLog(_("This command causes the player to leave the guild.")); - } - else - return false; - } - else if (type == "invite" && guildManager) - { - guildManager->invite(args); - } - else if (type == "leave" && guildManager) - { - guildManager->leave(); - } - else if (type == "kick" && guildManager) - { - guildManager->kick(args); - } - else if (type == "notice" && guildManager) - { - guildManager->notice(args); - } - else - { - return false; - } - - return true; -} - -void GuildTab::handleInput(const std::string &msg) -{ - if (!guildManager) - return; - - if (chatWindow) - guildManager->chat(chatWindow->doReplace(msg)); - else - guildManager->chat(msg); -} - -void GuildTab::showHelp() -{ - chatLog(_("/help > Display this help.")); - chatLog(_("/invite > Invite a player to your guild")); - chatLog(_("/leave > Leave the guild you are in")); - chatLog(_("/kick > Kick some one from the guild you are in")); -} - -void GuildTab::getAutoCompleteList(std::vector &names) const -{ - if (!guildManager) - return; - - guildManager->getNames(names); - names.push_back("/notice "); -} - -void GuildTab::saveToLogFile(std::string &msg) -{ - if (chatLogger) - chatLogger->log("#Guild", msg); -} diff --git a/src/gui/widgets/guildtab.h b/src/gui/widgets/guildtab.h deleted file mode 100644 index a7f0aa766..000000000 --- a/src/gui/widgets/guildtab.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 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 . - */ - -#ifndef GUI_GUILDTAB_H -#define GUI_GUILDTAB_H - -#include "gui/widgets/chattab.h" - -/** - * A tab for a guild chat channel. - */ -class GuildTab : public ChatTab -{ - public: - GuildTab(); - - ~GuildTab(); - - bool handleCommand(const std::string &type, const std::string &args); - - void showHelp(); - - void saveToLogFile(std::string &msg); - - int getType() const { return ChatTab::TAB_GUILD; } - - protected: - void handleInput(const std::string &msg); - - void getAutoCompleteList(std::vector &names) const; -}; - -#endif diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 22b9de5a1..624193698 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -28,7 +28,7 @@ #include "gui/socialwindow.h" -#include "gui/widgets/guildtab.h" +#include "gui/widgets/guildchattab.h" #include "net/chathandler.h" #include "net/net.h" @@ -172,7 +172,7 @@ void GuildManager::createTab(Guild *guild) { if (!mTab) { - mTab = new GuildTab(); + mTab = new GuildChatTab(); mTab->loadFromLogFile("#Guild"); if (player_node) player_node->addGuild(guild); diff --git a/src/guildmanager.h b/src/guildmanager.h index 177cec12a..c89cba0a6 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -28,7 +28,7 @@ #include class Guild; -class GuildTab; +class GuildChatTab; class GuildManager { @@ -81,7 +81,7 @@ class GuildManager bool mGotName; bool mHavePower; std::vector mTempList; - GuildTab *mTab; + GuildChatTab *mTab; bool mRequest; }; -- cgit v1.2.3-70-g09d2 From 6b6fbd4eb1c0122a1c5346f29d54f2aca9b11009 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 28 Aug 2011 16:45:10 +0300 Subject: Add support for guild invitation in guild bot integration. --- src/gui/socialwindow.cpp | 11 +++++++++-- src/guildmanager.cpp | 18 +++++++++++++++++- src/guildmanager.h | 2 ++ 3 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src/gui/socialwindow.cpp') diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index b517911ba..789d98b73 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -23,6 +23,7 @@ #include "actorspritemanager.h" #include "guild.h" +#include "guildmanager.h" #include "keyboardconfig.h" #include "localplayer.h" #include "logger.h" @@ -1310,7 +1311,10 @@ void SocialWindow::action(const gcn::ActionEvent &event) strprintf(_("Accepted guild invite from %s."), mPartyInviter.c_str())); } - Net::getGuildHandler()->inviteResponse(mGuildInvited, true); + if (!guildManager || !guildManager->getEnableGuildBot()) + Net::getGuildHandler()->inviteResponse(mGuildInvited, true); + else + guildManager->inviteResponse(true); } else if (eventId == "no") { @@ -1320,7 +1324,10 @@ void SocialWindow::action(const gcn::ActionEvent &event) strprintf(_("Rejected guild invite from %s."), mPartyInviter.c_str())); } - Net::getGuildHandler()->inviteResponse(mGuildInvited, false); + if (!guildManager || !guildManager->getEnableGuildBot()) + Net::getGuildHandler()->inviteResponse(mGuildInvited, false); + else + guildManager->inviteResponse(false); } mGuildInvited = 0; diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 624193698..12bcf717a 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -318,6 +318,14 @@ bool GuildManager::process(std::string msg) mRequest = true; return true; } + else if (findCutFirst(msg, "You have been invited to the ") + && findCutLast(msg, " guild chat. If you would like to accept " + "this invitation please reply \"yes\" and if not then \"no\" .")) + { + if (socialWindow) + socialWindow->showGuildInvite(msg, 1, ""); + return true; + } else { Guild *guild = createGuild(); @@ -388,4 +396,12 @@ void GuildManager::clear() if (guild) socialWindow->removeTab(guild); } -} \ No newline at end of file +} + +void GuildManager::inviteResponse(bool response) +{ + if (response) + send("yes"); + else + send("no"); +} diff --git a/src/guildmanager.h b/src/guildmanager.h index c89cba0a6..b95583192 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -70,6 +70,8 @@ class GuildManager void reload(); + void inviteResponse(bool response); + bool havePower() { return mHavePower; } -- cgit v1.2.3-70-g09d2 From 1d5e1e10214b2f992888045dc750c8d8b7937b21 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 28 Aug 2011 19:44:25 +0300 Subject: Fix code style. --- src/gui/socialwindow.cpp | 7 ++++++- src/gui/widgets/guildchattab.cpp | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gui/socialwindow.cpp') diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 789d98b73..ca52ea283 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1575,9 +1575,14 @@ void SocialWindow::selectPortal(unsigned num) int SocialWindow::getPortalIndex(int x, int y) { if (mNavigation) - return static_cast(mNavigation)->getPortalIndex(x, y); + { + return static_cast( + mNavigation)->getPortalIndex(x, y); + } else + { return -1; + } } void SocialWindow::addPortal(int x, int y) diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp index 0d40506dd..0353ac23f 100644 --- a/src/gui/widgets/guildchattab.cpp +++ b/src/gui/widgets/guildchattab.cpp @@ -49,7 +49,8 @@ GuildChatTab::~GuildChatTab() { } -bool GuildChatTab::handleCommand(const std::string &type, const std::string &args) +bool GuildChatTab::handleCommand(const std::string &type, + const std::string &args) { if (type == "help") { -- cgit v1.2.3-70-g09d2 From 9f752d5431364c052b364045015d3574da2c320c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 30 Aug 2011 01:57:05 +0300 Subject: Dont create guild manager instance if guild bot support not enabled. --- src/client.cpp | 4 +--- src/game.cpp | 11 ++++------- src/gui/setup_other.cpp | 3 +++ src/gui/socialwindow.cpp | 4 ++-- src/guildmanager.cpp | 7 ++++++- src/guildmanager.h | 6 +++--- src/net/ea/beinghandler.cpp | 2 +- src/net/ea/chathandler.cpp | 2 +- 8 files changed, 21 insertions(+), 18 deletions(-) (limited to 'src/gui/socialwindow.cpp') diff --git a/src/client.cpp b/src/client.cpp index 60af41ed3..2e3652188 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -794,9 +794,7 @@ int Client::exec() if (mumbleManager) mumbleManager->setServer(mCurrentServer.hostname); - if (!guildManager) - guildManager = new GuildManager(); - guildManager->init(); + GuildManager::init(); if (!mConfigAutoSaved) { diff --git a/src/game.cpp b/src/game.cpp index 8df48b775..303c59edb 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -177,11 +177,7 @@ static void initEngines() commandHandler = new CommandHandler; channelManager = new ChannelManager; effectManager = new EffectManager; - if (!guildManager) - { - guildManager = new GuildManager; - guildManager->init(); - } + GuildManager::init(); particleEngine = new Particle(NULL); particleEngine->setupEngine(); @@ -338,7 +334,7 @@ static void destroyGuiWindows() Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSUNLOADED)); - if (guildManager && guildManager->getEnableGuildBot()) + if (guildManager && GuildManager::getEnableGuildBot()) guildManager->reload(); } @@ -406,7 +402,7 @@ Game::Game(): setupWindow->setInGame(true); clearKeysArray(); - if (guildManager && guildManager->getEnableGuildBot()) + if (guildManager && GuildManager::getEnableGuildBot()) guildManager->requestGuildInfo(); Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_CONSTRUCTED)); @@ -437,6 +433,7 @@ Game::~Game() del_0(mCurrentMap) del_0(spellManager) del_0(spellShortcut) + del_0(guildManager) del_0(mumbleManager) Being::clearCache(); diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index 05ec9d672..1cad4c594 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -147,6 +147,9 @@ Setup_Other::Setup_Other() new SetupItemLabel(_("Bots support"), "", this); + new SetupItemCheckBox(_("Enable auction bot support"), "", + "enableAuctionBot", this, "enableAuctionBotEvent", false); + new SetupItemCheckBox(_("Enable guild bot support and disable native " "guild support"), "", "enableGuildBot", this, "enableGuildBotEvent", false); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index ca52ea283..b9c8cb365 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1311,7 +1311,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) strprintf(_("Accepted guild invite from %s."), mPartyInviter.c_str())); } - if (!guildManager || !guildManager->getEnableGuildBot()) + if (!guildManager || !GuildManager::getEnableGuildBot()) Net::getGuildHandler()->inviteResponse(mGuildInvited, true); else guildManager->inviteResponse(true); @@ -1324,7 +1324,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) strprintf(_("Rejected guild invite from %s."), mPartyInviter.c_str())); } - if (!guildManager || !guildManager->getEnableGuildBot()) + if (!guildManager || !GuildManager::getEnableGuildBot()) Net::getGuildHandler()->inviteResponse(mGuildInvited, false); else guildManager->inviteResponse(false); diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 77324e67e..2c55caefa 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -38,9 +38,9 @@ #include "debug.h" +bool GuildManager::mEnableGuildBot = false; GuildManager::GuildManager() : - mEnableGuildBot(false), mGotInfo(false), mGotName(false), mHavePower(false), @@ -57,6 +57,9 @@ GuildManager::~GuildManager() void GuildManager::init() { + if (guildManager) + return; + int val = serverConfig.getValue("enableGuildBot", -1); if (val == -1) { @@ -67,6 +70,8 @@ void GuildManager::init() serverConfig.setValue("enableGuildBot", val); } mEnableGuildBot = val; + if (mEnableGuildBot) + guildManager = new GuildManager(); } void GuildManager::reload() diff --git a/src/guildmanager.h b/src/guildmanager.h index d0ee7fb62..80014e352 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -37,7 +37,7 @@ class GuildManager ~GuildManager(); - void init(); + static void init(); void chat(std::string msg); @@ -51,7 +51,7 @@ class GuildManager void updateList(); - bool getEnableGuildBot() + static bool getEnableGuildBot() { return mEnableGuildBot; } void kick(std::string msg); @@ -80,7 +80,7 @@ class GuildManager private: bool process(std::string msg); - bool mEnableGuildBot; + static bool mEnableGuildBot; bool mGotInfo; bool mGotName; bool mHavePower; diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 2714f94ce..4a5cfb841 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -662,7 +662,7 @@ void BeingHandler::processPlayerGuilPartyInfo(Net::MessageIn &msg) if ((dstBeing = actorSpriteManager->findBeing(msg.readInt32()))) { dstBeing->setPartyName(msg.readString(24)); - if (!guildManager || !guildManager->getEnableGuildBot()) + if (!guildManager || !GuildManager::getEnableGuildBot()) dstBeing->setGuildName(msg.readString(24)); dstBeing->setGuildPos(msg.readString(24)); dstBeing->addToCache(); diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index e430dfc0f..5737cc2b2 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -162,7 +162,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (nick != "Server") { - if (guildManager && guildManager->getEnableGuildBot() + if (guildManager && GuildManager::getEnableGuildBot() && nick == "guild" && guildManager->processGuildMessage(chatMsg)) { return; -- cgit v1.2.3-70-g09d2 From adeb8e6091694e228f081ca8843e101ae598f26c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 31 Aug 2011 23:24:57 +0300 Subject: Add ability to lock any window position and size. Using sticky image for this. --- src/gui/botcheckerwindow.cpp | 1 + src/gui/buydialog.cpp | 1 + src/gui/charcreatedialog.cpp | 3 +++ src/gui/chatwindow.cpp | 4 +++- src/gui/debugwindow.cpp | 2 ++ src/gui/didyouknowwindow.cpp | 2 ++ src/gui/equipmentwindow.cpp | 2 ++ src/gui/helpwindow.cpp | 2 ++ src/gui/inventorywindow.cpp | 1 + src/gui/killstats.cpp | 1 + src/gui/npcdialog.cpp | 1 + src/gui/outfitwindow.cpp | 2 ++ src/gui/selldialog.cpp | 1 + src/gui/setup.cpp | 1 + src/gui/shopwindow.cpp | 1 + src/gui/skilldialog.cpp | 1 + src/gui/socialwindow.cpp | 2 ++ src/gui/specialswindow.cpp | 1 + src/gui/statuswindow.cpp | 1 + src/gui/tradewindow.cpp | 1 + src/gui/whoisonline.cpp | 1 + src/gui/widgets/window.cpp | 52 ++++++++++++++++++++++++++++++++++---------- src/gui/widgets/window.h | 15 +++++++++++++ 23 files changed, 86 insertions(+), 13 deletions(-) (limited to 'src/gui/socialwindow.cpp') diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 4a8f8cf0d..7c0339ead 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -302,6 +302,7 @@ BotCheckerWindow::BotCheckerWindow(): setWindowName("BotCheckerWindow"); setCloseButton(true); + setStickyButtonLock(true); setDefaultSize(w, h, ImageRect::CENTER); playersScrollArea = new ScrollArea(mTable); diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 04dd425c1..8c1ad62ce 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -72,6 +72,7 @@ void BuyDialog::init() setWindowName("Buy"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setMinWidth(260); setMinHeight(230); setDefaultSize(260, 230, ImageRect::CENTER); diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 91c284985..d1773e7f3 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -60,6 +60,9 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mRace(0), mSlot(slot) { + setStickyButtonLock(true); + setSticky(true); + mPlayer = new Being(0, ActorSprite::PLAYER, mRace, NULL); mPlayer->setGender(GENDER_MALE); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 9c75320a6..784fb812a 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -167,6 +167,8 @@ ChatWindow::ChatWindow(): setResizable(true); setDefaultVisible(true); setSaveVisible(true); + setStickyButtonLock(true); + setDefaultSize(600, 123, ImageRect::LOWER_LEFT); setMinWidth(150); setMinHeight(90); @@ -660,7 +662,7 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) if (event.isConsumed()) return; - if (isMovable() && mMoved) + if (canMove() && isMovable() && mMoved) { int newX = std::max(0, getX() + event.getX() - mDragOffsetX); int newY = std::max(0, getY() + event.getY() - mDragOffsetY); diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 0b84dda1e..dc540a782 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -60,6 +60,8 @@ DebugWindow::DebugWindow(): setResizable(true); setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); + setDefaultSize(400, 150, ImageRect::CENTER); mTabs = new TabbedArea; diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index 4d89bd924..d62417fc4 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -51,6 +51,8 @@ DidYouKnowWindow::DidYouKnowWindow(): setContentSize(455, 350); setWindowName("DidYouKnow"); setResizable(true); + setStickyButtonLock(true); + setupWindow->registerWindowForReset(this); setDefaultSize(500, 400, ImageRect::CENTER); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 3abd97c73..0375d096f 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -80,6 +80,8 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); + setDefaultSize(180, 345, ImageRect::CENTER); mBoxes.reserve(13); diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index 368049389..b772ea36a 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -47,6 +47,8 @@ HelpWindow::HelpWindow(): setContentSize(455, 350); setWindowName("Help"); setResizable(true); + setStickyButtonLock(true); + setupWindow->registerWindowForReset(this); setDefaultSize(500, 400, ImageRect::CENTER); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 3b7b7b273..d0454c4e1 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -89,6 +89,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): setResizable(true); setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize(387, 307, ImageRect::CENTER); setMinWidth(316); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 05a265da7..b9ce7c2a7 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -55,6 +55,7 @@ KillStats::KillStats(): setWindowName("Kill stats"); setCloseButton(true); setResizable(true); + setStickyButtonLock(true); setDefaultSize(250, 250, 350, 300); listen(Mana::CHANNEL_ATTRIBUTES); diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 36677446d..0db618d69 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -69,6 +69,7 @@ NpcDialog::NpcDialog(int npcId) setResizable(true); //setupWindow->registerWindowForReset(this); setFocusable(true); + setStickyButtonLock(true); setMinWidth(200); setMinHeight(150); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index d3bc6a302..3845aaf64 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -72,6 +72,8 @@ OutfitWindow::OutfitWindow(): setWindowName("Outfits"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); + setDefaultSize(250, 400, 150, 230); setMinWidth(145); setMinHeight(220); diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index cf9bfb667..d9030e3fb 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -69,6 +69,7 @@ void SellDialog::init() //setupWindow->registerWindowForReset(this); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setMinWidth(260); setMinHeight(230); setDefaultSize(260, 230, ImageRect::CENTER); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 690871189..76e3936c2 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -55,6 +55,7 @@ Setup::Setup(): { setCloseButton(true); setResizable(true); + setStickyButtonLock(true); int width = 620; int height = 450; diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 38985a01c..9aaf88bf3 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -86,6 +86,7 @@ ShopWindow::ShopWindow(): setWindowName("Personal Shop"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setMinWidth(260); setMinHeight(230); setDefaultSize(380, 300, ImageRect::CENTER); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index ff57195a9..bf87e804d 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -279,6 +279,7 @@ SkillDialog::SkillDialog(): setCloseButton(true); setResizable(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); setupWindow->registerWindowForReset(this); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index b9c8cb365..749f26f85 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1129,6 +1129,8 @@ SocialWindow::SocialWindow() : setResizable(true); setSaveVisible(true); setCloseButton(true); + setStickyButtonLock(true); + setMinWidth(120); setMinHeight(55); setDefaultSize(590, 200, 150, 120); diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index a5d95c7ff..702c31718 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -82,6 +82,7 @@ SpecialsWindow::SpecialsWindow(): setCloseButton(true); setResizable(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); setupWindow->registerWindowForReset(this); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 7ab2afa2d..d1fde2dd1 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -132,6 +132,7 @@ StatusWindow::StatusWindow(): setResizable(true); setCloseButton(true); setSaveVisible(true); + setStickyButtonLock(true); setDefaultSize((windowContainer->getWidth() - 365) / 2, (windowContainer->getHeight() - 255) / 2, 365, 275); diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index d00fb61f4..3c19ee9c2 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -78,6 +78,7 @@ TradeWindow::TradeWindow(): setWindowName("Trade"); setResizable(true); setCloseButton(true); + setStickyButtonLock(true); setDefaultSize(386, 180, ImageRect::CENTER); setMinWidth(386); setMinHeight(180); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 99da53c66..1e9f686e4 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -97,6 +97,7 @@ WhoIsOnline::WhoIsOnline(): // setContentSize(w, h); setCloseButton(true); setResizable(true); + setStickyButtonLock(true); mUpdateButton = new Button(_("Update"), "update", this); mUpdateButton->setEnabled(false); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index cdb9d3d55..9cb7cb620 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -60,6 +60,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mSaveVisible(false), mStickyButton(false), mSticky(false), + mStickyButtonLock(false), mMinWinWidth(100), mMinWinHeight(40), mMaxWinWidth(graphics->mWidth), @@ -158,9 +159,9 @@ void Window::draw(gcn::Graphics *graphics) // Draw Close Button if (mCloseButton && mSkin->getCloseImage()) { - g->drawImage(mSkin->getCloseImage(), - getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(), - getPadding()); + Image *button = mSkin->getCloseImage(); + const int x = getWidth() - button->getWidth() - getPadding(); + g->drawImage(button, x, getPadding()); } // Draw Sticky Button @@ -171,7 +172,7 @@ void Window::draw(gcn::Graphics *graphics) { int x = getWidth() - button->getWidth() - getPadding(); if (mCloseButton && mSkin->getCloseImage()) - x -= mSkin->getCloseImage()->getWidth(); + x -= mSkin->getCloseImage()->getWidth() + getPadding(); g->drawImage(button, x, getPadding()); } @@ -399,6 +400,13 @@ void Window::setSticky(bool sticky) mSticky = sticky; } +void Window::setStickyButtonLock(bool lock) +{ + mStickyButtonLock = lock; + mStickyButton = lock; +// mMovable = false; +} + void Window::setVisible(bool visible) { setVisible(visible, false); @@ -413,7 +421,10 @@ void Window::setVisible(bool visible, bool forceSticky) if (visible) checkIfIsOffScreen(); - gcn::Window::setVisible((!forceSticky && isSticky()) || visible); + if (isStickyButtonLock()) + gcn::Window::setVisible(visible); + else + gcn::Window::setVisible((!forceSticky && isSticky()) || visible); } void Window::scheduleDelete() @@ -479,7 +490,10 @@ void Window::mousePressed(gcn::MouseEvent &event) // Handle window resizing mouseResize = getResizeHandles(event); - mMoved = !mouseResize; + if (canMove()) + mMoved = !mouseResize; + else + mMoved = false; } } @@ -541,10 +555,24 @@ void Window::mouseMoved(gcn::MouseEvent &event) viewport->hideBeingPopup(); } +bool Window::canMove() +{ + return !mStickyButtonLock || !mSticky; +} + void Window::mouseDragged(gcn::MouseEvent &event) { - // Let Guichan handle title bar drag - gcn::Window::mouseDragged(event); + if (canMove()) + { + // Let Guichan handle title bar drag + gcn::Window::mouseDragged(event); + } + else + { + if (!event.isConsumed() && event.getSource() == this) + event.consume(); + return; + } // Keep guichan window inside screen when it may be moved if (isMovable() && mMoved) @@ -638,18 +666,18 @@ void Window::loadWindowState() assert(!name.empty()); setPosition(config.getValueInt(name + "WinX", mDefaultX), - config.getValueInt(name + "WinY", mDefaultY)); + config.getValueInt(name + "WinY", mDefaultY)); if (mSaveVisible) { setVisible(config.getValueBool(name - + "Visible", mDefaultVisible)); + + "Visible", mDefaultVisible)); } if (mStickyButton) { setSticky(config.getValueBool(name - + "Sticky", isSticky())); + + "Sticky", isSticky())); } if (mGrip) @@ -811,7 +839,7 @@ void Window::resetToDefaultSize() int Window::getResizeHandles(gcn::MouseEvent &event) { - if (event.getX() < 0 || event.getY() < 0) + if ((mStickyButtonLock && mSticky) || event.getX() < 0 || event.getY() < 0) return 0; int resizeHandles = 0; diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index d36d6c5ad..b9f65dceb 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -188,6 +188,17 @@ class Window : public gcn::Window, gcn::WidgetListener bool isSticky() const { return mSticky; } + /** + * Sets whether the window sticky mean window locked or not. + */ + void setStickyButtonLock(bool sticky); + + /** + * Returns whether the window sticky locking window. + */ + bool isStickyButtonLock() const + { return mStickyButtonLock; } + /** * Overloads window setVisible by Guichan to allow sticky window * handling. @@ -387,6 +398,9 @@ class Window : public gcn::Window, gcn::WidgetListener void setCaptionFont(gcn::Font *font) { mCaptionFont = font; } + protected: + bool canMove(); + private: enum ResizeHandles { @@ -423,6 +437,7 @@ class Window : public gcn::Window, gcn::WidgetListener bool mSaveVisible; /**< Window will save visibility */ bool mStickyButton; /**< Window has a sticky button */ bool mSticky; /**< Window resists hiding*/ + bool mStickyButtonLock; /**< Window locked if sticky enabled*/ int mMinWinWidth; /**< Minimum window width */ int mMinWinHeight; /**< Minimum window height */ int mMaxWinWidth; /**< Maximum window width */ -- cgit v1.2.3-70-g09d2