コード例 #1
0
ファイル: qtodo_list.cpp プロジェクト: tobimensch/qtodo
QTodoItem* QTodoListIterator::item()
{
	if(isItem())
		return (dynamic_cast<QTodoItem*>(current()));
	else
		return 0;
}
コード例 #2
0
bool cUObject::onCollide( cUObject* Obstacle )
{
	// If we got ANY events process them in order
	for( UI08 i = 0; i < scriptChain.size(); i++ )
	{
		// Items cannot collide with items
		if( !isChar() ) // Item, so obstacle has to be character
			scriptChain[ i ]->onCollideItem( (P_CHAR)Obstacle, (P_ITEM)this );
		else
			if( Obstacle->isItem() )
				if( scriptChain[ i ]->onCollideItem( (P_CHAR)this, (P_ITEM)Obstacle ) )
					return true;

			else // Character, Character
				if( scriptChain[ i ]->onCollideChar( (P_CHAR)this, (P_CHAR)Obstacle ) )
					return true;
	}

	// Try to process the hooks then
	QValueVector< WPDefaultScript* > hooks;
	QValueVector< WPDefaultScript* >::const_iterator it;

	hooks = ScriptManager->getGlobalHooks( OBJECT_OBJECT, EVENT_COLLIDE );
	for( it = hooks.begin(); it != hooks.end(); ++it )
	{
		// Items cannot collide with items
		if( !isChar() ) // Item, so obstacle has to be character
			(*it)->onCollideItem( (P_CHAR)Obstacle, (P_ITEM)this );
		else
		{
			if( Obstacle->isItem() )
				(*it)->onCollideItem( (P_CHAR)this, (P_ITEM)Obstacle );
			else
				(*it)->onCollideChar( (P_CHAR)this, (P_CHAR)Obstacle );
		}
	}

	if( isChar() )
	{
		hooks = ScriptManager->getGlobalHooks( OBJECT_CHAR, EVENT_COLLIDE );
		for( it = hooks.begin(); it != hooks.end(); ++it )
		{
			if( Obstacle->isItem() )
				(*it)->onCollideItem( (P_CHAR)this, (P_ITEM)Obstacle );
			else
				(*it)->onCollideChar( (P_CHAR)this, (P_CHAR)Obstacle );
		}
	}
	
	if( isItem() )
	{
		hooks = ScriptManager->getGlobalHooks( OBJECT_ITEM, EVENT_COLLIDE );
		for( it = hooks.begin(); it != hooks.end(); ++it )
			(*it)->onCollideItem( (P_CHAR)Obstacle, (P_ITEM)this );
	}

	return false;
}
コード例 #3
0
void GameShell::loadMap()
{
    SDL_Rect srctile, destile;
    std::ifstream mapfile("map.txt");
    int nr, id = 1;
    mapfile >> layerNumber;
    std::vector<Tile*> layer;

    for(unsigned int i = 0; i < layerNumber; i++)
    {
        destile.x = -TILE_WIDTH;
        destile.y = 0;
        layer.clear();
        for(int j = 0; j < MAXTILES; j++)
        {
            mapfile >> nr;
            if(nr == 1)
            {
                int posx = j % (SCREEN_WIDTH / TILE_WIDTH);
                int posy = j / (SCREEN_WIDTH / TILE_WIDTH);
                exit.x = posx * TILE_WIDTH;
                exit.y = posy * TILE_HEIGHT;
                std::cout<<"XEXIT = " <<exit.x <<" "<<"YEXIT = " << exit.y<<"\n";
            }

            srctile = bkgtiles[nr];
            destile.x += TILE_WIDTH;

            Tile* tile = new Tile(destile.x, destile.y);
            tile->id = id++;
            tile->type = nr;

            if(nr == TRANSPARENCY)
            {
                tile->setTransparency(true);
            }

            if(isItem(nr) == true)
            {
                tile->setItem(true);
            }

            layer.push_back(tile);

            SDL_BlitSurface(tileset, &srctile, screen, &destile);
            if(destile.x >= SCREEN_WIDTH - TILE_WIDTH)
            {
                destile.y += TILE_WIDTH;
                destile.x = -TILE_WIDTH;
            }
        }
        tiles.push_back(layer);
    }
    mapfile.close();
    SDL_UpdateWindowSurface(window);
}
コード例 #4
0
ファイル: josm_presets.cpp プロジェクト: AMDmi3/osm2go
/**
 * @brief check if the currently active object uses this preset and the preset is interactive
 */
