void WPAccount::slotSendMessage(const QString &Body, const QString &Destination) { kdDebug(14170) << "WPAccount::slotSendMessage(" << Body << ", " << Destination << ")" << endl; if (myself()->onlineStatus().status() == Kopete::OnlineStatus::Away) myself()->setOnlineStatus(mProtocol->WPOnline); mProtocol->sendMessage(Body, Destination); }
void Account::fillActionMenu( KActionMenu *actionMenu ) { //default implementation // KActionMenu *menu = new KActionMenu( QIcon(myself()->onlineStatus().iconFor( this )), accountId(), 0, 0); #ifdef __GNUC__ #warning No icon shown, we should go away from QPixmap genered icons with overlays. #endif QString nick; if (identity()->hasProperty( Kopete::Global::Properties::self()->nickName().key() )) nick = identity()->property( Kopete::Global::Properties::self()->nickName() ).value().toString(); else nick = myself()->displayName(); // Always add title at the beginning of actionMenu QAction *before = actionMenu->menu()->actions().value( 0, 0 ); actionMenu->menu()->addTitle( myself()->onlineStatus().iconFor( myself() ), nick.isNull() ? accountLabel() : i18n( "%2 <%1>", accountLabel(), nick ), before ); actionMenu->menu()->addSeparator(); KAction *propertiesAction = new KAction( i18n("Properties"), actionMenu ); QObject::connect( propertiesAction, SIGNAL(triggered(bool)), this, SLOT(editAccount()) ); actionMenu->addAction( propertiesAction ); }
GaduAccount::GaduAccount( Kopete::Protocol* parent, const QString& accountID,const char* name ) : Kopete::PasswordedAccount( parent, accountID, 0, name ) { QHostAddress ip; p = new GaduAccountPrivate; p->pingTimer_ = NULL; p->saveListDialog = NULL; p->loadListDialog = NULL; p->forFriends = false; p->textcodec_ = QTextCodec::codecForName( "CP1250" ); p->session_ = new GaduSession( this, "GaduSession" ); KGlobal::config()->setGroup( "Gadu" ); setMyself( new GaduContact( accountId().toInt(), accountId(), this, Kopete::ContactList::self()->myself() ) ); p->status = GaduProtocol::protocol()->convertStatus( GG_STATUS_NOT_AVAIL ); p->lastDescription = QString::null; for ( unsigned int i = 0; i < NUM_SERVERS ; i++ ) { ip.setAddress( QString( servers_ip[i] ) ); p->servers.append( htonl( ip.toIPv4Address() ) ); kdDebug( 14100 ) << "adding IP: " << p->servers[ i ] << " to cache" << endl; } p->currentServer = -1; p->serverIP = 0; // initialize KGaduLogin structure to default values p->loginInfo.uin = accountId().toInt(); p->loginInfo.useTls = false; p->loginInfo.status = GG_STATUS_AVAIL; p->loginInfo.server = 0; p->loginInfo.client_port = 0; p->loginInfo.client_addr = 0; p->pingTimer_ = new QTimer( this ); p->exportTimer_ = new QTimer( this ); p->exportUserlist = false; p->gaduDcc_ = NULL; p->config = configGroup(); p->ignoreAnons = ignoreAnons(); p->forFriends = loadFriendsMode(); initConnections(); initActions(); QString nick = p->config->readEntry( QString::fromAscii( "nickName" ) ); if ( !nick.isNull() ) { myself()->setProperty( Kopete::Global::Properties::self()->nickName(), nick ); } else { myself()->setProperty( Kopete::Global::Properties::self()->nickName(), accountId() ); p->config->writeEntry( QString::fromAscii( "nickName" ), accountId() ); } }
KActionMenu* WPAccount::actionMenu() { kdDebug(14170) << "WPAccount::actionMenu()" << endl; /// How to remove an action from Kopete::Account::actionMenu()? GF KActionMenu *theActionMenu = new KActionMenu(accountId() , myself()->onlineStatus().iconFor(this), this); theActionMenu->popupMenu()->insertTitle(myself()->onlineStatus().iconFor(this), i18n("WinPopup (%1)").arg(accountId())); if (mProtocol) { KAction *goOnline = new KAction("Online", QIconSet(mProtocol->WPOnline.iconFor(this)), 0, this, SLOT(connect()), theActionMenu, "actionGoAvailable"); goOnline->setEnabled(isConnected() && isAway()); theActionMenu->insert(goOnline); KAction *goAway = new KAction("Away", QIconSet(mProtocol->WPAway.iconFor(this)), 0, this, SLOT(goAway()), theActionMenu, "actionGoAway"); goAway->setEnabled(isConnected() && !isAway()); theActionMenu->insert(goAway); /// One can not really go offline manually - appears online as long as samba server is running. GF theActionMenu->popupMenu()->insertSeparator(); theActionMenu->insert(new KAction(i18n("Properties"), 0, this, SLOT(editAccount()), theActionMenu, "actionAccountProperties")); } return theActionMenu; }
GraphicsZone::GraphicsZone(battledata_ptr i, BattleDefaultTheme *theme) : mInfo(i) { setScene(&scene); setMouseTracking(true); int nslots = info()->numberOfSlots(); tooltips.resize(nslots); items.resize(nslots); scene.setSceneRect(0,0,321,181); scene.addItem(new QGraphicsPixmapItem(theme->pic(QString("battle_fields/%1.png").arg((rand()%11)+1)))); for (int i = 0; i < nslots; i++) { items[i] = new QGraphicsPixmapItem(); scene.addItem(items[i]); } int size = Version::avatarSize[info()->gen().num-1]; if (!info()->multiples()) { items[info()->spot(myself())]->setPos(50 - size/2, 146 - size); items[info()->spot(opponent())]->setPos(184- size/2, 96 - size); } else { for (int i = 0; i < nslots/2; i++) { items[info()->spot(myself(), i)]->setPos(i*60, 146-size); int base = 257-80-(nslots/2 - 1)*60; items[info()->spot(opponent(), i)]->setPos(base+i*60, 96 - size); } } }
void WPAccount::setOnlineStatus(const Kopete::OnlineStatus &status, const QString &reason) { if (myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Online) connect( status ); else if (myself()->onlineStatus().status() != Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Offline) disconnect(); else if (myself()->onlineStatus().status() != Kopete::OnlineStatus::Offline && status.status() == Kopete::OnlineStatus::Away) setAway( true, reason ); }
bool Account::suspend( const Kopete::StatusMessage &reason ) { if ( d->suspended ) return false; d->suspendStatus = myself()->onlineStatus(); if( myself()->onlineStatus().status() == OnlineStatus::Connecting ) d->suspendStatus = d->restoreStatus; setOnlineStatus( OnlineStatus::Offline, reason ); d->suspended = true; return true; }
int main() { auto fib = [](int x, auto myself = dummy) -> int { if (x < 2) return 1; return myself(x - 1) + myself(x - 2); }; static_assert(std::is_same<combinator_traits<decltype(fib)>::result_type, std::function<int(int)>>::value, "!"); std::cout << fib(5, foo) << std::endl; // 8 }
void IRCAccount::connect( const Kopete::OnlineStatus& /* initialStatus */ ) { kDebug ( 14210 ) ; myself()->setOnlineStatus( IRCProtocol::protocol()->ircOnline ); QObject::connect ( m_server, SIGNAL (messageReceived(QString)), this, SLOT (receivedMessage(QString)) ); }
KActionMenu * Account::actionMenu() { //default implementation KActionMenu *menu = new KActionMenu( accountId(), myself()->onlineStatus().iconFor( this ), this ); QString nick = myself()->property( Kopete::Global::Properties::self()->nickName()).value().toString(); menu->popupMenu()->insertTitle( myself()->onlineStatus().iconFor( myself() ), nick.isNull() ? accountLabel() : i18n( "%2 <%1>" ).arg( accountLabel(), nick ) ); OnlineStatusManager::self()->createAccountStatusActions(this, menu); menu->popupMenu()->insertSeparator(); menu->insert( new KAction ( i18n( "Properties" ), 0, this, SLOT( editAccount() ), menu, "actionAccountProperties" ) ); return menu; }
void IRCAccount::setOnlineStatus(const Kopete::OnlineStatus& status, const Kopete::StatusMessage &reason, const OnlineStatusOptions& /*options*/) { if ( status.status() == Kopete::OnlineStatus::Online && myself()->onlineStatus().status() == Kopete::OnlineStatus::Offline ) slotGoOnline(); else if (status.status() == Kopete::OnlineStatus::Online && (myself()->onlineStatus().status() == Kopete::OnlineStatus::Away || myself()->onlineStatus().status() == Kopete::OnlineStatus::Busy) ) setAway( false, reason.message() ); else if ( status.status() == Kopete::OnlineStatus::Offline ) slotGoOffline(); else if ( status.status() == Kopete::OnlineStatus::Away ) slotGoAway( /* reason */ ); else if ( status.status() == Kopete::OnlineStatus::Busy ) slotGoBusy( /* reason */ ); }
void Kopete::ChatSession::appendMessage( Kopete::Message &msg ) { msg.setManager( this ); if ( msg.direction() == Kopete::Message::Inbound ) { const QString nick = myself()->nickName(); if ( Kopete::BehaviorSettings::self()->highlightEnabled() && !nick.isEmpty() ) { const QString nickNameRegExp = QString::fromLatin1( "(^|[\\W])(%1)([\\W]|$)" ).arg( QRegExp::escape( nick ) ); if ( msg.plainBody().contains( QRegExp( nickNameRegExp, Qt::CaseInsensitive ) ) ) { msg.setImportance( Kopete::Message::Highlight ); } } emit messageReceived( msg, this ); } // outbound messages here are ones the user has sent that are now // getting reflected back to the chatwindow. they should go down // the incoming chain. Kopete::Message::MessageDirection chainDirection = msg.direction(); if( chainDirection == Kopete::Message::Outbound ) chainDirection = Kopete::Message::Inbound; chainForDirection( chainDirection )->processMessage( msg ); //looking for urls in the message urlSearch( msg ); // emit messageAppended( msg, this ); }
void JabberTransport::eatContacts( ) { /* * "Gateway Contact Eating" (c)(r)(tm)(g)(o)(f) * this comes directly from my mind into the kopete code. * principle: - the transport is hungry * - it will eat contacts which belong to him * - the contact will die * - a new contact will born, with the same characteristics, but owned by the transport * - Olivier 2006-01-17 - */ kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << endl; QDict<Kopete::Contact> cts=account()->contacts(); QDictIterator<Kopete::Contact> it( cts ); for( ; it.current(); ++it ) { JabberContact *contact=dynamic_cast<JabberContact*>(it.current()); if( contact && !contact->transport() && contact->rosterItem().jid().domain() == myself()->contactId() && contact != account()->myself()) { XMPP::RosterItem item=contact->rosterItem(); Kopete::MetaContact *mc=contact->metaContact(); Kopete::OnlineStatus status = contact->onlineStatus(); kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << item.jid().full() << " will be soon eat - " << contact << endl; delete contact; Kopete::Contact *c2=account()->contactPool()->addContact( item , mc , false ); //not sure this is false; if(c2) c2->setOnlineStatus( status ); //put back the old status } } }
void Kopete::ChatSession::appendMessage( Kopete::Message &msg ) { msg.setManager( this ); if ( msg.direction() == Kopete::Message::Inbound ) { QString nick=myself()->property(Kopete::Global::Properties::self()->nickName()).value().toString(); if ( KopetePrefs::prefs()->highlightEnabled() && !nick.isEmpty() && msg.plainBody().contains( QRegExp( QString::fromLatin1( "\\b(%1)\\b" ).arg( nick ), false ) ) ) { msg.setImportance( Kopete::Message::Highlight ); } emit messageReceived( msg, this ); } // outbound messages here are ones the user has sent that are now // getting reflected back to the chatwindow. they should go down // the incoming chain. Kopete::Message::MessageDirection chainDirection = msg.direction(); if( chainDirection == Kopete::Message::Outbound ) chainDirection = Kopete::Message::Inbound; chainForDirection( chainDirection )->processMessage( msg ); // emit messageAppended( msg, this ); }
void IRCAccount::updateContactStatus() { QHashIterator<QString, Kopete::Contact*>itr( contacts() ); for ( ; itr.hasNext(); ) { itr.next(); itr.value()->setOnlineStatus( myself()->onlineStatus() ); } }
IRCAccount::IRCAccount( IRCProtocol *parent, const QString& accountID ) : Kopete::Account ( parent, accountID ) { // Init the myself contact setMyself( new IRCContact( this, accountId(), Kopete::ContactList::self()->myself() ) ); myself()->setOnlineStatus( IRCProtocol::protocol()->ircOffline ); m_server = new IRCFakeServer();; }
void pc_callback(const sensor_msgs::PointCloud2ConstPtr msg) { pcl::PointCloud<pcl::PointXYZ> temp; pcl::fromROSMsg(*msg, temp); // Make sure the point cloud is in the base-frame listener_.waitForTransform(base_frame_,msg->header.frame_id,msg->header.stamp,ros::Duration(1.0)); pcl_ros::transformPointCloud(base_frame_,msg->header.stamp, temp, msg->header.frame_id, lastpc_, listener_); // unsigned int n = lastpc.size(); // ROS_INFO("New point cloud: %d points",n); // for (unsigned int i=0;i<n;i++) { // float x = lastpc[i].x; // float y = lastpc[i].y; // float z = lastpc[i].z; // ROS_INFO("%d %.3f %.3f %.3f",i,x,y,z); // } // printf("\n\n\n"); og_ = FREE; // reset the map unsigned int n = lastpc_.size(); for (unsigned int i=0;i<n;i++) { float x = lastpc_[i].x; float y = lastpc_[i].y; float d = hypot(x,y); if (d < 1e-2) { // Bogus point, ignore continue; } cv::Point P(x / map_resolution_ + grid_width_/2., y/map_resolution_ + grid_width_/2.); cv::circle(og_,P, ceil(robot_radius_/map_resolution_ + 1), cv::Scalar(OCCUPIED), -1); // filled circle } // Marked the robot own space as FREE, whatever the point cloud // is saying. This means that rotation on the spot are always // possible cv::Point myself(grid_width_/2,grid_width_/2); cv::circle(og_,myself, ceil(robot_radius_/map_resolution_ + 1), cv::Scalar(FREE), -1); // filled circle cv::imshow( "OccGrid", og_ ); // // First convert the obstacle into the ego-kinematic space // (d,alpha), where d is the distance on the arc of circle, and // alpha = atan2(v,w) cv::remap(og_,d_alpha_,dalpha_remap_x,dalpha_remap_y, CV_INTER_LINEAR, cv::BORDER_CONSTANT, UNKNOWN ); // Now we need to go through all the d_alpha combination. If we hit // an obstacle at a given value of d, any further distance is also // going to hit it. for (unsigned int i=0;i<n_alpha_;i++) { for (int j=n_d_/2;j<(signed)n_d_;j++) { if (d_alpha_(j,i) != FREE) { for (;j<(signed)n_d_;j++) d_alpha_(j,i) = OCCUPIED; } } for (int j=n_d_/2;j>=0;j--) { if (d_alpha_(j,i) != FREE) { for (;j>=0;j--) d_alpha_(j,i) = OCCUPIED; } } } cv::imshow( "DAlpha", d_alpha_ ); }
void Account::slotOnlineStatusChanged( Contact * /* contact */, const OnlineStatus &newStatus, const OnlineStatus &oldStatus ) { const bool wasOffline = !oldStatus.isDefinitelyOnline(); const bool isOffline = !newStatus.isDefinitelyOnline(); d->suspended = false; if ( wasOffline && !isOffline ) d->lastLoginTime = QDateTime::currentDateTime(); // If we went offline we have to ensure that all of our contacts // are online too. Otherwise the "Last Seen" tooltip won't work // properly. See bug 266580. if ( !wasOffline && isOffline ) setAllContactsStatus( Kopete::OnlineStatus::Offline ); if ( wasOffline || newStatus.status() == OnlineStatus::Offline ) { // Wait for twenty seconds until we treat status notifications for contacts // as unrelated to our own status change. // Twenty seconds may seem like a long time, but just after your own // connection it's basically neglectible, and depending on your own // contact list's size, the protocol you are using, your internet // connection's speed and your computer's speed you *will* need it. d->suppressStatusNotification = true; d->suppressStatusTimer.setSingleShot( true ); d->suppressStatusTimer.start( 20000 ); //the timer is also used to reset the d->connectionTry } if ( !isOffline ) { d->restoreStatus = newStatus; d->restoreMessage.setTitle( myself()->property( Kopete::Global::Properties::self()->statusTitle() ).value().toString() ); d->restoreMessage.setMessage( myself()->property( Kopete::Global::Properties::self()->statusMessage() ).value().toString() ); } /* kDebug(14010) << "account " << d->id << " changed status. was " << Kopete::OnlineStatus::statusTypeToString(oldStatus.status()) << ", is " << Kopete::OnlineStatus::statusTypeToString(newStatus.status()) << endl;*/ if ( wasOffline != isOffline ) emit isConnectedChanged(); }
void IRCAccount::slotGoBusy () { kDebug ( 14210 ) ; if (!isConnected ()) connect(); myself()->setOnlineStatus( IRCProtocol::protocol()->ircBusy ); updateContactStatus(); }
void WPAccount::setAway(bool status, const QString &awayMessage) { // kdDebug(14170) << "WPAccount::setAway()" << endl; theAwayMessage = awayMessage; // if(!isConnected()) // theInterface->goOnline(); myself()->setOnlineStatus(status ? mProtocol->WPAway : mProtocol->WPOnline); }
KActionMenu *JabberTransport::actionMenu () { KActionMenu *menu = new KActionMenu( accountId(), myself()->onlineStatus().iconFor( this ), this ); QString nick = myself()->property( Kopete::Global::Properties::self()->nickName()).value().toString(); menu->popupMenu()->insertTitle( myself()->onlineStatus().iconFor( myself() ), nick.isNull() ? accountLabel() : i18n( "%2 <%1>" ).arg( accountLabel(), nick ) ); QPtrList<KAction> *customActions = myself()->customContextMenuActions( ); if( customActions && !customActions->isEmpty() ) { menu->popupMenu()->insertSeparator(); for( KAction *a = customActions->first(); a; a = customActions->next() ) a->plug( menu->popupMenu() ); } delete customActions; return menu; /* KActionMenu *m_actionMenu = Kopete::Account::actionMenu(); m_actionMenu->popupMenu()->insertSeparator(); m_actionMenu->insert(new KAction (i18n ("Join Groupchat..."), "jabber_group", 0, this, SLOT (slotJoinNewChat ()), this, "actionJoinChat")); m_actionMenu->popupMenu()->insertSeparator(); m_actionMenu->insert ( new KAction ( i18n ("Services..."), "jabber_serv_on", 0, this, SLOT ( slotGetServices () ), this, "actionJabberServices") ); m_actionMenu->insert ( new KAction ( i18n ("Send Raw Packet to Server..."), "mail_new", 0, this, SLOT ( slotSendRaw () ), this, "actionJabberSendRaw") ); m_actionMenu->insert ( new KAction ( i18n ("Edit User Info..."), "identity", 0, this, SLOT ( slotEditVCard () ), this, "actionEditVCard") ); return m_actionMenu;*/ }
GraphicsZone::GraphicsZone(battledata_ptr i, BattleDefaultTheme *theme) : mInfo(i) { setScene(&scene); setMouseTracking(true); int nslots = info()->numberOfSlots(); tooltips.resize(nslots); items.resize(nslots); scene.setSceneRect(0,0,400,240); QDir directory((theme->directoryPath("battle_fields"))); directory.setNameFilters(QStringList() << "*.png"); QStringList files = directory.entryList(); QString fileName = ""; if (!files.isEmpty()) { fileName = files[(rand()%files.length())]; } scene.addItem(new QGraphicsPixmapItem(theme->pic(QString("battle_fields/%1").arg(fileName)))); for (int i = 0; i < nslots; i++) { items[i] = new QGraphicsPixmapItem(); scene.addItem(items[i]); } int size = Version::avatarSize[info()->gen().num-1]; if (!info()->multiples()) { items[info()->spot(myself())]->setPos(60 - size/2, 175 - size); items[info()->spot(opponent())]->setPos(310 - size/2, 60 - size); } else { for (int i = 0; i < nslots/2; i++) { items[info()->spot(myself(), i)]->setPos(i*65, 200-size); int base = 240-(nslots/2 - 1)*60; items[info()->spot(opponent(), i)]->setPos(base+i*65, 165 - size); } } }
bool Account::addContact(const QString &contactId , MetaContact *parent, AddMode mode ) { if ( !protocol()->canAddMyself() && contactId == myself()->contactId() ) { if ( isConnected() && d->lastLoginTime.secsTo(QDateTime::currentDateTime()) > 30 ) { KMessageBox::queuedMessageBox( Kopete::UI::Global::mainWidget(), KMessageBox::Error, i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.", contactId, accountId()), i18n("Error Creating Contact") ); } else { kWarning(14010) << "You are not allowed to add yourself to the contact list. The addition of" << contactId << "to account" << accountId() << "will not take place."; } return 0L; } const bool isTemporary= parent->isTemporary(); Contact *c = d->contacts.value( contactId ); if ( c && c->metaContact() ) { if ( c->metaContact()->isTemporary() && !isTemporary ) { kDebug( 14010 ) << "Account::addContact: You are trying to add an existing temporary contact. Just add it on the list" << endl; //setMetaContact ill take care about the deletion of the old contact c->setMetaContact(parent); return true; } else { // should we here add the contact to the parentContact if any? kDebug( 14010 ) << "Account::addContact: Contact already exists"; } return false; //(the contact is not in the correct metacontact, so false) } const bool success = createContact(contactId, parent); if ( success && mode == ChangeKABC ) { kDebug( 14010 ) << " changing KABC"; KABCPersistence::self()->write( parent ); } return success; }
int main(int argc, char *argv[]) { UdpAdvertiser advertiser(true); Advert myself("???", "1.0", "computer", "beta"); for(;;) { std::cout << "pulse" << std::endl; advertiser.pulse(myself); std::list<IncomingAdvert> adverts = advertiser.sample(1000); std::list<IncomingAdvert>::iterator it = adverts.begin(); for(; it != adverts.end(); ++it) { std::cout << "Name " << (*it).ad.name << std::endl; } } }
int main(void) { WSADATA data; WSAStartup(MAKEWORD(1,1),&data); Shared::NetPeer myself("127.0.0.1", 8889); Shared::NetworkManager netManager(myself, 8889); bool is_ok = netManager.Init(); while (1) { bool bnewmessage = netManager.Refresh(); if (bnewmessage) printf("new message ...\n"); } return 0; }
bool JabberTransport::removeAccount( ) { if(m_status == Removing || m_status == AccountRemoved) return true; //so it can be deleted if (!account()->isConnected()) { account()->errorConnectFirst (); return false; } m_status = Removing; XMPP::JT_Register *task = new XMPP::JT_Register ( m_account->client()->rootTask () ); QObject::connect ( task, SIGNAL ( finished () ), this, SLOT ( removeAllContacts() ) ); //JabberContact *my=static_cast<JabberContact*>(myself()); task->unreg ( myself()->contactId() ); task->go ( true ); return false; //delay the removal }
bool Account::addContact(const QString &contactId , MetaContact *parent, AddMode mode ) { if ( contactId == myself()->contactId() ) { KMessageBox::error( Kopete::UI::Global::mainWidget(), i18n("You are not allowed to add yourself to the contact list. The addition of \"%1\" to account \"%2\" will not take place.").arg(contactId,accountId()), i18n("Error Creating Contact") ); return 0L; } bool isTemporary= parent->isTemporary(); Contact *c = d->contacts[ contactId ]; if ( c && c->metaContact() ) { if ( c->metaContact()->isTemporary() && !isTemporary ) { kdDebug( 14010 ) << "Account::addContact: You are trying to add an existing temporary contact. Just add it on the list" << endl; //setMetaContact ill take care about the deletion of the old contact c->setMetaContact(parent); return true; } else { // should we here add the contact to the parentContact if any? kdDebug( 14010 ) << "Account::addContact: Contact already exists" << endl; } return false; //(the contact is not in the correct metacontact, so false) } bool success = createContact(contactId, parent); if ( success && mode == ChangeKABC ) { kdDebug( 14010 ) << k_funcinfo << " changing KABC" << endl; KABCPersistence::self()->write( parent ); } return success; }
void GraphicsZone::updatePos(int spot) { int player = info()->player(spot); int width = items[spot]->pixmap().width(); int height = items[spot]->pixmap().height(); if (player == myself()) { if (!info()->multiples()) { items[spot]->setPos(50 - width/2, 146 - height); } else { items[spot]->setPos(info()->slotNum(spot)*60, 146-height); } } else { if (!info()->multiples()) { items[spot]->setPos(184 - width/2, 96 - height); } else { int base = 257-80-(info()->numberOfSlots()/2 - 1)*60; items[spot]->setPos(base + info()->slotNum(spot)*60, 96-height); } } }
void GraphicsZone::updatePos(int spot) { int player = info()->player(spot); int width = items[spot]->pixmap().width(); int height = items[spot]->pixmap().height(); if (player == myself()) { if (!info()->multiples()) { items[spot]->setPos(75 - width/2, 182 - height); } else { items[spot]->setPos(info()->slotNum(spot)*75, 182-height); } } else { if (!info()->multiples()) { items[spot]->setPos(235 - width/2, 115 - height); } else { //Triples has really erratic placing at some points still in 6G. int base = 321-90-(info()->numberOfSlots()/2 - 1)*60; items[spot]->setPos(base + info()->slotNum(spot)*60, 120-height); } } }
void RegularBattleScene::setupGui() { int nslots = data()->numberOfSlots(); gui.nick.resize(nslots); gui.level.resize(nslots); gui.gender.resize(nslots); gui.bars.resize(nslots); gui.status.resize(nslots); QVBoxLayout *l= new QVBoxLayout(this); l->setMargin(0); /* As anyway the GraphicsZone is a fixed size, it's useless to resize that part, might as well let the chat be resized */ l->setSizeConstraint(QLayout::SetFixedSize); QHBoxLayout *firstLine = new QHBoxLayout(); l->addLayout(firstLine); QHBoxLayout *midzone = new QHBoxLayout(); l->addLayout(midzone); QHBoxLayout *lastLine = new QHBoxLayout(); l->addLayout(lastLine); QVBoxLayout *teamAndName[2]; for (int i = 0; i < 2; i++) { teamAndName[i] = new QVBoxLayout(); teamAndName[i]->addLayout(createTeamLayout(gui.pokeballs[i])); teamAndName[i]->addWidget(gui.trainers[i] = new QLabel(data()->name(i)),0, Qt::AlignRight); gui.trainers[i]->setObjectName("TrainerNick"); } firstLine->addWidget(gui.fullBars[opponent()] = createFullBarLayout(nslots, opponent())); firstLine->addLayout(teamAndName[opponent()]); gui.zone = new GraphicsZone(data(), gui.theme); /* Make the code below more generic? */ QVBoxLayout *midme = new QVBoxLayout(); midzone->addLayout(midme); midme->addStretch(100); gui.timers[myself()] = new QProgressBar(); gui.timers[myself()]->setObjectName("TimeOut"); //for style sheets gui.timers[myself()]->setRange(0,300); QLabel *mybox = new QLabel(); mybox->setObjectName("MyTrainerBox"); mybox->setFixedSize(82,82); mybox->setPixmap(gui.theme->trainerSprite(data()->avatar(myself()))); midme->addWidget(gui.timers[myself()]); midme->addWidget(mybox); midzone->addWidget(gui.zone); QVBoxLayout *midopp = new QVBoxLayout(); midzone->addLayout(midopp); midopp->addStretch(100); gui.timers[opponent()] = new QProgressBar(); gui.timers[opponent()]->setObjectName("TimeOut"); //for style sheets gui.timers[opponent()]->setRange(0,300); QLabel *oppbox = new QLabel(); oppbox->setPixmap(gui.theme->trainerSprite(data()->avatar(opponent()))); oppbox->setObjectName("OppTrainerBox"); oppbox->setFixedSize(82,82); midopp->addWidget(oppbox); midopp->addWidget(gui.timers[opponent()]); lastLine->addLayout(teamAndName[myself()]); lastLine->addWidget(gui.fullBars[myself()] = createFullBarLayout(nslots, myself())); QTimer *t = new QTimer (this); t->start(200); connect(t, SIGNAL(timeout()), SLOT(updateTimers())); }