Пример #1
0
void CStatusScreenGalaxy::GenerateStatusEp4()
{
    SDL_Rect EditRect;
    drawBase(EditRect);

    GsFont &Font = gGraphics.getFont(0);
    Font.setupColor(0x555555);

    Font.drawFontCentered(mStatusSurface.getSDLSurface(), "LOCATION", EditRect.x, EditRect.w, EditRect.y, false);


    // drawing Rect for stuff like background for scores and items
    SDL_Rect TempRect;

    // Location Rect
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+10;
    TempRect.w = EditRect.w;
    TempRect.h = 20;

    Font.setupColor(0x0);

    mStatusSurface.fillRGBA(TempRect, 0xFF, 0xFF, 0xFF, 0xFF);
    Font.drawFontCentered(mStatusSurface.getSDLSurface(),
                          m_Item.mLevelName,
                          TempRect.x,
                          TempRect.w,
                          TempRect.y+6,
                          false);
    Font.setupColor(mStatusSurface.mapRGB(0x44, 0x44, 0x44));


    /// SCORE and EXTRA Rect
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+32;
    TempRect.w = EditRect.w/2; TempRect.h = 10;
    Font.drawFont(mStatusSurface, "SCORE            EXTRA", TempRect.x+16, TempRect.y, false);
    TempRect.w = (EditRect.w/2)-16; TempRect.h = 11;
    TempRect.y = EditRect.y+42;

    // Score Box
    TempRect.w = 8*8;
    mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_points), 8), TempRect.x, TempRect.y+2,
                         mStatusSurface.getSDLSurface());

    // Extra Box
    TempRect.x = EditRect.x+96;
    mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifeAt), 8),
                         TempRect.x, TempRect.y+2,
                         mStatusSurface.getSDLSurface());

    byte *ptr = gKeenFiles.exeFile.getRawData();

    std::string rescLine = "RESCUED           LEVEL";
    std::string dropsLine;
    std::string swLine;

    char rescBuf[9];
    char dropsBuf[9];
    char swBuf[9];

    memcpy(rescBuf, ptr+0x2F49C, 9 );
    memcpy(dropsBuf, ptr+0x2F4CB, 9 );
    memcpy(swBuf, ptr+0x2F4D1, 9 );

    rescLine.replace ( 0, 7, (const char*)rescBuf );
    dropsLine = dropsBuf;
    swLine = swBuf;

    /// RESCUED and LEVEL Rects
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+56;
    TempRect.w = EditRect.w/2; TempRect.h = 10;
    Font.drawFont(mStatusSurface, rescLine, TempRect.x+8, TempRect.y, false);
    TempRect.w = (EditRect.w/2)-16; TempRect.h = 11;
    TempRect.y = EditRect.y+66;

    // Rescued Box
    TempRect.w = 8*8;
    mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
    for( int count=0 ; count<m_Item.m_special.elders ; count++ )
    {
        gGraphics.drawDigit(40,
                            TempRect.x+8*count,
                            TempRect.y+1,
                            mStatusSurface.getSDLSurface());
    }

    // Level Box
    TempRect.x = EditRect.x+96;
    mStatusSurface.fillRGBA(TempRect, 0xFF, 0xFF, 0xFF, 0xFF);
    Font.setupColor(0x0);

    const std::string difftext = getDifficultyText();

    Font.drawFontCentered(mStatusSurface.getSDLSurface(), difftext, TempRect.x, TempRect.w, TempRect.y+1, false);
    Font.setupColor(0x333333);

    // Keys Box
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+80;
    Font.drawFont(mStatusSurface, "KEYS", TempRect.x, TempRect.y, false);
    TempRect.w = 8*4; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5;


    mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);

    if(m_Item.m_gem.red)
    {
        gGraphics.drawDigit(36, TempRect.x, TempRect.y+1, mStatusSurface.getSDLSurface());
    }
    if(m_Item.m_gem.yellow)
    {
        gGraphics.drawDigit(37, TempRect.x+8, TempRect.y+1, mStatusSurface.getSDLSurface());
    }
    if(m_Item.m_gem.blue)
    {
        gGraphics.drawDigit(38, TempRect.x+16, TempRect.y+1, mStatusSurface.getSDLSurface());
    }
    if(m_Item.m_gem.green)
    {
        gGraphics.drawDigit(39, TempRect.x+24, TempRect.y+1, mStatusSurface.getSDLSurface());
    }

    // Ammo Box
    TempRect.x = EditRect.x+96;
    TempRect.y = EditRect.y+80;
    Font.drawFont(mStatusSurface, "AMMO", TempRect.x, TempRect.y, false);
    TempRect.w = 8*3; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5;

    mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_bullets), 3),
                         TempRect.x, TempRect.y+1,
                         mStatusSurface.getSDLSurface());

    // Keens Box
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+96;
    Font.drawFont(mStatusSurface, "KEENS", TempRect.x, TempRect.y, false);
    TempRect.w = 8*2; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5+8;
    mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifes), 2),
                         TempRect.x,
                         TempRect.y+1,
                         mStatusSurface.getSDLSurface());

    // Drops Box
    TempRect.x = EditRect.x+96;
    TempRect.y = EditRect.y+96;
    Font.drawFont(mStatusSurface, dropsLine, TempRect.x, TempRect.y, false);
    TempRect.w = 8*2; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5+8;

    mStatusSurface.fillRGBA(TempRect, 0x0, 0x0, 0x0, 0xFF);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_drops), 2),
                         TempRect.x,
                         TempRect.y+1,
                         mStatusSurface.getSDLSurface());

    // Swim Suit Box
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+114;
    TempRect.w = (EditRect.w/2)-16; TempRect.h = 11;

    mStatusSurface.fillRGBA(TempRect, 0xFF, 0xFF, 0xFF, 0xFF);
    Font.setupColor(0x0);
    Font.drawFontCentered(mStatusSurface.getSDLSurface(),
                          m_Item.m_special.swimsuit ? swLine : "???",
                          TempRect.x,
                          TempRect.w,
                          TempRect.y+1, false);

    // Press a Key Sign
    GsTilemap &Tilemap = gGraphics.getTileMap(2);
    TempRect.x = EditRect.x+(EditRect.w/2);
    TempRect.y = EditRect.y+110;
    for( int c=0 ; c<10 ; c++ )
    {
        Tilemap.drawTile(mStatusSurface, TempRect.x+c*8, TempRect.y, 72+c);
    }
    TempRect.y += 8;
    for( int c=0 ; c<10 ; c++ )
    {
        Tilemap.drawTile(mStatusSurface, TempRect.x+c*8, TempRect.y, 82+c);
    }
}
Пример #2
0
void CStatusScreenGalaxy::GenerateStatusEp5()
{
    SDL_Rect EditRect;
    drawBase(EditRect);

    GsFont &Font = gGraphics.getFont(0);
    Font.setupColor(0x555555);

    Font.drawFontCentered(mStatusSurface.getSDLSurface(), "LOCATION",
                          EditRect.x, EditRect.w, EditRect.y, false);

    // Temporary Rect for drawing some stuff like background for scores and so...
    SDL_Rect TempRect;

    // Location Rect
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+10;
    TempRect.w = EditRect.w;
    TempRect.h = 20;

    Font.setupColor(0x0);

    mStatusSurface.fillRGBA(TempRect, 0xFF, 0xFF, 0xFF, 0xFF);

    Font.drawFontCentered(mStatusSurface.getSDLSurface(), m_Item.mLevelName, TempRect.x, TempRect.w, TempRect.y+6, false);
    Font.setupColor(0x444444);


    /// SCORE and EXTRA Rect
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+32;
    TempRect.w = EditRect.w/2; TempRect.h = 10;
    Font.drawFont(mStatusSurface.getSDLSurface(), "SCORE            EXTRA", TempRect.x+16, TempRect.y, false);
    TempRect.w = (EditRect.w/2)-16; TempRect.h = 11;
    TempRect.y = EditRect.y+42;

    // Score Box
    TempRect.w = 8*8;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFF000000);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_points), 8), TempRect.x, TempRect.y+2, mStatusSurface.getSDLSurface());

    // Extra Box
    TempRect.x = EditRect.x+96;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFF000000);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifeAt), 8), TempRect.x, TempRect.y+2, mStatusSurface.getSDLSurface());

    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+56;
    Font.drawFont(mStatusSurface.getSDLSurface(), "KEYCARD", TempRect.x, TempRect.y+4, false);

    // Small Keycard Box
    TempRect.y = EditRect.y+59;
    TempRect.x = EditRect.x+54;
    TempRect.w = 10;
    TempRect.h = 10;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFF000000);
    if(m_Item.m_keycards)
    {
        gGraphics.drawDigit(40, TempRect.x+1, TempRect.y+1, mStatusSurface.getSDLSurface());
    }

    // LEVEL Rects
    TempRect.w = EditRect.w/2;
    TempRect.x = EditRect.x+24;
    TempRect.y = EditRect.y+56;
    Font.drawFont(mStatusSurface.getSDLSurface(), "                  LEVEL", TempRect.x, TempRect.y, false);
    TempRect.h = 11;
    TempRect.y = EditRect.y+66;


    // Level Box
    TempRect.x = EditRect.x+96;
    TempRect.w = 64;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFFFFFFFF);
    Font.setupColor(0x0);

    const std::string difftext = getDifficultyText();

    Font.drawFontCentered(mStatusSurface.getSDLSurface(), difftext, TempRect.x, TempRect.w, TempRect.y+1, false);
    Font.setupColor(0x333333);

    // Keys Box
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+80;
    Font.drawFont(mStatusSurface.getSDLSurface(), "KEYS", TempRect.x, TempRect.y, false);
    TempRect.w = 8*4; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFF000000);
    if(m_Item.m_gem.red)
        gGraphics.drawDigit(36, TempRect.x, TempRect.y+1, mStatusSurface.getSDLSurface());
    if(m_Item.m_gem.yellow)
        gGraphics.drawDigit(37, TempRect.x+8, TempRect.y+1, mStatusSurface.getSDLSurface());
    if(m_Item.m_gem.blue)
        gGraphics.drawDigit(38, TempRect.x+16, TempRect.y+1, mStatusSurface.getSDLSurface());
    if(m_Item.m_gem.green)
        gGraphics.drawDigit(39, TempRect.x+24, TempRect.y+1, mStatusSurface.getSDLSurface());

    // Ammo Box
    TempRect.x = EditRect.x+96;
    TempRect.y = EditRect.y+80;
    Font.drawFont(mStatusSurface.getSDLSurface(), "AMMO", TempRect.x, TempRect.y, false);
    TempRect.w = 8*3; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFF000000);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_bullets), 3), TempRect.x, TempRect.y+1, mStatusSurface.getSDLSurface());

    // Keens Box
    TempRect.x = EditRect.x;
    TempRect.y = EditRect.y+96;
    Font.drawFont(mStatusSurface.getSDLSurface(), "KEENS", TempRect.x, TempRect.y, false);
    TempRect.w = 8*2; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5+8;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFF000000);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifes), 2), TempRect.x, TempRect.y+1, mStatusSurface.getSDLSurface());

    // Drops Box
    TempRect.x = EditRect.x+96;
    TempRect.y = EditRect.y+96;
    Font.drawFont(mStatusSurface.getSDLSurface(), "VITALIN", TempRect.x, TempRect.y, false);
    TempRect.w = 8*2; TempRect.h = 10;
    TempRect.x = TempRect.x+8*5+8;
    SDL_FillRect(mStatusSurface.getSDLSurface(), &TempRect, 0xFF000000);
    gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_drops), 2), TempRect.x, TempRect.y+1, mStatusSurface.getSDLSurface());

    // Press a Key Sign
    GsTilemap &Tilemap = gGraphics.getTileMap(2);
    TempRect.x = EditRect.x+(EditRect.w-80)/2;
    TempRect.y = EditRect.y+110;
    for( int c=0 ; c<10 ; c++ )
    {
        Tilemap.drawTile(mStatusSurface.getSDLSurface(), TempRect.x+c*8, TempRect.y, 72+c);
        Tilemap.drawTile(mStatusSurface.getSDLSurface(), TempRect.x+c*8, TempRect.y+8, 82+c);
    }
}
Пример #3
0
/** Draws the object to the specified painter & x/y offsets */
void MLineObject::draw( FLStylePainter * p ) {
  drawBase( p );
}
Пример #4
0
	void M11TabBar::paintEvent(QPaintEvent*)
	{
		QStyleOptionTab tabOverlap;
		tabOverlap.shape = shape();
		int overlap = style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, this);
		QWidget *theParent = parentWidget();
		QStyleOptionTabBarBase optTabBase;
		optTabBase.init(this);
		optTabBase.shape = shape();
		if (theParent && overlap > 0) {
			QRect rect;
			switch (tabOverlap.shape) {
			case M11TabBar::RoundedNorth:
			case M11TabBar::TriangularNorth:
				rect.setRect(0, height() - overlap, width(), overlap);
				break;
			case M11TabBar::RoundedSouth:
			case M11TabBar::TriangularSouth:
				rect.setRect(0, 0, width(), overlap);
				break;
			case M11TabBar::RoundedEast:
			case M11TabBar::TriangularEast:
				rect.setRect(0, 0, overlap, height());
				break;
			case M11TabBar::RoundedWest:
			case M11TabBar::TriangularWest:
				rect.setRect(width() - overlap, 0, overlap, height());
				break;
			}
			optTabBase.rect = rect;
		}

		QStylePainter p(this);
		p.fillRect(rect(), Utils::instance().gradientTopToBottom(rect()));
		QPen pen = p.pen();

		int selected = -1;
		int cut = -1;
		bool rtl = optTabBase.direction == Qt::RightToLeft;
		bool verticalTabs = (shape() == M11TabBar::RoundedWest || shape() == M11TabBar::RoundedEast
		                     || shape() == M11TabBar::TriangularWest
		                     || shape() == M11TabBar::TriangularEast);
		QStyleOptionTab cutTab;
		QStyleOptionTab selectedTab;
		for (int i = 0; i < count(); ++i) {
			QStyleOptionTabV2 tab = getStyleOption(i);
			if (!(tab.state & QStyle::State_Enabled)) {
				tab.palette.setCurrentColorGroup(QPalette::Disabled);
			}
			// If this tab is partially obscured, make a note of it so that we can pass the information
			// along when we draw the tear.
			if ((!verticalTabs && (!rtl && tab.rect.left() < 0) ||
			     (rtl && tab.rect.right() > width())) ||
			    (verticalTabs && tab.rect.top() < 0)) {
				cut = i;
				cutTab = tab;
			}
			// Don't bother drawing a tab if the entire tab is outside of the visible tab bar.
			if ((!verticalTabs && (tab.rect.right() < 0 || tab.rect.left() > width()))
			    || (verticalTabs && (tab.rect.bottom() < 0 || tab.rect.top() > height())))
				continue;

			optTabBase.tabBarRect |= tab.rect;
			if (i == currentIndex()) {
				selected = i;
				selectedTab = tab;
				optTabBase.selectedTabRect = tab.rect;
			}

			QIcon icon = tabIcon(i);
			QSize iconSize = icon.actualSize(QSize(tab.rect.height(), tab.rect.height()));
			int iconMargin = (tab.rect.height() - iconSize.height()) / 2;
			QRect iconRect(tab.rect.left() + iconMargin, tab.rect.top(), iconSize.width(), tab.rect.height());
			QString text = tabText(i);
			QRect textRect(
			    tab.rect.left() + iconMargin + iconSize.width(),
			    tab.rect.top(),
			    tab.rect.width() - iconSize.width(),
			    tab.rect.height()
			);

			p.fillRect(
			    tab.rect,
			    i == currentIndex() ?
			    Utils::instance().palette().base() :
			    tab.rect.contains(mapFromGlobal(QCursor::pos())) ?
			    Utils::instance().palette().light() : Utils::instance().gradientTopToBottom(tab.rect)
			);

			p.setPen(Utils::instance().palette().dark().color());

			switch (shape()) { // override the widget's border to make it consistent over inactive tabs
			case M11TabBar::RoundedNorth:
			case M11TabBar::TriangularNorth:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(0, 0, -1, 0));
				}
				else {
					p.drawLine(tab.rect.bottomLeft(), tab.rect.bottomRight());
				}
				break;
			case M11TabBar::RoundedSouth:
			case M11TabBar::TriangularSouth:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(0, -1, -1, -1));
				}
				else {
					p.drawLine(tab.rect.topLeft(), tab.rect.topRight());
				}
				break;
			case M11TabBar::RoundedEast:
			case M11TabBar::TriangularEast:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(-1, 0, -1, -1));
				}
				else {
					p.drawLine(tab.rect.topLeft(), tab.rect.bottomLeft());
				}
				break;
			case M11TabBar::RoundedWest:
			case M11TabBar::TriangularWest:
				if (i == currentIndex()) {
					p.drawRect(tab.rect.adjusted(0, 0, 0, -1));
				}
				else {
					p.drawLine(tab.rect.topRight(), tab.rect.bottomRight());
				}
				break;
			default:
				Q_ASSERT(false);
				break;
			}

			p.setPen(m_tabLabelColors.contains(i) ? m_tabLabelColors.value(i).color() : pen);

			QString textToDraw = fontMetrics().elidedText(
			                         text,
			                         elideMode(),
			                         1 + (
			                             verticalTabs ? tabRect(i).height() : tabRect(i).width()
			                         ) - style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &tab, this),
			                         Qt::TextShowMnemonic
			                     );

			p.drawItemPixmap(iconRect, Qt::AlignCenter, icon.pixmap(iconSize));

			p.drawItemText(
			    textRect,
			    Qt::AlignLeft | Qt::AlignVCenter,
			    QPalette(),
			    tab.state & QStyle::State_Enabled,
			    textToDraw
			);

			p.setPen(pen);
		}

		if (!drawBase()) {
			p.setBackgroundMode(Qt::TransparentMode);
		}
		else {
			// p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
		}

		// Only draw the tear indicator if necessary. Most of the time we don't need too.
		if (cut >= 0) {
			cutTab.rect = rect();
			cutTab.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicator, &cutTab, this);
			p.drawPrimitive(QStyle::PE_IndicatorTabTear, cutTab);
		}

		// p.setPen(Qt::black);
		// p.drawRect(rect());
	}
