Пример #1
0
TextEdit::~TextEdit(void)
{
	Video *video = core->GetVideoDriver();
	gamedata->FreePalette( palette );
	free( Buffer );
	video->FreeSprite( Back );
	video->FreeSprite( Cursor );
}
Пример #2
0
MapControl::~MapControl(void)
{
	Video *video = core->GetVideoDriver();

	if (MapMOS) {
		video->FreeSprite(MapMOS);
	}
	for(int i=0;i<8;i++) {
		if (Flag[i]) {
			video->FreeSprite(Flag[i]);
		}
	}
}
Пример #3
0
Button::~Button()
{
	Video* video = core->GetVideoDriver();
	video->FreeSprite( Disabled );
	video->FreeSprite( Selected );
	video->FreeSprite( Pressed );
	video->FreeSprite( Unpressed );
	video->FreeSprite( Picture );
	ClearPictureList();
	if (Text) {
		free( Text );
	}
	gamedata->FreePalette( normal_palette);
	gamedata->FreePalette( disabled_palette);
}
Пример #4
0
Font::~Font(void)
{
	Video *video = core->GetVideoDriver();
	video->FreeSprite( sprBuffer );
	SetPalette(NULL);

	free(resRefs);
}
Пример #5
0
/** Clears the list of Pictures */
void Button::ClearPictureList()
{
	Video* video = core->GetVideoDriver();
	for (std::list<Sprite2D*>::iterator iter = PictureList.begin();
		 iter != PictureList.end(); ++iter)
		video->FreeSprite( *iter );
	PictureList.clear();
	MarkDirty();
}
Пример #6
0
Animation::~Animation(void)
{
	Video *video = core->GetVideoDriver();

	for (unsigned int i = 0; i < indicesCount; i++) {
		video->FreeSprite( frames[i] );
	}
	free(frames);
}
Пример #7
0
/** Clears the list of Pictures */
void Button::ClearPictureList()
{
	Video* video = core->GetVideoDriver();
	for (std::list<Sprite2D*>::iterator iter = PictureList.begin();
		 iter != PictureList.end(); ++iter)
		video->FreeSprite( *iter );
	PictureList.clear();
	Changed = true;
	Owner->Invalidate();
}
Пример #8
0
Button::~Button()
{
	Video* video = core->GetVideoDriver();
	SetImage(BUTTON_IMAGE_NONE, NULL);
	video->FreeSprite( Picture );
	ClearPictureList();
	if (Text) {
		free( Text );
	}
	gamedata->FreePalette( normal_palette);
	gamedata->FreePalette( disabled_palette);
}
Пример #9
0
void Animation::MirrorAnimationVert()
{
	Video *video = core->GetVideoDriver();

	for (size_t i = 0; i < indicesCount; i++) {
		Sprite2D * tmp = frames[i];
		frames[i] = video->MirrorSpriteVertical( tmp, true );
		video->FreeSprite(tmp);
	}

	// flip animArea vertically as well
//	animArea.y = -animArea.h - animArea.y;
}
Пример #10
0
void Animation::MirrorAnimation()
{
	Video *video = core->GetVideoDriver();

	for (size_t i = 0; i < indicesCount; i++) {
		Sprite2D * tmp = frames[i];
		frames[i] = video->MirrorSpriteHorizontal( tmp, true );
		video->FreeSprite(tmp);
	}

	// flip animArea horizontally as well
	animArea.x = -animArea.w - animArea.x;
}
Пример #11
0
Font::~Font(void)
{
    Video *video = core->GetVideoDriver();
    gamedata->FreePalette( palette );
    video->FreeSprite( sprBuffer );
}
Пример #12
0
/*
glyphs should be all characters we are interested in printing with the font save whitespace
Font takes responsibility for glyphs so we must free them once done
*/
Font::Font(Sprite2D* glyphs[], ieWord firstChar, ieWord lastChar, Palette* pal)
	: glyphCount(lastChar - firstChar + 1), glyphInfo(glyphCount), whiteSpace()
{
	assert(glyphs);
	assert(pal);
	assert(firstChar <= lastChar);

	FirstChar = firstChar;
	LastChar = lastChar;

	palette = NULL;
	resRefs = NULL;
	numResRefs = 0;
	maxHeight = 0;

	ptSize = 0;
	name[0] = '\0';
	style = NORMAL;

	SetPalette(pal);

	int w = 0;
	glyphCount = lastChar - firstChar + 1;

	unsigned int lastX = 0;
	Sprite2D* currGlyph = NULL;
	ieWord i;
	for (i = 0; i < glyphCount; i++) { // printable characters range perhaps minus whitespace (whitespace handled later)
		currGlyph = glyphs[i];
		if (!currGlyph) { // not printble
			glyphInfo[i].size.x = 0;
			glyphInfo[i].size.y = 0;
			glyphInfo[i].size.w = 0;
			glyphInfo[i].size.h = 0;
			glyphInfo[i].xPos = 0;
			glyphInfo[i].yPos = 0;
			continue;
		}

		w += currGlyph->Width;
		if (currGlyph->Height > maxHeight) maxHeight = currGlyph->Height;

		glyphInfo[i].size.x = lastX;
		glyphInfo[i].size.y = 0;
		glyphInfo[i].size.w = currGlyph->Width;
		glyphInfo[i].size.h = currGlyph->Height;
		glyphInfo[i].xPos = currGlyph->XPos;
		glyphInfo[i].yPos = currGlyph->YPos;
		lastX += currGlyph->Width;
	}

	// we dont really need a whitespace sprite since its blank we just need its size
	if (FirstChar > ' ') whiteSpace[1].size = Region(0, 0, (int)(maxHeight * 0.25), 0);// standard space width is 1/4 ptSize
	if (FirstChar > '\t') whiteSpace[2].size = Region(0, 0, (whiteSpace[1].size.w * 4), 0);// standard tab width is 4 spaces???

	Video* video = core->GetVideoDriver();

	//cast to uchar because uchar is 1 byte and we can do pointer arithmatic with it.
	unsigned char* tmpPixels = (unsigned char*)malloc(w * maxHeight);

	lastX = 0;
	for (i = 0; i < glyphCount; i++) { //printable characters range perhapps minus whitespace (whitespace handled later)
		currGlyph = glyphs[i];
		if (!currGlyph) continue;

		assert(currGlyph->Bpp == 8);
		// copy the pixels into the buffer
		// this is assuming the width will be the pitch
		unsigned char * dstPtr = (unsigned char*)tmpPixels + lastX;
		unsigned char * srcPtr = (unsigned char*)currGlyph->pixels;
		for (int glyphY = 0; glyphY < currGlyph->Height; glyphY++) {
			memcpy( dstPtr, srcPtr, currGlyph->Width);
			srcPtr += currGlyph->Width;
			dstPtr += w;
		}
		lastX += currGlyph->Width;

		video->FreeSprite(currGlyph);
	}

	sprBuffer = core->GetVideoDriver()->CreateSprite8(w, maxHeight, 8, (void*)tmpPixels, pal->col, true, 0);
}
Пример #13
0
/** Draws the Control on the Output Display */
void WorldMapControl::Draw(unsigned short XWin, unsigned short YWin)
{
	WorldMap* worldmap = core->GetWorldMap();
	if (!Width || !Height) {
		return;
	}
	if(!Changed)
		return;
	Changed = false;
	Video* video = core->GetVideoDriver();
	Region r( XWin+XPos, YWin+YPos, Width, Height );
	Region clipbackup;
	video->GetClipRect(clipbackup);
	video->SetClipRect(&r);
	video->BlitSprite( worldmap->GetMapMOS(), MAP_TO_SCREENX(0), MAP_TO_SCREENY(0), true, &r );

	unsigned int i;
	unsigned int ec = worldmap->GetEntryCount();
	for(i=0;i<ec;i++) {
		WMPAreaEntry *m = worldmap->GetEntry(i);
		if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;

		int xOffs = MAP_TO_SCREENX(m->X);
		int yOffs = MAP_TO_SCREENY(m->Y);
		Sprite2D* icon = m->GetMapIcon(worldmap->bam);
		if( icon ) {
			if (m == Area) {
				Palette *pal = icon->GetPalette();
				icon->SetPalette(pal_selected);
				video->BlitSprite( icon, xOffs, yOffs, true, &r );
				icon->SetPalette(pal);
				pal->Release();
			} else {
				video->BlitSprite( icon, xOffs, yOffs, true, &r );
			}
			video->FreeSprite( icon );
		}

		if (AnimPicture && !strnicmp(m->AreaResRef, currentArea, 8) ) {
			video->BlitSprite( AnimPicture, xOffs, yOffs, true, &r );
		}
	}

	// Draw WMP entry labels
	if (ftext==NULL) {
		video->SetClipRect(&clipbackup);
		return;
	}
	for(i=0;i<ec;i++) {
		WMPAreaEntry *m = worldmap->GetEntry(i);
		if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;
		Sprite2D *icon=m->GetMapIcon(worldmap->bam);
		int h=0,w=0,xpos=0,ypos=0;
		if (icon) {
			h=icon->Height;
			w=icon->Width;
			xpos=icon->XPos;
			ypos=icon->YPos;
			video->FreeSprite( icon );
		}

		Region r2 = Region( MAP_TO_SCREENX(m->X-xpos), MAP_TO_SCREENY(m->Y-ypos), w, h );
		if (!m->GetCaption())
			continue;

		int tw = ftext->CalcStringWidth( (unsigned char*)m->GetCaption() ) + 5;
		int th = ftext->maxHeight;
		
		Palette* text_pal = pal_normal;
		
		if (Area == m) {
			text_pal = pal_selected;
		} else {
			if (! (m->GetAreaStatus() & WMP_ENTRY_VISITED)) {
				text_pal = pal_notvisited;
			}
		}

		ftext->Print( Region( r2.x + (r2.w - tw)/2, r2.y + r2.h, tw, th ),
				( const unsigned char * ) m->GetCaption(), text_pal, 0, true );
	}
	video->SetClipRect(&clipbackup);
}