void Battle::PickupArtifactsAction(HeroBase & hero1, HeroBase & hero2, bool local)
{
    BagArtifacts & bag1 = hero1.GetBagArtifacts();
    BagArtifacts & bag2 = hero2.GetBagArtifacts();

    for(u8 ii = 0; ii < bag2.size(); ++ii)
    {
	Artifact & art = bag2[ii];

	if(art.isUltimate())
	{
	    art = Artifact::UNKNOWN;
	}
	else
	if(art() != Artifact::UNKNOWN && art() != Artifact::MAGIC_BOOK)
        {
            BagArtifacts::iterator it = std::find(bag1.begin(), bag1.end(), Artifact((Artifact::UNKNOWN)));
            if(bag1.end() != it)
            {
        	*it = art;
        	if(local)
		{
		    Game::PlayPickupSound();
		    Dialog::ArtifactInfo(_("You have captured an enemy artifact!"), "", art);
		}
    	    }
    	    art = Artifact::UNKNOWN;
	}
    }
}
Exemple #2
0
const char* GetPluralDescription(const Artifact & art, u32 count)
{
    switch(art())
    {
	case Artifact::ENCHANTED_HOURGLASS:
	    return ngettext("The %{name} extends the duration of all your spells by %{count} turn.",
			    "The %{name} extends the duration of all your spells by %{count} turns.", count);
	case Artifact::WIZARD_HAT:
	    return ngettext("The %{name} increases the duration of your spells by %{count} turn.",
			    "The %{name} increases the duration of your spells by %{count} turns.", count);
	case Artifact::POWER_RING:
	    return ngettext("The %{name} returns %{count} extra power point/turn to your hero.",
			    "The %{name} returns %{count} extra power points/turn to your hero.", count);
        case Artifact::ENDLESS_POUCH_SULFUR:
	    return ngettext("The %{name} provides %{count} unit of sulfur per day.",
			    "The %{name} provides %{count} units of sulfur per day.", count);
        case Artifact::ENDLESS_VIAL_MERCURY:
	    return ngettext("The %{name} provides %{count} unit of mercury per day.",
			    "The %{name} provides %{count} units of mercury per day.", count);
        case Artifact::ENDLESS_POUCH_GEMS:
	    return ngettext("The %{name} provides %{count} unit of gems per day.",
			    "The %{name} provides %{count} units of gems per day.", count);
        case Artifact::ENDLESS_CORD_WOOD:
	    return ngettext("The %{name} provides %{count} unit of wood per day.",
			    "The %{name} provides %{count} units of wood per day.", count);
        case Artifact::ENDLESS_CART_ORE:
	    return ngettext("The %{name} provides %{count} unit of ore per day.",
			    "The %{name} provides %{count} units of ore per day.", count);
        case Artifact::ENDLESS_POUCH_CRYSTAL:
	    return ngettext("The %{name} provides %{count} unit of crystal per day.",
			    "The %{name} provides %{count} units of crystal per day.", count);
	default: break;
    }
    return _(artifacts[art()].description);
}
Exemple #3
0
/*!
  @fn void MontrerPoint::modification()
  @brief Construit la fenêtre et initialise les données importantes
  @param POI PointDInteret. La fenêtre va se construire en utilisant ses attributs
  @note Nous creeons un fenetre qui va afficher les attributs du point et sa position geographique, pour se faire on initialise les champs de la fenêtre avec chaque attributs
    Pour l'affichage de l'heure nous créeons une table et nous récuperons les heures du points à l'aide d'une requete sur la base de donnée.
*/
void MontrerPoint::modification()
{
    edit_point_gui art(PointDInteretA.Getlat(),PointDInteretA.Getlon(),PointDInteretA.GetId());
    qDebug()<< "n°" << PointDInteretA.GetId();
    art.exec();

}
bool SkBicubicImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
                                          SkBitmap* result, SkIPoint* offset) {
    SkBitmap srcBM;
    if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &srcBM, offset)) {
        return false;
    }
    GrTexture* srcTexture = srcBM.getTexture();
    GrContext* context = srcTexture->getContext();

    SkRect dstRect = SkRect::MakeWH(srcBM.width() * fScale.fWidth,
                                    srcBM.height() * fScale.fHeight);

    GrTextureDesc desc;
    desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
    desc.fWidth = SkScalarCeilToInt(dstRect.width());
    desc.fHeight = SkScalarCeilToInt(dstRect.height());
    desc.fConfig = kSkia8888_GrPixelConfig;

    GrAutoScratchTexture ast(context, desc);
    SkAutoTUnref<GrTexture> dst(ast.detach());
    if (!dst) {
        return false;
    }
    GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
    GrPaint paint;
    paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->unref();
    SkRect srcRect;
    srcBM.getBounds(&srcRect);
    context->drawRectToRect(paint, dstRect, srcRect);
    return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, result);
}
Handle<BDDAlbum> BDDAlbum::recupererBDD(const int id)
{
    QString queryStr = "SELECT Album, Album_Formate, Id_Pochette, Annee, Type, Id_Artiste FROM Album WHERE Id_Album='" + QString::number(id) + "'";
    QSqlQuery query = madatabase.exec(queryStr);

    QString nom, nomFormate;
    int Annee=0;
    Handle<BDDPoch> pochette(nullptr);
    Handle<BDDArtiste> art(nullptr);
    Handle<BDDType> type(nullptr);

    if ( query.first() )
    {
        QSqlRecord rec = query.record();

        nom = rec.value("Album").toString().replace("$", "'");
        pochette = BDDPoch::recupererBDD(rec.value("Id_Pochette").toInt());
        nomFormate = rec.value("Album_Formate").toString();
        Annee = rec.value("Annee").toInt();
        type = BDDType::RecupererType(rec.value("Type").toInt());
        art = BDDArtiste::recupererBDD(rec.value("Id_artiste").toInt());

    }

    return Handle<BDDAlbum>(new BDDAlbum(id,nom,nomFormate,pochette,Annee,type,art ));
}
ActiveRelationshipTable PolicyServicesPlatformConfigurationData::getActiveRelationshipTable(void)
{
    throwIfNotWorkItemThread();

    UInt32 dataLength = 0;
    DptfMemory binaryData;
    binaryData.allocate(Constants::DefaultBufferSize, true);

    try
    {
        getEsifServices()->primitiveExecuteGet(
            esif_primitive_type::GET_ACTIVE_RELATIONSHIP_TABLE,
            ESIF_DATA_BINARY,
            binaryData,
            binaryData.getSize(),
            &dataLength);
    }
    catch (buffer_too_small e)
    {
        binaryData.deallocate();
        binaryData.allocate(e.getNeededBufferSize(), true);
        getEsifServices()->primitiveExecuteGet(
            esif_primitive_type::GET_ACTIVE_RELATIONSHIP_TABLE,
            ESIF_DATA_BINARY,
            binaryData,
            binaryData.getSize(),
            &dataLength);
    }

    ActiveRelationshipTable art(BinaryParse::activeArtObject(dataLength, binaryData));

    binaryData.deallocate();

    return art;
}
Exemple #7
0
void Artifact::UpdateStats(const std::string & spec)
{
#ifdef WITH_XML
    // parse artifacts.xml
    TiXmlDocument doc;
    const TiXmlElement* xml_artifacts = NULL;

    if(doc.LoadFile(spec.c_str()) &&
        NULL != (xml_artifacts = doc.FirstChildElement("artifacts")))
    {
	size_t index = 0;
        const TiXmlElement* xml_artifact = xml_artifacts->FirstChildElement("artifact");
        for(; xml_artifact && index < UNKNOWN; xml_artifact = xml_artifact->NextSiblingElement("artifact"), ++index)
        {
            int value;
	    artifactstats_t* ptr = &artifacts[index];

            xml_artifact->Attribute("disable", &value);
            if(value) ptr->bits |= ART_DISABLED;

            xml_artifact->Attribute("extra", &value);
	    if(value && !SkipExtra(index)) ptr->extra = value;

	    Artifact art(index);
        }
    }
    else
    VERBOSE(spec << ": " << doc.ErrorDesc());
#endif
}
Exemple #8
0
const char* Artifact::GetScenario(const Artifact & art)
{
    switch(art())
    {
	case SPELL_SCROLL: return _("You find an elaborate aontainer which housesan old vellum scroll. The runes on the container are very old, and the artistry with whitch it was put together is stunning. As you pull the scroll out, you feel imbued with magical power.");
        case ARM_MARTYR: return _("One of the less intelligent members of your party picks up an arm off of the ground. Despite its missing a body, it is still moving. Your troops find the dismembered arm repulsive, but you cannot bring yourself to drop it: it seems to hold some sort of magical power that influences your decision making.");
        case BREASTPLATE_ANDURAN: return _("You come upon a sign. It reads: \"Here lies the body of Anduran. Bow and swear fealty, and you shall be rewarded.\" You decide to do as it says. As you stand up, you feel a coldness against your skin. Looking down, you find that you are suddenly wearing a gleaming, ornate breastplate.");
        case BROACH_SHIELDING: return _("A kindly Sorceress thinks that your army's defenses could use a magical boost. She offers to enchant the Broach that you wear on your cloak, and you accept.");
        case BATTLE_GARB: return _("Out of pity for a poor peasant, you purchase a chest of old junk they are hawking for too much gold. Later, as you search through it, you find it contains the 3 pieces of the legendary battle garb of Anduran!");
	case CRYSTAL_BALL: return _("You come upon a caravan of gypsies who are feasting and fortifying their bodies with mead. They call you forward and say \"If you prove that you can dance the Rama-Buta, we will reward you.\" You don't know it, but try anyway. They laugh hysterically, but admire your bravery, giving you a Crystal Ball.");
        case HEART_FIRE: return _("You enter a recently burned glade and come upon a Fire Elemental sitting atop a rock. It looks up, its flaming face contorted in a look of severe pain. It then tosses a glowing object at you. You put up your hands to block it, but it passes right through them and sears itself into your chest.");
        case HEART_ICE: return _("Suddenly, a biting coldness engulfs your body. You seize up, falling from your horse. The pain subsides, but you still feel as if your chest is frozen.  As you pick yourself up off of the ground, you hear hearty laughter. You turn around just in time to see a Frost Giant run off into the woods and disappear.");
        case HELMET_ANDURAN: return _("You spy a gleaming object poking up out of the ground. You send a member of your party over to investigate. He comes back with a golden helmet in his hands. You realize that it must be the helmet of the legendary Anduran, the only man who was known to wear solid gold armor.");
        case HOLY_HAMMER: return _("You come upon a battle where a Paladin has been mortally wounded by a group of Zombies. He asks you to take his hammer and finish what he started.  As you pick it up, it begins to hum, and then everything becomes a blur. The Zombies lie dead, the hammer dripping with blood. You strap it to your belt.");
        case LEGENDARY_SCEPTER: return _("Upon cresting a small hill, you come upon a ridiculous looking sight. A Sprite is attempting to carry a Scepter that is almost as big as it is. Trying not to laugh, you ask, \"Need help?\" The Sprite glares at you and answers: \"You think this is funny? Fine. You can carry it. I much prefer flying anyway.\"");
        case MASTHEAD: return _("An old seaman tells you a tale of an enchanted masthead that he used in his youth to rally his crew during times of trouble. He then hands you a faded map that shows where he hid it. After much exploring, you find it stashed underneath a nearby dock.");
        case SPHERE_NEGATION: return _("You stop to help a Peasant catch a runaway mare. To show his gratitude, he hands you a tiny sphere. As soon as you grasp it, you feel the magical energy drain from your limbs...");
        case STAFF_WIZARDRY: return _("While out scaring up game, your troops find a mysterious staff levitating about three feet off of the ground. They hand it to you, and you notice an inscription. It reads: \"Brains best brawn and magic beats might. Heed my words, and you'll win every fight.\"");
        case SWORD_BREAKER: return _("A former Captain of the Guard admires your quest and gives you the enchanted Sword Breaker that he relied on during his tour of duty.");
        case SWORD_ANDURAN: return _("A Troll stops you and says: \"Pay me 5,000 gold, or the Sword of Anduran will slay you where you stand.\" You refuse. The troll grabs the sword hanging from its belt, screams in pain, and runs away. Picking up the fabled sword, you give thanks that half-witted Trolls tend to grab the wrong end of sharp objects.");
        case SPADE_NECROMANCY: return _("A dirty shovel has been thrust into a dirt mound nearby. Upon investigation, you discover it to be the enchanted shovel of the Gravediggers, long thought lost by mortals.");

	default: break;
    }

    return NULL;
}
Exemple #9
0
bool SlimServerInfo::ReadDataFile( void )
{
    DEBUGF("");
    QString dataPath = QDir::homePath()+DATAPATH;
    QDir d(dataPath);
    if(!d.exists())
        d.mkpath(dataPath);
    QDir::setCurrent(dataPath);

    QFile file;
    if( file.exists(DATAFILE) ) // there is a file, so read from it
        file.setFileName(DATAFILE);
    else {
        DEBUGF("no file to read at " << dataPath+DATAFILE);
        return false;
    }

    quint16 albumCount;

    //update the images
    file.open(QIODevice::ReadOnly);
    QDataStream in(&file);   // read the data serialized from the file

    // check version of data
    qint16 versionNo;
    in >> versionNo;
    qDebug() << versionNo << DATAVERSION;
    if(versionNo != (qint16)DATAVERSION)
        return false;


    in >> freshnessDate;
    in >> m_Artist2AlbumIds;
    in >> m_AlbumArtist2AlbumID;
    in >> albumCount;
    in >> m_albumList;
    in >> m_AlbumID2AlbumInfo;
    in >> m_artistList;

    DEBUGF("reading in info on " << albumCount << " files");

#ifdef SLIMSERVERINFO_DEBUG
    QListIterator<Artist> art(m_artistList);
    while(art.hasNext()) {
        Artist a = art.next();
        qDebug() << a.id << a.name << a.textKey;
    }

    QListIterator<Album> al(m_albumList);
    while(al.hasNext()) {
        Album a = al.next();
        qDebug() << a.albumTextKey << a.albumtitle << a.artist;
    }
#endif

    DEBUGF( "Reading file of size: " << file.size() );
    file.close();
    return true;
}
Exemple #10
0
bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
                                           const SkBitmap& src,
                                           const Context& ctx,
                                           SkBitmap* result,
                                           SkIPoint* offset) const {
    SkBitmap background = src;
    SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
    if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &background,
                                                       &backgroundOffset)) {
        return onFilterImage(proxy, src, ctx, result, offset);
    }
    GrTexture* backgroundTex = background.getTexture();
    SkBitmap foreground = src;
    SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
    if (getInput(1) && !getInput(1)->getInputResultGPU(proxy, src, ctx, &foreground,
                                                       &foregroundOffset)) {
        return onFilterImage(proxy, src, ctx, result, offset);
    }
    GrTexture* foregroundTex = foreground.getTexture();
    GrContext* context = foregroundTex->getContext();

    GrFragmentProcessor* xferProcessor = NULL;

    GrSurfaceDesc desc;
    desc.fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFlag;
    desc.fWidth = src.width();
    desc.fHeight = src.height();
    desc.fConfig = kSkia8888_GrPixelConfig;
    SkAutoTUnref<GrTexture> dst(
        context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch));
    if (!dst) {
        return false;
    }
    GrContext::AutoRenderTarget art(context, dst->asRenderTarget());

    if (!fMode || !fMode->asFragmentProcessor(&xferProcessor, backgroundTex)) {
        // canFilterImageGPU() should've taken care of this
        SkASSERT(false);
        return false;
    }

    SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foregroundTex);
    foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOffset.fX),
                                  SkIntToScalar(backgroundOffset.fY-foregroundOffset.fY));


    SkRect srcRect;
    src.getBounds(&srcRect);

    GrPaint paint;
    paint.addColorTextureProcessor(foregroundTex, foregroundMatrix);
    paint.addColorProcessor(xferProcessor)->unref();
    context->drawRect(paint, srcRect);

    offset->fX = backgroundOffset.fX;
    offset->fY = backgroundOffset.fY;
    WrapTexture(dst, src.width(), src.height(), result);
    return true;
}
    void RedrawItem(const int & index, s32 dstx, s32 dsty, bool current)
    {
      Artifact art(index);
      AGG::GetICN(ICN::ARTFX, art.IndexSprite32()).Blit(dstx + 5, dsty + 3);

      Text text(art.GetName(), (current ? Font::YELLOW_BIG : Font::BIG));
      text.Blit(dstx + 50, dsty + 10);
    };
