void CStatusScreenGalaxy::scaleToResolution()
{
    SDL_Rect gameres = gVideoDriver.getGameResolution().SDLRect();
    const int scaleFac = gameres.h/200;
    GsWeakSurface blit(gVideoDriver.getBlitSurface());

    SDL_PixelFormat *format = mpStatusSurface->format;

    mStatusSfcTransformed.create(0,
                                 blit.width(),
                                 blit.height(),
                                 32,
                                 format->Rmask,
                                 format->Gmask,
                                 format->Bmask,
                                 format->Amask );


#if SDL_VERSION_ATLEAST(2, 0, 0)
    SDL_SetSurfaceBlendMode(mpStatusSurface.get(), SDL_BLENDMODE_NONE);
#else
    SDL_SetAlpha(mpStatusSurface.get(), 0, 0);
#endif

    SDL_Rect srcRect = mpStatusSurface->clip_rect;
    srcRect.w *= scaleFac;
    srcRect.h *= scaleFac;

    blitScaled(mpStatusSurface.get(),
               srcRect,
               mStatusSfcTransformed.getSDLSurface(),
               srcRect,
               NONE);
}
Exemplo n.º 2
0
void drawTrophyAlert(void)
{
	int x, y;
	
	if (alertTrophy)
	{
		SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
		SDL_RenderFillRect(app.renderer, &alertRect);

		SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
		SDL_RenderDrawRect(app.renderer, &alertRect);

		drawText(alertRect.x + 15, alertRect.y + 5, 30, TA_LEFT, colors.white, alertTrophy->title);
		drawText(alertRect.x + 15, alertRect.y + 45, 20, TA_LEFT, colors.white, alertTrophy->description);
		
		setSparkleColor(alertTrophy);
		
		x = alertRect.x + alertRect.w - 72;
		y = alertRect.y + 20;

		blit(alertSphere, x + 24, y + 24, 1);
		blitRotated(sparkle, x + 24, y + 24, sparkleAngle);
		blitRotated(sparkle, x + 24, y + 24, -sparkleAngle);
		blitScaled(trophyIcons[alertTrophy->value], x, y, 48, 48, 0);
	}
}
Exemplo n.º 3
0
void drawShieldHitEffect(Entity *e)
{
	int size = MAX(e->w, e->h) + 32;
	
	SDL_SetTextureBlendMode(shieldHitTexture, SDL_BLENDMODE_BLEND);
	SDL_SetTextureAlphaMod(shieldHitTexture, e->shieldHit);
	blitScaled(shieldHitTexture, e->x - battle.camera.x, e->y - battle.camera.y, size, size, 1);
}
Exemplo n.º 4
0
Arquivo: draw.c Projeto: nnesse/tbftss
void drawBackground(SDL_Texture *texture)
{
    int i;

    for (i = 0 ; i < 4 ; i++)
    {
        blitScaled(texture, backgroundPoint[i].x, backgroundPoint[i].y, SCREEN_WIDTH, SCREEN_HEIGHT);
    }
}
Exemplo n.º 5
0
void drawEffects(void)
{
	int i;
	Effect *e;

	SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);

	for (i = 0, e = effectsToDraw[i] ; e != NULL ; e = effectsToDraw[++i])
	{
		SDL_SetRenderDrawColor(app.renderer, e->r, e->g, e->b, e->a);

		SDL_SetTextureBlendMode(e->texture, SDL_BLENDMODE_ADD);
		SDL_SetTextureAlphaMod(e->texture, e->a);

		switch (e->type)
		{
			case EFFECT_POINT:
				SDL_RenderDrawPoint(app.renderer, e->x - battle.camera.x, e->y - battle.camera.y);
				break;

			case EFFECT_LINE:
				SDL_RenderDrawLine(app.renderer, e->x - battle.camera.x, e->y - battle.camera.y, e->x + (e->dx * 3) - battle.camera.x, e->y + (e->dy * 3) - battle.camera.y);
				break;

			case EFFECT_TEXTURE:
				SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b);
				blitScaled(e->texture, e->x - battle.camera.x, e->y - battle.camera.y, e->size, e->size, 0);
				break;

			case EFFECT_HALO:
				SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b);
				blitScaled(e->texture, e->x - battle.camera.x - (e->size / 2), e->y - battle.camera.y - (e->size / 2), e->size, e->size, 0);
				break;

			case EFFECT_ECM:
				SDL_SetTextureColorMod(e->texture, e->r, e->g, e->b);
				blitScaled(e->texture, SCREEN_WIDTH / 2 - (e->size / 2), SCREEN_HEIGHT / 2 - (e->size / 2), e->size, e->size, 0);
				break;
		}
	}

	SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
}
Exemplo n.º 6
0
bool GsBitmap::scaleTo(const GsRect<Uint16> &destRes)
{
    SDL_Rect newRect = destRes.SDLRect();

    // Need to do that, otherwise it won't work.
    optimizeSurface();

    if(newRect.w == mpBitmapSurface->w &&
       newRect.h == mpBitmapSurface->h)
        return true;


    std::shared_ptr<SDL_Surface> newSfc;

    auto bmpSfc = mpBitmapSurface.get();
    auto bmpFormat = bmpSfc->format;

    newSfc.reset( SDL_CreateRGBSurface(bmpSfc->flags,
                                       newRect.w, newRect.h,
                                       bmpFormat->BitsPerPixel,
                                       bmpFormat->Rmask,
                                       bmpFormat->Gmask,
                                       bmpFormat->Bmask,
                                       bmpFormat->Amask ),
                    &SDL_FreeSurface );

    if(!newSfc)
      return false;

#if SDL_VERSION_ATLEAST(2, 0, 0)

    SDL_BlendMode blendMode;

    SDL_GetSurfaceBlendMode(bmpSfc, &blendMode);
    SDL_SetSurfaceBlendMode(newSfc.get(), blendMode);

#endif

    CVidConfig &vidConf = gVideoDriver.getVidConfig();


    blitScaled(bmpSfc,
               bmpSfc->clip_rect,
               newSfc.get(),
               newRect,
               vidConf.m_ScaleXFilter);

    mpBitmapSurface = newSfc;

    return true;
}
Exemplo n.º 7
0
	SPSurface Surface::resize(const spn::Size& s) const {
		auto bm = getBlendMode();
		auto* self = const_cast<Surface*>(this);
		self->setBlendMode(SDL_BLENDMODE_NONE);

		auto sz = getSize();
		spn::Rect srcRect(0,sz.width, 0,sz.height),
				dstRect(0,s.width, 0,s.height);
		SPSurface nsfc = Create(s.width, s.height, getFormat().format);
		blitScaled(nsfc, srcRect, dstRect);

		self->setBlendMode(bm);
		return nsfc;
	}
