Example #1
0
// pValidRect or origin may be NULL
BOOLEAN
GetContextValidRect (RECT *pValidRect, POINT *origin)
{
    RECT tempRect;
    POINT tempPt;
    if (!pValidRect)
        pValidRect = &tempRect;
    if (!origin)
        origin = &tempPt;

    // Start with a rect the size of foreground frame
    pValidRect->corner.x = 0;
    pValidRect->corner.y = 0;
    pValidRect->extent = GetFrameBounds (_CurFramePtr);
    *origin = _CurFramePtr->HotSpot;


    if (_pCurContext->ClipRect.extent.width)
    {
        // If the cliprect is completely outside of the valid frame
        // bounds we have nothing to draw
        if (!BoxIntersect (&_pCurContext->ClipRect,
                           pValidRect, pValidRect))
            return (FALSE);

        // Foreground frame hotspot defines a drawing position offset
        // WRT the context cliprect
        origin->x += _pCurContext->ClipRect.corner.x;
        origin->y += _pCurContext->ClipRect.corner.y;
    }

    return (TRUE);
}
void
InitSlider (int x, int y, int width, FRAME sliderFrame, FRAME buttonFrame)
{
	EXTENT sliderSize = GetFrameBounds (sliderFrame);
	EXTENT buttonSize = GetFrameBounds (buttonFrame);

	sliderStamp.origin.x = x;
	sliderStamp.origin.y = y;
	sliderStamp.frame = sliderFrame;
	
	buttonStamp.origin.x = x;
	buttonStamp.origin.y = y - ((buttonSize.height - sliderSize.height) / 2);
	buttonStamp.frame = buttonFrame;

	sliderSpace = width - buttonSize.width;
}
// Returns a rect based at 0,0 and the size of context foreground frame
static inline RECT
_get_context_fg_rect (void)
{
	RECT r = { {0, 0}, {0, 0} };
	if (_CurFramePtr)
		r.extent = GetFrameBounds (_CurFramePtr);
	return r;
}
Example #4
0
void AnimatedSprite::render(SDL_Surface* screen) {
    if ( this->isCursorInSprite() ) {
        SpriteManager::mouseEventFrom = this->getName();
    }

    if (frame >= frameBegin && frame <= frameEnd) {
        SDL_Rect location = getPosition();
        clip = GetFrameBounds();
        SDL_BlitSurface(image, &clip, screen, &location);
    } else {
       frame = frameBegin;
    }
}
void
InitOscilloscope (FRAME scopeBg)
{
	scope_frame = scopeBg;
	if (!scope_init)
	{
		EXTENT size = GetFrameBounds (scope_frame);
		POINT midPt = {size.width / 2, size.height / 2};

		// mid-image pixel defines the color of scope lines
		scopeColor = GetFramePixel (scope_frame, midPt);
		
		scopeWork = CaptureDrawable (CreateDrawable (
				WANT_PIXMAP | MAPPED_TO_DISPLAY,
				size.width, size.height, 1));

		// assume and subtract the borders
		scopeSize.width = size.width - 2;
		scopeSize.height = size.height - 2;

		scope_init = 1;
	}
}
Example #6
0
static void
DrawCargoDisplay (void)
{
	STAMP s;
	TEXT t;
	RECT r;
	COORD cy;
	COUNT i;

	r.corner.x = 2;
	r.extent.width = FIELD_WIDTH + 1;
	r.corner.y = 20;
	// XXX: Shouldn't the height be 1 less? This draws the bottom border
	//   1 pixel too low. Or if not, why do we need another box anyway?
	r.extent.height = 129 - r.corner.y;
	DrawStarConBox (&r, 1,
			SHADOWBOX_MEDIUM_COLOR, SHADOWBOX_DARK_COLOR,
			TRUE, CARGO_BACK_COLOR);

	// draw the "CARGO" title
	SetContextFont (StarConFont);
	t.baseline.x = (STATUS_WIDTH >> 1) - 1;
	t.baseline.y = 27;
	t.align = ALIGN_CENTER;
	t.pStr = GAME_STRING (CARGO_STRING_BASE);
	t.CharCount = (COUNT)~0;
	SetContextForeGroundColor (CARGO_SELECTED_AMOUNT_COLOR);
	font_DrawText (&t);

	SetContextFont (TinyFont);

	s.frame = SetAbsFrameIndex (MiscDataFrame,
			(NUM_SCANDOT_TRANSITIONS * 2) + 3);
	r.corner.x = ELEMENT_COL_0;
	r.extent = GetFrameBounds (s.frame);
	s.origin.x = r.corner.x + (r.extent.width >> 1);

	cy = ELEMENT_ORG_Y;

	// print element column headings
	t.align = ALIGN_RIGHT;
	t.baseline.y = cy - 1;
	t.CharCount = (COUNT)~0;

	SetContextForeGroundColor (CARGO_WORTH_COLOR);
	t.baseline.x = ELEMENT_COL_1;
	t.pStr = "$";
	font_DrawText (&t);

	t.baseline.x = ELEMENT_COL_2;
	t.pStr = "#";
	font_DrawText (&t);

	// draw element icons and print amounts
	for (i = 0; i < NUM_ELEMENT_CATEGORIES; ++i, cy += ELEMENT_SPACING_Y)
	{
		// erase background under an element icon
		SetContextForeGroundColor (BLACK_COLOR);
		r.corner.y = cy;
		DrawFilledRectangle (&r);

		// draw an element icon
		s.origin.y = r.corner.y + (r.extent.height >> 1);
		DrawStamp (&s);
		s.frame = SetRelFrameIndex (s.frame, 5);

		DrawElementAmount (i, false);
	}

	// erase background under the Bio icon
	SetContextForeGroundColor (BLACK_COLOR);
	r.corner.y = BIO_ORG_Y;
	DrawFilledRectangle (&r);

	// draw the Bio icon
	s.origin.y = r.corner.y + (r.extent.height >> 1);
	s.frame = SetAbsFrameIndex (s.frame, 68);
	DrawStamp (&s);

	// print the Bio amount
	DrawElementAmount (NUM_ELEMENT_CATEGORIES, false);

	// draw the line over the Bio amount
	r.corner.x = 4;
	r.corner.y = BIO_ORG_Y - 2;
	r.extent.width = FIELD_WIDTH - 3;
	r.extent.height = 1;
	SetContextForeGroundColor (CARGO_SELECTED_BACK_COLOR);
	DrawFilledRectangle (&r);

	// print "Free"
	t.baseline.x = 5;
	t.baseline.y = FREE_ORG_Y + TEXT_BASELINE;
	t.align = ALIGN_LEFT;
	t.pStr = GAME_STRING (CARGO_STRING_BASE + 1);
	t.CharCount = (COUNT)~0;
	font_DrawText (&t);

	ShowRemainingCapacity ();
}