void EditRatioWindow::draw(DrawBuf buf,bool) const
 {
  if( pane.dx<10 || pane.dy<10 ) return;

  MCoord w=+cfg.width;

  VColor face=+cfg.face;
  VColor gray=+cfg.gray;

  SmoothDrawArt art(buf.cut(pane));

  MPane p(pane);
  FigureBox fig(p);

  // body

  {
   fig.solid(art,+cfg.back);

   buf.erase(shade1,gray);
   buf.erase(shade2,gray);
  }

  // length

  {
   Coord d=RoundUpLen(w);
   MPoint endA=base.addX(Cap<Coord>(-base.x+d,a,base.x+1+d));
   MPoint endB=base.subY(b);

   art.ball(base,2*w,face);
   art.ball(endA,2*w,face);
   art.ball(endB,2*w,face);

   art.path(w,face,base,endA);
   art.path(w,face,base,endB);
  }

  // text

  {
   char temp[TextBufLen];
   PrintBuf out(Range(temp));

   Printf(out,"#;/#;",a,b);

   cfg.font->text(buf,text,TextPlace(AlignX_Center,AlignY_Top),out.close(),+cfg.text);
  }

  // border

  {
   VColor vc = focus? +cfg.focus : ( hilight? +cfg.hilight : +cfg.border ) ;

   fig.loop(art,HalfPos,w,vc);
  }
 }