Exemplo n.º 8
0
bool GsSurface::scaleTo(const GsRect<Uint16> &scaledRect, const filterOptionType filter)
{
    SDL_Rect newRect = scaledRect.SDLRect();

    if(newRect.w == mpSurface->w && newRect.h == mpSurface->h)
        return true;


    // Need to do that, otherwise it won't work ???
    //optimizeSurface();

    auto sfcFormat = mpSurface->format;

    SDL_Surface *newSfc =
            SDL_CreateRGBSurface(mpSurface->flags,
                                 newRect.w, newRect.h,
                                 sfcFormat->BitsPerPixel,
                                 sfcFormat->Rmask,
                                 sfcFormat->Gmask,
                                 sfcFormat->Bmask,
                                 sfcFormat->Amask  );

    if(!newSfc)
      return false;

#if SDL_VERSION_ATLEAST(2, 0, 0)

    SDL_BlendMode blendMode;

    SDL_GetSurfaceBlendMode(mpSurface, &blendMode);
    SDL_SetSurfaceBlendMode(newSfc, blendMode);

#endif

    blitScaled(mpSurface,
               mpSurface->clip_rect,
               newSfc,
               newRect,
               filter);

    // Tear down old surface!
    SDL_FreeSurface(mpSurface);

    // And set the newly created and scaled one
    mpSurface = newSfc;

    return true;
}
Exemplo n.º 9
0
void CPassiveGalaxy::renderIntroZoom()
{
    SDL_Rect dstRect, srGsRect;
    srGsRect.x = srGsRect.y = 0;

    if(mZoomSfcPos.x < 16)
    {
        srGsRect.x -= mZoomSfcPos.x;
    }

    if(mZoomSfcPos.y > 8)
    {
        srGsRect.y -= mZoomSfcPos.y;
    }

    SDL_Surface *zoomSfc = mpZoomSurface.get();

    // Here we define the Rects to zoom
    srGsRect.w = zoomSfc->w;
    srGsRect.h = zoomSfc->h;


    dstRect.x = mZoomSfcPos.x;
    dstRect.y = mZoomSfcPos.y;
    dstRect.w = mZoomSfcZoom.x;
    dstRect.h = mZoomSfcZoom.y;

    GsRect<Uint16> gameRes = gVideoDriver.getGameResolution();
    SDL_Rect gameResSDL = gameRes.SDLRect();

    SDL_Surface *blitSfc = gVideoDriver.getBlitSurface();
    SDL_FillRect( blitSfc, &gameResSDL, SDL_MapRGB(blitSfc->format, 0, 0, 0) );

    CVidConfig &vidConf = gVideoDriver.getVidConfig();

    blitScaled( zoomSfc, srGsRect, blitSfc, dstRect, vidConf.m_ScaleXFilter );
}
Exemplo n.º 10
0
void drawTrophies(void)
{
	Trophy *t;
	SDL_Rect r;
	int start, end, i, x, y;
	
	SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
	SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
	SDL_RenderFillRect(app.renderer, NULL);
	SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
	
	r.w = boxWidth;
	r.h = 650;
	r.x = (SCREEN_WIDTH / 2) - r.w / 2;
	r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
	
	SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
	SDL_RenderFillRect(app.renderer, &r);
	SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
	SDL_RenderDrawRect(app.renderer, &r);
	
	drawText(SCREEN_WIDTH / 2, 40, 28, TA_CENTER, colors.white, TROPHIES_TEXT);
	drawText(SCREEN_WIDTH / 2, 83, 16, TA_CENTER, colors.lightGrey, AWARDED_TEXT, awarded, total);
	drawText(SCREEN_WIDTH / 2, 110, 16, TA_CENTER, colors.lightGrey, PAGE_TEXT, page + 1, (int)maxPages);
	
	SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255);
	SDL_RenderDrawLine(app.renderer, r.x, 150, r.x + r.w, 150);
	
	x = r.x + 15;
	y = 180;
	start = page * TROPHIES_PER_PAGE;
	end = start + TROPHIES_PER_PAGE;
	i = 0;
	
	for (t = game.trophyHead.next ; t != NULL ; t = t->next)
	{
		if (i >= start && i < end)
		{
			if (t->awarded)
			{
				setSparkleColor(t);
				blitRotated(sparkle, x + 32, y + 32, sparkleAngle);
				blitRotated(sparkle, x + 32, y + 32, -sparkleAngle);
				
				blitScaled(trophyIcons[t->value], x, y, 64, 64, 0);
				drawText(x + 85, y - 10, 20, TA_LEFT, colors.yellow, t->title);
				drawText(x + 85, y + 20, 18, TA_LEFT, colors.white, t->description);
				drawText(x + 85, y + 48, 18, TA_LEFT, colors.white, t->awardDateStr);
			}
			else
			{
				blitScaled(trophyIcons[TROPHY_UNEARNED], x, y, 64, 64, 0);
				
				if (!t->hidden)
				{
					drawText(x + 85, y - 10, 20, TA_LEFT, colors.lightGrey, t->title);
					drawText(x + 85, y + 20, 18, TA_LEFT, colors.darkGrey, t->description);
					drawText(x + 85, y + 48, 18, TA_LEFT, colors.darkGrey, "-");
				}
				else
				{
					drawText(x + 85, y + 20, 20, TA_LEFT, colors.darkGrey, HIDDEN_TEXT);
				}
			}
			
			y += 120;
		}
		
		i++;
	}
		
	drawWidgets("trophies");
}
Exemplo n.º 11
0
void Surface::blitScaled(const Surface &from, Common::Rational scale, int32 transp) {
	blitScaled(from, 0, 0, from._width - 1, from._height - 1, 0, 0, scale, transp);
}