From 4749c8977e2e803692bd844b5400f8d72cbaf17f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 24 May 2015 21:16:44 +0300 Subject: Add strong typed bool type Online. --- src/enums/simpletypes/online.h | 28 ++++++++++++++++++++++++++++ src/gui/widgets/tabs/chat/chattab.cpp | 4 ++-- src/gui/widgets/tabs/chat/chattab.h | 4 +++- src/net/eathena/guildhandler.cpp | 2 +- src/net/eathena/partyhandler.cpp | 4 ++-- src/net/tmwa/guildhandler.cpp | 2 +- src/net/tmwa/guildmanager.cpp | 4 ++-- src/net/tmwa/partyhandler.cpp | 4 ++-- 8 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 src/enums/simpletypes/online.h (limited to 'src') diff --git a/src/enums/simpletypes/online.h b/src/enums/simpletypes/online.h new file mode 100644 index 000000000..47ccddd95 --- /dev/null +++ b/src/enums/simpletypes/online.h @@ -0,0 +1,28 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 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 ENUMS_SIMPLETYPES_ONLINE_H +#define ENUMS_SIMPLETYPES_ONLINE_H + +#include "enums/simpletypes/simpledefines.h" + +defBoolEnum(Online); + +#endif // ENUMS_SIMPLETYPES_ONLINE_H diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index eef6cfd5d..bd3759c65 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -548,12 +548,12 @@ void ChatTab::playNewMessageSound() const } void ChatTab::showOnline(const std::string &nick, - const bool isOnline) + const Online online) { if (!mShowOnline) return; - if (isOnline) + if (online == Online_true) { // TRANSLATORS: chat message chatLog(strprintf(_("%s is now Online."), nick.c_str())); diff --git a/src/gui/widgets/tabs/chat/chattab.h b/src/gui/widgets/tabs/chat/chattab.h index ac6129194..cc694a874 100644 --- a/src/gui/widgets/tabs/chat/chattab.h +++ b/src/gui/widgets/tabs/chat/chattab.h @@ -25,6 +25,8 @@ #include "enums/gui/chatmsgtype.h" +#include "enums/simpletypes/online.h" + #include "gui/widgets/browserbox.h" #include "gui/widgets/tabs/tab.h" @@ -168,7 +170,7 @@ class ChatTab notfinal : public Tab void addNewRow(std::string &line); void showOnline(const std::string &nick, - const bool isOnline); + const Online online); virtual void playNewMessageSound() const; diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index cd4078666..1a6c29b80 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -412,7 +412,7 @@ void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) if (online) m->setGender(gender); if (guildTab) - guildTab->showOnline(m->getName(), online); + guildTab->showOnline(m->getName(), fromBool(online, Online)); if (socialWindow) socialWindow->updateGuildCounter(); } diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index 87b30eb52..5f859d12e 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -246,7 +246,7 @@ void PartyHandler::processPartyMemberInfo(Net::MessageIn &msg) if (member) { if (partyTab && member->getOnline() != online) - partyTab->showOnline(nick, online); + partyTab->showOnline(nick, fromBool(online, Online)); member->setLeader(leader); member->setOnline(online); member->setMap(map); @@ -349,7 +349,7 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) || (onlineNames.find(nick) != onlineNames.end() && !online))) { - partyTab->showOnline(nick, online); + partyTab->showOnline(nick, fromBool(online, Online)); } member->setLeader(leader); diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 29eeaaaa6..f58f873a4 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -389,7 +389,7 @@ void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) { m->setOnline(online); if (guildTab) - guildTab->showOnline(m->getName(), online); + guildTab->showOnline(m->getName(), fromBool(online, Online)); if (socialWindow) socialWindow->updateGuildCounter(); } diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp index 0e7b7a43a..8bc3c2a18 100644 --- a/src/net/tmwa/guildmanager.cpp +++ b/src/net/tmwa/guildmanager.cpp @@ -290,7 +290,7 @@ bool GuildManager::process(std::string msg) guild->sort(); mRequest = false; if (mTab) - mTab->showOnline(msg, false); + mTab->showOnline(msg, Online_false); if (socialWindow) socialWindow->updateGuildCounter(); return true; @@ -310,7 +310,7 @@ bool GuildManager::process(std::string msg) guild->sort(); mRequest = false; if (mTab) - mTab->showOnline(msg, true); + mTab->showOnline(msg, Online_true); if (socialWindow) socialWindow->updateGuildCounter(); return true; diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 6d9e448f0..6f8787be4 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -294,7 +294,7 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) || (onlineNames.find(nick) != onlineNames.end() && !online))) { - partyTab->showOnline(nick, online); + partyTab->showOnline(nick, fromBool(online, Online)); } member->setLeader(leader); @@ -417,7 +417,7 @@ void PartyHandler::processPartyMove(Net::MessageIn &msg) m->setY(msg.readInt16("y")); const bool online = msg.readUInt8("online") != 0; if (m->getOnline() != online) - partyTab->showOnline(m->getName(), online); + partyTab->showOnline(m->getName(), fromBool(online, Online)); m->setOnline(online); msg.readString(24, "party"); msg.readString(24, "nick"); -- cgit v1.2.3-70-g09d2