Exemple #13
0
void Life::draw(DrawBuf buf,bool) const
{
    try
    {
        CommonDrawArt art(buf);

        art.erase(cfg.outer);

        // status
        {
            char temp[TextBufLen];
            PrintBuf out(Range(temp));

            Printf(out,"Step #; per second #; div = #;",map.getStepNumber(),speed,divider.getDiv());

            cfg.font->text(buf,status,TextPlace(AlignX_Left,AlignY_Center),out.close(),cfg.text);
        }

        // arena
        {
            art.block(arena,cfg.back);

            PaneBorder border(arena.expand(1));

            art.path(cfg.border_up,border.bottomLeft(),border.topLeft(),border.topRight());
            art.path(cfg.border_down,border.bottomLeft(),border.bottomRight(),border.topRight());
        }

        // cells
        {
            Coord dxy=this->dxy;

            const bool *src=map.getPtr();

            Coord cx=cfg.cx;
            Coord cy=cfg.cy;

            Pos pos=map.getPos();

            Coord x0=arena.x+cfg.space_dxy;
            Coord y0=arena.y+cfg.space_dxy;

            for(Coord x=0; x<cx ; x++)
                for(Coord y=0; y<cy ; y++)
                {
                    if( src[pos(x,y)] )
                    {
                        art.block(Pane(x0+x*dxy,y0+y*dxy,cfg.cell_dxy,cfg.cell_dxy),cfg.cell);
                    }
                }
        }
    }
    catch(CatchType)
    {
    }
}
Exemple #14
0
void DrawLab::drawMarks(DrawBuf buf) const
 {
  if( show_marks )
    {
     Smooth::DrawArt art(buf);
     
     for(Smooth::Dot dot : dots )
       {
        drawMark(art,dot.point.toPoint(),dot.type);
       }
    }
 }
