コード例 #1
0
ファイル: settingsmenu.cpp プロジェクト: AlexandreSousa/mkxp
	void drawText(SDL_Surface *surf, const char *str,
	              int x, int y, int alignW,
	              Justification just, SDL_Color c, bool bold = false)
	{
		SDL_Surface *txt = createTextSurface(str, c, bold);
		blitTextSurf(surf, x, y, alignW, txt, just);
		SDL_FreeSurface(txt);
	}
コード例 #2
0
ファイル: RenderHUD_SDL2.cpp プロジェクト: viroulep/libTAS
void RenderHUD_SDL2::renderText(const char* text, Color fg_color, Color bg_color, int x, int y)
{
    static int inited = 0;
    if (inited == 0) {
        init();
        inited = 1;
    }

    std::unique_ptr<SurfaceARGB> surf = createTextSurface(text, fg_color, bg_color);
    SDL_Surface* sdlsurf = orig::SDL_CreateRGBSurfaceFrom(surf->pixels.data(), surf->w, surf->h, 32, surf->pitch, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
    void* tex = orig::SDL_CreateTextureFromSurface(renderer, sdlsurf);

    SDL_Rect rect = {x, y, x+sdlsurf->w, y+sdlsurf->h};
    orig::SDL_RenderCopy(renderer, tex, NULL, &rect);
}
コード例 #3
0
ファイル: settingsmenu.cpp プロジェクト: AlexandreSousa/mkxp
	void redraw()
	{
		fillSurface(winSurf, cBgNorm);

		for (size_t i = 0; i < widgets.size(); ++i)
			widgets[i]->draw(winSurf);

		if (state == AwaitingInput)
		{
			char buf[64];
			snprintf(buf, sizeof(buf), "Press key or joystick button for \"%s\"", captureName);

			drawOff = Vec2i();

			SDL_Surface *dark = createSurface(winSize.x, winSize.y);
			fillSurface(dark, 0);
			SDL_SetSurfaceAlphaMod(dark, 128);
			SDL_SetSurfaceBlendMode(dark, SDL_BLENDMODE_BLEND);
			SDL_Surface *txt = createTextSurface(buf, false);

			SDL_BlitSurface(dark, 0, winSurf, 0);

			SDL_Rect fill;
			fill.x = (winSize.x - txt->w - 20) / 2;
			fill.y = (winSize.y - txt->h - 20) / 2;
			fill.w = txt->w + 20;
			fill.h = txt->h + 20;

			fillRect(winSurf, cBgNorm, fill.x, fill.y, fill.w, fill.h);
			strokeRectInner(winSurf, cLine, fill.x, fill.y, fill.w, fill.h, 2);

			fill.x += 10;
			fill.y += 10;
			fill.w = txt->w;
			fill.h = txt->h;

			SDL_BlitSurface(txt, 0, winSurf, &fill);

			SDL_FreeSurface(txt);
			SDL_FreeSurface(dark);
		}

		SDL_UpdateWindowSurface(window);
	}