Item_spawn_data::ItemList Single_item_creator::create(int birthday, RecursionList &rec) const
{
    ItemList result;
    int cnt = 1;
    if (modifier.get() != NULL) {
        cnt = (modifier->count.first == modifier->count.second) ? modifier->count.first : rng(
                  modifier->count.first, modifier->count.second);
    }
    for( ; cnt > 0; cnt--) {
        if (type == S_ITEM) {
            result.push_back(create_single(birthday, rec));
        } else {
            if (std::find(rec.begin(), rec.end(), id) != rec.end()) {
                debugmsg("recursion in item spawn list %s", id.c_str());
                return result;
            }
            rec.push_back(id);
            Item_spawn_data *isd = item_controller->get_group(id);
            if (isd == NULL) {
                debugmsg("unknown item spawn list %s", id.c_str());
                return result;
            }
            ItemList tmplist = isd->create(birthday, rec);
            if (modifier.get() != NULL) {
                for(ItemList::iterator a = tmplist.begin(); a != tmplist.end(); ++a) {
                    modifier->modify(*a);
                }
            }
            result.insert(result.end(), tmplist.begin(), tmplist.end());
        }
    }
    return result;
}
Item_spawn_data::ItemList Item_group::create( const time_point &birthday, RecursionList &rec ) const
{
    ItemList result;
    if( type == G_COLLECTION ) {
        for( const auto &elem : items ) {
            if( rng( 0, 99 ) >= ( elem )->probability ) {
                continue;
            }
            ItemList tmp = ( elem )->create( birthday, rec );
            result.insert( result.end(), tmp.begin(), tmp.end() );
        }
    } else if( type == G_DISTRIBUTION ) {
        int p = rng( 0, sum_prob - 1 );
        for( const auto &elem : items ) {
            p -= ( elem )->probability;
            if( p >= 0 ) {
                continue;
            }
            ItemList tmp = ( elem )->create( birthday, rec );
            result.insert( result.end(), tmp.begin(), tmp.end() );
            break;
        }
    }

    return result;
}
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
    ItemList result;
    if (type == G_COLLECTION) {
        for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) {
            if(rng(0, 99) >= (*a)->probability) {
                continue;
            }
            ItemList tmp = (*a)->create(birthday, rec);
            result.insert(result.end(), tmp.begin(), tmp.end());
        }
    } else if (type == G_DISTRIBUTION) {
        int p = rng(0, sum_prob - 1);
        for(prop_list::const_iterator a = items.begin(); a != items.end(); ++a) {
            p -= (*a)->probability;
            if (p >= 0) {
                continue;
            }
            ItemList tmp = (*a)->create(birthday, rec);
            result.insert(result.end(), tmp.begin(), tmp.end());
            break;
        }
    }
    if (with_ammo && !result.empty()) {
        it_gun *maybe_gun = dynamic_cast<it_gun *>(result.front().type);
        if (maybe_gun != NULL) {
            item ammo(default_ammo(maybe_gun->ammo), birthday);
            // TODO: change the spawn lists to contain proper references to containers
            ammo = ammo.in_its_container();
            result.push_back(ammo);
        }
    }
    return result;
}
Exemple #4
0
bool House::transferToDepot()
{
	if(!townId)
		return false;

	Player* player = NULL;
	if(owner)
	{
		uint32_t tmp = owner;
		if(isGuild() && !IOGuild::getInstance()->swapGuildIdToOwner(tmp))
			tmp = 0;

		if(tmp)
			player = g_game.getPlayerByGuidEx(tmp);
	}

	Item* item = NULL;
	Container* tmpContainer = NULL;

	ItemList moveList;
	for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it)
	{
		for(uint32_t i = 0; i < (*it)->getThingCount(); ++i)
		{
			if(!(item = (*it)->__getThing(i)->getItem()))
				continue;

			if(item->isPickupable())
				moveList.push_back(item);
			else if((tmpContainer = item->getContainer()))
			{
				for(ItemList::const_iterator it = tmpContainer->getItems(); it != tmpContainer->getEnd(); ++it)
					moveList.push_back(*it);
			}
		}
	}

	if(player)
	{
		Depot* depot = player->getDepot(townId, true);
		for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it)
			g_game.internalMoveItem(NULL, (*it)->getParent(), depot, INDEX_WHEREEVER, (*it), (*it)->getItemCount(), NULL, FLAG_NOLIMIT);

		if(player->isVirtual())
		{
			IOLoginData::getInstance()->savePlayer(player);
			delete player;
		}
	}
	else
	{
		for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it)
			g_game.internalRemoveItem(NULL, (*it), (*it)->getItemCount(), false, FLAG_NOLIMIT);
	}

	return true;
}
ItemList<BodyItem>::iterator findItemOfName(ItemList<BodyItem>& items, const std::string& name)
{
    for(ItemList<BodyItem>::iterator p = items.begin(); p != items.end(); ++p){
        if((*p)->name() == name){
            return p;
        }
    }
    return items.end();
}
Exemple #6
0
bool House::transferToDepot()
{
	if(!townId)
		return false;

	Player* player = NULL;
	if(owner)
	{
		uint32_t tmp = owner;
		if(isGuild() && !IOGuild::getInstance()->swapGuildIdToOwner(tmp))
			tmp = 0;

		if(tmp)
			player = g_game.getPlayerByGuidEx(tmp);
	}

	Container* tmpContainer = NULL;
	TileItemVector* items = NULL;

	ItemList moveList;
	for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it)
	{
		if(!(items = (*it)->getItemList()))
			continue;

		for(ItemVector::iterator iit = items->begin(); iit != items->end(); ++iit)
		{
			if((*iit)->isPickupable())
				moveList.push_back(*iit);
			else if((tmpContainer = (*iit)->getContainer()))
			{
				for(ItemList::const_iterator cit = tmpContainer->getItems(); cit != tmpContainer->getEnd(); ++cit)
					moveList.push_back(*cit);
			}
		}
	}

	if(player)
	{
		for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it)
			g_game.internalMoveItem(NULL, (*it)->getParent(), player->getInbox(), INDEX_WHEREEVER, (*it), (*it)->getItemCount(), NULL, FLAG_NOLIMIT);

		if(player->isVirtual())
		{
			IOLoginData::getInstance()->savePlayer(player);
			delete player;
		}
	}
	else
	{
		for(ItemList::iterator it = moveList.begin(); it != moveList.end(); ++it)
			g_game.internalRemoveItem(NULL, (*it), (*it)->getItemCount(), false, FLAG_NOLIMIT);
	}

	return true;
}
Exemple #7
0
// LinkItems - This function is the main entry point into linking. It takes a
// list of LinkItem which indicates the order the files should be linked and
// how each file should be treated (plain file or with library search). The
// function only links bitcode and produces a result list of items that are
// native objects. 
bool
Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) {
  // Clear the NativeItems just in case
  NativeItems.clear();

  // For each linkage item ...
  for (ItemList::const_iterator I = Items.begin(), E = Items.end();
       I != E; ++I) {
    if (I->second) {
      // Link in the library suggested.
      bool is_native = false;
      if (LinkInLibrary(I->first, is_native))
        return true;
      if (is_native)
        NativeItems.push_back(*I);
    } else {
      // Link in the file suggested
      bool is_native = false;
      if (LinkInFile(sys::Path(I->first), is_native))
        return true;
      if (is_native)
        NativeItems.push_back(*I);
    }
  }

  return false;
}
Exemple #8
0
  /**
   * Find an existing item by its FLARM id.  This is a simple linear
   * search that doesn't scale well with a large list.
   */
  gcc_pure
  ItemList::iterator FindItem(FlarmId id) {
    assert(id.IsDefined());

    return std::find_if(items.begin(), items.end(),
                        [id](const Item &item) { return item.id == id; });
  }