Пример #5
0
void CStatusScreenGalaxyEp6::GenerateStatus()
{
	SDL_Rect EditRect;
	drawBase(EditRect);

	GsFont &Font = gGraphics.getFont(0);
	Font.setupColor(0x555555);

	Font.drawFontCentered(mpStatusSurface.get(), "LOCATION", EditRect.x, EditRect.w, EditRect.y, false);

	// Temporary Rect for drawing some stuff like background for scores and so...
	SDL_Rect TempRect;

	// Location Rect
	TempRect.x = EditRect.x;
	TempRect.y = EditRect.y+10;
	TempRect.w = EditRect.w;
	TempRect.h = 20;

	Font.setupColor(0x0);
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFFFFFFFF);
    Font.drawFontCentered(mpStatusSurface.get(), m_Item.mLevelName, TempRect.x, TempRect.w, TempRect.y+6, false);
	Font.setupColor(0x444444);


	/// SCORE and EXTRA Rect
	TempRect.x = EditRect.x;
	TempRect.y = EditRect.y+32;
	TempRect.w = EditRect.w/2; TempRect.h = 10;
	Font.drawFont(mpStatusSurface.get(), "SCORE            EXTRA", TempRect.x+16, TempRect.y);
	TempRect.w = (EditRect.w/2)-16; TempRect.h = 11;
	TempRect.y = EditRect.y+42;

	// Score Box
	TempRect.w = 8*8;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
	gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_points), 8), TempRect.x, TempRect.y+2, mpStatusSurface.get());

	// Extra Box
	TempRect.x = EditRect.x+96;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
	gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifeAt), 8), TempRect.x, TempRect.y+2, mpStatusSurface.get());
	
	// Items Box
	TempRect.x = EditRect.x;
	TempRect.y = EditRect.y+66;
	Font.drawFont(mpStatusSurface.get(), "ITEMS", TempRect.x, TempRect.y+1);
	
	TempRect.x = EditRect.x+44;
	TempRect.w = 30;
	TempRect.h = 10;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
	
	auto &spItem = m_Item.m_special.ep6;
	
	const int sandwichTile = (spItem.sandwich > 0) ? 2 : 1;
	const int hookTile = (spItem.hook > 0) ? 4 : 3;
	const int keycardTile = (spItem.rocketKeycard > 0) ? 6 : 5;	
	
	gGraphics.drawDigit(sandwichTile, TempRect.x+1, TempRect.y+1, mpStatusSurface.get());
	gGraphics.drawDigit(hookTile, TempRect.x+11, TempRect.y+1, mpStatusSurface.get());
	gGraphics.drawDigit(keycardTile, TempRect.x+21, TempRect.y+1, mpStatusSurface.get());

	// LEVEL Rects
	TempRect.w = EditRect.w/2;
	TempRect.x = EditRect.x+24;
	TempRect.y = EditRect.y+56;
	Font.drawFont(mpStatusSurface.get(), "                  LEVEL", TempRect.x, TempRect.y);	
	TempRect.h = 11;
	TempRect.y = EditRect.y+66;


	// Level Box
	TempRect.x = EditRect.x+96;
	TempRect.w = 64;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFFFFFFFF);
	Font.setupColor(0x0);

    const std::string difftext = getDifficultyText();
		
	Font.drawFontCentered(mpStatusSurface.get(), difftext, TempRect.x, TempRect.w, TempRect.y+1, false);
	Font.setupColor(0x333333);

	// Keys Box
	TempRect.x = EditRect.x;
	TempRect.y = EditRect.y+80;
	Font.drawFont(mpStatusSurface.get(), "KEYS", TempRect.x, TempRect.y);
	TempRect.w = 8*4; TempRect.h = 10;
	TempRect.x = TempRect.x+8*5;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
	if(m_Item.m_gem.red)
		gGraphics.drawDigit(36, TempRect.x, TempRect.y+1, mpStatusSurface.get());
	if(m_Item.m_gem.yellow)
		gGraphics.drawDigit(37, TempRect.x+8, TempRect.y+1, mpStatusSurface.get());
	if(m_Item.m_gem.blue)
		gGraphics.drawDigit(38, TempRect.x+16, TempRect.y+1, mpStatusSurface.get());
	if(m_Item.m_gem.green)
		gGraphics.drawDigit(39, TempRect.x+24, TempRect.y+1, mpStatusSurface.get());

	// Ammo Box
	TempRect.x = EditRect.x+96;
	TempRect.y = EditRect.y+80;
	Font.drawFont(mpStatusSurface.get(), "AMMO", TempRect.x, TempRect.y);
	TempRect.w = 8*3; TempRect.h = 10;
	TempRect.x = TempRect.x+8*5;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
	gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_bullets), 3), TempRect.x, TempRect.y+1, mpStatusSurface.get());

	// Keens Box
	TempRect.x = EditRect.x;
	TempRect.y = EditRect.y+96;
	Font.drawFont(mpStatusSurface.get(), "KEENS", TempRect.x, TempRect.y);
	TempRect.w = 8*2; TempRect.h = 10;
	TempRect.x = TempRect.x+8*5+8;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
	gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_lifes), 2), TempRect.x, TempRect.y+1, mpStatusSurface.get());

	// Drops Box
	TempRect.x = EditRect.x+96;
	TempRect.y = EditRect.y+96;
	Font.drawFont(mpStatusSurface.get(), "VIVAS", TempRect.x, TempRect.y);
	TempRect.w = 8*2; TempRect.h = 10;
	TempRect.x = TempRect.x+8*5+8;
	SDL_FillRect(mpStatusSurface.get(), &TempRect, 0xFF000000);
	gGraphics.drawDigits(getRightAlignedString(itoa(m_Item.m_drops), 2), TempRect.x, TempRect.y+1, mpStatusSurface.get());

	// Press a Key Sign
	GsTilemap &Tilemap = gGraphics.getTileMap(2);
	TempRect.x = EditRect.x+(EditRect.w-80)/2;
	TempRect.y = EditRect.y+110;
	for( int c=0 ; c<10 ; c++ )
	{
		Tilemap.drawTile(mpStatusSurface.get(), TempRect.x+c*8, TempRect.y, 72+c);
		Tilemap.drawTile(mpStatusSurface.get(), TempRect.x+c*8, TempRect.y+8, 82+c);
	}
}
Пример #6
0
void CompositionRenderer::paint(QPainter *painter)
{
#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
    if (usesOpenGL()) {

        int new_pbuf_size = m_pbuffer_size;
        if (size().width() > m_pbuffer_size ||
            size().height() > m_pbuffer_size)
            new_pbuf_size *= 2;

        if (size().width() < m_pbuffer_size/2 &&
            size().height() < m_pbuffer_size/2)
            new_pbuf_size /= 2;

        if (!m_pbuffer || new_pbuf_size != m_pbuffer_size) {
            if (m_pbuffer) {
                m_pbuffer->deleteTexture(m_base_tex);
                m_pbuffer->deleteTexture(m_compositing_tex);
                delete m_pbuffer;
            }

            m_pbuffer = new QGLPixelBuffer(QSize(new_pbuf_size, new_pbuf_size), QGLFormat::defaultFormat(), glWidget());
            m_pbuffer->makeCurrent();
            m_base_tex = m_pbuffer->generateDynamicTexture();
            m_compositing_tex = m_pbuffer->generateDynamicTexture();
            m_pbuffer_size = new_pbuf_size;
        }

        if (size() != m_previous_size) {
            m_previous_size = size();
            QPainter p(m_pbuffer);
            p.setCompositionMode(QPainter::CompositionMode_Source);
            p.fillRect(QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()), Qt::transparent);
            drawBase(p);
            p.end();
            m_pbuffer->updateDynamicTexture(m_base_tex);
        }

        qreal x_fraction = width()/float(m_pbuffer->width());
        qreal y_fraction = height()/float(m_pbuffer->height());

        {
            QPainter p(m_pbuffer);
            p.setCompositionMode(QPainter::CompositionMode_Source);
            p.fillRect(QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()), Qt::transparent);

            p.save(); // Needed when using the GL1 engine
            p.beginNativePainting(); // Needed when using the GL2 engine

            glBindTexture(GL_TEXTURE_2D, m_base_tex);
            glEnable(GL_TEXTURE_2D);
            glColor4f(1.,1.,1.,1.);

            glBegin(GL_QUADS);
            {
                glTexCoord2f(0, 1.0);
                glVertex2f(0, 0);

                glTexCoord2f(x_fraction, 1.0);
                glVertex2f(width(), 0);

                glTexCoord2f(x_fraction, 1.0-y_fraction);
                glVertex2f(width(), height());

                glTexCoord2f(0, 1.0-y_fraction);
                glVertex2f(0, height());
            }
            glEnd();

            glDisable(GL_TEXTURE_2D);

            p.endNativePainting(); // Needed when using the GL2 engine
            p.restore(); // Needed when using the GL1 engine

            drawSource(p);
            p.end();
            m_pbuffer->updateDynamicTexture(m_compositing_tex);
        }

        painter->beginNativePainting(); // Needed when using the GL2 engine
        glWidget()->makeCurrent(); // Needed when using the GL1 engine
        glBindTexture(GL_TEXTURE_2D, m_compositing_tex);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
        glColor4f(1.,1.,1.,1.);
        glBegin(GL_QUADS);
        {
            glTexCoord2f(0, 1.0);
            glVertex2f(0, 0);

            glTexCoord2f(x_fraction, 1.0);
            glVertex2f(width(), 0);

            glTexCoord2f(x_fraction, 1.0-y_fraction);
            glVertex2f(width(), height());

            glTexCoord2f(0, 1.0-y_fraction);
            glVertex2f(0, height());
        }
        glEnd();
        glDisable(GL_TEXTURE_2D);
        painter->endNativePainting(); // Needed when using the GL2 engine
    } else
