Exemple #1
0
void TEXTEDITBOX::GetInput(char Stringx[100]){
	MSG Msg;
	//save the original programflow variable to change it back later.
	int ProgramFlowTemp=Pass.ProgramFlow;
	Pass.ProgramFlow=PF_TEXTEDITBOX;
	Info=TEBI_NOTHING;
	//display the text box on the screen.

	//message loop
	while(Info!=TEBI_DONE){
		UpdateBox();
		if(!GetMessage(&Msg, NULL, 0, 0)){
   			//if they're trying to quit...
			Pass.SettingsInfo=SETTINGS_EXIT;
			Pass.ProgramFlow=PF_EXIT;
			Info=TEBI_DONE;
		}
		TranslateMessage(&Msg);
		DispatchMessage(&Msg);
	}	
	if(Pass.ProgramFlow!=PF_EXIT) Pass.ProgramFlow=ProgramFlowTemp;
	//now put the screen back together again.
	Blit(Pass.DDFront, StorageSurface, 0, 0, TEXTENTRYBOX_WIDTH, TEXTENTRYBOX_HEIGHT,
						TEXTENTRYBOX_LEFT, TEXTENTRYBOX_TOP);
	Blit(Pass.DDBack, StorageSurface, 0, 0, TEXTENTRYBOX_WIDTH, TEXTENTRYBOX_HEIGHT,
                         TEXTENTRYBOX_LEFT, TEXTENTRYBOX_TOP);
	lstrcpy(Stringx, String);
}
static void DrawObjectiveInfo(
	const struct MissionOptions *mo, const int idx, const Vec2i pos)
{
	const MissionObjective *mobj =
		CArrayGet(&mo->missionData->Objectives, idx);
	const ObjectiveDef *o = CArrayGet(&mo->Objectives, idx);
	const CharacterStore *store = &gCampaign.Setting.characters;

	switch (mobj->Type)
	{
	case OBJECTIVE_KILL:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetSpecialId(store, 0));
			const int i = cd->looks.face;
			TOffsetPic pic;
			pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
			pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
			pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
			DrawTTPic(
				pos.x + pic.dx, pos.y + pic.dy,
				PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
		}
		break;
	case OBJECTIVE_RESCUE:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetPrisonerId(store, 0));
			const int i = cd->looks.face;
			TOffsetPic pic;
			pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
			pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
			pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
			DrawTTPic(
				pos.x + pic.dx, pos.y + pic.dy,
				PicManagerGetOldPic(&gPicManager, pic.picIndex), &cd->table);
		}
		break;
	case OBJECTIVE_COLLECT:
		{
			const Pic *p = o->pickupClass->Pic;
			Blit(&gGraphicsDevice, p, Vec2iAdd(pos, p->offset));
		}
		break;
	case OBJECTIVE_DESTROY:
		{
			Vec2i picOffset;
			const Pic *p =
				MapObjectGetPic(IntMapObject(mobj->Index), &picOffset, false);
			Blit(&gGraphicsDevice, p, Vec2iAdd(pos, picOffset));
		}
		break;
	case OBJECTIVE_INVESTIGATE:
		// Don't draw
		return;
	default:
		CASSERT(false, "Unknown objective type");
		return;
	}
}
Exemple #3
0
int CreditsProc(PASSPROCVARS Params){
	int r=0;
	r+=ccbOK.ProcFunction(Params);
	if(r){
		//we have to flip the screen
		Flip(Pass.DDFront);
		Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0);
	}
