Beispiel #1
0
void TCOD_sys_console_to_bitmap(void *vbitmap, int console_width, int console_height, char_t *console_buffer, char_t *prev_console_buffer) {
	int x,y;
	sfImage *bitmap=(sfImage *)vbitmap;
	TCOD_color_t fading_color = TCOD_console_get_fading_color();
	static int oldFade=-1;
	uint8 fade = TCOD_console_get_fade();
	static sfShape *rectShape=NULL;

	if ( ! rectShape ) {
		rectShape=sfShape_CreateRectangle(0.5f, 0.5f, 0.5f + fontWidth, 0.5f + fontHeight, sfBlack, 0.0f, sfBlack);
		sfShape_EnableOutline(rectShape, sfFalse);
	}
	for (y=0;y<console_height;y++) {
		for (x=0; x<console_width; x++) {
			char_t *c=&console_buffer[x+y*console_width];
			bool changed=true;
			if ( changed ) {
				sfColor b={c->back.r,c->back.g,c->back.b,255};
				// background
				b.r = ((int)b.r) * fade / 255 + ((int)fading_color.r) * (255-fade)/255;
				b.g = ((int)b.g) * fade / 255  + ((int)fading_color.g) * (255-fade)/255;
				b.b = ((int)b.b) * fade / 255 + ((int)fading_color.b) * (255-fade)/255;
				int destx=x*fontWidth;
				int desty=y*fontHeight;
				if ( (void *)bitmap == (void *)renderWindow && fullscreen_on ) {
					destx+=fullscreen_offsetx;
					desty+=fullscreen_offsety;
				}
				sfShape_SetPosition(rectShape,destx+0.5f,desty+0.5f);
				sfShape_SetColor(rectShape,sfWhite);
				sfRenderWindow_DrawShape (renderWindow, rectShape);
				nbBlit++;
				int srcx,srcy;
				if ( c->c != ' ') {
					// foreground
					int ascii=(int)c->c;
					sfColor f={c->fore.r,c->fore.g,c->fore.b,255};
					f.r = ((int)f.r) * fade / 255 + ((int)fading_color.r) * (255-fade)/255;
					f.g = ((int)f.g) * fade / 255 + ((int)fading_color.g) * (255-fade)/255;
					f.b = ((int)f.b) * fade / 255 + ((int)fading_color.b) * (255-fade)/255;
					if (fontInRow) {
						srcx = (ascii%fontNbCharHoriz)*fontWidth;
						srcy = (ascii/fontNbCharHoriz)*fontHeight;
					} else {
						srcx = (ascii/fontNbCharVertic)*fontWidth;
						srcy = (ascii%fontNbCharVertic)*fontHeight;
					}
					sfIntRect rect={srcx,srcy,srcx+fontWidth-1,srcy+fontHeight-1};
					sfSprite_SetSubRect(charmapSprite,&rect);
					sfSprite_SetX(charmapSprite,destx);
					sfSprite_SetY(charmapSprite,desty);
					sfSprite_SetColor(charmapSprite,f);
					sfRenderWindow_DrawSprite(renderWindow,charmapSprite);
				}
			}
		}
	}

}
Beispiel #2
0
value drawFightInterface()
{
	if (game.popupClock)
		if (sfClock_GetTime(game.popupClock) > game.popupTime)
		{
			sfClock_Destroy(game.popupClock);
			game.popupClock = NULL;
			game.popupTime = 0.0f;
			sfString_Destroy(game.popupMessage);
			game.popupMessage = NULL;
			sfSprite_Destroy(game.popupBackground);
			game.popupBackground = NULL;
			game.popupMessageCount--;
			if (game.popupMessageCount > 0)
				updatePopup();
		}

	sfRenderWindow_Clear(game.renderWindow, sfWhite);


	if (fi.background)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.background);
	if (fi.headerBackground)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.headerBackground);
	if (fi.leftLifeBarContainer)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.leftLifeBarContainer);
	if (fi.leftManaBarContainer)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.leftManaBarContainer);
	if (fi.rightLifeBarContainer)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.rightLifeBarContainer);
	if (fi.rightManaBarContainer)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.rightManaBarContainer);
	if (fi.leftManaBar && fi.leftMana > 0)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.leftManaBar);
	if (fi.rightManaBar && fi.rightMana > 0)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.rightManaBar);
	if (fi.leftLifeBar && fi.leftLife > 0)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.leftLifeBar);
	if (fi.rightLifeBar && fi.rightLife > 0)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.rightLifeBar);
	if (fi.leftCreature)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.leftCreature);
	if (fi.rightCreature)
		sfRenderWindow_DrawSprite(game.renderWindow, fi.rightCreature);

	if (fi.rightCreatureName)
		sfRenderWindow_DrawString(game.renderWindow, fi.rightCreatureName);
	if (fi.leftCreatureName)
		sfRenderWindow_DrawString(game.renderWindow, fi.leftCreatureName);
	if (fi.rightCreatureLevel)
		sfRenderWindow_DrawString(game.renderWindow, fi.rightCreatureLevel);
	if (fi.leftCreatureLevel)
		sfRenderWindow_DrawString(game.renderWindow, fi.leftCreatureLevel);

	if (fi.leftLifeBarText)
		sfRenderWindow_DrawString(game.renderWindow, fi.leftLifeBarText);
	if (fi.leftManaBarText)
		sfRenderWindow_DrawString(game.renderWindow, fi.leftManaBarText);
	if (fi.rightLifeBarText)
		sfRenderWindow_DrawString(game.renderWindow, fi.rightLifeBarText);
	if (fi.rightManaBarText)
		sfRenderWindow_DrawString(game.renderWindow, fi.rightManaBarText);
	
	DialogPanel_draw(game.dialogPanel, game.renderWindow);

	if (anythingSelection.running == 1)
		drawAnythingSelection();
	
	if (game.trophyBackground)
		sfRenderWindow_DrawSprite(game.renderWindow, game.trophyBackground);
	if (game.trophy)
		sfRenderWindow_DrawSprite(game.renderWindow, game.trophy);
	if (game.text)
		sfRenderWindow_DrawString(game.renderWindow, game.text);

	if (game.popupBackground != NULL)
		sfRenderWindow_DrawSprite(game.renderWindow, game.popupBackground);
	if (game.popupMessage != NULL)
		sfRenderWindow_DrawString(game.renderWindow, game.popupMessage);
	
	
	sfRenderWindow_Display(game.renderWindow);
	return Val_unit;
	
}