Example #1
0
/// returns true if command is processed
bool CRRecentBooksMenu::onCommand( int command, int params )
{
    if ( command==MCMD_SCROLL_FORWARD ) {
        setCurPage( getCurPage()+1 );
        return true;
    }
    if ( command==MCMD_SCROLL_BACK ) {
        setCurPage( getCurPage()-1 );
        return true;
    }
    if ( command>=MCMD_SELECT_1 && command<=MCMD_SELECT_9 ) {
        int index = command - MCMD_SELECT_1 + getTopItem();
        if ( index < 0 || index >= getItems().length() ) {
            closeMenu( 0 );
            return true;
        }
        CRMenuItem * item = getItems()[index];
        int n = item->getId();
        highlightCommandItem( n );
        closeMenu( MCMD_OPEN_RECENT_BOOK, n );
        return true;
    } else if ( command>=MCMD_SELECT_1_LONG && command<=MCMD_SELECT_9_LONG ) {
        int index = command - MCMD_SELECT_1_LONG + getTopItem();
        if ( index >=0 && index < _pageItems ) {
            //TODO: allow removing book from history
            //closeMenu( MCMD_REMOVE_RECENT_BOOK, index );
            removeItem( index );
            setDirty();
            return true;
        }
    }
    closeMenu( 0 );
    return true;
}
void StackLayout::processLine(uint8_t *pixelData, int dataOffset)
{
	if (itemNr < 0)
		return;
	if (itemScanLine >= getItemHeight(itemNr)) {
		itemScanLine = 0;
		if (--itemNr < 0)
			return;
		currentNumberWidth = getNumberWidth(itemNr + firstLevelVisible);
	}
	DisplayItem *item = NULL;
	if (itemNr < getItems().getLength())
		item = getItems().getAt(itemNr);
	if (itemScanLine == 0 && item) {
		if (drawOffsetX <= item->getX())
			item->initLineScanning(0, 0, drawWidth - item->getX());
		else
			item->initLineScanning(0, drawOffsetX - item->getX(), drawWidth);
	}

	if (itemNr > 0)
		drawNumber(pixelData, dataOffset, itemNr + firstLevelVisible);
	if (item != NULL && isItemVisible(item)) {
		if (itemScanLine < item->getHeight()) {
			if (drawOffsetX <= item->getX())
				item->processLine(pixelData, dataOffset + item->getX() - drawOffsetX);
			else
				item->processLine(pixelData, dataOffset);
		}
	}

	itemScanLine++;
}
Example #3
0
Location::~Location()
{
  // Remove all references from buffers to this location
  for (auto buf = Buffer::begin(); buf != Buffer::end(); ++buf)
    if (buf->getLocation() == this)
      buf->setLocation(nullptr);

  // Remove all references from resources to this location
  for (auto res = Resource::begin(); res != Resource::end(); ++res)
    if (res->getLocation() == this)
      res->setLocation(nullptr);

  // Remove all references from operations to this location
  for (auto oper = Operation::begin(); oper != Operation::end(); ++oper)
    if (oper->getLocation() == this)
      oper->setLocation(nullptr);

  // Remove all references from demands to this location
  for (auto dmd = Demand::begin(); dmd != Demand::end(); ++dmd)
    if (dmd->getLocation() == this)
      dmd->setLocation(nullptr);

  // Remove all item suppliers referencing this location
  for (auto sup = Supplier::begin(); sup != Supplier::end(); ++sup)
  {
    for (auto it = sup->getItems().begin(); it != sup->getItems().end(); )
    {
      if (it->getLocation() == this)
      {
        const ItemSupplier *itemsup = &*it;
        ++it;   // Advance iterator before the delete
        delete itemsup;
      }
      else
        ++it;
    }
  }

  // Remove all item distributions referencing this location
  for (auto it = Item::begin(); it != Item::end(); ++it)
  {
    for (auto dist = it->getDistributions().begin(); dist != it->getDistributions().end(); )
    {
      if (dist->getOrigin() == this)
      {
        const ItemDistribution *itemdist = &*dist;
        ++dist;   // Advance iterator before the delete
        delete itemdist;
      }
      else
        ++dist;
    }
  }

}
int StackLayout::getItemHeight(int i)
{
	if (i >= getItems().getLength())
		return font->getLineHeight();
	int h = 0;
	DisplayItem *item = getItems().getAt(i);
	if (item)
		h = item->getHeight();
	if (h < font->getLineHeight())
		h = font->getLineHeight();
	return h;
}
Example #5
0
File: Room.cpp Project: xantoz/spel
std::string Room::getDescription() const
{
    std::string desc = GameObject::getDescription();

    std::vector<Actor*> actors_minus_player;
    // won't have any troubles even if player is NULL since it's not being dereffed
    std::remove_copy(getActors().begin(), getActors().end(),
                     std::back_inserter(actors_minus_player), player);
    
    if(getItems().size() > 0 || actors_minus_player.size() > 0)
    {
        desc += "\nYou see: ";
    }
    
    if (getItems().size() > 0)
    {
        auto it = getItems().begin();
        desc += (*it)->getName();
        ++it;
        for (; it != getItems().end(); ++it)
            desc += ", " + (*it)->getName();
        desc += " on the floor.";
    }
    

    if(actors_minus_player.size() > 0)
    {
        if(getItems().size() > 0)
            desc += " and ";
        auto it = actors_minus_player.begin();
        desc += (*it)->getName();
        ++it;
        for (; it != actors_minus_player.end(); ++it)
            desc += ", " + (*it)->getName();
    }

    if (exits.size() > 0)
    {
        desc += "\n\nObvious Exits are: ";
        auto it = exits.begin();
        desc += it->first;
        ++it;
        for (; it != exits.end(); ++it)
            desc += ", " + it->first;
    }
    else
    {
        desc += "\n\nYou see no immediate exits. You're trapped!";
    }
    

    return desc;
}
Example #6
0
void LLWearableItemsList::updateChangedItems(const LLInventoryModel::changed_items_t& changed_items_uuids)
{
    // nothing to update
    if (changed_items_uuids.empty()) return;

    typedef std::vector<LLPanel*> item_panel_list_t;

    item_panel_list_t items;
    getItems(items);

    for (item_panel_list_t::iterator items_iter = items.begin();
            items_iter != items.end();
            ++items_iter)
    {
        LLPanelInventoryListItemBase* item = dynamic_cast<LLPanelInventoryListItemBase*>(*items_iter);
        if (!item) continue;

        LLViewerInventoryItem* inv_item = item->getItem();
        if (!inv_item) continue;

        LLUUID linked_uuid = inv_item->getLinkedUUID();

        for (LLInventoryModel::changed_items_t::const_iterator iter = changed_items_uuids.begin();
                iter != changed_items_uuids.end();
                ++iter)
        {
            if (linked_uuid == *iter)
            {
                item->setNeedsRefresh(true);
                break;
            }
        }
    }
}
Example #7
0
int main()
{
    List list;
    double  items[] = {0.3, 9.7, 88, 7.7, 5.3, 4.2}, *listItems;
    int i;  

    list = create();
    printf("dinoume mia kenh list\n>");
    if(increaseAfter(list, 1, 0.3) != -1){
       printf("error: increaseAfter with empty list\n");
       return 0;
    }
    
    for(i = 0; i < 6; i++){
         if(add(&list, i+1, items[i]) == -1){
             printf("error: list add\n");
             destroy(&list);
             return 0;
         }
    }

    printf("dinoume atopo position\n>");
    if(increaseAfter(list, -1, 0.3) != -1){
       printf("error: increaseAfter with wrong position\n");
       destroy(&list);
       return 0;
    }
    printf("dinoume position megalutero apo to megethos ths listas\n>");
    if(increaseAfter(list, 10, 0.3) != -1){
       printf("error: increaseAfter with wrong position\n");
       destroy(&list);
       return 0;
    }
    
    printf("elegxoume th swsth leitourgia..\n");
    if(increaseAfter(list, 3, 0.5) < 0){
         printf("error: increaseAfter  normal use\n");
         destroy(&list);
         return 0;
    }
    listItems = getItems(list);
    if(listItems == NULL){
      printf("error:  getItems normal use\n");
      destroy(&list);
      return 0;
    }
    for(i = 0; i < 6; i++){
        if((i > 3) && (items[i] + 0.5 != listItems[i])){
            printf("error:  increaseAfter wrong values\n");
            free(listItems);
            destroy(&list);
            return 0;
        } 
    }  
        
    printf("\nok!!\n");
    free(listItems);
    destroy(&list);
    return 1;
}
Example #8
0
void Square::tick(double time) {
  dirty = true;
  if (!inventory.isEmpty())
    for (Item* item : inventory.getItems()) {
      item->tick(time, level, position);
      if (item->isDiscarded())
        inventory.removeItem(item);
    }
  poisonGas.tick(level, position);
  if (creature && poisonGas.getAmount() > 0.2) {
    creature->poisonWithGas(min(1.0, poisonGas.getAmount()));
  }
  if (fire.isBurning()) {
    modViewObject().setAttribute(ViewObject::Attribute::BURNING, fire.getSize());
    Debug() << getName() << " burning " << fire.getSize();
    for (Vec2 v : position.neighbors8(true))
      if (fire.getSize() > Random.getDouble() * 40)
        level->getSquare(v)->setOnFire(fire.getSize() / 20);
    fire.tick(level, position);
    if (fire.isBurntOut()) {
      level->globalMessage(position, "The " + getName() + " burns out");
      burnOut();
      return;
    }
    if (creature)
      creature->setOnFire(fire.getSize());
    for (Item* it : getItems())
      it->setOnFire(fire.getSize(), level, position);
    for (Trigger* t : extractRefs(triggers))
      t->setOnFire(fire.getSize());
  }
  for (Trigger* t : extractRefs(triggers))
    t->tick(time);
  tickSpecial(time);
}
Example #9
0
void ForestCell::buildBatches()
{
   // Gather items for batches.
   Vector<ForestItem> items;
   getItems( &items );

   // Ask the item to batch itself.
   Vector<ForestItem>::const_iterator item = items.begin();
   bool batched = false;
   for ( ; item != items.end(); item++ )
   {
      // Loop thru the batches till someone 
      // takes this guy off our hands.
      batched = false;
      for ( S32 i=0; i < mBatches.size(); i++ )
      {
         if ( mBatches[i]->add( *item ) )
         {
            batched = true;
            break;
         }
      }

      if ( batched )
         continue;
      
      // Gotta create a new batch.
      ForestCellBatch *batch = item->getData()->allocateBatch();
      if ( batch )
      {
         batch->add( *item );
         mBatches.push_back( batch );
      }
   }
}
Example #10
0
void MapView::mouseDoubleClickEvent(QMouseEvent *event) {
  int centerblockx = floor(this->x);
  int centerblockz = floor(this->z);

  int centerx = image.width() / 2;
  int centery = image.height() / 2;

  centerx -= (this->x - centerblockx) * zoom;
  centery -= (this->z - centerblockz) * zoom;

  int mx = floor(centerblockx - (centerx - event->x()) / zoom);
  int mz = floor(centerblockz - (centery - event->y()) / zoom);

  // get the y coordinate
  int my = getY(mx, mz);

  QList<QVariant> properties;
  for (auto &item : getItems(mx, my, mz)) {
    properties.append(item->properties());
  }

  if (!properties.isEmpty()) {
    emit showProperties(properties);
  }
}
Example #11
0
//returns a single item from a list where the title starts with a specific value
Item* Model::getItem(vector<Item*>* list,Item* item)
{
    vector<Item*>* items=getItems(list,item);
    if(items->size()>0)
        return items->at(0);
    else
        return NULL;
}
Example #12
0
QJsonObject PlaylistState::toQJsonObject() const
{
    QJsonArray array;

    foreach(Multimedia *item, getItems())
    {
        array.append(item->toQJsonObject());
    }
Example #13
0
struct Player* createPlayer(char* name, int pointsToAttribut)
{
    struct Equipment* playerEquipment = Equipment_ctor(returnListElementItem(getItems(),7), returnListElementItem(getItems(),1),
                                                       returnListElementItem(getItems(),2), returnListElementItem(getItems(),3),
                                                       returnListElementItem(getItems(),4), returnListElementItem(getItems(),5));

    struct Mob* playerMob = Mob_ctor(0, name, returnListElementRace(getRaces(), 1), 100, 10, 50, 10, 10, playerEquipment);

    /*struct DlistMob* mobsList= dlistMob_new();
    dlistMob_append(mobsList, *playerMob);
    writeToFileMob(mobsList);*/

    struct Player* playerCharacter = Player_ctor(0, playerMob, 3, 500, createFirstInventory(), selectFirstPotions(), createMob(playerMob));


    return playerCharacter;

}
Download::Download(client *client, QWidget *parent) :   
    QDialog(parent),
    ui(new Ui::Download),
    m_client(client)
{
    ui->setupUi(this);  
    init_items();
    getItems();    
}
void StackLayout::doRelayout()
{
	const List<DisplayItem *> &items = getItems();
	DisplayItem *inputField = items.getAt(0);
	int bottom;
	if (isItemVisible(inputField)) {
		setItemSize(inputField, getWidth(), font->getLineHeight());
		bottom = getHeight() - inputField->getHeight();
		setItemPosition(inputField, 0, bottom);
	}
	else {
		bottom = getHeight();
	}
	int i = 0;
	upperItemNr = 0;
	while (bottom > 0 && i + firstLevelVisible < stack->getLength()) {
		upperItemNr++;
		DisplayItem *item;
		if (items.getLength() <= upperItemNr) {
			item = stack->getAt(i + firstLevelVisible)->getDisplayItem(*font);
			addItem(item);
		}
		else {
			item = items.getAt(upperItemNr);
			if (item == NULL) {
				item = stack->getAt(i + firstLevelVisible)->getDisplayItem(*font);
				setItemAt(upperItemNr, item);
			}
		}
		if (item) {
			int nw = getNumberWidth(upperItemNr + firstLevelVisible);
			setItemSize(item, getWidth() - nw, -1);
			int h = item->getHeight();
			if (h < font->getLineHeight())
				h = font->getLineHeight();
			bottom -= h;
			int w = item->getWidth();
			if (w < getWidth() - nw)
				setItemPosition(item, getWidth() - w, bottom);
			else
				setItemPosition(item, nw, bottom);
		}
		else {
			bottom -= font->getLineHeight();
		}
		i++;
	}
	while (items.getLength() > upperItemNr + 1) {
		removeItemAt(upperItemNr + 1);
	}
	while (bottom > 0) {
		upperItemNr++;
		bottom -= font->getLineHeight();
	}
	upperItemScanStart = -bottom;
}
void LLAvatarList::showAvatarAge(bool visible)
{
	mShowAge = visible;
	std::vector<LLPanel*> items;
	getItems(items);
	for(std::vector<LLPanel*>::const_iterator it = items.begin(), end_it = items.end(); it != end_it; ++it)
	{
		static_cast<LLAvatarListItem*>(*it)->showAvatarAge(visible);
	}
}
void LLAvatarList::showRange(bool visible)
{
	mShowRange = visible;
	// Enable or disable showing distance field for all detected avatars.
	std::vector<LLPanel*> items;
	getItems(items);
	for(std::vector<LLPanel*>::const_iterator it = items.begin(), end_it = items.end(); it != end_it; ++it)
	{
		static_cast<LLAvatarListItem*>(*it)->showRange(mShowRange);
	}	
}
Example #18
0
/// Erase -> Install = Upgrade
void
MergedTransactionTest::testMergeEraseInstallUpgrade()
{
    auto merged = prepareMergedTransaction(
        conn, TransactionItemAction::OBSOLETED, TransactionItemAction::INSTALL, "0.11.0", "0.12.0");

    auto items = merged->getItems();
    CPPUNIT_ASSERT_EQUAL(1, (int)items.size());
    auto item = items.at(0);
    CPPUNIT_ASSERT_EQUAL(TransactionItemAction::UPGRADE, item->getAction());
}
void LLAvatarList::showPaymentStatus(bool visible)
{
	mShowPaymentStatus = visible;
	std::vector<LLPanel*> items;
	getItems(items);
	for(std::vector<LLPanel*>::const_iterator it = items.begin(), end_it = items.end(); it != end_it; ++it)
	{
		static_cast<LLAvatarListItem*>(*it)->showPaymentStatus(visible);
	}
	mNeedUpdateNames = true;
}
void LLAvatarList::showStatusFlags(bool visible)
{
	mShowStatusFlags = visible;
	// Enable or disable showing movement flags for all detected avatars.
	std::vector<LLPanel*> items;
	getItems(items);
	for(std::vector<LLPanel*>::const_iterator it = items.begin(), end_it = items.end(); it != end_it; ++it)
	{
		static_cast<LLAvatarListItem*>(*it)->showStatusFlags(visible);
	}	
}
// [Ansariel: Colorful radar]
void LLAvatarList::setUseRangeColors(bool UseRangeColors)
{
	mUseRangeColors = UseRangeColors;

	std::vector<LLPanel*> items;
	getItems(items);
	for( std::vector<LLPanel*>::const_iterator it = items.begin(); it != items.end(); it++)
	{
		static_cast<LLAvatarListItem*>(*it)->setUseRangeColors(mUseRangeColors);
	}
}
Example #22
0
void NetFEM_elems::localCopy(void) {
  //  CkPrintf("localCopy: nodesPer=%d, items=%d, bytesPer=%d\n",nodesPer,getItems(),bytesPer);
	if (isHeapAllocated) return;
	const int *src=conn;
	//Make a canonical heap copy of this data
	allocate();
	for (int i=0;i<getItems();i++)
		for (int j=0;j<nodesPer;j++)
			conn[i*nodesPer+j]=CkShiftPointer(src,i*bytesPer)[j]-idxBase;
	idxBase=0; //Array is now zero-based
}
Example #23
0
File: Label.cpp Project: scrpi/zasm
/*	Destructor for Labels[]
	nach der sdas-Anweisung .globl werden derart markierte globale Label
	auch in die lokale Labellisten gelegt. Sie stehen also in mehreren Listen,
	dürfen aber natürlich nicht mehrfach deleted werden.
	Deshalb werden in nicht-globalen Labels[] alle globalen Labels genullt.
	*NOTE* Die globalen Labels[] dürfen erst nach allen lokalen Labels[] gelöscht werden!
*/
Labels::~Labels()
{
	if(!is_global)
	{
		Array<Label*>& labels = getItems();
		for(uint i=0;i<labels.count();i++)
		{
			if(labels[i]->is_global) labels[i] = NULL;
		}
	}
}
Example #24
0
boost::any StringListModel::getElementAt(UInt32 index) const
{
    //Check for valid indexing
    if(index >= getMFItems()->size())
    {
        SWARNING << "Cannot get value of from index " << index << ", because the Items fields has size " << getMFItems()->size() << std::endl;
        return boost::any();
    }

    return boost::any(getItems(index));
}
Example #25
0
/// Erase -> Install = Reinstall
void
MergedTransactionTest::testMergeEraseInstallReinstall()
{
    auto merged = prepareMergedTransaction(
        conn, TransactionItemAction::REMOVE, TransactionItemAction::INSTALL, "1.0.0", "1.0.0");

    auto items = merged->getItems();
    CPPUNIT_ASSERT_EQUAL(1, (int)items.size());
    auto item = items.at(0);
    CPPUNIT_ASSERT_EQUAL(TransactionItemAction::REINSTALL, item->getAction());
}
Example #26
0
QList<QTreeWidgetItem*> GTTreeWidget::getItems(QTreeWidgetItem* root) {

    QList<QTreeWidgetItem*> treeItems;

    for (int i=0; i<root->childCount(); i++) {
        treeItems.append(root->child(i));
        treeItems.append(getItems(root->child(i)));
    }

    return treeItems;
}
Example #27
0
/*################################################################*/
int main()
{
	item itemArray[3];
	int num_item = 3; /* Number of item. */
	
	getItems(itemArray,num_item);
	printItems(itemArray,num_item);
	
	
	return 0;
}
Example #28
0
/// Install -> Erase = (nothing)
void
MergedTransactionTest::testMergeInstallErase()
{
    auto merged = prepareMergedTransaction(
        conn, TransactionItemAction::INSTALL, TransactionItemAction::REMOVE, "1.0.0", "1.0.0");

    auto items = merged->getItems();

    // nothing
    CPPUNIT_ASSERT_EQUAL(0, (int)items.size());
}
void LLAvatarList::showFirstSeen(bool visible)
{
	mShowFirstSeen = visible;
	// Enable or disable showing time since noticed, for all detected avatars.
	std::vector<LLPanel*> items;
	getItems(items);
	for(std::vector<LLPanel*>::const_iterator it = items.begin(), end_it = items.end(); it != end_it; ++it)
	{
		static_cast<LLAvatarListItem*>(*it)->showFirstSeen(visible);
	}	
}
Example #30
0
Item* Container::getItem(uint32_t index)
{
	size_t n = 0;			
	for (ItemList::const_iterator cit = getItems(); cit != getEnd(); ++cit) {
		if(n == index)
			return *cit;
		else
			++n;
	}

	return NULL;
}