#endif
    {
        // using a QImage
        if (m_buffer.size() != size()) {
#ifdef Q_WS_QWS
            m_base_buffer = QPixmap(size());
            m_base_buffer.fill(Qt::transparent);
#else
            m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);
            m_base_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);

            m_base_buffer.fill(0);
#endif

            QPainter p(&m_base_buffer);

            drawBase(p);
        }

#ifdef Q_WS_QWS
        m_buffer = m_base_buffer;
#else
        memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.byteCount());
#endif

        {
            QPainter p(&m_buffer);
            drawSource(p);
        }

#ifdef Q_WS_QWS
        painter->drawPixmap(0, 0, m_buffer);
#else
        painter->drawImage(0, 0, m_buffer);
#endif
    }
}
Пример #7
0
void Gui::draw(void) {
    drawBase();
    GuiElement::draw();
}
Пример #8
0
/** Draws the label using the specificed painter & x/y-offsets */
void MLabelObject::draw(QPainter* p, int xoffset, int yoffset){
    QFont font(fontFamily, fontSize, fontWeight, fontItalic);
    QPen textPen(foregroundColor, 0, QPen::NoPen);

    int tf;

        // Set the offsets
    int xcalc = xpos + xoffset;
    int ycalc = ypos + yoffset;

        // Draw the base
    drawBase(p, xoffset, yoffset);

        // Set the font
    p->setFont(font);
    QFontMetrics fm = p->fontMetrics();

        // Set the text alignment flags

        // Horizontal
    switch(hAlignment){
        case MLabelObject::Left:
            tf = QPainter::AlignLeft;
            break;
        case MLabelObject::Center:
            tf = QPainter::AlignHCenter;
            break;
        case MLabelObject::Right:
	    tf = QPainter::AlignRight;
    }

        // Vertical
    switch(vAlignment){
        case MLabelObject::Top:
            tf = tf | QPainter::AlignTop;
            break;
        case MLabelObject::Bottom:
            tf = tf | QPainter::AlignBottom;
            break;
        case MLabelObject::Middle:
	    tf = tf | QPainter::AlignVCenter;
    }

        // Word wrap
    if(wordWrap) tf = tf | QPainter::WordBreak;

        // Draw the text
    p->setPen(textPen);
    QString newtext = text;
    newtext.replace( QRegExp( "<br>", false ), QString( "\n" ) );
    p->drawText(xcalc + xMargin, ycalc + yMargin,
                width - xMargin, height - yMargin,
                tf, newtext);

        // leave this in place - possible use for other tags
        //
//          // ----------------------------------------
//          // look for line breaks (<br>)
//          // ----------------------------------------

//      int idx = 0;
//      int ysub = ycalc;
//      int line_height = height;
//      int len = text.length();
//      int line_len = len;
//      QString sep = "<br>";
//      int len_sep = sep.length();
//      while ( idx < len )
//      {
//          int eol = text.find( sep, idx, FALSE );
//          if ( eol < 0 )
//              eol = len;
        
//          line_len = eol - idx;

//              // draw the line and determine the space used.
//          QRect brect = p->boundingRect(xcalc + xMargin, ysub + yMargin,
//                                        width - xMargin, line_height - yMargin,
//                                        tf, text.mid( idx, line_len ), line_len);
//          p->drawText( xcalc + xMargin, ysub + yMargin,
//                       width - xMargin, line_height - yMargin,
//                       tf, text.mid( idx, line_len ), line_len );

//              // substract the vert space used.
//          ysub += brect.height();
//          line_height -= brect.height();
        
//              // nothing more
//          if ( eol == len )
//              break;
//          else
//              idx = eol + len_sep;
//      }
}
Пример #9
0
/** Draws the object to the specified painter & x/y offsets */
void MLineObject::draw( QPainter* p, int xoffset, int yoffset )
{
    drawBase( p, xoffset, yoffset );
}