void PointEditWindow::drawBack(DrawBuf buf,bool) const
 {
  SmoothDrawArt art(buf);

  Pane pane=Envelope(pos,pos+getPoint());

  MCoord width=+cfg.width;

  FigureBox fig(pane);

  fig.loop(art,HalfPos,width,+cfg.line);
 }
Exemple #16
0
void Track::deleteTrack() {
    log("Deleting track: " + title + " (" + number(id) + ")");

    Art art(id);
    if(art) art.remove();
    Audio(this).unlink();

    Playlist::removeTrack(id);
    DB::query("DELETE FROM events WHERE track_id = " + number(id));
    DB::query("DELETE FROM featured_tracks WHERE track_id = " + number(id));
    DB::query("DELETE FROM favorites WHERE type = 'track' AND ref = " + number(id));
    DB::query("DELETE FROM user_features WHERE type = 'track' AND ref = " + number(id));
    DB::query("DELETE FROM tracks WHERE id = " + number(id));
}
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
                                   SkBitmap* result, SkIPoint* offset) {
#if SK_SUPPORT_GPU
    SkBitmap input;
    SkASSERT(fInputCount == 1);
    if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, ctm, &input, offset)) {
        return false;
    }
    GrTexture* srcTexture = input.getTexture();
    SkIRect bounds;
    src.getBounds(&bounds);
    if (!this->applyCropRect(&bounds, ctm)) {
        return false;
    }
    SkRect srcRect = SkRect::Make(bounds);
    SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
    GrContext* context = srcTexture->getContext();

    GrTextureDesc desc;
    desc.fFlags = kRenderTarget_GrTextureFlagBit,
    desc.fWidth = bounds.width();
    desc.fHeight = bounds.height();
    desc.fConfig = kRGBA_8888_GrPixelConfig;

    GrAutoScratchTexture dst(context, desc);
    GrContext::AutoMatrix am;
    am.setIdentity(context);
    GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
    GrContext::AutoClip acs(context, dstRect);
    GrEffectRef* effect;
    SkMatrix matrix(ctm);
    matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
    this->asNewEffect(&effect, srcTexture, matrix, bounds);
    SkASSERT(effect);
    SkAutoUnref effectRef(effect);
    GrPaint paint;
    paint.addColorEffect(effect);
    context->drawRectToRect(paint, dstRect, srcRect);

    SkAutoTUnref<GrTexture> resultTex(dst.detach());
    SkImageFilterUtils::WrapTexture(resultTex, bounds.width(), bounds.height(), result);
    offset->fX += bounds.left();
    offset->fY += bounds.top();
    return true;
