Exemple #1
0
void WhisperTab::handleCommandStr(const std::string &msg)
{
    if (msg == "close")
    {
        delete this;
        return;
    }

    const size_t pos = msg.find(' ');
    const std::string type(msg, 0, pos);
    const std::string args(msg, pos == std::string::npos
        ? msg.size() : pos + 1);

    if (type == "me")
    {
        std::string str = textToMe(args);
        chatHandler->privateMessage(mNick, str);
        if (localPlayer)
            chatLog(localPlayer->getName(), str);
        else
            chatLog("?", str);
    }
    else
    {
        ChatTab::handleCommandStr(msg);
    }
}
Exemple #2
0
void WhisperTab::handleCommand(const std::string &msg)
{
    if (msg == "close")
    {
        delete this;
        return;
    }

    size_t pos = msg.find(' ');
    std::string type(msg, 0, pos);
    std::string args(msg, pos == std::string::npos
                     ? msg.size() : pos + 1);

    if (type == "me")
    {
        std::string str = strprintf("*%s*", args.c_str());
        Net::getChatHandler()->privateMessage(mNick, str);
        if (player_node)
            chatLog(player_node->getName(), str);
        else
            chatLog("?", str);
    }
    else
    {
        ChatTab::handleCommand(msg);
    }
}
Exemple #3
0
 void notify(const unsigned int message, const std::string &str)
 {
     if (message >= NotifyTypes::TYPE_END || !localChatTab)
         return;
     const NotificationInfo &info = notifications[message];
     switch (info.flags)
     {
         case NotifyFlags::STRING:
         {
             localChatTab->chatLog(strprintf(gettext(info.text),
                 str.c_str()), ChatMsgType::BY_SERVER);
             break;
         }
         case NotifyFlags::GUILD_STRING:
         {
             ChatTab *const tab = getGuildTab();
             chatLog(tab, strprintf(gettext(info.text), str.c_str()));
             break;
         }
         case NotifyFlags::PARTY_STRING:
         {
             ChatTab *const tab = partyHandler->getTab();
             chatLog(tab, strprintf(gettext(info.text), str.c_str()));
             break;
         }
         case NotifyFlags::EMPTY:
         case NotifyFlags::INT:
         case NotifyFlags::GUILD:
         case NotifyFlags::PARTY:
         case NotifyFlags::SPEECH:
         default:
             break;
     }
     soundManager.playSfx(SoundDB::getSound(message));
 }
Exemple #4
0
    void notify(const unsigned int message)
    {
        if (message >= NotifyTypes::TYPE_END ||
            localChatTab == nullptr)
        {
            return;
        }
        const NotificationInfo &info = notifications[message];
        if (*info.text == 0)
        {
            soundManager.playSfx(SoundDB::getSound(message), 0, 0);
            return;
        }

        switch (info.flags)
        {
            case NotifyFlags::EMPTY:
                localChatTab->chatLog(gettext(info.text),
                    ChatMsgType::BY_SERVER,
                    IgnoreRecord_false,
                    TryRemoveColors_true);
                break;

            case NotifyFlags::GUILD:
            {
                if (localPlayer == nullptr)
                    return;
                ChatTab *const tab = getGuildTab();
                chatLog(tab, gettext(info.text));
                break;
            }

            case NotifyFlags::PARTY:
            {
                ChatTab *const tab = partyHandler->getTab();
                chatLog(tab, gettext(info.text));
                break;
            }

            case NotifyFlags::SPEECH:
            {
                if (localPlayer != nullptr)
                    localPlayer->setSpeech(gettext(info.text));
                break;
            }

            case NotifyFlags::INT:
            case NotifyFlags::STRING:
            case NotifyFlags::GUILD_STRING:
            case NotifyFlags::PARTY_STRING:
            default:
                break;
        }
        soundManager.playSfx(SoundDB::getSound(message), 0, 0);
    }
