/* EditorDisplay
 * This function does the work of drawing your
 * object on the frame editor. In this example,
 * the Icon.png file is simply drawn to the
 * frame, but you can change this to draw
 * anything you want.
 */
void MMF2Func EditorDisplay(mv *mV, OI *oi, LO *lo, SerializedED *SED, RECT *rect)
{
#ifndef RUN_ONLY
	cSurface *Surface = WinGetSurface(int(mV->mvIdEditWin)); //get access to the frame editor surface
	if(!Surface) return; //failure
	SDK->Icon->Blit(*Surface, rect->left, rect->top, BMODE_TRANSP, BOP_COPY, 0); //copy the icon onto the frame editor surface
#endif
}
示例#2
0
void WINAPI DLLExport EditorDisplay(mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr, RECT FAR *rc)
{
#ifndef RUN_ONLY

	LPSURFACE Surface = WinGetSurface((int) mV->mvIdEditWin);

	if (!Surface)
        return;

    SDK->Icon->Blit(*Surface, rc->left, rc->top, BMODE_TRANSP, BOP_COPY, 0);

#endif // !defined(RUN_ONLY)
}
示例#3
0
void WINAPI DLLExport EditorDisplay(mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr, RECT FAR *rc)
{
#ifndef RUN_ONLY

	LPSURFACE ps = WinGetSurface((int)mV->mvIdEditWin);
	if ( ps != NULL )		// Do the following if this surface exists
	{
		int x = rc->left;	// get our boundaries
		int y = rc->top;
		int w = rc->right-rc->left;
		int h = rc->bottom-rc->top;

		cSurface is;
		is.Create(edPtr->swidth, edPtr->sheight, ps);
		is.Fill( (COLORREF)0 );
				
		/*is.Line(0,0,w,h,1,DARK_GRAY);
		is.Line(0,h,w,0,1,DARK_GRAY);
		is.Rectangle(0,0,w,h,NULL,1,DARK_GRAY,false);*/

		cSurface imageSurface;
		::LockImageSurface( mV->mvIdAppli, edPtr->imageFrames[0], imageSurface, LOCKIMAGE_READBLITONLY );

			int width = !edPtr->direction ? imageSurface.GetWidth() : edPtr->swidth;
			int height = edPtr->direction ? imageSurface.GetHeight() : edPtr->sheight;

			imageSurface.Stretch(
				is,
				is.GetWidth()/2 - width/2,
				is.GetHeight()/2 - height/2,
				width,
				height,
				0,0,
				imageSurface.GetWidth(),
				imageSurface.GetHeight(),
				BMODE_OPAQUE, BOP_COPY, 0, imageSurface.HasAlpha() ? STRF_COPYALPHA : 0 );

		::UnlockImageSurface( imageSurface );
		
		is.Blit(*ps, x, y, BMODE_TRANSP, BOP_COPY);
	}

#endif // !defined(RUN_ONLY)
}
示例#4
0
void CheckSurfaceRecreation(LPRDATA rdPtr)
{

	fprh rhPtr = rdPtr->rHo.hoAdRunHeader;
	LPSURFACE ps = WinGetSurface((int)rhPtr->rhIdEditWin);
	LPSURFACE pProto = NULL;

	ParallaxFrame current = *rdPtr->currentPframe;

	//Recreate surface if nessecary.
	if( (rdPtr->direction == HORIZONTAL && rdPtr->rHo.hoImgWidth != rdPtr->oldWidth) ||
		(rdPtr->direction == VERTICAL && rdPtr->rHo.hoImgHeight != rdPtr->oldHeight) ||
		(rdPtr->finalImage == NULL)
	)
	{
		if( rdPtr->finalImage != NULL )
		{
			rdPtr->finalImage->Delete();
			delete rdPtr->finalImage;
		}
		rdPtr->finalImage = new cSurface();
		if ( GetSurfacePrototype( &pProto, ps->GetDepth(), ST_MEMORY, SD_DIB) )
		{
			int newWidth = (rdPtr->direction == HORIZONTAL) ? rdPtr->rHo.hoImgWidth : current.parallaxImage->GetWidth();
			int newHeight = (rdPtr->direction == HORIZONTAL) ? current.parallaxImage->GetHeight() : rdPtr->rHo.hoImgHeight;

			rdPtr->finalImage->Create(newWidth, newHeight, pProto);

			if( !rdPtr->finalImage->IsValid() )
			{
				rdPtr->finalImage->Delete();
				delete rdPtr->finalImage;
			}
				
		}
	}

	rdPtr->oldWidth = rdPtr->rHo.hoImgWidth;
	rdPtr->oldHeight = rdPtr->rHo.hoImgHeight;
}
short WINAPI DLLExport CreateRunObject(LPRDATA rdPtr, LPEDATA edPtr, fpcob cobPtr)
{
// Do some rSDK stuff
#include "rCreateRunObject.h"

#ifdef _DEBUG

    AllocConsole();
    freopen("conin$", "r", stdin);
    freopen("conout$", "w", stdout);
    freopen("conout$", "w", stderr);

    printf("TILEMAPVIEWPORT DEBUG MODE");

#ifdef HWABETA
    printf(" (HWA)");

#endif

    printf("\n");
#endif

    LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
    rdPtr->isHwa = rhPtr->rh4.rh4Mv->mvCallFunction(NULL, EF_ISHWA, 0, 0, 0) != 0;
    rdPtr->isUnicode = rhPtr->rh4.rh4Mv->mvCallFunction(NULL, EF_ISUNICODE, 0, 0, 0) != 0;

    rdPtr->rHo.hoImgWidth = edPtr->width;
    rdPtr->rHo.hoImgHeight = edPtr->height;
    rdPtr->rc.rcChanged = true;

    // No parent by default...
    rdPtr->p = 0;

    // Create surface, get MMF depth..
    cSurface * ps = WinGetSurface((int)rdPtr->rHo.hoAdRunHeader->rhIdEditWin);
    rdPtr->depth = ps->GetDepth();

    rdPtr->surface = 0;

#ifndef HWABETA

    /*	Non-transparent surfaces are rendered to an opaque viewport surface so
       that
            the tiles do not have to be redrawn every single frame.
       */
    if (!edPtr->transparent) {
        cSurface * proto;
        GetSurfacePrototype(&proto, rdPtr->depth, ST_MEMORY, SD_DIB);
        rdPtr->surface = new cSurface;
        rdPtr->surface->Create(rdPtr->rHo.hoImgWidth, rdPtr->rHo.hoImgHeight, proto);
    }

#endif

    // Animation settings
    rdPtr->lastTick = GetTickCount();
    rdPtr->animMode = edPtr->animMode;
    for (int i = 0; i < 255; ++i) {
        memset(&rdPtr->anim[i], 0, sizeof(Animation));
        rdPtr->anim[i].width = 1;
        rdPtr->anim[i].height = 1;
        rdPtr->anim[i].speed = 8.0f;
    }
    rdPtr->animTime = 0;

    // HWA blit flags
    rdPtr->blitFlags = edPtr->resample ? STRF_RESAMPLE : 0;

    // Background settings
    rdPtr->transparent = edPtr->transparent;
    rdPtr->background = edPtr->background;
    rdPtr->accurateClip = edPtr->accurateClip;

    // Layer stuff
    rdPtr->minLayer = edPtr->minLayer;
    rdPtr->maxLayer = edPtr->maxLayer;

    // Misc
    rdPtr->outsideColl = edPtr->outsideColl;
    rdPtr->fineColl = edPtr->fineColl;
    rdPtr->zoomColl = !edPtr->unscaledColl;
    memset(&rdPtr->collMargin, 0, sizeof(RECT));

    // Camera/drawing
    rdPtr->zoom = 1.0f;
    rdPtr->zoomPointX = 0.0f;
    rdPtr->zoomPointY = 0.0f;
    rdPtr->cameraX = 0;
    rdPtr->cameraY = 0;
    rdPtr->autoScroll = edPtr->autoScroll;

    // Initialize callbacks
    rdPtr->tileCallback.use = false;
    rdPtr->tileCallback.settings = 0;
    rdPtr->tileCallback.tile = 0;
    rdPtr->layerCallback.use = false;
    rdPtr->layerCallback.settings = 0;

    // Overlap stuff
    rdPtr->ovlpFilterCount = 0;

    return 0;
}
void WINAPI DLLExport EditorDisplay(mv _far * mV, fpObjInfo oiPtr, fpLevObj loPtr,
                                    LPEDATA edPtr, RECT FAR * rc)
{
#ifndef RUN_ONLY

    LPSURFACE ps = WinGetSurface((int)mV->mvIdEditWin);
    if (ps != NULL) // Do the following if this surface exists
    {
        // ps->SetClipRect(rc->left, rc->top, rc->right-rc->left,
        // rc->bottom-rc->top);

        // Prevent the user from having a seizure
        // srand((long)mV->mvEditFrame + edPtr->width + edPtr->height);

        // Get surfaces of tilesets
        // cSurface surfs[TILESETCOUNT];
        // for (int i = 0; i < edPtr->tilesetCount; ++i)
        //{
        //	LockImageSurface(mV->mvIdAppli, edPtr->tilesets[i], surfs[i]);
        //}

        // Draw opaque background
        if (!edPtr->transparent)
            ps->Rectangle(rc->left, rc->top, rc->right, rc->bottom, edPtr->background, 0, 0, 1);

        //// For each tile
        // if (edPtr->tileWidth > 0 && edPtr->tileHeight > 0)
        //{
        //	for (int x = rc->left; x <= rc->right; x += edPtr->tileWidth)
        //	{
        //		for (int y = rc->top; y <= rc->bottom; y +=
        // edPtr->tileHeight)
        //		{
        //			// Draw a random tile
        //			if (edPtr->tilesetCount)
        //			{
        //				int tileset = 0;
        //				//int tileset = rand() %
        // edPtr->tilesetCount;
        //				int tx = rand() %
        //(surfs[tileset].GetWidth()
        ///
        // edPtr->tileWidth);
        //				int ty = rand() %
        //(surfs[tileset].GetHeight()
        ///
        // edPtr->tileHeight);
        //				surfs[tileset].Blit(*ps, x, y,
        // tx*edPtr->tileWidth,
        // ty*edPtr->tileHeight, edPtr->tileWidth, edPtr->tileHeight,
        // BMODE_TRANSP, BOP_COPY);
        //			}
        //			// Draw grid
        //			else
        //			{
        //				ps->Rectangle(x, y,
        // x+edPtr->tileWidth+1,
        // y+edPtr->tileHeight+1,
        // 1, 0x999999);
        //			}
        //		}
        //	}
        //}

        // Draw border
        ps->Rectangle(rc->left, rc->top, rc->right, rc->bottom, 1, OPAQUE_BLACK);
        ps->ClearClipRect();

        // Unlock stuff
        // for (int i = 0; i < edPtr->tilesetCount; ++i)
        //{
        //	UnlockImageSurface(surfs[i]);
        //}
    }

#endif // !RUN_ONLY
}
示例#7
0
void LoadImageFile(LPRDATA rdPtr, LPSTR pFileName)
{
	LPRH	rhPtr = rdPtr->rHo.hoAdRunHeader;
	HANDLE	hf = INVALID_HANDLE_VALUE;

	do {	
		if ( pFileName == NULL || *pFileName == 0 )
			break;

		// Copy filename to temp buffer
		char fname[MAX_PATH];
		strcpy(fname, pFileName);

		// Get surface prototype
		LPSURFACE wSurf = WinGetSurface((int)rhPtr->rhIdEditWin);
		LPSURFACE proto;
		GetSurfacePrototype(&proto, (wSurf != NULL) ? wSurf->GetDepth() : 24, ST_MEMORYWITHDC, SD_DIB);
		if ( proto == NULL )
			break;

		// Ask MMF2 to open the file (opens external file and embedded files, and downloads files in Vitalize mode)
		DWORD dwSize;
		hf = rhPtr->rh4.rh4Mv->mvOpenHFile(fname, &dwSize, 0);
		if ( hf == INVALID_HANDLE_VALUE )
			break;

		// Create CInpuBufFile object associated with the file handle
		DWORD dwOff = File_GetPosition((HFILE)hf);
		CInputBufFile bf;
		if ( bf.Create((HFILE)hf, dwOff, dwSize) != 0 )
			break;

		// Create surface
		cSurface* psf = NewSurface();
		if ( psf == NULL )
			break;
		psf->Create(4, 4, proto);
		psf->Fill(RGB(0,0,0));
		if ( psf->GetDepth() == 8 )
			psf->SetPalette (*wSurf);

		// Load picture
		CImageFilterMgr* pImgMgr = rhPtr->rh4.rh4Mv->mvImgFilterMgr;
		if ( ImportImageFromInputFile(pImgMgr, &bf, psf, NULL, IMPORT_IMAGE_USESURFACEDEPTH | IMPORT_IMAGE_USESURFACEPALETTE) )
		{
			// Copy filename if file successfully loaded
			strcpy(rdPtr->sFilename, fname);
			rdPtr->nWidth = rdPtr->rHo.hoImgWidth = psf->GetWidth();
			rdPtr->nHeight = rdPtr->rHo.hoImgHeight = psf->GetHeight();

			// Replace picture surface
			if ( rdPtr->pSf != NULL )
				DeleteSurface(rdPtr->pSf);
			rdPtr->pSf = psf;

			// Free collision mask
			FreeColMask(rdPtr);

			// Set transparent color
			if ( psf->GetTransparentColor() == RGB(0,0,0) )
			{
				COLORREF trspColor = rdPtr->dwTranspColor;
				if ( (rdPtr->dwOptions & SPICTFLAGS_TRANSP_FIRSTPIXEL) != 0 )
					psf->GetPixel(0,0,trspColor);
				psf->SetTransparentColor(trspColor);
			}
		}
		else
			DeleteSurface(psf);

	} while(FALSE);

	// Close picture file (opened with mvOpenHFile)
	if ( hf != INVALID_HANDLE_VALUE )
		rhPtr->rh4.rh4Mv->mvCloseHFile(hf);
}
示例#8
0
//cSurface* WINAPI DLLExport GetRunObjectSurface(LPRDATA rdPtr)
short WINAPI DLLExport DisplayRunObject(LPRDATA rdPtr)
{
	MaskChanged();

	if(rdPtr->dispTarget)
	{
		rdPtr->currentId = rdPtr->targetId;
		CurrentImg = TargetImg;
	}

	if(!CurrentImg)
	{
		rdPtr->rHo.hoImgWidth = 0;
		rdPtr->rHo.hoImgHeight = 0;
		return 0;
	}

	//Get scaled size of the surface
	int scaleW = CurrentImg->GetWidth()*abs(rdPtr->rc.rcScaleX);
	int scaleH = CurrentImg->GetHeight()*abs(rdPtr->rc.rcScaleY);

	//Object is too small
	if(scaleW <= 0 || scaleH <= 0)
	{
		rdPtr->rHo.hoImgWidth = 0;
		rdPtr->rHo.hoImgHeight = 0;
		rdPtr->rHo.hoImgXSpot = 0;
		rdPtr->rHo.hoImgYSpot = 0;
		return 0;
	}

	// Begin render process...
	LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
	LPSURFACE ps = WinGetSurface((int)rhPtr->rhIdEditWin);
	cSurface* renderImage = CurrentImg;

	// On-screen coords
	int screenX = rdPtr->rHo.hoX - rhPtr->rhWindowX;
	int screenY = rdPtr->rHo.hoY - rhPtr->rhWindowY;

	// Pure HWA blitting, yay!
#ifdef HWABETA

	if (rdPtr->isHWA)// && CurrentImg->GetType() >= ST_HWA_RTTEXTURE)
	{
		DWORD flags = 0;

		// Rotate quality 1
		if (rdPtr->rc.rcAngle && rdPtr->rs.rsFlags & RSFLAG_ROTATE_ANTIA)
			flags |= BLTF_ANTIA;

		// Scale quality 1
		if ((rdPtr->rc.rcScaleX != 1.0f || rdPtr->rc.rcScaleY != 1.0f) && rdPtr->rs.rsFlags & RSFLAG_SCALE_RESAMPLE)
			flags |= BLTF_ANTIA;

		// Hot spot (transform center)
		POINT point = {ImageS(rdPtr->currentId)->hotX, ImageS(rdPtr->currentId)->hotY};

		CurrentImg->BlitEx(*ps, screenX, screenY, 
			rdPtr->rc.rcScaleX, rdPtr->rc.rcScaleY, 0, 0,
			CurrentImg->GetWidth(), CurrentImg->GetHeight(), &point, rdPtr->rc.rcAngle,
			(rdPtr->rs.rsEffect & EFFECTFLAG_TRANSPARENT) ? BMODE_TRANSP : BMODE_OPAQUE,
			BlitOp(rdPtr->rs.rsEffect & EFFECT_MASK),
			rdPtr->rs.rsEffectParam, flags);
		return 0;
	}

#endif

	// Software blit: Offset draw position by transformed hotspot
	screenX -= rdPtr->rHo.hoImgXSpot;
	screenY -= rdPtr->rHo.hoImgYSpot;

	// Temporary surface for transformations
	cSurface temp;

	//Need scaling
	if(rdPtr->rc.rcScaleX != 1.0 || rdPtr->rc.rcScaleY != 1.0)
	{
		temp.Create(scaleW, scaleH, renderImage);
		renderImage->Stretch(temp, 0, 0, scaleW, scaleH, BMODE_OPAQUE, BOP_COPY, 0, 
			((rdPtr->rs.rsFlags&RSFLAG_SCALE_RESAMPLE)?STRF_RESAMPLE:0)|STRF_COPYALPHA);
	
		//Mirror for negative values.
		if(rdPtr->rc.rcScaleX < 0)
			temp.ReverseX();
		if(rdPtr->rc.rcScaleY < 0)
			temp.ReverseY();

		// For now, the scaled image is the 'final' one
		renderImage = &temp;
	}

	//Need rotation
	if(rdPtr->rc.rcAngle)
	{
		cSurface rotateBuffer;
		rotateBuffer.Clone(*renderImage);
		rotateBuffer.CreateRotatedSurface(temp, rdPtr->rc.rcAngle, 
			rdPtr->rs.rsFlags & RSFLAG_ROTATE_ANTIA, CurrentImg->GetTransparentColor(), TRUE);
		renderImage = &temp;
	}

	if (renderImage && renderImage->IsValid())
	{
		rdPtr->rHo.hoImgWidth = renderImage->GetWidth();
		rdPtr->rHo.hoImgHeight = renderImage->GetHeight();

		renderImage->Blit(
			*ps,
			screenX,
			screenY,
			0, 0,
			renderImage->GetWidth(),
			renderImage->GetHeight(),
			(rdPtr->rs.rsEffect & EFFECTFLAG_TRANSPARENT) ? BMODE_TRANSP : BMODE_OPAQUE,
			BlitOp(rdPtr->rs.rsEffect & EFFECT_MASK),
			rdPtr->rs.rsEffectParam
		);

		//Update window
		RECT rect;
		rect.left = screenX;
		rect.top = screenY;
		rect.right = screenX + renderImage->GetWidth();
		rect.bottom = screenY + renderImage->GetHeight();
		//ps->Rectangle(rect.left, rect.top, rect.right, rect.bottom, RED, 0, 0, TRUE);
		WinAddZone(rhPtr->rhIdEditWin, &rect);
	}

	return 0;
}
示例#9
0
short WINAPI DLLExport CreateRunObject(LPRDATA rdPtr, LPEDATA edPtr, fpcob cobPtr)
{
	// Do some rSDK stuff
	#include "rCreateRunObject.h"

#ifdef _DEBUG
	AllocConsole();
	freopen("conin$","r",stdin);
	freopen("conout$","w",stdout);
	freopen("conout$","w",stderr);
#ifdef UNICODE
	printf("Surface Unicode version\n");
#endif
#endif

	srand(time(NULL));

	LPRH rhPtr = rdPtr->rHo.hoAdRunHeader;
	mv* mV = rdPtr->rHo.hoAdRunHeader->rh4.rh4Mv;

	rdPtr->rHo.hoImgWidth = edPtr->width_def;
	rdPtr->rHo.hoImgHeight = edPtr->height_def;
	rdPtr->useAbs = edPtr->useAbs;
	rdPtr->keepPoints = edPtr->keepPoints;
	rdPtr->dispTarget = edPtr->dispTarget;
	rdPtr->selectLast = edPtr->selectLast;
	rdPtr->threadedIO = edPtr->threadedIO;
	rdPtr->ioFile = 0;

	//Font
	rdPtr->hFont = 0;
	memcpy(&rdPtr->textFont,&edPtr->textFont,sizeof(LOGFONT));
	rdPtr->hFlags = edPtr->textFlags;	

	//Depth
	rdPtr->depth = 24;

	//Internal blending
	rdPtr->b.mode = BMODE_TRANSP;
	rdPtr->b.operation = BOP_COPY;
	rdPtr->b.param = 0;
	rdPtr->b.param = 0xffffffff;
	rdPtr->b.flags = 0;
	rdPtr->b.destX = 0;
	rdPtr->b.destY = 0;
	rdPtr->b.destW = 0;
	rdPtr->b.destH = 0;
	rdPtr->b.StretchMode = 0;
	rdPtr->b.srcX = 0;
	rdPtr->b.srcY = 0;
	rdPtr->b.srcW = 0;
	rdPtr->b.srcH = 0;
	rdPtr->b.srcUse = false;
	rdPtr->b.callback[0] = 0;
	rdPtr->b.procOp[0] = 0;
	rdPtr->b.procOpSrc = 1;
	rdPtr->b.composeAlpha = false;
	rdPtr->b.angle = 0;
	rdPtr->b.angleResample = false;
	rdPtr->b.hotX = 0;
	rdPtr->b.hotY = 0;
	rdPtr->b.hotspotMode = 1; // no longer possible to disable
	rdPtr->blitStackCursor = -1;
	//Current & target surfaces
	rdPtr->targetId = -1;
	rdPtr->target = 0;
	rdPtr->currentId = -1;
	rdPtr->current = 0;
	rdPtr->lastId = -1;
	rdPtr->targetValid = false;
	//Default settings
	rdPtr->transCol = BLACK;
	//Collision mask and fill data
	rdPtr->collision = 0;
	rdPtr->fill = new FillDB;
	//Polygon's points
	rdPtr->points = new PolyPoints;
	//Buffer
	rdPtr->buffer = 0;
	rdPtr->buffPitch = 0;
	rdPtr->buffSurf = 0;
	//Overlay
	rdPtr->ovl = 0;
	//Callback
	rdPtr->colSrc = 0;
	rdPtr->colDest = 0;
	rdPtr->colNew = 0;
	rdPtr->colAlphaSrc = 0;
	rdPtr->colAlphaDest = 0;
	rdPtr->colAlphaNew = 0;
	rdPtr->callback = 0;
	rdPtr->callX = 0;
	rdPtr->callY = 0;
	rdPtr->colAlphaRet = 0;
	rdPtr->colRet = 0;
	//Flood fill region
	rdPtr->floodL = 0;
	rdPtr->floodT = 0;
	rdPtr->floodR = 0;
	rdPtr->floodB = 0;
	//I/O
	rdPtr->ioHandle = 0;
	//Quick store
	rdPtr->stored = 0;
	// Random color function
	rdPtr->randomSeed = 0;
	//Functions for extension integration
	rdPtr->imageAt = GetImgAt;
	rdPtr->imageCount = GetImgCount;
	//Running HWA?
	LPSURFACE wSurf = WinGetSurface((int)rhPtr->rhIdEditWin);
	int nDrv = wSurf->GetDriver();
	rdPtr->isHWA = nDrv >= SD_3DFX;
		
	//Display surface not necessary by default
	rdPtr->display = 0;
	rdPtr->rc.rcAngle = 0;
	rdPtr->rc.rcScaleX = 1.0f;
	rdPtr->rc.rcScaleY = 1.0f;

	//Images
	rdPtr->surf = new ImageBank;

	//Hotspot info
	Img imgInfo;
	//Prototype for new surfaces
	cSurface *proto = 0;

	if(edPtr->multiImg)
	{
		//First image empty
		if(!edPtr->images[0]&&edPtr->loadFirst)
		{
			cSurface *tmp = new cSurface;
			rdPtr->surf->push_back(new SImage(tmp));
			//Empty image with size
			if(edPtr->loadFirst)
			{
				GetSurfacePrototype(&proto,rdPtr->depth,ST_MEMORYWITHDC,SD_DIB);
				tmp->Create(edPtr->width,edPtr->height,proto);
				tmp->Fill(BLACK);
			}
			rdPtr->targetId = rdPtr->currentId = rdPtr->lastId = 0;
			TargetImg = CurrentImg = tmp;
			rdPtr->targetValid = true;
		}
		for(int i=0;i<edPtr->imageCount;i++)
		{
			//Get surface prototype on first loop
			if(!i)
				GetSurfacePrototype(&proto,rdPtr->depth,ST_MEMORYWITHDC,SD_DIB);
			//Valid image? Load
			if(edPtr->images[i])
			{
				cSurface is, *tmp = new cSurface;
				GetImageInfos(rhPtr->rhIdAppli,edPtr->images[i],&imgInfo);
				rdPtr->surf->push_back(new SImage(tmp,true,imgInfo.imgXSpot,imgInfo.imgYSpot));
				LockImageSurface(rhPtr->rhIdAppli,edPtr->images[i],is);
				
				if(is.GetWidth())
				{
					if(!i)
					{
						rdPtr->targetId = 0;
						TargetImg = tmp;
						rdPtr->lastId = rdPtr->targetId;
						rdPtr->targetValid = true;
						if(edPtr->loadFirst)
						{
							rdPtr->currentId = rdPtr->targetId;
							CurrentImg = TargetImg;
						}
					}
					tmp->Create(is.GetWidth(),is.GetHeight(),proto);
					tmp->SetTransparentColor(is.GetTransparentColor());
					is.Blit(*tmp,0,0,BMODE_OPAQUE,BOP_COPY,0,BLTF_COPYALPHA);
				}
				else if(!i&&edPtr->loadFirst)
				{
					rdPtr->targetId = rdPtr->currentId = 0;
					TargetImg = CurrentImg = 0;
					rdPtr->lastId = rdPtr->targetId;
				}
				UnlockImageSurface(is);
			}
			//Add prototype if there's more than one empty image
			else if(i&&edPtr->imageCount>1)
			{
				rdPtr->surf->push_back(new SImage(new cSurface));
			}

		}
	}
	//Single image
	else
	{
		//First image is set
		if(edPtr->images[0])
		{
			cSurface is, *tmp = new cSurface;
			GetImageInfos(rhPtr->rhIdAppli,edPtr->images[0],&imgInfo);
			rdPtr->surf->push_back(new SImage(tmp,true,imgInfo.imgXSpot,imgInfo.imgYSpot));
			LockImageSurface(rhPtr->rhIdAppli,edPtr->images[0],is);

			if(is.GetWidth())
			{
				GetSurfacePrototype(&proto,rdPtr->depth,ST_MEMORYWITHDC,SD_DIB);
				rdPtr->targetId = rdPtr->currentId = rdPtr->lastId = 0;
				TargetImg = CurrentImg = tmp;
				tmp->Create(is.GetWidth(),is.GetHeight(),proto);
				tmp->SetTransparentColor(is.GetTransparentColor());
				is.Blit(*tmp);
			}
			UnlockImageSurface(is);
			rdPtr->targetValid = true;
		}
		//Create empty image if wanted
		else
		{
			cSurface *tmp = new cSurface;
			rdPtr->surf->push_back(new SImage(tmp));
			//Empty image with size
			if(edPtr->loadFirst)
			{
				GetSurfacePrototype(&proto,rdPtr->depth,ST_MEMORYWITHDC,SD_DIB);
				tmp->Create(edPtr->width,edPtr->height,proto);
				tmp->Fill(BLACK);
			}
			rdPtr->targetId = rdPtr->currentId = rdPtr->lastId = 0;
			TargetImg = CurrentImg = tmp;
			rdPtr->targetValid = TargetImg->IsValid();
		}
	}
	
	//Initialize information
	if(rdPtr->current)
	{	
		rdPtr->rHo.hoImgWidth = rdPtr->current->GetWidth();
		rdPtr->rHo.hoImgHeight = rdPtr->current->GetHeight();
		rdPtr->rHo.hoImgXSpot = ImageS(rdPtr->currentId)->hotX;
		rdPtr->rHo.hoImgYSpot = ImageS(rdPtr->currentId)->hotY;
	}

	// No errors
		return 0;
}
示例#10
0
void WINAPI DLLExport EditorDisplay(mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr, RECT FAR *rc)
{
#ifndef RUN_ONLY

	// This is a simple case of drawing an image onto MMF's frame editor window
	// First, we must get a pointer to the surface used by the frame editor

	LPSURFACE ps = WinGetSurface((int)mV->mvIdEditWin);
	if ( ps != NULL )		// Do the following if this surface exists
	{

        int x = rc->left;
        int y = rc->top;
        int w = rc->right-rc->left;
        int h = rc->bottom-rc->top;



		cSurface is;			// New surface variable for us to use
		is.Create(4, 4, ps);	// Create a surface implementation from a prototype (frame editor win)
 
		is.LoadImage(hInstLib, EXO_IMAGE, LI_NONE);	// Load our bitmap from the resource,
		
        COLORREF color;
        is.GetPixel(0,0,color);
        
        ps->Fill(x, y, w, h, color);

        ps->Rectangle(x+4,y+4,rc->right-4,rc->bottom -4, (COLORREF)0x000000, 1, (COLORREF)0x000000, false);
        ps->Rectangle(x,y,x+36,y+36,color,0,color,true);
        ps->Line(rc->right-112,rc->bottom-5,rc->right-8,rc->bottom-5,1,color);


		// This actually blits (or copies) the whole of our surface onto the frame editor's surface
		// at a specified position.
		// We could use different image effects when we copy, e.g. invert, AND, OR, XOR,
		// blend (semi-transparent, the 6th param is amount of transparency)
		// You can 'anti-alias' with the 7th param (default=0 or off)      

        is.Blit(*ps, x, y, BMODE_TRANSP, BOP_COPY, 0);	// Blit the image to the frame editor surface!

        		// Create font
		HFONT hFnt = NULL;

		// Ink effects
		BOOL bTransp = ((oiPtr->oiHdr.oiInkEffect & EFFECTFLAG_TRANSPARENT) != 0);
		BlitMode bm = (bTransp) ? BMODE_TRANSP : BMODE_OPAQUE;
		BOOL bAntiA = (oiPtr->oiHdr.oiInkEffect & EFFECTFLAG_ANTIALIAS) ? TRUE : FALSE;
		BlitOp bo = (BlitOp)(oiPtr->oiHdr.oiInkEffect & EFFECT_MASK);
		LPARAM boParam = oiPtr->oiHdr.oiInkEffectParam;

		// Draw text
		DWORD dwDTFlags =  DT_RIGHT | DT_BOTTOM | DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS;
		ps->DrawText("Exclusion Zone", 14, rc, dwDTFlags, 0x000000, hFnt,
					 bm, bo, boParam, bAntiA, 0UL,8UL);

		// Delete font
		if ( hFnt != NULL )
			DeleteObject(hFnt);

        
        
	}

#endif // !RUN_ONLY
}