Exemple #9
0
bool MonsterType::createChildLoot(Container* parent, const LootBlock& lootBlock)
{
	LootItems::const_iterator it = lootBlock.childLoot.begin();
	if(it == lootBlock.childLoot.end())
		return true;

	ItemList items;
	for(; it != lootBlock.childLoot.end() && !parent->full(); ++it)
	{
		items = createLoot(*it);
		if(items.empty())
			continue;

		for(ItemList::iterator iit = items.begin(); iit != items.end(); ++iit)
		{
			Item* tmpItem = *iit;
			if(Container* container = tmpItem->getContainer())
			{
				if(createChildLoot(container, *it))
					parent->__internalAddThing(tmpItem);
				else
					delete container;
			}
			else
				parent->__internalAddThing(tmpItem);
		}
	}

	return !parent->empty();
}
void DesktopSortingStrategy::sortItems(ItemList &items)
{
    GroupManager *gm = qobject_cast<GroupManager *>(parent());
    qStableSort(items.begin(), items.end(), (gm && gm->separateLaunchers()) ?
                DesktopSortingStrategy::lessThanSeperateLaunchers :
                DesktopSortingStrategy::lessThan);
}
Exemple #11
0
bool House::transferToDepot(Player* player)
{
	if (townid == 0 || houseOwner == 0) {
		return false;
	}

	ItemList moveItemList;
	for (HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it) {
		if (const TileItemVector* items = (*it)->getItemList()) {
			for (ItemVector::const_iterator iit = items->begin(), iend = items->end(); iit != iend; ++iit) {
				Item* item = *iit;
				if (item->isPickupable()) {
					moveItemList.push_back(item);
				} else {
					Container* container = item->getContainer();
					if (container) {
						for (ItemDeque::const_iterator cit = container->getItems(); cit != container->getEnd(); ++cit) {
							moveItemList.push_back(*cit);
						}
					}
				}
			}
		}
	}

	for (ItemList::iterator it = moveItemList.begin(); it != moveItemList.end(); ++it) {
		Item* item = *it;
		g_game.internalMoveItem(item->getParent(), player->getInbox(), INDEX_WHEREEVER,
		                        item, item->getItemCount(), NULL, FLAG_NOLIMIT);
	}

	return true;
}
Exemple #12
0
  /**
   * Add a new item to the list, unless the given FLARM id already
   * exists.
   */
  Item &AddItem(FlarmId id) {
    auto existing = FindItem(id);
    if (existing != items.end())
      return *existing;

    items.emplace_back(id);
    return items.back();
  }