bool presets_item_t::matches(const osm_t::TagMap &tags, bool interactive) const
{
  bool is_interactive = false;
  bool hasPositive = false;
  used_preset_functor fc(tags, is_interactive, hasPositive);
  if(isItem()) {
    const std::vector<presets_element_t *> &widgets = static_cast<const presets_item *>(this)->widgets;
    if(std::find_if(widgets.begin(), widgets.end(), fc) != widgets.end())
      return false;
  }

  return hasPositive && (is_interactive || !interactive);
}
コード例 #5
0
bool cUObject::onUse( cUObject *Target )
{
	// If we got ANY events process them in order
	for( UI08 i = 0; i < scriptChain.size(); i++ )
	{
		// If we're the Character pass us as the second param
		// if not as the first
		bool Handeled = false;

		if( !this->isChar() )
			Handeled = scriptChain[ i ]->onUse( (P_PLAYER)Target, (P_ITEM)this );
		else
			Handeled = scriptChain[ i ]->onUse( (P_PLAYER)this, (P_ITEM)Target );

		if( Handeled )
			return true;
	}

	// Try to process the hooks then
	QValueVector< WPDefaultScript* > hooks;
	QValueVector< WPDefaultScript* >::const_iterator it;

	hooks = ScriptManager->getGlobalHooks( OBJECT_OBJECT, EVENT_USE );
	for( it = hooks.begin(); it != hooks.end(); ++it )
	{
		if( !this->isChar() )
			(*it)->onUse( (P_PLAYER)Target, (P_ITEM)this );
		else
			(*it)->onUse( (P_PLAYER)this, (P_ITEM)Target );
	}

	if( isChar() )
	{
		hooks = ScriptManager->getGlobalHooks( OBJECT_CHAR, EVENT_USE );
		for( it = hooks.begin(); it != hooks.end(); ++it )
				(*it)->onUse( (P_PLAYER)this, (P_ITEM)Target );
	}
	
	if( isItem() )
	{
		hooks = ScriptManager->getGlobalHooks( OBJECT_ITEM, EVENT_USE );
		for( it = hooks.begin(); it != hooks.end(); ++it )
			(*it)->onUse( (P_PLAYER)Target, (P_ITEM)this );
	}

	return false;
}
コード例 #6
0
QVariant QPartitionValueModel::data(const QModelIndex &index, int role) const
{
    QLocale locale; // Constructs a default QLocale
    if(index.column()<2)
        return QPartitionModel::data(index, role);
    if (!index.isValid() || isItem(index) || val == NULL)
            return QVariant();
    switch(role) {
        case Qt::DisplayRole:
            if(val[index.internalId()]>=0)
//                return locale.toString(val[index.internalId()], 'e', 2);
                return val[index.internalId()];
            else
                return DBL_MAX;
        case Qt::TextAlignmentRole:
            return Qt::AlignRight + Qt::AlignVCenter;
    }
    return QVariant();
}
コード例 #7
0
bool cUObject::onCreate( const QString &definition )
{
	// If we got ANY events process them in order
	for( UI08 i = 0; i < scriptChain.size(); i++ )
	{
		// If we're the Character pass us as the second param
		// if not as the first
		bool Handeled = false;

		Handeled = scriptChain[ i ]->onCreate( this, definition );

		if( Handeled )
			return true;
	}

	// Try to process the hooks then
	QValueVector< WPDefaultScript* > hooks;
	QValueVector< WPDefaultScript* >::const_iterator it;

	hooks = ScriptManager->getGlobalHooks( OBJECT_OBJECT, EVENT_CREATE );
	for( it = hooks.begin(); it != hooks.end(); ++it )
		(*it)->onCreate( this, definition );

	if( isChar() )
	{
		hooks = ScriptManager->getGlobalHooks( OBJECT_CHAR, EVENT_CREATE );
		for( it = hooks.begin(); it != hooks.end(); ++it )
			(*it)->onCreate( this, definition );
	}
	
	if( isItem() )
	{
		hooks = ScriptManager->getGlobalHooks( OBJECT_ITEM, EVENT_CREATE );
		for( it = hooks.begin(); it != hooks.end(); ++it )
			(*it)->onCreate( this, definition );
	}

	return false;
}