Пример #1
0
/**
 * Initialize the GUI.
 */
int SDLGui_Init(void)
{
	SDL_Color blackWhiteColors[2] = {{255, 255, 255, 255}, {0, 0, 0, 255}};

	if (pSmallFontGfx && pBigFontGfx)
	{
		/* already initialized */
		return 0;
	}

	/* Initialize the font graphics: */
	pSmallFontGfx = SDLGui_LoadXBM(font5x8_width, font5x8_height, font5x8_bits);
	pBigFontGfx = SDLGui_LoadXBM(font10x16_width, font10x16_height, font10x16_bits);
	if (pSmallFontGfx == NULL || pBigFontGfx == NULL)
	{
		fprintf(stderr, "Error: Can not init font graphics!\n");
		return -1;
	}

	/* Set color palette of the font graphics: */
	SDL_SetColors(pSmallFontGfx, blackWhiteColors, 0, 2);
	SDL_SetColors(pBigFontGfx, blackWhiteColors, 0, 2);

	/* Set font color 0 as transparent: */
	SDL_SetColorKey(pSmallFontGfx, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0);
	SDL_SetColorKey(pBigFontGfx, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0);

	return 0;
}
Пример #2
0
/*
  Initialize the GUI.
*/
bool SDLGui_Init()
{
	// Load the font graphics
	char font_filename[256];
	unsigned char font_data[4096];
	getConfFilename("font", font_filename, sizeof(font_filename));
	FILE *f = fopen(font_filename, "rb");
	bool font_loaded = false;
	if (f != NULL) {
		if (fread(font_data, 1, sizeof(font_data), f) == sizeof(font_data)) {
			font_loaded = true;
		}
		fclose(f);
	}
	// If font can't be loaded use the internal one
	if (! font_loaded) {
		memcpy(font_data, font_bits, sizeof(font_data));
	}
	
	fontgfx = SDLGui_LoadXBM(font_data);
	if (fontgfx == NULL)
	{
		panicbug("Could not create font data");
		panicbug("ARAnyM GUI will not be available");
		return false;
	}

	gui_hsurf = host->video->createSurface(76*8+16,25*16+16,8);
	if (!gui_hsurf) {
		panicbug("Could not create surface for GUI");
		panicbug("ARAnyM GUI will not be available");
		return false;
	}

	gui_surf = gui_hsurf->getSdlSurface();

	gui_hsurf->setPalette(gui_palette, 0, 4);

//	gui_hsurf->setParam(HostSurface::SURF_ALPHA, bx_options.opengl.gui_alpha);
//	gui_hsurf->setParam(HostSurface::SURF_USE_ALPHA, 1);

	/* Set font color 0 as transparent */
	SDL_SetColorKey(fontgfx, SDL_SRCCOLORKEY, 0);

	/* Get the font width and height: */
	fontwidth = fontgfx->w/16;
	fontheight = fontgfx->h/16;

	return true;
}