#else
    return false;
#endif
}
void CoordEditWindow::drawBack(DrawBuf buf,bool) const
 {
  Coord mark_dy=+cfg.mark_dy;
  MCoord width=+cfg.width;
  VColor line=+cfg.line;

  SmoothDrawArt art(buf);

  Point end=pos.addX(getCoord());

  art.path(width,line,pos,end);

  art.path(width,line,pos.subY(mark_dy),pos.addY(mark_dy));

  art.path(width,line,end.subY(mark_dy),end.addY(mark_dy));
 }
Exemple #19
0
RssArticlePtr hashToRssArticle(RssFeed* parent, const QVariantHash& h) {
  const QString guid = h.value("id").toString();
  if (guid.isEmpty())
    return RssArticlePtr();

  RssArticlePtr art(new RssArticle(parent, guid));
  art->m_title = h.value("title", "").toString();
  art->m_torrentUrl = h.value("torrent_url", "").toString();
  art->m_link = h.value("news_link", "").toString();
  art->m_description = h.value("description").toString();
  art->m_date = h.value("date").toDateTime();
  art->m_author = h.value("author").toString();
  art->m_read = h.value("read", false).toBool();

  return art;
}
Exemple #20
0
void mdeath::amigara(game *g, monster *z)
{
 if (g->u.has_disease(DI_AMIGARA)) {
  int count = 0;
  for (int i = 0; i < g->z.size(); i++) {
   if (g->z[i].type->id == mon_amigara_horror)
    count++;
  }
  if (count <= 1) { // We're the last!
   g->u.rem_disease(DI_AMIGARA);
   g->add_msg("Your obsession with the fault fades away...");
   item art(g->new_artifact(), g->turn);
   g->m.add_item(z->posx, z->posy, art);
  }
 }
 normal(g, z);
}
Exemple #21
0
void mdeath::amigara(game *g, monster *z)
{
 if (g->u.has_disease("amigara")) {
  int count = 0;
  for (int i = 0; i < g->num_zombies(); i++) {
   if (g->zombie(i).type->id == mon_amigara_horror)
    count++;
  }
  if (count <= 1) { // We're the last!
   g->u.rem_disease("amigara");
   g->add_msg(_("Your obsession with the fault fades away..."));
   item art(g->new_artifact(), g->turn);
   g->m.add_item_or_charges(z->posx(), z->posy(), art);
  }
 }
 normal(g, z);
}
void mdeath::amigara(monster *z) {
    if (!g->u.has_disease("amigara")) {
        return;
    }
    int count = 0;
    for (int i = 0; i < g->num_zombies(); i++) {
        if (g->zombie(i).type->id == "mon_amigara_horror") {
            count++;
        }
    }
    if (count <= 1) { // We're the last!
        g->u.rem_disease("amigara");
        add_msg(_("Your obsession with the fault fades away..."));
        item art(new_artifact(itypes), calendar::turn);
        g->m.add_item_or_charges(z->posx(), z->posy(), art);
    }
}
int ArtifactsModifiersResult(int type, const u8* arts, u32 size, const HeroBase & base, std::string* strs)
{
    int result = 0;

    for(u32 ii = 0; ii < size; ++ii)
    {
	    const Artifact art(arts[ii]);

    	    if(art.isValid())
    	    {
		int acount = base.HasArtifact(art);
		if(acount)
		{
		    s32 mod = art.ExtraValue();

		    switch(art())
		    {
			case Artifact::SWORD_BREAKER:		if(type == MDF_ATTACK) mod = 1; break;
			// power
			case Artifact::BROACH_SHIELDING:	if(type == MDF_POWER) mod = -2; break;
			// morale/luck
			case Artifact::BATTLE_GARB:		if(type == MDF_MORALE || type == MDF_LUCK) mod = 10; break;
			case Artifact::MASTHEAD:		if(type == MDF_MORALE || type == MDF_LUCK) mod = base.Modes(Heroes::SHIPMASTER) ? art.ExtraValue() : 0; break;
			// morale
			case Artifact::FIZBIN_MISFORTUNE:	if(type == MDF_MORALE) mod = -art.ExtraValue(); break;
			default: break;
		    }

    		    result += mod * acount;

    		    if(strs && mod)
    		    {
        		strs->append(art.GetName());
			StringAppendModifiers(*strs, mod);
        		strs->append("\n");
		    }
		}
	    }
    }

    return result;
}
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result) {
#if SK_SUPPORT_GPU
    SkBitmap input;
    SkASSERT(fInputCount == 1);
    if (!SkImageFilterUtils::GetInputResultGPU(this->getInput(0), proxy, src, &input)) {
        return false;
    }
    GrTexture* srcTexture = (GrTexture*) input.getTexture();
    SkRect rect;
    src.getBounds(&rect);
    GrContext* context = srcTexture->getContext();

    GrTextureDesc desc;
    desc.fFlags = kRenderTarget_GrTextureFlagBit,
    desc.fWidth = input.width();
    desc.fHeight = input.height();
    desc.fConfig = kRGBA_8888_GrPixelConfig;

    GrAutoScratchTexture dst(context, desc);
    GrContext::AutoMatrix am;
    am.setIdentity(context);
    GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
    GrContext::AutoClip acs(context, rect);
    GrEffectRef* effect;
    this->asNewEffect(&effect, srcTexture);
    SkASSERT(effect);
    SkAutoUnref effectRef(effect);
    GrPaint paint;
    paint.colorStage(0)->setEffect(effect);
    context->drawRect(paint, rect);
    SkAutoTUnref<GrTexture> resultTex(dst.detach());
    SkImageFilterUtils::WrapTexture(resultTex, input.width(), input.height(), result);
    return true;
#else
    return false;
#endif
}
Exemple #25
0
void Render::Html::submissions(const Contest &c, const std::vector<Track> &tracks){
    if(tracks.empty())
        o << "<div class=\"empty tracklist\">No submissions yet.</div>";
    else {
        o << "<div class=\"submissions\">";
        bool voting = c.state()==Contest::Voting;
        std::vector<int> uvotes;
        if(voting){
            uvotes = c.usersVotes();
            o << "<form action=\"" + c.url() + "/vote\" method=\"post\">";
        }
        std::map<int,int> votes = c.getVotes();
        o << "<ul class=\"tracklist\">";
        for(std::vector<Track>::const_iterator i=tracks.begin(); i!=tracks.end(); i++){
            Art art(i->id());
            o << "<li onclick=\"toggle(this.getElementsByClassName('player')[0]);\">";
            if(art) o << "<img class=\"cover\" alt=\"\" src=\"" << art.url(Art::Thumbnail) << "\" />";
            o << "<div class=\"title\">";
            int vcount = votes[i->id()];
            if(vcount>0 && voting)
                o << " <span class=\"votes\">(" + number(vcount) + " vote" + (vcount>1?"s":"") + ")</span>";
            if(voting){
                bool vote = std::find(uvotes.begin(),uvotes.end(),i->id()) != uvotes.end();
                o << (std::string) "<button type=\"submit\" name=\"tid\" title=\"" + (vote?"Cancel vote":"Vote") + "\" value=\"" + (vote?"-":"+") + number(i->id()) + "\">" + icon(vote?"vote":"star-empty", vote?"Cancel vote":"Vote") + "</button> ";
            }
            o << "<a href=\"" << i->url() << "\" title=\"" << escape(i->title()) << "\">" << escape(i->title()) << "</a></div>"
                 "<div class=\"by\">by <a href=\"" << i->artist().url() << "\">" << escape(i->artist().name()) << "</a></div>"
                 "<div style=\"clear:both;\"></div>";
            player(*i, "contest", false);
            o << "</li>";
        }
        o << "</ul>";
        if(voting) o << "</form>";
        o << "</div>";
    }
}
   virtual void draw(DrawBuf buf,bool drag_active) const
    {
     Used(drag_active);

     CommonDrawArt art(buf);

     art.erase(+cfg.back);

     AlignX align_x[4]={AlignX_Left,AlignX_Center,AlignX_Right,AlignX_Given};
     AlignY align_y[4]={AlignY_Top,AlignY_Center,AlignY_Bottom,AlignY_Given};

     for(int i=0; i<4 ;i++)
       for(int j=0; j<4 ;j++)
         {
          art.block(pane[i][j],+cfg.field);

          TextPlace place(align_x[i],align_y[j]);

          place.x=base.x;
          place.y=base.y;

          cfg.font->text(buf,pane[i][j],place,StrLen(text,len),+cfg.text);
         }
    }
