From 08d5f2d6f3eeded6d7a2e1adcf94e850098aa85f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 5 Apr 2015 15:34:11 +0300 Subject: On room creation show room name in general tab caption. Not allow move if in room. --- src/being/playerinfo.cpp | 16 ++++++++++++++++ src/being/playerinfo.h | 6 ++++++ src/gui/windows/chatwindow.cpp | 17 +++++++++++------ src/gui/windows/chatwindow.h | 5 ++--- src/input/inputcondition.h | 3 ++- src/input/inputmanager.cpp | 2 ++ src/net/eathena/chathandler.cpp | 15 ++++++++++++++- 7 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index cfeb56a28..687ab5382 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -60,6 +60,7 @@ Inventory *mCartInventory = nullptr; MercenaryInfo *mMercenary = nullptr; HomunculusInfo *mHomunculus = nullptr; PetInfo *mPet = nullptr; +std::string mRoomName; #endif Equipment *mEquipment = nullptr; int mPetBeingId = 0; @@ -575,6 +576,21 @@ void updateAttackAi(const int targetId, const bool keep) if (mHomunculus) homunculusHandler->attack(targetId, keep); } + +std::string getRoomName() +{ + return mRoomName; +} + +void setRoomName(const std::string &name) +{ + mRoomName = name; +} + +bool isInRoom() +{ + return !mRoomName.empty(); +} #endif void setGuildPositionFlags(const GuildPositionFlags::Type pos) diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h index 20da29e44..c0932cfb8 100644 --- a/src/being/playerinfo.h +++ b/src/being/playerinfo.h @@ -267,6 +267,12 @@ namespace PlayerInfo void updateMoveAI(); void updateAttackAi(const int targetId, const bool keep); + + std::string getRoomName(); + + void setRoomName(const std::string &name); + + bool isInRoom(); #endif void setGuildPositionFlags(const GuildPositionFlags::Type pos); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 2c1f580ad..853d2a51c 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1219,12 +1219,6 @@ ChatTab *ChatWindow::addSpecialChannelTab(const std::string &name, return ret; } -ChatTab *ChatWindow::addChatRoomTab(const std::string &name, - const bool switchTo) -{ - return nullptr; -} - ChatTab *ChatWindow::addChannelTab(const std::string &name, const bool switchTo) { @@ -2132,3 +2126,14 @@ void ChatWindow::debugMessage(const std::string &msg) if (debugChatTab) debugChatTab->chatLog(msg, ChatMsgType::BY_SERVER); } + +void ChatWindow::joinRoom(const bool isJoin) +{ + Tab *const tab = mChatTabs->getTabByIndex(0); + std::string name; + if (isJoin) + name = PlayerInfo::getRoomName(); + else + name = _("General"); + tab->setCaption(name); +} diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 33d6a89bd..479d7db6a 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -199,9 +199,6 @@ class ChatWindow final : public Window, WhisperTab *getWhisperTab(const std::string &nick) const A_WARN_UNUSED; - ChatTab *addChatRoomTab(const std::string &name, - const bool switchTo = false); - ChatTab *addChannelTab(const std::string &name, const bool switchTo = false); @@ -212,6 +209,8 @@ class ChatWindow final : public Window, const bool switchTo, const bool join) A_WARN_UNUSED; + void joinRoom(const bool isJoin); + void removeAllWhispers(); void removeAllChannels(); diff --git a/src/input/inputcondition.h b/src/input/inputcondition.h index de479b328..5687b6f6a 100644 --- a/src/input/inputcondition.h +++ b/src/input/inputcondition.h @@ -45,11 +45,12 @@ namespace InputCondition // dialogs what prevent moving ALIVE = 32768, // player alive NOVENDING = 65536, // vending disabled + NOROOM = 131072, // not joined room SHORTCUT = 2 + 4 + 16 + 512 + 2048, // flags for shortcut keys SHORTCUT0 = 2 + 4 + 16 + 512, // flags for shortcut keys GAME = 2 + 4 + 8 + 16 + 64 + 2048, // main game key GAME2 = 2 + 8 + 16 + 64 + 2048, - ARROWKEYS = 2 + 4 + 8 + 16 + 64 + 2048 + 4096 + 16384 + 65536 + ARROWKEYS = 2 + 4 + 8 + 16 + 64 + 2048 + 4096 + 16384 + 65536 + 131072 }; } // namespace InputCondition diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 11ff7f291..c60056c3e 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -693,6 +693,8 @@ void InputManager::updateConditionMask() if (!PlayerInfo::isVending()) mMask |= InputCondition::NOVENDING; + if (!PlayerInfo::isInRoom()) + mMask |= InputCondition::NOROOM; if (!settings.awayMode) mMask |= InputCondition::NOAWAY; diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 1dfeb7ccb..eb7dfe375 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -26,6 +26,7 @@ #include "notifymanager.h" #include "being/localplayer.h" +#include "being/playerinfo.h" #include "being/playerrelations.h" #include "gui/chatconsts.h" @@ -852,8 +853,19 @@ void ChatHandler::processChatRoomCreateAck(Net::MessageIn &msg) switch(result) { case 0: - chatWindow->addChatRoomTab(mChatRoom, true); + { + PlayerInfo::setRoomName(mChatRoom); + chatWindow->joinRoom(true); + ChatObject *const obj = new ChatObject; + obj->ownerId = localPlayer->getId(); + obj->chatId = 0; + obj->maxUsers = 1000; + obj->currentUsers = 1; + obj->type = 1; + obj->title = mChatRoom; + localPlayer->setChat(obj); break; + } case 1: NotifyManager::notify(NotifyTypes::ROOM_LIMIT_EXCEEDED); break; @@ -864,6 +876,7 @@ void ChatHandler::processChatRoomCreateAck(Net::MessageIn &msg) UNIMPLIMENTEDPACKET; break; } + mChatRoom.clear(); } void ChatHandler::processChatRoomDestroy(Net::MessageIn &msg) -- cgit v1.2.3-60-g2f50