//now handle some messages
	switch(Params.uMsg){
	case WM_CLOSE:
		Pass.ProgramFlow=PF_EXIT;
		CreditsInfo=CREDITS_EXIT;
		break;
	case WM_PAINT:
		ddsCredits->Restore();
		ddsCreditsh->Restore();
		DDReLoadBitmap(ddsCredits,BMP_CREDITS);
		DDReLoadBitmap(ddsCreditsh,BMP_CREDITSH);
		Blit(Pass.DDFront, ddsCredits, 0, 0, 640, 480, 0, 0);
		Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0);
		break;
	case WM_KEYDOWN:
   	switch(Params.wParam){
      	case VK_ESCAPE:
         	CreditsInfo=CREDITS_EXIT;
         break;
      }
	break;
	}
	return 0;
}
Exemple #4
0
void settingsRedrawScreen(){
	ScreenHighlighted->Restore();
	ScreenUnhighlighted->Restore();
	DDReLoadBitmap(ScreenHighlighted,BMP_SETTINGSH);
	DDReLoadBitmap(ScreenUnhighlighted,BMP_SETTINGS);
	DrawString("Setting up alpha table/@", 0, 0, 8);
	Blit(Pass.DDFront, ScreenUnhighlighted, 0, 0, 640, 480, 0, 0);
	Blit(Pass.DDBack, ScreenUnhighlighted, 0, 0, 640, 480, 0, 0);
}
Exemple #5
0
void dd_Window::activate()
{
	image *tempimg = new image(xres,yres);
	Blit(0,0,img,tempimg);
	if(bActive)
		return;
	bActive = true;
	set_win(xres,yres,vid_bpp);
	Blit(0,0,tempimg,img);
	if(bVisible)
		ShowWindow(hwnd,SW_SHOWNA);
}
Exemple #6
0
void Mouvement_depart(SDL_Surface *ecran, int *a)
{
    Blit(ecran, TAILLE_X/8*7-TAILLE_CARRE,TAILLE_Y/8-TAILLE_CARRE,TAILLE_CARRE*2,TAILLE_CARRE*2,255,0,255);
    Blit(ecran, TAILLE_X/8*7-TAILLE_CARRE,TAILLE_Y/8*7-TAILLE_CARRE,TAILLE_CARRE*2,TAILLE_CARRE*2,255,0,255);

    if(a[1]<=TAILLE_Y/8+TAILLE_CARRE) a[3]= 6;
    else if(a[1]>=TAILLE_Y/8*7-TAILLE_CARRE*2) a[3]= -6;

    a[1] += a[3];

    Blit(ecran,a[0],a[1],TAILLE_CARRE,TAILLE_CARRE,255,0,0);

}
Exemple #7
0
static BlitVec calcBlitsInt(ColumnVec &srcCols, ColumnVec &dstCols)
{
	BlitVec blits;

	/* Using signed indices here is safer, as we
	 * might decrement dstI while it is zero. */
	int dstI = 0;

	for (size_t srcI = 0; srcI < srcCols.size(); ++srcI)
	{
		Column &srcCol = srcCols[srcI];

		for (; dstI < (int) dstCols.size() && srcCol.h > 0; ++dstI)
		{
			Column &dstCol = dstCols[dstI];

			if (srcCol.h > dstCol.h)
			{
				/* srcCol doesn't fully fit into dstCol */
				blits.push_back(Blit(srcCol.x, srcCol.y,
				                     dstCol.x, dstCol.y, dstCol.h));

				srcCol.y += dstCol.h;
				srcCol.h -= dstCol.h;
			}
			else if (srcCol.h < dstCol.h)
			{
				/* srcCol fits into dstCol with space remaining */
				blits.push_back(Blit(srcCol.x, srcCol.y,
				                     dstCol.x, dstCol.y, srcCol.h));

				dstCol.y += srcCol.h;
				dstCol.h -= srcCol.h;

				/* Queue this column up again for processing */
				--dstI;

				srcCol.h = 0;
			}
			else
			{
				/* srcCol fits perfectly into dstCol */
				blits.push_back(Blit(srcCol.x, srcCol.y,
				                     dstCol.x, dstCol.y, dstCol.h));
			}
		}
	}

	return blits;
}
Exemple #8
0
///////////////////////////////////////////////////////////
/// Stretch blit
///////////////////////////////////////////////////////////
void Bitmap::StretchBlit(Rect dst_rect, Bitmap* src_bitmap, Rect src_rect, int opacity) {
	if (src_rect.width == dst_rect.width && src_rect.height == dst_rect.height) {
		Blit(dst_rect.x, dst_rect.y, src_bitmap, src_rect, opacity);
	} else {
		src_rect.Adjust(src_bitmap->GetWidth(), src_bitmap->GetHeight());
		if (src_rect.IsOutOfBounds(src_bitmap->GetWidth(), src_bitmap->GetHeight())) return;

		Bitmap* resampled = src_bitmap->Resample(dst_rect.width, dst_rect.height, src_rect);
		Rect rect(0, 0, dst_rect.width, dst_rect.height);
		Blit(dst_rect.x, dst_rect.y, resampled, rect, opacity);
		delete resampled;
	}

	Changed();
}
Exemple #9
0
void Image::Resize(const Extent3D& extent, const ColorRGBAd& fillColor, const Offset3D& offset)
{
    if (extent != GetExtent())
    {
        /* Store ownership of current image buffer in temporary image */
        Image prevImage;

        prevImage.extent_   = GetExtent();
        prevImage.format_   = GetFormat();
        prevImage.dataType_ = GetDataType();
        prevImage.data_     = std::move(data_);

        if ( extent.width  > GetExtent().width  ||
             extent.height > GetExtent().height ||
             extent.depth  > GetExtent().depth )
        {
            /* Resize image buffer with fill color */
            extent_ = extent;
            data_   = GenerateImageBuffer(GetFormat(), GetDataType(), GetNumPixels(), fillColor);
        }
        else
        {
            /* Resize image buffer with uninitialized image buffer */
            extent_ = extent;
            data_   = GenerateEmptyByteBuffer(GetDataSize(), false);
        }

        /* Copy previous image into new image */
        Blit(offset, prevImage, { 0, 0, 0 }, prevImage.GetExtent());
    }
}
Exemple #10
0
void VideoSystem::DrawRectAlpha(SDL_Rect *r, Uint32 color) {
#if 0
    SDL_Surface *surf = Surface(r->w, r->h, screen->format->BitsPerPixel);
    if (!surf)
        return;

    for (int y=0;y<surf->h;y++) {
        Uint16 *src = (Uint16*)(screen->pixels + ((r->y+y)*screen->pitch) + (r->x*2));
        Uint16 *dst = (Uint16*)(surf->pixels + (y*surf->pitch));
        for (int x=0;x<surf->w;x++) {
            Uint8 r1, g1, b1;
            Uint8 r2, g2, b2;
            int r3, g3, b3;
            Uint16 px;
            SDL_GetRGB(*src, screen->format, &r1, &g1, &b1);
            SDL_GetRGB(color, surf->format, &r2, &g2, &b2);
            r3 = std::min(255, ((r1*256)/256 + (r2*256)/256));
            g3 = std::min(255, ((g1*256)/256 + (g2*256)/256));
            b3 = std::min(255, ((b1*256)/256 + (b2*256)/256));
            px = SDL_MapRGB(surf->format, r3, g3, b3);
            *dst = px;
            src++;
        }
    }
    Blit(surf, NULL, r);
    SDL_FreeSurface(surf);
#endif
}
Exemple #11
0
int Fastclic(SDL_Surface *ecran)
{
    int score=0;
    int combo=0;
    int temps=SDL_GetTicks();
    int carre_x[20]={-1}, carre_y[20]={-1}, carre_t[20]={-1}, carre_c[20]={255};

    while(Genere_carre(ecran,carre_x,carre_y,carre_t,carre_c) && !Situation.exit)
    {
        SDL_Flip(ecran);
        Blit(ecran,0,0,TAILLE_X,TAILLE_Y,0,0,0);
        Changer_situation();
        switch(Gerer_clic(carre_x, carre_y, carre_t))
        {
            case 1: combo+=N; score += combo; break;
            case -1: combo=0; break;
            case 0: break;
        }
        if(combo >= 5*N*(N+2)) N++;

        Affichage_score2(ecran,score*100,TAILLE_X-67,TAILLE_Y-15);

        temps=SDL_GetTicks()-temps;
        if(temps<15) SDL_Delay(15- temps);
        temps=SDL_GetTicks();
    }

    return score*100;
}
Exemple #12
0
void PixmanBitmap::FlipBlit(int x, int y, Bitmap* _src, Rect src_rect, bool horizontal, bool vertical) {
	if (!horizontal && !vertical) {
		Blit(x, y, _src, src_rect, 255);
		return;
	}

	PixmanBitmap* src = (PixmanBitmap*) _src;

	pixman_transform_t xform;
	pixman_transform_init_scale(&xform,
								pixman_int_to_fixed(horizontal ? -1 : 1),
								pixman_int_to_fixed(vertical ? -1 : 1));

	pixman_transform_translate((pixman_transform_t*) NULL, &xform,
							   pixman_int_to_fixed(horizontal ? src_rect.width : 0),
							   pixman_int_to_fixed(vertical ? src_rect.height : 0));

	pixman_image_set_transform(bitmap, &xform);

	pixman_image_composite32(PIXMAN_OP_SRC,
							 src->bitmap, (pixman_image_t*) NULL, bitmap,
							 src_rect.x, src_rect.y,
							 0, 0,
							 x, y,
							 src_rect.width, src_rect.height);

	pixman_transform_init_identity(&xform);
	pixman_image_set_transform(bitmap, &xform);

	RefreshCallback();
}
Exemple #13
0
void PixmanBitmap::BlendBlit(int x, int y, Bitmap* _src, Rect src_rect, const Color& color) {
	PixmanBitmap* src = (PixmanBitmap*) _src;

	if (color.alpha == 0) {
		if (_src != this)
			Blit(x, y, _src, src_rect, 255);
		return;
	}

	if (src != this)
		pixman_image_composite32(PIXMAN_OP_SRC,
								 src->bitmap, (pixman_image_t*) NULL, bitmap,
								 src_rect.x, src_rect.y,
								 0, 0,
								 x, y,
								 src_rect.width, src_rect.height);

	pixman_color_t tcolor = PixmanColor(color);
	pixman_image_t* timage = pixman_image_create_solid_fill(&tcolor);

	pixman_image_composite32(PIXMAN_OP_OVER,
							 timage, src->bitmap, bitmap,
							 0, 0,
							 src_rect.x, src_rect.y,
							 x, y,
							 src_rect.width, src_rect.height);

	pixman_image_unref(timage);

	RefreshCallback();
}
Exemple #14
0
void PixmanBitmap::OpacityBlit(int x, int y, Bitmap* _src, Rect src_rect, int opacity) {
	PixmanBitmap* src = (PixmanBitmap*) _src;

	if (opacity == 255) {
		if (_src != this)
			Blit(x, y, _src, src_rect, opacity);
		return;
	}

	if (src == this) {
		pixman_color_t pcolor = {0, 0, 0, opacity << 8};
		pixman_rectangle16_t rect = {src_rect.x, src_rect.y, src_rect.width, src_rect.height};

		pixman_image_fill_rectangles(PIXMAN_OP_IN_REVERSE, bitmap, &pcolor, 1, &rect);
	}
	else {
		if (opacity > 255)
			opacity = 255;

		pixman_color_t tcolor = {0, 0, 0, opacity << 8};
		pixman_image_t* mask = pixman_image_create_solid_fill(&tcolor);

		pixman_image_composite32(PIXMAN_OP_OVER,
								 src->bitmap, mask, bitmap,
								 src_rect.x, src_rect.y,
								 0, 0,
								 x, y,
								 src_rect.width, src_rect.height);

		pixman_image_unref(mask);
	}

	RefreshCallback();
}
Exemple #15
0
int SettingsWindowProc(PASSPROCVARS Params){
	int r=0;
	r+=cbHighScores.ProcFunction(Params);
	r+=cbPlay.ProcFunction(Params);
	r+=cbExit.ProcFunction(Params);
	r+=cbOptions.ProcFunction(Params);
	r+=cbCredits.ProcFunction(Params);

	if(r){
//DrawString("Setting up alpha table/@", 0, 10, 8);
//DrawString("Setting up alpha table/@", 0, 20, 12);
//DrawString("Setting up alpha table/@", 0, 35, 13);
//DrawString("Setting up alpha table/@", 0, 50, 21);
		Flip(Pass.DDFront);
		Blit(Pass.DDBack, ScreenUnhighlighted, 0,0,640,480,0,0);
	}
	switch(Params.uMsg){
	case WM_PAINT:
		settingsRedrawScreen();
		break;
	case WM_CLOSE:
		Pass.SettingsInfo=SETTINGS_EXIT;
		Pass.ProgramFlow=PF_EXIT;
		break;
	}

return 0;
}
Exemple #16
0
void DrawKeycards(HUD *hud)
{
	int keyFlags[] =
	{
		FLAGS_KEYCARD_YELLOW,
		FLAGS_KEYCARD_GREEN,
		FLAGS_KEYCARD_BLUE,
		FLAGS_KEYCARD_RED
	};
	int i;
	int xOffset = -30;
	int xOffsetIncr = 20;
	int yOffset = 20;
	for (i = 0; i < 4; i++)
	{
		if (hud->mission->KeyFlags & keyFlags[i])
		{
			const Pic *pic = KeyPickupClass(hud->mission->keyStyle, i)->Pic;
			Blit(
				&gGraphicsDevice,
				pic,
				Vec2iNew(CenterX(pic->size.x) - xOffset, yOffset));
		}
		xOffset += xOffsetIncr;
	}
}
int DrawEndGame(void *pCtx, state *ptr) {
	attron(A_BOLD | A_BLINK);
	mvprintw(14, 9, "GAME OVER");
	attroff(A_BOLD | A_BLINK);
	Blit(pCtx);
	return 0;
}
Exemple #18
0
int
Stage::DrawScreen(int h) {
	jsval rval;
	int x, y, ytimesw;

	if (SDL_MUSTLOCK(screen)) {
		if (SDL_LockSurface(screen) < 0) {
			return 0;
		}
	}

	jsval argv[5];
	argv[0] = OBJECT_TO_JSVAL(screenArrayBuffer);
	argv[1] = INT_TO_JSVAL(WIDTH);
	argv[2] = INT_TO_JSVAL(HEIGHT);
	argv[3] = INT_TO_JSVAL(screen->pitch);
	argv[4] = INT_TO_JSVAL(BPP);
	JSBool ok = JS_CallFunctionName(cx, global, "paint", 5, argv, &rval);


	Blit((char *)screen->pixels, screenBuffer, screenBufferSize);

	if (SDL_MUSTLOCK(screen))
		SDL_UnlockSurface(screen);

	SDL_Flip(screen);
}
Exemple #19
0
PixmanBitmap::PixmanBitmap(Bitmap* source, Rect src_rect, bool transparent) {
	format = (transparent ? pixel_format : opaque_pixel_format);
	pixman_format = find_format(format);

	Init(src_rect.width, src_rect.height, (void *) NULL);

	Blit(0, 0, source, src_rect, 255);
}
Exemple #20
0
void SoftBitmap::ConvertImage(int& width, int& height, void*& pixels, bool transparent) {
	Init(width, height, NULL);
	const DynamicFormat& img_format = transparent ? image_format : opaque_image_format;
	SoftBitmap src(pixels, width, height, 0, img_format);
	Clear();
	Blit(0, 0, &src, src.GetRect(), 255);
	free(pixels);
}
Exemple #21
0
void Genere_mobile(SDL_Surface *ecran, int sens, int *y, int *xdeb, int *xfin, int ecart, int trou, int affichage)
{
    int i=0;
    int k=0;
    int t=0;
    while(i<50 && y[i]>-1)
    {
        y[i]++;
        if((y[i]==TAILLE_Y && (sens==1 || sens== -1)) || (y[i]==TAILLE_X && (sens==2 || sens== -2)))
        {
            k=i;
            while(k<49 && y[k]!=-1)
            {
                y[k]=y[k+1];
                xdeb[k]=xdeb[k+1];
                xfin[k]=xfin[k+1];
                k++;
            }
        }
        else if(sens==1)
        {
            if(affichage)Blit(ecran,0,y[i],xdeb[i],2,255,0,0);
            if(affichage)Blit(ecran,xfin[i],y[i],TAILLE_X-xfin[i],2,255,0,0);
            i++;
        }
        else if(sens==-1)
        {
            if(affichage)Blit(ecran,0,TAILLE_Y-y[i],xdeb[i],2,255,0,0);
            if(affichage)Blit(ecran,xfin[i],TAILLE_Y-y[i],TAILLE_X-xfin[i],2,255,0,0);
            i++;
        }
        else if(sens==2)
        {
            if(affichage)Blit(ecran,TAILLE_X-y[i],0,2,xdeb[i],255,0,0);
            if(affichage)Blit(ecran,TAILLE_X-y[i],xfin[i],2,TAILLE_X-xfin[i],255,0,0);
            i++;
        }
        else if(sens==-2)
        {
            if(affichage)Blit(ecran,y[i],0,2,xdeb[i],255,0,0);
            if(affichage)Blit(ecran,y[i],xfin[i],2,TAILLE_X-xfin[i],255,0,0);
            i++;
        }
    }

    if(y[i]==-1) y[i]= rand()%(ecart/2) - 5*ecart/4;

    else if(y[i]>-y[i-1])
    {
        y[i]=0;
        t=rand()%(trou)+trou/2;
        if(sens==1 || sens ==-1) xdeb[i]=rand()%(TAILLE_X-t);
        else                     xdeb[i]=rand()%(TAILLE_Y-t);
        xfin[i]=xdeb[i]+t;
    }
}
Exemple #22
0
////////////////////////////////////////////////////////////
// Waver, Single Opacity
void Surface::EffectsBlit(int x, int y, Bitmap* src, Rect src_rect,
						   int opacity,
						   int waver_depth, double waver_phase) {
	if (waver_depth == 0)
		Blit(x, y, src, src_rect, opacity);
	else
		WaverBlit(x, y, src, src_rect, waver_depth, waver_phase, opacity);
}
Exemple #23
0
int Longer_Higher(SDL_Surface *ecran)
{
    int score=0;
    int past_longueur=0;
    int a[6]={0}; // 0 : px, 1 py, 2 : vx, 3 : vy, 4 : longueur, 5 : hauteur
    int tir[3];


    tir[0]=0; // direction de frappe du marteau ( ou contenant la vitesse algebrique )
    tir[1]=TAILLE_X/2; // marteaux
    tir[2]=TAILLE_Y/10 + TAILLE_Y/2 ; // marteauy
    a[0]=TAILLE_X/8*7-TAILLE_CARRE/2;
    a[1]=TAILLE_Y/2-TAILLE_CARRE/2;
    a[3]=6;

    // Phase de départ
    while(Gestion_lanceur(ecran,a, tir) && !Situation.exit)
    {
        SDL_Flip(ecran);
        Blit(ecran,0,0,TAILLE_X,TAILLE_Y,0,0,0);
        Changer_situation();
        Mouvement_depart(ecran,a);
        SDL_Delay(3);
    }

    //Test de vitesse initiale
    a[2] = 5;
    a[3] *= -1;
    a[5]= TAILLE_Y - a[1];

    // Phase de jeu
    while(a[5] >= 0 && !Situation.exit)
    {
        SDL_Flip(ecran);
        Blit(ecran,0,0,TAILLE_X,TAILLE_Y,0,0,0);
        Changer_situation();
        Mouvement_reel(ecran,a);
        score += (a[4]-past_longueur)*a[5];
        past_longueur=a[4];

        Affichage_score2(ecran,score,TAILLE_X-67,TAILLE_Y-15);
    }

    return score;
}
Exemple #24
0
static BlitList calcBlitsInt(ColumnList &srcCols, ColumnList &dstCols)
{
	BlitList blits;

	while (!srcCols.empty())
	{
		Column srcCol = srcCols.takeFirst();
		Q_ASSERT(srcCol.h > 0);

		while (!dstCols.empty() && srcCol.h > 0)
		{
			Column dstCol = dstCols.takeFirst();

			if (srcCol.h > dstCol.h)
			{
				/* srcCol doesn't fully fit into dstCol */
				blits << Blit(srcCol.x, srcCol.y,
				              dstCol.x, dstCol.y, dstCol.h);

				srcCol.y += dstCol.h;
				srcCol.h -= dstCol.h;
			}
			else if (srcCol.h < dstCol.h)
			{
				/* srcCol fits into dstCol with space remaining */
				blits << Blit(srcCol.x, srcCol.y,
				              dstCol.x, dstCol.y, srcCol.h);

				dstCol.y += srcCol.h;
				dstCol.h -= srcCol.h;
				dstCols.prepend(dstCol);
				srcCol.h = 0;
			}
			else
			{
				/* srcCol fits perfectly into dstCol */
				blits << Blit(srcCol.x, srcCol.y,
				              dstCol.x, dstCol.y, dstCol.h);
			}
		}
	}

	return blits;
}
void WgGfxDevice::TileBlit( const WgSurfacePtr& _pSrc, const WgRect& _src, const WgRect& _dest )
{
    if( !_pSrc || _dest.h == 0 || _dest.w == 0 )
        return;

    WgRect	r = _src;
    WgRect	r2 = _src;

    int nCol = _dest.w / _src.w;
    r2.w = _dest.w % _src.w;

    int nRow = (_dest.h+(_src.h-1))/ _src.h;	// Including any cut row....

    int		destX = _dest.x;
    int		destY = _dest.y;

    for( int row = 1 ; row <= nRow ; row++ )
    {
        // Possibly cut the height if this is the last row...

        if( row == nRow )
        {
            r.h = _dest.y + _dest.h - destY;
            r2.h = r.h;
        }

        // Blit a row.

        for( int col = 0 ; col < nCol ; col++ )
        {
            Blit( _pSrc, r, destX, destY );
            destX += r.w;
        }

        // Blit any left over part at end of row.

        if( r2.w > 0 )
            Blit( _pSrc, r2, destX, destY );

        destX = _dest.x;
        destY += _src.h;
    }
    return;
}
void WgGfxDevice::BlitHorrBar(	const WgSurfacePtr& _pSurf, const WgRect& _src,
                                const WgBorder& _borders, bool _bTile,
                                int _dx, int _dy, int _len )
{
    // Blit left edge

    WgRect	r( _src.x, _src.y, _borders.left, _src.h );
    Blit( _pSurf, r, _dx, _dy );

    _len -= _borders.Width();			// Remove left and right edges from len.
    _dx += _borders.left;

    // Blit tiling part

    r.x += _borders.left;
    r.w = _src.w - _borders.Width();

    if( _bTile )
    {
        while( _len > r.w )
        {
            Blit( _pSurf, r, _dx, _dy );
            _len -= r.w;
            _dx += r.w;
        }
        if( _len != 0 )
        {
            r.w = _len;
            Blit( _pSurf, r, _dx, _dy );
            _dx += _len;
        }
    }
    else
    {
        StretchBlit( _pSurf, r, WgRect( _dx, _dy, _len, r.h ) );
        _dx += _len;
    }

    // Blit right edge

    r.x = _src.x + _src.w - _borders.right;
    r.w = _borders.right;
    Blit( _pSurf, r, _dx, _dy );
}
void WgGfxDevice::BlitVertBar(	const WgSurfacePtr& _pSurf, const WgRect& _src,
                                const WgBorder& _borders, bool _bTile,
                                int _dx, int _dy, int _len )
{
    // Blit top edge

    WgRect	r( _src.x, _src.y, _src.w, _borders.top );
    Blit( _pSurf, r, _dx, _dy );

    _len -= _borders.Height();			// Remove top and bottom borders from len.
    _dy += _borders.top;

    // Blit tiling part

    r.y += _borders.top;
    r.h = _src.h - _borders.Height();

    if( _bTile )
    {
        while( _len > r.h )
        {
            Blit( _pSurf, r, _dx, _dy );
            _len -= r.h;
            _dy += r.h;
        }
        if( _len != 0 )
        {
            r.h = _len;
            Blit( _pSurf, r, _dx, _dy );
            _dy += _len;
        }
    }
    else
    {
        StretchBlit( _pSurf, r, WgRect( _dx, _dy, r.w, _len ) );
        _dy += _len;
    }

    // Blit bottom edge

    r.y = _src.y + _src.h - _borders.bottom;
    r.h = _borders.bottom;
    Blit( _pSurf, r, _dx, _dy );
}
static void DrawObjectiveInfo(const Objective *o, const Vec2i pos)
{
	const CharacterStore *store = &gCampaign.Setting.characters;

	switch (o->Type)
	{
	case OBJECTIVE_KILL:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetSpecialId(store, 0));
			DrawHead(cd, DIRECTION_DOWN, STATE_IDLE, pos);
		}
		break;
	case OBJECTIVE_RESCUE:
		{
			const Character *cd = CArrayGet(
				&store->OtherChars, CharacterStoreGetPrisonerId(store, 0));
			DrawHead(cd, DIRECTION_DOWN, STATE_IDLE, pos);
		}
		break;
	case OBJECTIVE_COLLECT:
		{
			const Pic *p = o->u.Pickup->Pic;
			Blit(&gGraphicsDevice, p,
				Vec2iMinus(pos, Vec2iScaleDiv(p->size, 2)));
		}
		break;
	case OBJECTIVE_DESTROY:
		{
			Vec2i picOffset;
			const Pic *p =
				MapObjectGetPic(o->u.MapObject, &picOffset, false);
			Blit(&gGraphicsDevice, p, Vec2iAdd(pos, picOffset));
		}
		break;
	case OBJECTIVE_INVESTIGATE:
		// Don't draw
		return;
	default:
		CASSERT(false, "Unknown objective type");
		return;
	}
}
Exemple #29
0
int cbOptionsProc(PASSPROCVARS Params){
	//cbsound
	FadeOut(Pass.DDObject, &Pass.DDFront, &ScreenUnhighlighted, 0);
	OptionsMain();
	if(Pass.ProgramFlow==PF_EXIT) Pass.SettingsInfo=SETTINGS_EXIT;
	else FadeIn(Pass.DDObject, &Pass.DDFront, &ScreenUnhighlighted, 0);
	Blit(Pass.DDBack, ScreenUnhighlighted, 0,0,640,480,0,0);
	settingsRedrawScreen();
	return 0;
}
void EC_WidgetCanvas::Update()
{
    if (framework->IsHeadless())
        return;

    if (!widget_.data() || texture_name_.empty())
        return;
    if (widget_->width() <= 0 || widget_->height() <= 0)
        return;

    try
    {
        Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(texture_name_);
        if (texture.isNull())
            return;

        if (buffer_.size() != widget_->size())
            buffer_ = QImage(widget_->size(), QImage::Format_ARGB32_Premultiplied);
        if (buffer_.width() <= 0 || buffer_.height() <= 0)
            return;

        QPainter painter(&buffer_);
        widget_->render(&painter);

        // Set texture to material
        if (update_internals_ && !material_name_.empty())
        {
            Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(material_name_);
            if (material.isNull())
                return;
            // Just for good measure, this is done once in the ctor already if everything went well.
            OgreRenderer::SetTextureUnitOnMaterial(material, texture_name_);
            UpdateSubmeshes();
            update_internals_ = false;
        }

        if ((int)texture->getWidth() != buffer_.width() || (int)texture->getHeight() != buffer_.height())
        {
            texture->freeInternalResources();
            texture->setWidth(buffer_.width());
            texture->setHeight(buffer_.height());
            texture->createInternalResources();
        }

        Blit(buffer_, texture);
    }
    catch (Ogre::Exception &e) // inherits std::exception
    {
        LogError("Exception occurred while blitting texture data from memory: " + std::string(e.what()));
    }
    catch (...)
    {
        LogError("Unknown exception occurred while blitting texture data from memory.");
    }
}