Exemple #13
0
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
    ItemList result;
    if (type == G_COLLECTION) {
        for( const auto &elem : items ) {
            if( rng( 0, 99 ) >= ( elem )->probability ) {
                continue;
            }
            ItemList tmp = ( elem )->create( birthday, rec );
            result.insert(result.end(), tmp.begin(), tmp.end());
        }
    } else if (type == G_DISTRIBUTION) {
        int p = rng(0, sum_prob - 1);
        for( const auto &elem : items ) {
            p -= ( elem )->probability;
            if (p >= 0) {
                continue;
            }
            ItemList tmp = ( elem )->create( birthday, rec );
            result.insert(result.end(), tmp.begin(), tmp.end());
            break;
        }
    }

    for( auto& e : result ) {
        bool spawn_ammo = rng( 0, 99 ) < with_ammo;
        bool spawn_mags = rng( 0, 99 ) < with_magazine || spawn_ammo;

        if( spawn_mags && !e.magazine_integral() && !e.magazine_current() ) {
            e.contents.emplace_back( e.magazine_default(), e.bday );
        }
        if( spawn_ammo && e.ammo_capacity() > 0 && e.ammo_remaining() == 0 ) {
            itype_id ammo = default_ammo( e.ammo_type() );
            if( e.magazine_current() ) {
                e.magazine_current()->contents.emplace_back( ammo, e.bday, e.ammo_capacity() );
            } else {
                e.set_curammo( ammo );
                e.charges = e.ammo_capacity();
            }
        }
    }

    return result;
}
Item_spawn_data::ItemList Single_item_creator::create( const time_point &birthday,
        RecursionList &rec ) const
{
    ItemList result;
    int cnt = 1;
    if( modifier ) {
        auto modifier_count = modifier->count;
        cnt = ( modifier_count.first == modifier_count.second ) ? modifier_count.first : rng(
                  modifier_count.first, modifier_count.second );
    }
    for( ; cnt > 0; cnt-- ) {
        if( type == S_ITEM ) {
            const auto itm = create_single( birthday, rec );
            if( !itm.is_null() ) {
                result.push_back( itm );
            }
        } else {
            if( std::find( rec.begin(), rec.end(), id ) != rec.end() ) {
                debugmsg( "recursion in item spawn list %s", id.c_str() );
                return result;
            }
            rec.push_back( id );
            Item_spawn_data *isd = item_controller->get_group( id );
            if( isd == nullptr ) {
                debugmsg( "unknown item spawn list %s", id.c_str() );
                return result;
            }
            ItemList tmplist = isd->create( birthday, rec );
            rec.erase( rec.end() - 1 );
            if( modifier ) {
                for( auto &elem : tmplist ) {
                    modifier->modify( elem );
                }
            }
            result.insert( result.end(), tmplist.begin(), tmplist.end() );
        }
    }
    return result;
}
	// Berechnungsmethoden
	void Inventory::calculateWeight(ItemList items)
	{
		ItemList::iterator it = items.begin();

		Ogre::Real totalWeight = 0.0;

		while (it != items.end())
		{
			totalWeight += (*it)->getMass();

			it++;
		}
		mCurrentWeight = totalWeight;
	}