Exemple #5
0
void WhisperTab::handleInput(const std::string &msg)
{
    std::string newMsg;
    newMsg = ChatWindow::doReplace(msg);
    chatHandler->privateMessage(mNick, newMsg);

    if (localPlayer)
        chatLog(localPlayer->getName(), newMsg);
    else
        chatLog("?", newMsg);
}
void WhisperTab::handleInput(const std::string &msg)
{
    if (msg.empty()) {
        chatLog(_("Cannot send empty chat!"), BY_SERVER, false);
        return;
    }

    Net::getChatHandler()->privateMessage(mNick, msg);

    chatLog(player_node->getName(), msg);
}
Exemple #7
0
void GuildChatTab::showHelp()
{
    // TRANSLATORS: guild chat tab help
    chatLog(_("/help > Display this help."));
    // TRANSLATORS: guild chat tab help
    chatLog(_("/invite > Invite a player to your guild"));
    // TRANSLATORS: guild chat tab help
    chatLog(_("/leave > Leave the guild you are in"));
    // TRANSLATORS: guild chat tab help
    chatLog(_("/kick > Kick some one from the guild you are in"));
}
Exemple #8
0
bool GuildChatTab::handleCommand(const std::string &type,
                                 const std::string &args)
{
    if (type == "help")
    {
        if (args == "invite")
        {
            // TRANSLATORS: guild chat tab help
            chatLog(_("Command: /invite <nick>"));
            // TRANSLATORS: guild chat tab help
            chatLog(_("This command invites <nick> to the guild you're in."));
            // TRANSLATORS: guild chat tab help
            chatLog(_("If the <nick> has spaces in it, enclose it in "
                            "double quotes (\")."));
        }
        else if (args == "leave")
        {
            // TRANSLATORS: guild chat tab help
            chatLog(_("Command: /leave"));
            // TRANSLATORS: guild chat tab help
            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;
}
Exemple #9
0
    void notify(const unsigned int message)
    {
        if (message >= NotifyTypes::TYPE_END || !localChatTab)
            return;
        const NotificationInfo &info = notifications[message];
        switch (info.flags)
        {
            case NotifyFlags::EMPTY:
                localChatTab->chatLog(gettext(info.text),
                    ChatMsgType::BY_SERVER);
                break;

            case NotifyFlags::GUILD:
            {
                if (!localPlayer)
                    return;
                ChatTab *const tab = getGuildTab();
                chatLog(tab, gettext(info.text));
                break;
            }

            case NotifyFlags::PARTY:
            {
                ChatTab *const tab = partyHandler->getTab();
                chatLog(tab, gettext(info.text));
                break;
            }

            case NotifyFlags::SPEECH:
            {
                if (localPlayer)
                    localPlayer->setSpeech(gettext(info.text));
                break;
            }

            case NotifyFlags::INT:
            case NotifyFlags::STRING:
            case NotifyFlags::GUILD_STRING:
            case NotifyFlags::PARTY_STRING:
            default:
                break;
        }
        soundManager.playSfx(SoundDB::getSound(message));
    }
Exemple #10
0
void ChatTab::showOnline(const std::string &nick,
                         const Online online)
{
    if (!mShowOnline)
        return;

    if (online == Online_true)
    {
        // TRANSLATORS: chat message
        chatLog(strprintf(_("%s is now Online."), nick.c_str()),
            ChatMsgType::BY_SERVER);
    }
    else
    {
        // TRANSLATORS: chat message
        chatLog(strprintf(_("%s is now Offline."), nick.c_str()),
            ChatMsgType::BY_SERVER);
    }
}
Exemple #11
0
bool WhisperTab::handleCommand(const std::string &type,
                               const std::string &args)
{
    if (type == "help")
    {
        if (args == "close")
        {
            chatLog(_("Command: /close"));
            chatLog(_("This command closes the current whisper tab."));
        }
        else
            return false;
    }
    else if (type == "close")
    {
        delete this;
    }
    else
        return false;

    return true;
}
Exemple #12
0
void WhisperTab::handleInput(const std::string &msg)
{
//    if (msg.empty())
//    {
//        chatLog(_("Cannot send empty chat!"), BY_SERVER, false);
//        return;
//    }

    if (chatWindow)
    {
        Net::getChatHandler()->privateMessage(mNick,
            chatWindow->doReplace(msg));
    }
    else
    {
        Net::getChatHandler()->privateMessage(mNick, msg);
    }

    if (player_node)
        chatLog(player_node->getName(), msg);
    else
        chatLog("?", msg);
}
Exemple #13
0
void ChatTab::chatLog(const std::string &nick, std::string msg)
{
    if (!localPlayer)
        return;

    const ChatMsgTypeT byWho = (nick == localPlayer->getName()
        ? ChatMsgType::BY_PLAYER : ChatMsgType::BY_OTHER);
    if (byWho == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors"))
        msg = removeColors(msg);
    chatLog(std::string(nick).append(" : ").append(msg),
        byWho,
        IgnoreRecord_false,
        TryRemoveColors_false);
}
Exemple #14
0
void PartyTab::showHelp()
{
    chatLog(_("/help > Display this help."));
    chatLog(_("/invite > Invite a player to your party"));
    chatLog(_("/leave > Leave the party you are in"));
    chatLog(_("/kick > Kick some one from the party you are in"));
    chatLog(_("/item > Show/change party item sharing options"));
    chatLog(_("/exp > Show/change party experience sharing options"));
}
Exemple #15
0
bool WhisperTab::handleCommand(const std::string &type,
                               const std::string &args)
{
    if (type == "help")
    {
        if (args == "close")
        {
            chatLog(_("Command: /close"));
            chatLog(_("This command closes the current whisper tab."));
        }
        else if (args == "ignore")
        {
            chatLog(_("Command: /ignore"));
            chatLog(_("This command ignores the other player regardless of "
                      "current relations."));
        }
        else if (args == "unignore")
        {
            chatLog(_("Command: /unignore <player>"));
            chatLog(_("This command stops ignoring the other player if they "
                      "are being ignored."));
        }
        else
        {
            return false;
        }
    }
    else if (type == "close")
    {
        delete this;
        if (chatWindow)
            chatWindow->defaultTab();
    }
    else if (type == "ignore")
    {
        if (commandHandler)
            commandHandler->handleIgnore(mNick, this);
    }
    else if (type == "unignore")
    {
        if (commandHandler)
            commandHandler->handleUnignore(mNick, this);
    }
    else
    {
        return false;
    }

    return true;
}
Exemple #16
0
void ChatTab::chatLog(const std::string &nick, const std::string &msg)
{
    chatLog(nick + " : " + msg,
            nick == player_node->getName() ? BY_PLAYER : BY_OTHER,
            false);
}
Exemple #17
0
bool PartyTab::handleCommand(const std::string &type, const std::string &args)
{
    if (type == "help")
    {
        if (args == "invite")
        {
            // TRANSLATORS: party help message
            chatLog(_("Command: /invite <nick>"));
            // TRANSLATORS: party help message
            chatLog(_("This command invites <nick> to party with you."));
            // TRANSLATORS: party help message
            chatLog(_("If the <nick> has spaces in it, enclose it in "
                            "double quotes (\")."));
        }
        else if (args == "leave")
        {
            // TRANSLATORS: party help message
            chatLog(_("Command: /leave"));
            // TRANSLATORS: party help message
            chatLog(_("This command causes the player to leave the party."));
        }
        else if (args == "item")
        {
            // TRANSLATORS: party help message
            chatLog(_("Command: /item <policy>"));
            // TRANSLATORS: party help message
            chatLog(
                _("This command changes the party's item sharing policy."));
            // TRANSLATORS: party help message
            chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to "
                      "enable item sharing, or \"0\", \"no\", \"false\" to "
                      "disable item sharing."));
            // TRANSLATORS: party help message
            chatLog(_("Command: /item"));
            // TRANSLATORS: party help message
            chatLog(_("This command displays the party's"
                    " current item sharing policy."));
        }
        else if (args == "exp")
        {
            // TRANSLATORS: party help message
            chatLog(_("Command: /exp <policy>"));
            // TRANSLATORS: party help message
            chatLog(_("This command changes the party's "
                    "experience sharing policy."));
            // TRANSLATORS: party help message
            chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to "
                      "enable experience sharing, or \"0\","
                      " \"no\", \"false\" to disable experience sharing."));
            // TRANSLATORS: party help message
            chatLog(_("Command: /exp"));
            // TRANSLATORS: party help message
            chatLog(_("This command displays the party's current "
                    "experience sharing policy."));
        }
        else
        {
            return false;
        }
    }
    else if (type == "create" || type == "new")
    {
        if (args.empty())
        {
            // TRANSLATORS: chat error message
            chatLog(_("Party name is missing."), BY_SERVER);
        }
        else
        {
            Net::getPartyHandler()->create(args);
        }
    }
    else if (type == "invite")
    {
        Net::getPartyHandler()->invite(args);
    }
    else if (type == "leave")
    {
        Net::getPartyHandler()->leave();
    }
    else if (type == "kick")
    {
        Net::getPartyHandler()->kick(args);
    }
    else if (type == "item")
    {
        if (args.empty())
        {
            switch (Net::getPartyHandler()->getShareItems())
            {
                case PARTY_SHARE:
                    // TRANSLATORS: chat message
                    chatLog(_("Item sharing enabled."), BY_SERVER);
                    return true;
                case PARTY_SHARE_NO:
                    // TRANSLATORS: chat message
                    chatLog(_("Item sharing disabled."), BY_SERVER);
                    return true;
                case PARTY_SHARE_NOT_POSSIBLE:
                    // TRANSLATORS: chat message
                    chatLog(_("Item sharing not possible."), BY_SERVER);
                    return true;
                case PARTY_SHARE_UNKNOWN:
                    // TRANSLATORS: chat message
                    chatLog(_("Item sharing unknown."), BY_SERVER);
                    return true;
                default:
                    break;
            }
        }

        const signed char opt = parseBoolean(args);

        switch (opt)
        {
            case 1:
                Net::getPartyHandler()->setShareItems(PARTY_SHARE);
                break;
            case 0:
                Net::getPartyHandler()->setShareItems(PARTY_SHARE_NO);
                break;
            case -1:
                chatLog(strprintf(BOOLEAN_OPTIONS, "item"));
                break;
            default:
                break;
        }
    }
    else if (type == "exp")
    {
        if (args.empty())
        {
            switch (Net::getPartyHandler()->getShareExperience())
            {
                case PARTY_SHARE:
                    // TRANSLATORS: chat message
                    chatLog(_("Experience sharing enabled."), BY_SERVER);
                    return true;
                case PARTY_SHARE_NO:
                    // TRANSLATORS: chat message
                    chatLog(_("Experience sharing disabled."), BY_SERVER);
                    return true;
                case PARTY_SHARE_NOT_POSSIBLE:
                    // TRANSLATORS: chat message
                    chatLog(_("Experience sharing not possible."), BY_SERVER);
                    return true;
                case PARTY_SHARE_UNKNOWN:
                    // TRANSLATORS: chat message
                    chatLog(_("Experience sharing unknown."), BY_SERVER);
                    return true;
                default:
                    break;
            }
        }

        const signed char opt = parseBoolean(args);

        switch (opt)
        {
            case 1:
                Net::getPartyHandler()->setShareExperience(PARTY_SHARE);
                break;
            case 0:
                Net::getPartyHandler()->setShareExperience(PARTY_SHARE_NO);
                break;
            case -1:
                chatLog(strprintf(BOOLEAN_OPTIONS, "exp"));
                break;
            default:
                break;
        }
    }
    else
    {
        return false;
    }

    return true;
}
Exemple #18
0
void WhisperTab::showHelp()
{
    chatLog(_("/close > Close the whisper tab"));
}
void WhisperTab::showHelp()
{
    chatLog(_("/ignore > Ignore the other player"));
    chatLog(_("/unignore > Stop ignoring the other player"));
    chatLog(_("/close > Close the whisper tab"));
}