void InfoShape::draw(const DrawBuf &buf) const
 {
  if( !pane ) return;

  Smooth::DrawArt art(buf);

  VColor text=enable?+cfg.text:+cfg.inactive;

  Point space=+cfg.space;

  // decor

  {
   MPane p(pane);

   MCoord width=+cfg.width;
   MCoord dx=Fraction(space.x)-width;
   MCoord dy=Fraction(space.y)-width;

   if( focus )
     {
      FigureBox fig(p.shrink(Fraction(space.x)/2,Fraction(space.y)/2));

      fig.loop(art,width,+cfg.focus);
     }

   if( xoff>0 )
     {
      FigureLeftMark fig(p,dx);

      fig.solid(art,text);
     }

   if( xoff<xoffMax )
     {
      FigureRightMark fig(p,dx);

      fig.solid(art,text);
     }

   if( yoff>0 )
     {
      FigureUpMark fig(p,dy);

      fig.solid(art,text);
     }

   if( yoff<yoffMax )
     {
      FigureDownMark fig(p,dy);

      fig.solid(art,text);
     }
  }

  // text

  {
   Pane inner=pane.shrink(space);

   if( !inner ) return;

   ulen count=info->getLineCount();
   ulen index=yoff;

   Font font=cfg.font.get();

   FontSize fs=font->getSize();

   DrawBuf tbuf=buf.cutRebase(inner);

   Pane row(-xoff,0,IntAdd(xoff,inner.dx),fs.dy);

   for(; index<count && row.y+row.dy<=inner.dy ;index++,row.y+=row.dy)
     {
      font->text(tbuf,row,TextPlace(AlignX_Left,AlignY_Top),info->getLine(index),text);
     }
  }
 }