Exemple #16
0
Item_spawn_data::ItemList Item_group::create(int birthday, RecursionList &rec) const
{
    ItemList result;
    if (type == G_COLLECTION) {
        for( const auto &elem : items ) {
            if( rng( 0, 99 ) >= ( elem )->probability ) {
                continue;
            }
            ItemList tmp = ( elem )->create( birthday, rec );
            result.insert(result.end(), tmp.begin(), tmp.end());
        }
    } else if (type == G_DISTRIBUTION) {
        int p = rng(0, sum_prob - 1);
        for( const auto &elem : items ) {
            p -= ( elem )->probability;
            if (p >= 0) {
                continue;
            }
            ItemList tmp = ( elem )->create( birthday, rec );
            result.insert(result.end(), tmp.begin(), tmp.end());
            break;
        }
    }
    if (with_ammo && !result.empty()) {
        const auto t = result.front().type;
        if( t->gun ) {
            const std::string ammoid = default_ammo( t->gun->ammo );
            if ( !ammoid.empty() ) {
                item ammo( ammoid, birthday );
                // TODO: change the spawn lists to contain proper references to containers
                ammo = ammo.in_its_container();
                result.push_back( ammo );
            }
        }
    }
    return result;
}
Exemple #17
0
void MonsterType::dropLoot(Container* corpse)
{
	ItemList items;
	for(LootItems::const_iterator it = lootItems.begin(); it != lootItems.end() && !corpse->full(); ++it)
	{
		items = createLoot(*it);
		if(items.empty())
			continue;

		for(ItemList::iterator iit = items.begin(); iit != items.end(); ++iit)
		{
			Item* tmpItem = *iit;
			if(Container* container = tmpItem->getContainer())
			{
				if(createChildLoot(container, *it))
					corpse->__internalAddThing(tmpItem);
				else
					delete container;
			}
			else
				corpse->__internalAddThing(tmpItem);
		}
	}

	corpse->__startDecaying();
	uint32_t ownerId = corpse->getCorpseOwner();
	if(!ownerId)
		return;

	Player* owner = g_game.getPlayerByGuid(ownerId);
	if(!owner)
		return;

	LootMessage_t message = lootMessage;
	if(message == LOOTMSG_IGNORE)
		message = (LootMessage_t)g_config.getNumber(ConfigManager::LOOT_MESSAGE);

	if(message < LOOTMSG_PLAYER)
		return;

	std::stringstream ss;
	ss << "Loot of " << nameDescription << ": " << corpse->getContentDescription() << ".";
	if(owner->getParty() && message > LOOTMSG_PLAYER)
		owner->getParty()->broadcastMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
	else if(message == LOOTMSG_PLAYER || message == LOOTMSG_BOTH)
		owner->sendTextMessage((MessageClasses)g_config.getNumber(ConfigManager::LOOT_MESSAGE_TYPE), ss.str());
}
Exemple #18
0
void	CampRegion::despawnCamp()
{
	mDestroyed	= true;
	mActive		= false;

	PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(mOwnerId));

	if(owner)
		owner->setHasCamp(false);

	//we need to destroy our camp!!
	Camp* camp = dynamic_cast<Camp*>(gWorldManager->getObjectById(mCampId));
	ItemList* iL = camp->getItemList();

	ItemList::iterator iLiT = iL->begin();
	while(iLiT != iL->end())
	{
		TangibleObject* tangible = (*iLiT);
		gMessageLib->sendDestroyObject_InRangeofObject(tangible);
		gWorldManager->destroyObject(tangible);
		iLiT++;
	}

	gMessageLib->sendDestroyObject_InRangeofObject(camp);
	gWorldManager->destroyObject(camp);

	gWorldManager->addRemoveRegion(this);

	//now grant xp
	applyXp();
	if(mXp)
	{
		if(mXp > mXpMax)
			mXp = mXpMax;

		PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(mOwnerId));
		if(player)
			gSkillManager->addExperience(XpType_camp,mXp,player);
		//still get db side in
	}

	
}
Exemple #19
0
// LinkItems - This function is the main entry point into linking. It takes a
// list of LinkItem which indicates the order the files should be linked and
// how each file should be treated (plain file or with library search). The
// function only links bitcode and produces a result list of items that are
// native objects. 
bool
Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) {
  // Clear the NativeItems just in case
  NativeItems.clear();

  // For each linkage item ...
  for (ItemList::const_iterator I = Items.begin(), E = Items.end();
       I != E; ++I) {
    if (I->second) {
      // Link in the library suggested.
      bool is_native = false;
      if (LinkInLibrary(I->first, is_native))
        return true;
      if (is_native)
        NativeItems.push_back(*I);
    } else {
      // Link in the file suggested
      bool is_native = false;
      if (LinkInFile(sys::Path(I->first), is_native))
        return true;
      if (is_native)
        NativeItems.push_back(*I);
    }
  }

  // At this point we have processed all the link items provided to us. Since
  // we have an aggregated module at this point, the dependent libraries in
  // that module should also be aggregated with duplicates eliminated. This is
  // now the time to process the dependent libraries to resolve any remaining
  // symbols.
  bool is_native;
  for (Module::lib_iterator I = Composite->lib_begin(),
         E = Composite->lib_end(); I != E; ++I) {
    if(LinkInLibrary(*I, is_native))
      return true;
    if (is_native)
      NativeItems.push_back(std::make_pair(*I, true));
  }

  return false;
}
Exemple #20
0
bool QueueEditor::InternEditList(DownloadQueue* pDownloadQueue, IDList* pIDList, bool bSmartOrder, EEditAction eAction, int iOffset, const char* szText)
{
	if (eAction == eaGroupMoveOffset)
	{
		AlignAffectedGroups(pDownloadQueue, pIDList, bSmartOrder, iOffset);
	}

	ItemList cItemList;
	PrepareList(pDownloadQueue, &cItemList, pIDList, bSmartOrder, eAction, iOffset);

	if (eAction == eaFilePauseAllPars || eAction == eaFilePauseExtraPars)
	{
		PauseParsInGroups(&cItemList, eAction == eaFilePauseExtraPars);
	}
	else if (eAction == eaGroupMerge)
	{
		MergeGroups(pDownloadQueue, &cItemList);
	}
	else if (eAction == eaFileReorder)
	{
		ReorderFiles(pDownloadQueue, &cItemList);
	}
	else
	{
		for (ItemList::iterator it = cItemList.begin(); it != cItemList.end(); it++)
		{
			EditItem* pItem = *it;
			switch (eAction)
			{
				case eaFilePause:
					PauseUnpauseEntry(pItem->m_pFileInfo, true);
					break;

				case eaFileResume:
					PauseUnpauseEntry(pItem->m_pFileInfo, false);
					break;

				case eaFileMoveOffset:
				case eaFileMoveTop:
				case eaFileMoveBottom:
					MoveEntry(pDownloadQueue, pItem->m_pFileInfo, pItem->m_iOffset);
					break;

				case eaFileDelete:
					DeleteEntry(pItem->m_pFileInfo);
					break;

				case eaFileSetPriority:
					SetPriorityEntry(pItem->m_pFileInfo, szText);
					break;

				case eaGroupSetCategory:
					SetNZBCategory(pItem->m_pFileInfo->GetNZBInfo(), szText);
					break;

				case eaGroupSetName:
					SetNZBName(pItem->m_pFileInfo->GetNZBInfo(), szText);
					break;

				case eaGroupSetParameter:
					SetNZBParameter(pItem->m_pFileInfo->GetNZBInfo(), szText);
					break;

				case eaGroupPause:
				case eaGroupResume:
				case eaGroupDelete:
				case eaGroupMoveTop:
				case eaGroupMoveBottom:
				case eaGroupMoveOffset:
				case eaGroupPauseAllPars:
				case eaGroupPauseExtraPars:
				case eaGroupSetPriority:
					EditGroup(pDownloadQueue, pItem->m_pFileInfo, eAction, iOffset, szText);
					break;

				case eaFilePauseAllPars:
				case eaFilePauseExtraPars:
				case eaGroupMerge:
				case eaFileReorder:
					// remove compiler warning "enumeration not handled in switch"
					break;
			}
			delete pItem;
		}
	}

	return cItemList.size() > 0;
}
Exemple #21
0
void InventoryView::Update() {
	Clear();
	for(int y = 0; y < 24; y++) {
		SetCharAt(49, y, '|', WHITE);
	}
	string toDraw = "Equipped Items";
	int wd2 = toDraw.length() / 2;
	SetStringAt(25 - wd2, 1, toDraw, WHITE);

	toDraw = "Inventory";
	wd2 = toDraw.length() / 2;
	SetStringAt(65 - wd2, 1, toDraw, WHITE);

	toDraw = "(Arrows navigate, Enter selects, 'd' discards, Esc exits. List scrolls)";
	wd2 = toDraw.length() / 2;
	SetStringAt(40 - wd2, 23, toDraw, WHITE);

	toDraw = DataManager::Instance()->GetStatusString();
	DataManager::Instance()->ClearStatusString();
	if(toDraw != "()") {
		wd2 = toDraw.length() / 2;
		SetStringAt(1, 22, toDraw, YELLOW_BOLD);
	}

	toDraw = "Head: ";
	SetStringAt(10, 6, toDraw, WHITE);
	toDraw = "Body: ";
	SetStringAt(10, 8, toDraw, WHITE);
	toDraw = "Legs: ";
	SetStringAt(10, 10, toDraw, WHITE);
	toDraw = "Weapon: ";
	SetStringAt(8, 12, toDraw, WHITE);
	toDraw = "Implant: ";
	SetStringAt(7, 14, toDraw, WHITE);

	// Show inventory items
	Player* p = DataManager::Instance()->GetPlayer();
	Inventory inv = p->GetInventory();
	if(inv.NumItems() == 0) {
		int attr = WHITE;
		if(m_inInventoryArea) {
			attr = YELLOW_BOLD;
		}
		toDraw = "<empty>";
		SetStringAt(51, 3, toDraw, attr);
	}
	else {
		ItemList items = inv.GetItems();
		int counter = m_scrollY;
		stringstream s;
		for(ItemList::iterator i = items.begin(); i != items.end(); i++) {
			if(counter < m_scrollY) {
				continue;
			}
			if(counter >= m_scrollY + 19) {
				break;
			}
			int attr = WHITE;
			if(m_inInventoryArea && counter == m_selectIdx) {
				attr = YELLOW_BOLD;
			}
			Item* toShow = *i;
			s.str("");
			s << (counter + 1) << ". " << toShow->GetDisplayName();
			if(toShow->CanStack()) {
				s << " (" << toShow->GetStackSize() << ")";
			}
			toDraw = s.str();
			if(toDraw.length() > 28) {
				toDraw.erase(28);
			}
			SetStringAt(51, 3 + counter - m_scrollY, toDraw, attr);
			counter++;
		}
	}

	// Show the equipped items
	DrawPaperDollItem(p->GetHeadItem(), 6, 0);
	DrawPaperDollItem(p->GetBodyItem(), 8, 1);
	DrawPaperDollItem(p->GetLegsItem(), 10, 2);
	DrawPaperDollItem(p->GetWeaponItem(), 12, 3);
	DrawPaperDollItem(p->GetImplantItem(), 14, 4);

	//stringstream s;
	//s << "scrolly: " << m_scrollY << " selectidx: " << m_selectIdx;
	//toDraw = s.str();
	//SetStringAt(1, 22, toDraw, WHITE);
}
Exemple #22
0
void QueueEditor::AlignAffectedGroups(DownloadQueue* pDownloadQueue, IDList* pIDList, bool bSmartOrder, int iOffset)
{
	// Build list of all groups; List contains first file of each group
	FileList cGroupList;
	BuildGroupList(pDownloadQueue, &cGroupList);

	// Find affected groups. It includes groups being moved and groups directly
	// above or under of these groups (those order is also changed)
	FileList cAffectedGroupList;
	cAffectedGroupList.clear();
	ItemList cItemList;
	PrepareList(pDownloadQueue, &cItemList, pIDList, bSmartOrder, eaFileMoveOffset, iOffset);
	for (ItemList::iterator it = cItemList.begin(); it != cItemList.end(); it++)
	{
		EditItem* pItem = *it;
		unsigned int iNum = 0;
		for (FileList::iterator it = cGroupList.begin(); it != cGroupList.end(); it++, iNum++)
		{
			FileInfo* pFileInfo = *it;
			if (pItem->m_pFileInfo->GetNZBInfo() == pFileInfo->GetNZBInfo())
			{
				if (!ItemExists(&cAffectedGroupList, pFileInfo))
				{
					cAffectedGroupList.push_back(pFileInfo);
				}
				if (iOffset < 0)
				{
					for (int i = iNum - 1; i >= -iOffset-1; i--)
					{
						if (!ItemExists(&cAffectedGroupList, cGroupList[i]))
						{
							cAffectedGroupList.push_back(cGroupList[i]);
						}
					}
				}
				if (iOffset > 0)
				{
					for (unsigned int i = iNum + 1; i <= cGroupList.size() - iOffset; i++)
					{
						if (!ItemExists(&cAffectedGroupList, cGroupList[i]))
						{
							cAffectedGroupList.push_back(cGroupList[i]);
						}
					}

					if (iNum + 1 < cGroupList.size())
					{
						cAffectedGroupList.push_back(cGroupList[iNum + 1]);
					}
				}
				break;
			}
		}
		delete pItem;
	}
	cGroupList.clear();

	// Aligning groups
	for (FileList::iterator it = cAffectedGroupList.begin(); it != cAffectedGroupList.end(); it++)
	{
		FileInfo* pFileInfo = *it;
		AlignGroup(pDownloadQueue, pFileInfo->GetNZBInfo());
	}
}