void TeamHolder::load() { QSettings s; m_teams.clear(); if (!s.contains("Teams/Locations")) { addTeam(); setCurrent(0); } else { QStringList l = s.value("Teams/Locations").toStringList(); for (int i = 0; i < l.length(); i++) { addTeam(); team(i).loadFromFile(l[i]); } if (count() == 0) { addTeam(); setCurrent(0); } else { if (currentTeam() >= count()) { setCurrent(count()-1); } } } if (!team().path().isEmpty()) { s.setValue("Teams/Folder", team().folder()); } profile().loadFromFile(s.value("Profile/Current").toString()); }
void TrainerMenu::updateTeam() { ui->pokemonButtons->setTeam(team().team()); ui->teamName->setText(team().team().name()); ui->teamTier->setText(team().team().defaultTier()); updateButtonName(); }
void Player::changeTier(const QString &newtier) { if (tier() == newtier) return; if (battling()) { sendMessage(tr("You can't change tiers while battling.")); return; } if (!TierMachine::obj()->exists(newtier)) { sendMessage(tr("The tier %1 doesn't exist!").arg(newtier)); return; } if (!TierMachine::obj()->isValid(team(), newtier)) { Tier *tier = &TierMachine::obj()->tier(newtier); if (!tier->allowGen(team().gen)) { sendMessage(tr("The generation of your team is invalid for that tier.")); return; } QList<int> indexList; for(int i = 0; i < 6; i++) { if (tier->isBanned(team().poke(i))) { indexList.append(i); } } if (indexList.size() > 0) { foreach(int i, indexList) { sendMessage(tr("The Pokemon '%1' is banned on tier '%2' for the following reasons: %3").arg(PokemonInfo::Name(team().poke(i).num()), newtier, tier->bannedReason(team().poke(i)))); }
void Robotcl::drawRobot(QPainter *painter) { painter->save(); painter->translate(px,py); QPen pen; QBrush brush; if(team() == Blue) { if(Field::SelectedRobotID == ID) pen.setColor(Qt::white); else pen.setColor(Qt::blue); brush = QBrush(QColor("blue")); } else if(team()==Yellow) { if(Field::SelectedRobotID == ID) pen.setColor(Qt::white); else pen.setColor(Qt::yellow); brush = QBrush(QColor("Yellow")); } QPainterPath robotPath; robotPath.moveTo(-diagonal/2.0,-diagonal/2.0); robotPath.arcMoveTo(-diagonal/2.0,-diagonal/2.0,diagonal,diagonal,0); robotPath.arcTo(-diagonal/2.0,-diagonal/2.0,diagonal,diagonal,0,290.0); pen.setWidth(10); painter->setPen(pen); qreal rotateAngle = 35.0; painter->rotate(orientation()-rotateAngle); painter->fillPath(robotPath,brush); painter->rotate(-(orientation()-rotateAngle)); QRectF rect; pen.setWidth(20); if(Field::SelectedRobotID == ID) pen.setColor(Qt::white); else pen.setColor(Qt::black); painter->setPen(pen); painter->setBrush(Qt::NoBrush); painter->setFont(QFont("Tahoma",100)); rect = painter->boundingRect(rect,QString::number(ID)); painter->scale(1,-1); painter->drawText(0,0 ,rect.width() ,rect.height() ,0 ,QString::number(ID)); painter->restore(); }
void TrainerMenu::setColor() { if (team().color().isValid()) { ui->colorButton->setStyleSheet(QString("background: %1; color: white;").arg(team().color().name())); } else { ui->colorButton->setStyleSheet(""); } }
void TrainerMenu::on_addTeam_clicked() { if (team().count() >= 6) { return; } team().addTeam(); updateTeamButtons(); }
void TrainerMenu::on_profileList_currentIndexChanged(int) { if (ui->profileList->currentText() == team().name()) { return; } QSettings s; QString path = s.value("Profile/Path").toString() + "/" + QUrl::toPercentEncoding(ui->profileList->currentText()) + ".xml"; s.setValue("Profile/Current", path); team().profile().loadFromFile(path); updateData(); }
void TrainerMenu::on_colorButton_clicked() { QColor c = QColorDialog::getColor(team().color()); if (c.isValid() && (c.lightness() > 140 || c.green() > 180)) { return; } team().color() = c; setColor(); }
void TrainerMenu::changeCurrentTeam(int t) { if (t == team().currentTeam()) { return; } teamButtons[t]->setChecked(true); team().setCurrent(t); updateTeam(); emit teamChanged(); }
void TeamHolder::addTeam() { m_teams.push_back(Team()); if (currentTeam() < count() - 1 && !team(currentTeam()).folder().isEmpty()) { m_teams.back().setFolder(team(currentTeam()).folder()); } else { QSettings s; m_teams.back().setFolder(s.value("Teams/Folder").toString()); } }
void TrainerMenu::loadProfileList() { QSettings s; ui->profileList->blockSignals(true); ui->profileList->addItems(team().profile().getProfileList(s.value("Profile/Path").toString())); ui->profileList->blockSignals(false); for (int i = 0; i < ui->profileList->count(); i++) { if (ui->profileList->itemText(i) == team().profile().name()) { ui->profileList->setCurrentIndex(i); return; } } }
// gets the blu and red team entities and puts them in the pointers passed in void GetTeamEnts( CSizzPluginContext *context, CBaseEntity **ppBluTeam, CBaseEntity **ppRedTeam ) { if (context && ppBluTeam && ppRedTeam) { *ppBluTeam = NULL; *ppRedTeam = NULL; edict_t *pTeamEdict = context->GetEntityByClassName("CTFTeam", context->GetMaxClients()); while (pTeamEdict && (!(*ppBluTeam) || !(*ppRedTeam))) { CBaseEntity *pTeam = SCHelpers::EdictToBaseEntity(pTeamEdict); if (pTeam) { CTFTeamWrapper team(pTeam); unsigned int team_num = team.GetTeamID(); if (team_num == 2) { *ppRedTeam = pTeam; } else if (team_num == 3) { *ppBluTeam = pTeam; } } int ent_index = SCHelpers::EntIndexFromEdict(pTeamEdict); pTeamEdict = context->GetEntityByClassName("CTFTeam", ent_index+1); } } }
void TBBWork() { if( AvailWork>=0 ) { int k = --AvailWork; if( k==-1 ) { TBB_RunTime.server->adjust_job_count_estimate(-(TBB_MaxThread-1)); ++CompletionCount; } else if( k>=0 ) { for( int k=0; k<4; ++k ) { OMP_Team team( *OMP_RunTime.server ); int n = OMP_RunTime.server->try_increase_load( OMP_ParallelRegionSize-1, /*strict=*/false ); team.barrier = 0; ::rml::job* array[OMP_ParallelRegionSize-1]; if( n>0) OMP_RunTime.server->get_threads( n, &team, array ); // Master does work inside parallel region too. OMPWork(); // Master waits for workers to finish if( n>0 ) while( team.barrier!=unsigned(n) ) { __TBB_Yield(); } } ++CompletionCount; } } }
void TeamMenu::tabIconChanged() { int slot = sender()->property("slot").toInt(); ui->pokemonTabs->setTabIcon(slot, PokemonInfo::Icon(team().team().poke(slot).num())); emit teamChanged(); }
static int32_t pretend_team(team_id teamid) { sptr<BProcess> team(new BProcess(teamid)); SLooper::InitMain(team); SLooper::SetContextObject(team->AsBinder(), B_DEFAULT_CONTEXT); SLooper::SetContextObject(team->AsBinder(), B_SYSTEM_CONTEXT); SLooper::Loop(); return 0; }
void TeamMenu::createIndexIfNeeded(int index) { if (index < 6) { if (!ui->pokemons.contains(index)) { ui->stack->addWidget(ui->pokemons[index]= new PokeEdit(this, &team().team().poke(index), ui->pokemonModel, ui->itemsModel, ui->natureModel)); ui->pokemons[index]->setProperty("slot", index); connect(ui->pokemons[index], SIGNAL(numChanged()), SLOT(tabIconChanged())); connect(ui->pokemons[index], SIGNAL(nameChanged()), SIGNAL(teamChanged())); connect(ui->pokemons[index], SIGNAL(itemChanged()), SIGNAL(teamChanged())); } } else if (index == 6) { if (!ui->boxes) { ui->stack->addWidget(ui->boxes = new PokeBoxes(this, &team())); connect(ui->boxes, SIGNAL(teamChanged()), SLOT(updatePokemons())); connect(ui->boxes, SIGNAL(teamChanged()), SIGNAL(teamChanged())); } } }
void TrainerMenu::on_removeTeam_clicked() { team().removeTeam(); updateTeamButtons(); updateTeam(); emit teamChanged(); }
void TrainerMenu::on_deleteProfile_clicked() { if(ui->profileList->currentText().isNull()) { QMessageBox::warning(0, tr("Deleting a Profile"), tr("There's no selected profile to delete.")); return; } QSettings s; QString path = s.value("Profile/Path").toString() + "/" + QUrl::toPercentEncoding(ui->profileList->currentText()) + ".xml"; ui->profileList->removeItem(ui->profileList->currentIndex()); team().profile().deleteProfile(path); }
void TrainerMenu::on_colorButton_clicked() { QColor c = QColorDialog::getColor(team().color()); if (c.green() + c.red() + c.blue() == 0) { c.setBlue(1); } if (!c.isValid()) return; int luma = (c.green()*3 + c.blue() +c.red()*2)/6; if ((luma > 140 && c.lightness() > 140) || c.green() > 200) { // So they can click cancel without their colour disappearing! QMessageBox::information(NULL, tr("Invalid Color"), tr("Your color must have less than 200 parts green, brightness less than 140, and lightness less than 140.\n\nYour selected color currently has %1 parts green, a brightness of %2, and a lightness of %3.").arg(c.green()).arg(luma).arg(c.lightness())); return; } team().color() = c; setColor(); }
void TeamHolder::save() { QSettings s; QStringList locations; for (int i = 0; i < count(); i++) { if (team(i).name().isEmpty()) { QMessageBox::warning(NULL, QObject::tr("Impossible to save team"), QObject::tr("The team number %1 could not be saved as it was given no name!").arg(i+1)); } else { team(i).saveToFile(team(i).path()); locations.push_back(team(i).path()); } } s.setValue("Teams/Locations", locations); QString path = s.value("Profile/Path").toString() + "/" + QUrl::toPercentEncoding(name()) + ".xml"; profile().saveToFile(path); }
int main() { for( int music, grp; scanf( "%d %d", &music, &grp ) == 2; ) { std::priority_queue<team> proc; for( int i = 0, n; i < grp; ++i, --music ) { scanf( "%d", &n ); proc.push( team( n ) ); } while( music-- ) { team t = proc.top(); proc.pop(); proc.push( team( t.people, t.have + 1 ) ); } printf( "%d\n", proc.top().ratio() ); } }
void TrainerMenu::on_infos_textChanged() { ui->infoLength->setText(tr("%1/500").arg(ui->infos->toPlainText().length())); if (ui->infos->toPlainText().length() > 500) { QString newinfo = ui->infos->toPlainText(); newinfo.chop(ui->infos->toPlainText().length() - 500); ui->infos->setPlainText(newinfo); ui->infos->moveCursor(QTextCursor::End,QTextCursor::MoveAnchor); ui->infoLength->setText(tr("%1/500 (Limit Reached)").arg(ui->infos->toPlainText().length())); } team().info().info = ui->infos->toPlainText(); }
void TrainerTeam::toXml(QDomDocument &document) const { QDomElement Team = document.createElement("Team"); Team.setAttribute("gen", team().gen()); Team.setAttribute("defaultTier", defaultTier()); Team.setAttribute("version", 1); document.appendChild(Team); QDomElement trainer = document.createElement("Trainer"); Team.appendChild(trainer); QDomText trainerName = document.createTextNode(trainerNick()); trainer.appendChild(trainerName); trainer.setAttribute("winMsg",trainerWin()); trainer.setAttribute("loseMsg",trainerLose()); trainer.setAttribute("infoMsg",trainerInfo()); trainer.setAttribute("avatar", avatar()); for(int i = 0; i < 6; i++) { QDomElement pokemon = document.createElement("Pokemon"); Team.appendChild(team().poke(i).toXml(pokemon)); } }
void TrainerMenu::on_teamFolderButton_clicked() { QSettings s; QString folder = QFileDialog::getExistingDirectory(NULL, tr("Folder in which to save the team"), team().team().folder().isEmpty() ? s.value("Teams/Folder").toString() : team().team().folder()); if (folder.length() > 0) { team().team().setFolder(folder); QSettings s; s.setValue("Teams/Folder", folder); } }
w8 g1_human_class::determine_cursor(g1_object_class * object_mouse_is_on) { if (object_mouse_is_on) { if (object_mouse_is_on->player_num==team()&& object_mouse_is_on->get_flag(g1_object_class::SELECTABLE)) { return G1_SELECT_CURSOR; } if (selected_object.valid()&&object_mouse_is_on->id==g1_get_object_type(takeover_pad.get())) { return G1_TAKEOVER_CURSOR; } if (g1_path_object_class::cast(object_mouse_is_on)) { return G1_TAKEOVER_CURSOR; } if (selected_object.valid()&&selected_object->player_num==team() && (selected_object->can_attack(object_mouse_is_on)|| single_sel_id(selected_object.get())==g1_get_object_type(supergun.get()))) { return G1_TARGET_CURSOR; } return G1_DEFAULT_CURSOR; //nothing selected that can shoot } if (selected_object.valid()&&selected_object->player_num==team()) { if (selected_object->id==g1_get_object_type(supergun.get())) { return G1_TARGET_CURSOR; } return G1_MOVE_CURSOR; } return G1_DEFAULT_CURSOR; }
void TrainerMenu::updateData() { ui->name->setText(team().name()); setColor(); ui->infos->setPlainText(team().info().info); ui->winningMessage->setText(team().info().winning); ui->losingMessage->setText(team().info().losing); ui->tieMessage->setText(team().info().tie); ui->avatarNumber->setValue(team().info().avatar); setAvatarPixmap(); }
void TeamMenu::switchToTab(int index) { if (ui->pokemonTabs->currentIndex() != index) { /* The signal/slot connection will call us again, thus we return */ ui->pokemonTabs->setCurrentIndex(index); return; } if (!ui->pokemons.contains(index)) { ui->stack->addWidget(ui->pokemons[index]= new PokeEdit(this, &team().team().poke(index), ui->pokemonModel, ui->itemsModel, ui->natureModel)); ui->pokemons[index]->setProperty("slot", index); connect(ui->pokemons[index], SIGNAL(switchToTrainer()), SIGNAL(switchToTrainer())); connect(ui->pokemons[index], SIGNAL(numChanged()), SLOT(tabIconChanged())); connect(ui->pokemons[index], SIGNAL(nameChanged()), SIGNAL(teamChanged())); connect(ui->pokemons[index], SIGNAL(itemChanged()), SIGNAL(teamChanged())); } ui->stack->setCurrentWidget(ui->pokemons[index]); }
void TrainerMenu::updateTeamButtons() { for (int i = 0; i < team().count(); i++) { teamButtons[i]->setVisible(true); teamButtons[i]->setText(team().team(i).name().isEmpty() ? tr("Untitled", "Team name") : team().team(i).name()); } for (int i = team().count(); i < 6; i++) { teamButtons[i]->setVisible(false); } teamButtons[team().currentTeam()]->setChecked(true); ui->removeTeam->setDisabled(team().count() <= 1); ui->addTeam->setDisabled(team().count() >= 6); }
void TrainerMenu::on_saveProfile_clicked() { QSettings s; QString path; if(ui->name->text().isEmpty()) { QMessageBox::warning(0, tr("Saving a Profile"), tr("You don't have any nickname for the profile.")); return; } if(ui->profileList->findText(ui->name->text()) == -1) { path = s.value("Profile/Path").toString() + "/" + QUrl::toPercentEncoding(ui->name->text()) + ".xml"; } else { path = s.value("Profile/Path").toString() + "/" + QUrl::toPercentEncoding(ui->profileList->currentText()) + ".xml"; } if(team().profile().saveToFile(path)) { // We need to re-do the check again since if name contains illegal char, why we would want to add it // before checking if it was successfully saved. if(ui->profileList->findText(ui->name->text()) == -1) { ui->profileList->addItem(ui->name->text()); ui->profileList->setCurrentIndex(ui->profileList->findText(ui->name->text())); } s.setValue("Profile/Current", path); } }
//! (koshi) don't delete commented things please, they might be need in the future and i'm lazy void IBattle::GetBattleFromScript( bool loadmapmod ) { BattleOptions opts; std::stringstream ss (GetScript()); LSL::TDF::PDataList script( LSL::TDF::ParseTDF(ss) ); LSL::TDF::PDataList replayNode ( script->Find("GAME") ); if ( replayNode.ok() ) { std::string modname = replayNode->GetString("GameType"); std::string modhash = replayNode->GetString("ModHash"); if ( !modhash.empty() ) modhash = STD_STRING(MakeHashUnsigned(TowxString(modhash))); SetHostMod( modname, modhash ); //don't have the maphash, what to do? //ui download function works with mapname if hash is empty, so works for now std::string mapname = replayNode->GetString("MapName"); std::string maphash = replayNode->GetString("MapHash"); if ( !maphash.empty() ) maphash = STD_STRING(MakeHashUnsigned(TowxString(maphash))); SetHostMap( mapname, maphash ); // opts.ip = replayNode->GetString( _T("HostIP") ); // opts.port = replayNode->GetInt ( _T("HostPort"), DEFAULT_EXTERNAL_UDP_SOURCE_PORT ); opts.spectators = 0; int playernum = replayNode->GetInt("NumPlayers", 0); int usersnum = replayNode->GetInt("NumUsers", 0); if ( usersnum > 0 ) playernum = usersnum; // int allynum = replayNode->GetInt ( _T("NumAllyTeams"), 1); // int teamnum = replayNode->GetInt ( _T("NumTeams"), 1); LSL::StringVector sides; if ( loadmapmod ) { sides = LSL::usync().GetSides(modname); } IBattle::TeamVec parsed_teams = GetParsedTeamsVec(); IBattle::AllyVec parsed_allies = GetParsedAlliesVec(); //[PLAYERX] sections for ( int i = 0; i < playernum ; ++i ) { LSL::TDF::PDataList player ( replayNode->Find(stdprintf("PLAYER%d", i))); LSL::TDF::PDataList bot ( replayNode->Find(stdprintf("AI%d", i ))); if ( player.ok() || bot.ok() ) { if ( bot.ok() ) player = bot; User user(player->GetString("Name"), boost::to_upper_copy(player->GetString("CountryCode")), 0); UserBattleStatus& status = user.BattleStatus(); status.isfromdemo = true; status.spectator = player->GetInt("Spectator", 0 ); opts.spectators += user.BattleStatus().spectator; status.team = player->GetInt("Team"); if ( !status.spectator ) { PlayerJoinedTeam( status.team ); } status.sync = true; status.ready = true; if ( status.spectator ) m_opts.spectators++; else { if ( !bot.ok() ) { if ( status.ready) m_players_ready++; if ( status.sync ) m_players_sync++; if ( status.sync && status.ready ) m_players_ok++; } } //! (koshi) changed this from ServerRankContainer to RankContainer user.Status().rank = (UserStatus::RankContainer)player->GetInt("Rank", -1 ); if ( bot.ok() ) { status.aishortname = bot->GetString("ShortName"); status.aiversion = bot->GetString("Version"); int ownerindex = bot->GetInt("Host"); LSL::TDF::PDataList aiowner (replayNode->Find(stdprintf("PLAYER%d", ownerindex))); if ( aiowner.ok() ) { status.owner = aiowner->GetString("Name"); } } IBattle::TeamInfoContainer teaminfos = parsed_teams[user.BattleStatus().team]; if ( !teaminfos.exist ) { LSL::TDF::PDataList team( replayNode->Find( stdprintf("TEAM%d", user.BattleStatus().team) )); if ( team.ok() ) { teaminfos.exist = true; teaminfos.TeamLeader = team->GetInt("TeamLeader", 0 ); teaminfos.StartPosX = team->GetInt("StartPosX", -1 ); teaminfos.StartPosY = team->GetInt("StartPosY", -1 ); teaminfos.AllyTeam = team->GetInt("AllyTeam", 0 ); teaminfos.RGBColor = GetColorFromFloatStrng(TowxString(team->GetString("RGBColor"))); teaminfos.SideName = team->GetString("Side", ""); teaminfos.Handicap = team->GetInt("Handicap", 0 ); const int sidepos = LSL::Util::IndexInSequence(sides, teaminfos.SideName); teaminfos.SideNum = sidepos; parsed_teams[ user.BattleStatus().team ] = teaminfos; } } if ( teaminfos.exist ) { status.ally = teaminfos.AllyTeam; status.pos.x = teaminfos.StartPosX; status.pos.y = teaminfos.StartPosY; status.colour = teaminfos.RGBColor; status.handicap = teaminfos.Handicap; if ( !status.spectator ) { PlayerJoinedAlly( status.ally ); } if ( teaminfos.SideNum >= 0 ) status.side = teaminfos.SideNum; IBattle::AllyInfoContainer allyinfos = parsed_allies[user.BattleStatus().ally]; if ( !allyinfos.exist ) { LSL::TDF::PDataList ally( replayNode->Find(stdprintf("ALLYTEAM%d", user.BattleStatus().ally) ) ); if ( ally.ok() ) { allyinfos.exist = true; allyinfos.NumAllies = ally->GetInt("NumAllies", 0 ); allyinfos.StartRectLeft = ally->GetInt("StartRectLeft", 0 ); allyinfos.StartRectTop = ally->GetInt("StartRectTop", 0 ); allyinfos.StartRectRight = ally->GetInt("StartRectRight", 0 ); allyinfos.StartRectBottom = ally->GetInt("StartRectBottom", 0 ); parsed_allies[ user.BattleStatus().ally ] = allyinfos; AddStartRect( user.BattleStatus().ally, allyinfos.StartRectTop, allyinfos.StartRectTop, allyinfos.StartRectRight, allyinfos.StartRectBottom ); } } } AddUserFromDemo( user ); } } SetParsedTeamsVec( parsed_teams ); SetParsedAlliesVec( parsed_allies ); //MMoptions, this'll fail unless loading map/mod into wrapper first if ( loadmapmod ) { LoadScriptMMOpts("mapoptions", replayNode ); LoadScriptMMOpts("modoptions", replayNode ); } opts.maxplayers = playernum ; } SetBattleOptions( opts ); }