void ButtonShape::draw(const DrawBuf &buf) const
 {
  MPane p(pane);

  if( !p ) return;

  Smooth::DrawArt art(buf);

  Font font=cfg.font.get();

  // figure

  MCoord width=+cfg.width;

  FontSize fs=font->getSize();

  MCoord ex=(Fraction(fs.dy)+2*width)/4;

  FigureButton fig(p,ex);

  VColor bottom=+cfg.bottom;

  // body

  if( down )
    {
     fig.curveSolid(art,bottom);
    }
  else
    {
     VColor top;

     if( mover && enable )
       top=+cfg.topUp;
     else
       top=+cfg.top;

     fig.curveSolid(art,TwoField(p.getTopLeft(),top,p.getBottomLeft(),bottom));
    }

  // text

  {
   Coord dx=RoundUpLen(ex);
   Coord dy=RoundUpLen(width);

   Point shift=Null;

   if( down ) shift=Point::Diag( (dy+1)/2 );

   VColor text=enable?+cfg.text:bottom;

   font->text(buf,pane.shrink(dx,dy)+shift,TextPlace(AlignX_Center,AlignY_Center),Range(face),text);
  }

  // border

  {
   VColor border;

   if( focus )
     {
      border=+cfg.focus;
     }
   else
     {
      if( enable )
        border=+cfg.border;
      else
        border=bottom;
     }

   fig.curveLoop(art,HalfPos,width,border);
  }
 }
