QString IRCChannelPerson::setVoice(const QString &nickname, bool set) { if(set) { m_flags |= PERSON_FLAG_VOICE; return ( nickname + QObject::tr(" gives voice to ") + nick() ); } m_flags &= 0xFFFF - PERSON_FLAG_VOICE; return ( nickname + QObject::tr(" removes voice from ") + nick()); }
QString IRCChannelPerson::setOp(const QString &nickname, bool set) { if(set) { m_flags |= PERSON_FLAG_OP; return ( nickname + QObject::tr(" gives channel operator status to ") + nick()); } m_flags &= 0xFFFF - PERSON_FLAG_OP; return ( nickname + QObject::tr(" removes channel operator status from ") + nick()); }
void RegularBattleScene::updatePoke(int spot) { int player = data()->player(spot); int slot = data()->slotNum(spot); auto &poke = *data()->team(player).poke(slot); if (!poke.isKoed()) { //zone->switchTo(poke, spot, info()->sub[spot], info()->specialSprite[spot]); gui.nick[spot]->setText(nick(spot)); gui.level[spot]->setText(tr("Lv. %1").arg(poke.level())); updateHp(spot); gui.gender[spot]->setPixmap(gui.theme->battleGenderPicture(poke.gender())); int status = poke.status(); gui.status[spot]->setPixmap(gui.theme->battleStatusIcon(status)); } else { //zone->switchToNaught(spot); gui.nick[spot]->setText(""); gui.status[spot]->setPixmap(gui.theme->battleStatusIcon(Pokemon::Fine)); gui.gender[spot]->setPixmap(QPixmap()); gui.bars[spot]->setValue(0); gui.level[spot]->setText(""); } gui.fullBars[player]->update(); //needed because qt5 doesn't do its job properly updateBall(player, slot); }
static int ProcessChatEvent(WPARAM, LPARAM lParam) { GCEVENT *gce = (GCEVENT*)lParam; if (gce == NULL || gce->pDest == NULL) return 0; GCDEST *gcd = (GCDEST*)gce->pDest; if (gcd->iType != GC_EVENT_MESSAGE) return 0; MCONTACT hContact = pci->FindRoom(gcd->pszModule, gcd->ptszID); if (hContact != 0) { ptrT nick(db_get_tsa(hContact, gcd->pszModule, "MyNick")); if (nick == NULL || gce->ptszText == NULL) return 0; if (_tcsstr(gce->ptszText, nick)) { isIgnoreSound = db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0); DBVARIANT dbv; if (!isIgnoreSound && !db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) { TCHAR PlaySoundPath[MAX_PATH] = { 0 }; PathToAbsoluteT(dbv.ptszVal, PlaySoundPath); isOwnSound = 0; SkinPlaySoundFile(PlaySoundPath); db_free(&dbv); isOwnSound = 1; } } } return 0; }
void IRC_Session::on_msgJoined(const QString& origin, const QString& channel) { if ( origin == nick() ) { //Prevent recreation of the channel if it is a channel you are rejoining if(ChanList.contains(channel)) { Message temp = ChanList[channel]->append("JOINED","*","Now talking in " + channel); names(channel); emit event_joined(this,channel,temp); } else { ChanList.insert(channel,new irc_channel(channel,ServerItem)); ChanList[channel]->append("JOINED","*","Now talking in " + channel); names(channel); emit event_newChannel(this,channel); } } else { Message temp = ChanList[channel]->append("JOINED",origin,""); ChanList[channel]->users.append(origin); emit event_joined(this,channel,temp); } return; }
void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING *cws, HANDLE hContact) { if (cws->value.type != DBVT_DELETED && !(cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) return; ptrT jid(getTStringA(hContact, "jid")); if (jid == NULL) return; debugLogA("Add %S permanently to list", jid); ptrT nick(db_get_tsa(hContact, "CList", "MyHandle")); if (nick == NULL) nick = getTStringA(hContact, "Nick"); if (nick == NULL) nick = JabberNickFromJID(jid); if (nick == NULL) return; AddContactToRoster(jid, nick, ptrT(db_get_tsa(hContact, "CList", "Group"))); XmlNode xPresence(_T("presence")); xPresence << XATTR(_T("to"), LPCTSTR(jid)) << XATTR(_T("type"), _T("subscribe")); ptrT myNick(getTStringA(NULL, "Nick")); if (myNick != NULL) xPresence << XCHILD(_T("nick"), LPCTSTR(myNick)) << XATTR(_T("xmlns"), JABBER_FEAT_NICK); m_ThreadInfo->send(xPresence); SendGetVcard(jid); db_unset(hContact, "CList", "Hidden"); }
INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM) { if (!hContact) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) ptrT roomID(getTStringA(hContact, "ChatRoomID")); if (roomID == NULL) return 0; if (ListGetItemPtr(LIST_ROSTER, roomID) == NULL) { ptrT group(db_get_tsa(hContact, "CList", "Group")); ptrT nick(getTStringA(hContact, "Nick")); AddContactToRoster(roomID, nick, group); if (m_options.AddRoster2Bookmarks == TRUE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID); if (item == NULL) { item = new JABBER_LIST_ITEM(); item->jid = mir_tstrdup(roomID); item->name = mir_tstrdup(nick); item->nick = getTStringA(hContact, "MyNick"); AddEditBookmark(item); delete item; } } } return 0; }
int ChannelAgent::FindPosition(const char* data) const { ASSERT(data != NULL); /* * Function purpose: Find the index of nickname {data} in the * ChannelAgent's NamesView */ if (fNamesList == NULL) return -1; int32 count(fNamesList->CountItems()); for (int32 i = 0; i < count; ++i) { NameItem* item(static_cast<NameItem*>(fNamesList->ItemAt(i))); if (item == NULL) continue; BString nick(item->Name()); if ((nick[0] == '@' || nick[0] == '+' || nick[0] == '%') && *data != nick[0]) nick.Remove(0, 1); if ((*data == '@' || *data == '+' || *data == '%') && nick[0] != *data) ++data; if (!nick.ICompare(data)) return i; } return -1; }
void __cdecl CSkypeProto::LoadContactList(void* data) { this->debugLogW(L"Updating contacts list"); bool isFirstLoad = data != NULL; this->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList); this->commonList.fetch(); this->commonList->GetContacts(this->contactList); fetch(this->contactList); for (uint i = 0; i < this->contactList.size(); i++) { CContact::Ref contact = this->contactList[i]; MCONTACT hContact = this->AddContact(contact); if ( !isFirstLoad) { // todo: move to AddContact? this->UpdateContactAuthState(hContact, contact); this->UpdateContactStatus(hContact, contact); ptrW nick( ::db_get_wsa(hContact, "CList", "MyHandle")); if ( !nick || !::wcslen(nick)) { nick = ::mir_utf8decodeW(contact->GetNick()); ::db_set_ws(hContact, "CList", "MyHandle", nick); } this->UpdateProfile(contact.fetch(), hContact); } } }
virtual void handleMUCParticipantPresence(gloox::MUCRoom* UNUSED(room), const gloox::MUCRoomParticipant participant, const gloox::Presence& presence) { glooxwrapper::MUCRoomParticipant part; glooxwrapper::JID nick(*participant.nick); glooxwrapper::JID jid(*participant.jid); glooxwrapper::JID actor(*participant.actor); glooxwrapper::JID alternate(*participant.alternate); part.nick = participant.nick ? &nick : NULL; part.affiliation = participant.affiliation; part.role = participant.role; part.jid = participant.jid ? &jid : NULL; part.flags = participant.flags; part.reason = participant.reason; part.actor = participant.actor ? &actor : NULL; part.newNick = participant.newNick; part.status = participant.status; part.alternate = participant.alternate ? &alternate : NULL; /* MUCRoom not supported */ m_Wrapped->handleMUCParticipantPresence(NULL, part, glooxwrapper::Presence(presence.presence())); /* gloox 1.0 leaks some JIDs (fixed in 1.0.1), so clean them up */ #if GLOOXVERSION == 0x10000 delete participant.jid; delete participant.actor; delete participant.alternate; #endif }
void IRC_Session::on_msgNoticeReceived(const QString& origin, const QString& receiver, const QString& notice) { Message temp; temp.text = notice; temp.sender = origin; temp.eventType = "NOTICE"; temp.timestamp = QTime::currentTime(); if(receiver == nick()) { if(!UserData.contains(origin)) emit event_unknown_notice(this,temp); else { for(QHash<QString,irc_channel*>::iterator i = ChanList.begin();i!=ChanList.end();i++) { if(ChanList[i.key()]->users.contains(origin)) { isInChan = true; break; } } if(isInChan) emit even_notice(this,temp); else emit event_external_notice(this,temp); } } return; }
bool irc::auth() { nick(); user(); return true; }
/* // Name: make_action // In: tag, the tag of the message. // command, the command that was send. // message, the trailing message (arguments). // c, the client that sent the message. // msg_is_quoted, wheater or no teh message contains quotes. // clients, all connected clients. // curr_topic, the current topic. // Out: The action that the client want to do in it's connection. // Purpose: Parses the command and does the proper action. */ int make_action(char* tag, char* command, char* message, clientconn_t *c, char msg_is_quoted, hash *clients, char *curr_topic) { if(strlen(tag)==0) { return 0; } if(strcmp(tag, "\r\n")==0) { client_write(c, "BAD No tag.\r\n", 13); return 0; } if(strlen(command)==0) { client_write(c, tag, strlen(tag)); client_write(c, " BAD No command.\r\n", 18); return 0; } if(msg_is_quoted && !msg_is_correctly_quoted(message, msg_is_quoted) && strcmp(command, "PRIVATE")) { return badly_formed(c, tag); } if(strcmp(command, "CAPABILITY")==0) { return capability(c, tag); } if(strcmp(command, "JOIN")==0) { return join(c, tag, clients); } if(strcmp(command, "NICK")==0) { return nick(c, tag, message, msg_is_quoted, clients); } if(strcmp(command,"QUIT")==0) { return quit(c, tag, clients); } if(!c->joined) { return not_joined(c, tag); } if(strcmp(command, "LEAVE")==0) { return leave(c, tag, clients); } if(strcmp(command, "TALK")==0) { return talk(c, tag, message, clients); } if(strcmp(command, "NAMES")==0) { return names(c, tag, clients); } if(strcmp(command, "TOPIC")==0) { return topic(c, tag, message, clients, curr_topic); } if(strcmp(command, "PRIVATE")==0) { return private(c, tag, message, clients); } if(strcmp(command, "WHOIS")==0) { return whois(c, tag, message, clients); } client_write(c, tag, strlen(tag)); client_write(c, " BAD Unkown command.\r\n", 22); return 0; }
/** * Tells this widget what is the network object. Then makes connections to it. * @param network - the network obejct. */ void Login::setNetworkObject( TAim *network ){ connection = network; connect(connection, SIGNAL(statusChanged(int)), this, SLOT(watchConnection(int))); connect(connection, SIGNAL(displayError(QString)), this, SLOT( displayNetworkError(QString))); connect(connection, SIGNAL(nick(QString)), this, SLOT(setNick(QString))); connect( connection, SIGNAL(initProgress(int, int, QString)), this, SLOT(initProgressBar(int, int, QString)) ); connect( connection, SIGNAL(updateProgress(int, QString)), this, SLOT(updateProgressBar(int, QString)) ); connect( connection, SIGNAL(endProgress()), this, SLOT(endProgressBar()) ); }
int main(int argc, char* argv[]) { if (argc < 3) { std::cout << "Insuficient parameters: host port [nick] [user]" << std::endl; return 1; } char* host = argv[1]; int port = atoi(argv[2]); std::string nick("MyIRCClient"); std::string user("IRCClient"); if (argc >= 4) nick = argv[3]; if (argc >= 5) user = argv[4]; IRCClient client; client.Debug(true); // Start the input thread Thread thread; thread.Start(&inputThread, &client); if (client.InitSocket()) { std::cout << "Socket initialized. Connecting..." << std::endl; if (client.Connect(host, port)) { std::cout << "Connected. Loggin in..." << std::endl; if (client.Login(nick, user)) { std::cout << "Logged." << std::endl; running = true; signal(SIGINT, signalHandler); while (client.Connected() && running) client.ReceiveData(); } if (client.Connected()) client.Disconnect(); std::cout << "Disconnected." << std::endl; } } }
// Modified to stop blank and invalid nicks from passing void ChatWindow::connecte() { QRegExp validNick("([A-Za-z0-9_\\-\\\\\\[\\]{}^`|.]+)"); QString nick(ui->editNickname->text()); if (nick == "" || !validNick.exactMatch(nick)) { QPalette *palette = new QPalette(Qt::red); palette->setColor(QPalette::Text,Qt::red); ui->editNickname->setPalette(*palette); ui->editNickname->setFocus(); } else { ui->splitter->show(); IRCServer *ircserver = new IRCServer; QTextEdit *textEdit = new QTextEdit; ui->hide3->hide(); ui->tab->addTab(textEdit, "Console"); ui->tab->setTabToolTip(ui->tab->count() - 1, "irc.freenode.net"); // current tab is now the last, therefore remove all but the last for (int i = ui->tab->count(); i > 1; --i) { ui->tab->removeTab(0); } ircservers.insert("irc.freenode.net", ircserver); ircserver->nickname = ui->editNickname->text(); ircserver->ircserver = "irc.freenode.net"; ircserver->port = 6667; ircserver->display = textEdit; ircserver->tab = ui->tab; ircserver->userList = ui->userView; ircserver->parent = this; ircserver->userList->setEditTriggers(QAbstractItemView::NoEditTriggers); ircserver->userList->setSelectionMode(QAbstractItemView::NoSelection); textEdit->setReadOnly(true); connect(ircserver, SIGNAL(joinTab()), this, SLOT(tabJoined())); connect(ircserver, SIGNAL(tabJoined()), this, SLOT(tabJoining())); ircserver->connectToHost("irc.freenode.net", 6667); ui->tab->setCurrentIndex(ui->tab->count() - 1); } }
MCONTACT CSkypeProto::AddContact(CContact::Ref contact, bool isTemporary) { ptrW sid(::mir_utf8decodeW(contact->GetSid())); CContact::AVAILABILITY availability; contact->GetPropAvailability(availability); MCONTACT hContact = this->GetContactBySid(sid); if ( !hContact) { hContact = (MCONTACT)::CallService(MS_DB_CONTACT_ADD, 0, 0); ::CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)this->m_szModuleName); ptrW nick(::mir_utf8decodeW(contact->GetNick())); switch(availability) { case CContact::SKYPEOUT: this->setByte(hContact, "IsSkypeOut", 1); break; case CContact::PENDINGAUTH: ::db_set_b(hContact, "CList", "NotOnList", 1); break; case CContact::BLOCKED: case CContact::BLOCKED_SKYPEOUT: ::db_set_b(hContact, "CList", "Hidden", 1); break; default: this->delSetting(hContact, "IsSkypeOut"); ::db_unset(hContact, "CList", "Hidden"); ::db_unset(hContact, "CList", "NotOnList"); } this->setTString(hContact, SKYPE_SETTINGS_SID, sid); this->setTString(hContact, "Nick", nick); DBVARIANT dbv; if ( !this->getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv)) { ::db_set_ts(hContact, "CList", "Group", dbv.ptszVal); ::db_free(&dbv); } } return hContact; }
void fe_userlist_insert (session *sess, struct User *newuser, int row, bool sel) { GtkTreeModel *model = static_cast<GtkTreeModel*>(sess->res->user_model); GdkPixbuf *pix = get_user_icon (sess->server, newuser); GtkTreeIter iter; int nick_color = 0; if (prefs.hex_away_track && newuser->away) nick_color = COL_AWAY; else if (prefs.hex_gui_ulist_color) nick_color = text_color_of(newuser->nick); std::string nick(newuser->nick); if (!prefs.hex_gui_ulist_icons) { if (newuser->prefix[0] || newuser->prefix[0] != ' ') nick.insert(nick.begin(), newuser->prefix[0]); pix = NULL; } gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, row, COL_PIX, pix, COL_NICK, nick.c_str(), COL_HOST, newuser->hostname ? newuser->hostname->c_str() : nullptr, COL_USER, newuser, COL_GDKCOLOR, nick_color ? &colors[nick_color] : NULL, -1); /* is it me? */ if (newuser->me && sess->gui->nick_box) { if (!sess->gui->is_tab || sess == current_tab) mg_set_access_icon (sess->gui, pix, sess->server->is_away); } /* is it the front-most tab? */ if (gtk_tree_view_get_model (GTK_TREE_VIEW (sess->gui->user_tree)) == model) { if (sel) gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (sess->gui->user_tree)), &iter); } }
void IRC_Session::on_msgMessageReceived(const QString& origin, const QString& receiver, const QString& message) { if(receiver == nick()) { if(!Queries.contains(origin)) Queries.insert(origin,new private_message(origin,ServerItem)); Message temp = Queries[origin]->append(origin,message); emit event_private_message(this,temp); } else { if(ChanList.contains(receiver)) { Message temp = ChanList[receiver]->append("MESSAGE",origin,message); emit event_channel_message(this,receiver,temp); } } }
void IRC_Session::on_msgNickChanged(const QString& origin, const QString& newNick) { for(QHash<QString,irc_channel*>::iterator i = ChanList.begin();i!=ChanList.end();i++) { if(ChanList[i.key()]->users.contains(origin)) { if(newNick == nick()) ChanList[i.key()]->append("NICK",origin,"You are now chatting as " + newNick); else ChanList[i.key()]->append("NICK",origin,"Is now chatting as " + newNick); ChanList[i.key()]->users.removeOne(origin); ChanList[i.key()]->users.append(newNick); } } emit event_nick(this,newNick); }
void PartyHandler::processPartyInvited(Net::MessageIn &msg) { int id = msg.readInt32(); std::string partyName = msg.readString(24); std::string nick(""); Being *being; if (actorSpriteManager) { if ((being = actorSpriteManager->findBeing(id))) { if (being && being->getType() == Being::PLAYER) nick = being->getName(); } } if (socialWindow) socialWindow->showPartyInvite(partyName, nick); }
int main(){ char* host = "irc.freenode.net"; int port = 6667; std::string nick("MyIRCBot2"); std::string user("IRCClient"); IRCClient client; client.Debug(true); if (client.InitSocket()) { std::cout << "Socket initialized. Connecting..." << std::endl; if (client.Connect(host, port)) { std::cout << "Connected. Loggin in..." << std::endl; if (client.Login(nick, user)) { std::cout << "Logged." << std::endl; client.SendIRC("JOIN #mybottest"); while (client.Connected()) client.ReceiveData(); } if (client.Connected()) client.Disconnect(); std::cout << "Disconnected." << std::endl; } } return 0; }
void IRC_Session::on_msgParted(const QString& origin,const QString& channel,const QString& message) { if (origin == nick()) { if(ChanList.contains(channel)) { delete ChanList.take(channel); emit event_parted_channel(this,channel); } } else { if(ChanList.contains(channel)) { ChanList[channel]->append("PARTED",origin,message); ChanList[channel]->users.removeOne(origin); emit event_parted(this,channel); } } return; }
bool Client::connect_to_server() { // The Ident object will delete itself after the ident response or if // it times out. if (config.use_ident) { ident = new Ident(config); } struct hostent* he; struct sockaddr_in remoteAddr; if ((he = gethostbyname(config.irc_host.c_str())) == NULL) { std::cout << "Could not get host!" << std::endl; return false; } if ((socketFd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { std::cout << "Could not create socket!" << std::endl; return false; } remoteAddr.sin_family = AF_INET; remoteAddr.sin_port = htons(config.irc_port); remoteAddr.sin_addr = *((struct in_addr *) he->h_addr); memset(&(remoteAddr.sin_zero), '\0', 8); if (connect(socketFd, (struct sockaddr *) &remoteAddr, sizeof (struct sockaddr)) < 0) { std::cout << "Could not connect!" << std::endl; return false; } if (!config.irc_password.empty()) { pass(config.irc_password); } user(config.irc_user_name, config.irc_real_name); nick(config.irc_nick_name); read_event.set<Client, &Client::handle_receive > (this); read_event.start(socketFd, ev::READ); return true; }
Message JabberRoomChatService::handleReceivedMessage(const QXmppMessage &xmppMessage) const { auto jid = Jid::parse(xmppMessage.from()); auto roomChat = getRoomChat(jid.bare()); if (!roomChat) return Message::null; if (jid.resource() == roomChat->nick()) // message from myself return Message::null; auto contact = m_contactManager->byId(account(), jid.full(), ActionCreateAndAdd); auto buddy = m_buddyManager->byContact(contact, ActionCreateAndAdd); buddy.setDisplay(jid.resource()); buddy.setTemporary(true); auto result = m_messageStorage->create(); result.setMessageChat(roomChat->chat()); result.setMessageSender(contact); return result; }
void management::parseEvents() { output::instance().addOutput("void management::parseEvents()"); std::vector< std::string > data; while(m_Run) { data = m_IrcData->getEventsQueue(); if (data.size() == 3) { if (data[1] == "NICK") { nick(data); } if (data[1] == "JOIN") { join(data); } } if (data.size() >= 3) { if (data[1] == "QUIT") { quit(data); } if (data[1] == "PART") { part(data); } } if (data.size() >= 4) { if (data[1] == "KICK") { kick(data); } } } }
INT_PTR __cdecl CJabberProto::OnJoinChat(WPARAM hContact, LPARAM) { ptrT jid(getTStringA(hContact, "ChatRoomID")); if (jid == NULL) return 0; ptrT nick(getTStringA(hContact, "MyNick")); if (nick == NULL) if ((nick = getTStringA("Nick")) == NULL) return 0; ptrT password(getTStringA(hContact, "Password")); if (getWord(hContact, "Status", 0) != ID_STATUS_ONLINE) { TCHAR *p = _tcschr(jid, '@'); if (p != NULL) { *p++ = 0; GroupchatJoinRoom(p, jid, nick, password); } } return 0; }
void WhatsAppProto::onGetParticipants(const std::string &gjid, const std::vector<string> &participants) { mir_cslock lck(m_csChats); WAChatInfo *pInfo = m_chats[gjid]; if (pInfo == NULL) return; pInfo->bActive = true; for (size_t i = 0; i < participants.size(); i++) { std::string curr = participants[i]; ptrT ujid(str2t(curr)), nick(GetChatUserNick(curr)); bool bIsOwner = !mir_tstrcmp(ujid, pInfo->tszOwner); GCDEST gcd = { m_szModuleName, pInfo->tszJid, GC_EVENT_JOIN }; GCEVENT gce = { sizeof(gce), &gcd }; gce.ptszNick = nick; gce.ptszUID = utils::removeA(ujid); gce.ptszStatus = (bIsOwner) ? _T("Owners") : _T("Members"); CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); } }
void RegularBattleScene::updateToolTip(int spot) { QString tooltip; QString stats[8] = { tu(StatInfo::Stat(0, data()->gen())), tu(StatInfo::Stat(1, data()->gen())), tu(StatInfo::Stat(2, data()->gen())), tu(StatInfo::Stat(3, data()->gen())), tu(StatInfo::Stat(4, data()->gen())), tu(StatInfo::Stat(5, data()->gen())), tu(StatInfo::Stat(6, data()->gen())), tu(StatInfo::Stat(7, data()->gen())) }; //Prevents a headache if it includes HP as a null value QString range[6] = { 0 }; QString statval[6] = { 0 }; for (int i = 1; i < 6; i++) { int min = data()->fieldPoke(spot).minStat(i); int max = data()->fieldPoke(spot).maxStat(i); range[i] = QString("%2-%3").arg(min).arg(max); int stat = data()->fieldPoke(spot).stat(i); if (stat == -1) { statval[i] = "???"; } else { statval[i] = QString::number(stat); } } /* Aligning various things on the tool tip */ int max = 0, max2 = 0, max3 = 0; for (int i = 0; i < 8; i++) { max = std::max(max, stats[i].length()); if (i > 0 && i < 6) { max2 = std::max(max2, range[i].length()); max3 = std::max(max3, statval[i].length()); } } for (int i = 0; i < 8; i++) { stats[i] = stats[i].leftJustified(max, '.', false); if (i > 0 && i < 6) { range[i] = range[i].leftJustified(max2, ' ', false); statval[i] = statval[i].rightJustified(max3, ' ', false); } } const auto &poke = data()->poke(spot).num(); tooltip += nick(spot) + "\n"; tooltip += TypeInfo::Name(PokemonInfo::Type1(poke, data()->gen())); int type2 = PokemonInfo::Type2(poke, data()->gen()); if (type2 != Pokemon::Curse) { tooltip += " " + TypeInfo::Name(type2); } tooltip += "\n"; for (int i = 0; i < 6; i++) { // Gen 1 only has Special, and we treat SAtk as Special hiding SDef. if (data()->gen().num == 1) { switch (i) { case 4: continue; default: tooltip += "\n" + stats[i] + " "; } } else { tooltip += "\n" + stats[i] + " "; } int boost = data()->fieldPoke(spot).statBoost(i); int stat = data()->fieldPoke(spot).stat(i); if (stat == 0 || i == 0) { int min = data()->fieldPoke(spot).minStat(i); int max = data()->fieldPoke(spot).maxStat(i); if (i == 0) { if (data()->isPlayer(spot)) { tooltip += QString("%1/%2").arg(data()->poke(spot).life()).arg(data()->poke(spot).totalLife()); } else { tooltip += QString("%3/%1-%4/%2").arg(min).arg(max).arg(gui.bars[spot]->value()*min/100).arg(gui.bars[spot]->value()*max/100); } } else { if (boost >= 0) { tooltip += range[i] + (boost > 0 ? QString(" (+%1)").arg(boost) : ""); } else if (boost < 0) { tooltip += range[i] + QString(" (%1)").arg(boost); } } } else { if (boost >= 0) { tooltip += statval[i] + (boost > 0 ? QString(" (+%1)").arg(boost) : ""); } else if (boost < 0) { tooltip += statval[i] + QString(" (%1)").arg(boost); } } } for (int i = 6; i < 8; i++) { int boost = data()->fieldPoke(spot).statBoost(i); if (boost) { tooltip += "\n" + stats[i] + " "; if (boost > 0) { tooltip += QString("+%1").arg(boost); } else if (boost < 0) { tooltip += QString("%1").arg(boost); } } } tooltip += "\n"; const auto &zone = *data()->field().zone(data()->player(spot)); if (zone.spikesLevel() > 0) { tooltip += "\n" + tr("Spikes level %1").arg(zone.spikesLevel()); } if (zone.tspikesLevel() > 0) { tooltip += "\n" + tr("Toxic Spikes level %1").arg(zone.tspikesLevel()); } if (zone.stealthRocks()) { tooltip += "\n" + tr("Stealth Rock"); } if (zone.stickyWeb()) { tooltip += "\n" + tr("Sticky Web"); } if (data()->field().weather() != Weather::NormalWeather) { tooltip += "\n" + tr("Weather: %1").arg(TypeInfo::weatherName(data()->field().weather())); } if (!data()->isPlayer(spot) && data()->poke(spot).move(0)->num() != Move::NoMove) { tooltip += "\n\nKnown Moves:\n"; for (int i = 0; i < 4; i++) { int move = data()->poke(spot).move(i)->num(); if (move != Move::NoMove) { tooltip += MoveInfo::Name(move) + QString(" %1/%2").arg(data()->poke(spot).move(i)->PP()).arg(data()->poke(spot).move(i)->totalPP()) + "\n"; } else { tooltip += "??? \n"; } } } gui.zone->tooltips[spot] = tooltip; }
QString IrcUser::hostmask() const { return QString("%1!%2@%3").arg(nick()).arg(user()).arg(host()); }