void ScrollListShape::draw(const DrawBuf &buf) const
 {
  if( !pane ) return;

  SmoothDrawArt art(buf.cut(pane));

  art.block(pane,+cfg.back);

  VColor text = enable? +cfg.text : +cfg.inactive ;
  VColor title = enable? +cfg.title : +cfg.inactive ;
  VColor gray=+cfg.gray;
  VColor snow=+cfg.snow;

  Point space=+cfg.space;

  // decor

  {
   MPane p(pane);

   MCoord width=+cfg.width;

   MPoint s(space);

   FigureTopBorder fig_top(p,width);

   fig_top.solid(art,gray);

   FigureBottomBorder fig_bottom(p,width);

   fig_bottom.solid(art,snow);

   if( focus )
     {
      FigureBox fig(p.shrink(s/2));

      fig.loop(art,width,+cfg.focus);
     }

   MCoord dx=s.x-width;
   MCoord dy=s.y-width;

   if( xoff>0 )
     {
      FigureLeftMark fig(p,dx);

      fig.solid(art,text);
     }

   if( xoff<xoffMax )
     {
      FigureRightMark fig(p,dx);

      fig.solid(art,text);
     }

   if( yoff>0 )
     {
      FigureUpMark fig(p,dy);

      fig.solid(art,text);
     }

   if( yoff<yoffMax )
     {
      FigureDownMark fig(p,dy);

      fig.solid(art,text);
     }
  }

  // text

  {
   Pane inner=pane.shrink(space);

   if( !inner ) return;

   ulen count=info->getLineCount();
   ulen index=yoff;

   Font font=cfg.font.get();

   FontSize fs=font->getSize();

   DrawBuf tbuf=buf.cut(inner);

   SmoothDrawArt tart(tbuf);

   Pane row=inner;

   row.dy=fs.dy;

   Coord pos_x=fs.dx0-xoff;

   Coord lim=inner.y+inner.dy;

   VColor titleTop=+cfg.titleTop;
   VColor titleBottom=+cfg.titleBottom;
   Coord off=fs.dy;

   for(; index<count && IntAdd(row.y,row.dy)<=lim ;index++,row.y+=row.dy)
     {
      if( enable && index==select ) tbuf.erase(row,+cfg.select);

      ComboInfoItem item=info->getLine(index);

      switch( item.type )
        {
         case ComboInfoText :
          {
           font->text(tbuf,row,TextPlace(pos_x,AlignY_Top),item.text,text);
          }
         break;

         case ComboInfoTitle :
          {
           MPane p(row);

           TwoField field(p.getTopLeft(),titleTop,p.getBottomLeft(),titleBottom);

           FigureBox(p).solid(tart,field);

           font->text(tbuf,row,TextPlace(pos_x+off,AlignY_Top),item.text,title);
          }
         break;

         default: // case ComboInfoSeparator :
          {
           MPane p(row);
           MCoord delta=2*(p.dy/5);

           p=p.shrinkY(delta);

           TwoField field(p.getTopLeft(),snow,p.getBottomLeft(),gray);

           FigureBox(p).solid(tart,field);
          }
        }
     }
  }
 }
Exemple #30
0
 virtual void draw(FrameBuf<DesktopColor> buf,bool) const
  {
   if( magnify )
     {
      CommonDrawArt art(buf);
      
      art.grid(cfg.magnify);
      
      switch( draw_type )
        {
         case DrawCurvePath       : art.curvePath_micro(Range_const(dots),cfg.path,focus,cfg.magnify); break;
         
         case DrawPathSmooth      : art.path_smooth_micro(Range_const(dots),cfg.path,focus,cfg.magnify); break;
         
         case DrawCurvePathSmooth : art.curvePath_smooth_micro(Range_const(dots),cfg.path,focus,cfg.magnify); break;
        }
     }
   else
     {
      CommonDrawArt art(buf);
      
      art.erase(cfg.back);
      
      art.block(field,cfg.field);
      
      if( draw_type<DrawSolid )
        {
         for(auto p : dots ) art.knob(p,cfg.knob_len,cfg.knob);
         
         if( selected<dots.getLen() ) cross(art,dots[selected],cfg.cross);
        }
      
      CommonDrawArt field_art(buf.cut(field));
      
      ClockTimer timer;
      
      switch( draw_type )
        {
         case DrawPath            : field_art.path(Range_const(dots_based),cfg.path); break;
         case DrawLoop            : field_art.loop(Range_const(dots_based),cfg.path); break;
         case DrawCurvePath       : field_art.curvePath(Range_const(dots_based),cfg.path); break;
         case DrawCurveLoop       : field_art.curveLoop(Range_const(dots_based),cfg.path); break;
         case DrawPathSmooth      : field_art.path_smooth(Range_const(dots_based),cfg.path); break;
         case DrawLoopSmooth      : field_art.loop_smooth(Range_const(dots_based),cfg.path); break;
         case DrawCurvePathSmooth : field_art.curvePath_smooth(Range_const(dots_based),cfg.path); break;
         case DrawCurveLoopSmooth : field_art.curveLoop_smooth(Range_const(dots_based),cfg.path); break;
         
         case DrawSolid           : field_art.solid(Range_const(dots_based),solid_flag,cfg.solid); break;
         case DrawCurveSolid      : field_art.curveSolid(Range_const(dots_based),solid_flag,cfg.solid); break;
        }
      
      auto time=timer.get();
      
      Printf(out,"#;[#;] #;\n",GetTextDesc(draw_type),dots.getLen(),time);
      
      if( draw_type>=DrawSolid )
        {
         if( selected<dots.getLen() ) cross(art,dots[selected],cfg.cross);
        }
     }
  }