Exemplo n.º 1
0
/* Draw bottom tabs */
static void formDisplayBTabs(W_TABFORM *psForm,SDWORD x0, SDWORD y0,
							 UDWORD width, UDWORD height,
							 UDWORD number, UDWORD selected, UDWORD hilite,
							 PIELIGHT *pColours,UDWORD TabType,UDWORD TabGap)
{
	SDWORD	x,x1, y1;
	UDWORD	i;

#if NO_DISPLAY_SINGLE_TABS
	if (number == 1)
	{
		/* Don't display single tabs */
		return;
	}
#endif

	x = x0 + 2;
	x1 = x + width - 2;
	y1 = y0 + height;
	for (i=0; i < number; i++)
	{
		if(psForm->pTabDisplay) {
			psForm->pTabDisplay((WIDGET*)psForm,TabType,WFORM_TABBOTTOM,i,i==selected,i==hilite,x,y0,width,height);
		} else {
			if (i == selected)
			{
				/* Fill in the tab */
				pie_BoxFill(x + 1, y0, x1 - 1, y1 - 1, pColours[WCOL_BKGRND]);
				/* Draw the outline */
				iV_Line(x,y0, x,y1-1, pColours[WCOL_LIGHT]);
				iV_Line(x,y1, x1-3,y1, pColours[WCOL_DARK]);
				iV_Line(x1-2,y1, x1,y1-2, pColours[WCOL_DARK]);
				iV_Line(x1,y1-3, x1,y0+1, pColours[WCOL_DARK]);
			}
			else
			{
				/* Fill in the tab */
				pie_BoxFill(x + 1, y0 + 1, x1 - 1, y1 - 2, pColours[WCOL_BKGRND]);
				/* Draw the outline */
				iV_Line(x,y0+1, x,y1-1, pColours[WCOL_LIGHT]);
				iV_Line(x+1,y1-1, x1-3,y1-1, pColours[WCOL_DARK]);
				iV_Line(x1-2,y1-1, x1,y1-3, pColours[WCOL_DARK]);
				iV_Line(x1,y1-4, x1,y0+1, pColours[WCOL_DARK]);
			}
			if (i == hilite)
			{
				/* Draw the hilite box */
				iV_Box(x+2,y0+3, x1-3, y1-4, pColours[WCOL_HILITE]);
			}
		}
		x += width + TabGap;
		x1 += width + TabGap;
	}
}
Exemplo n.º 2
0
void W_BUTTON::display(int xOffset, int yOffset)
{
	int x0 = x() + xOffset;
	int y0 = y() + yOffset;
	int x1 = x0 + width();
	int y1 = y0 + height();

	bool haveText = !pText.isEmpty();

	bool isDown = (state & (WBUT_DOWN | WBUT_LOCK | WBUT_CLICKLOCK)) != 0;
	bool isDisabled = (state & WBUT_DISABLE) != 0;
	bool isHighlight = (state & WBUT_HIGHLIGHT) != 0;

	// Display the button.
	if (!images.normal.isNull())
	{
		iV_DrawImage(images.normal, x0, y0);
		if (isDown && !images.down.isNull())
		{
			iV_DrawImage(images.down, x0, y0);
		}
		if (isDisabled && !images.disabled.isNull())
		{
			iV_DrawImage(images.disabled, x0, y0);
		}
		if (isHighlight && !images.highlighted.isNull())
		{
			iV_DrawImage(images.highlighted, x0, y0);
		}
	}
	else
	{
		iV_ShadowBox(x0, y0, x1, y1, 0, WZCOL_FORM_LIGHT, isDisabled ? WZCOL_FORM_LIGHT : WZCOL_FORM_DARK, WZCOL_FORM_BACKGROUND);
		if (isHighlight)
		{
			iV_Box(x0 + 2, y0 + 2, x1 - 3, y1 - 3, WZCOL_FORM_HILITE);
		}
	}

	if (haveText)
	{
		int fw = iV_GetTextWidth(pText.toUtf8().c_str(), FontID);
		int fx = x0 + (width() - fw) / 2;
		int fy = y0 + (height() - iV_GetTextLineSize(FontID)) / 2 - iV_GetTextAboveBase(FontID);
		if (isDisabled)
		{
			iV_SetTextColour(WZCOL_FORM_LIGHT);
			iV_DrawText(pText.toUtf8().c_str(), fx + 1, fy + 1, FontID);
			iV_SetTextColour(WZCOL_FORM_DISABLE);
		}
		else
		{
			iV_SetTextColour(WZCOL_FORM_TEXT);
		}
		iV_DrawText(pText.toUtf8().c_str(), fx, fy, FontID);
	}

	if (isDisabled && !images.normal.isNull() && images.disabled.isNull())
	{
		// disabled, render something over it!
		iV_TransBoxFill(x0, y0, x0 + width(), y0 + height());
	}
}
Exemplo n.º 3
0
void W_EDITBOX::display(int xOffset, int yOffset)
{
	int x0 = x() + xOffset;
	int y0 = y() + yOffset;
	int x1 = x0 + width();
	int y1 = y0 + height();

	if (pBoxDisplay != nullptr)
	{
		pBoxDisplay(this, xOffset, yOffset);
	}
	else
	{
		iV_ShadowBox(x0, y0, x1, y1, 0, boxColourFirst, boxColourSecond, boxColourBackground);
	}

	int fx = x0 + WEDB_XGAP;// + (psEdBox->width - fw) / 2;

	iV_SetTextColour(WZCOL_FORM_TEXT);

	int fy = y0 + (height() - iV_GetTextLineSize(FontID)) / 2 - iV_GetTextAboveBase(FontID);

	/* If there is more text than will fit into the box, display the bit with the cursor in it */
	QString tmp = aText;
	tmp.remove(0, printStart);  // Erase anything there isn't room to display.
	tmp.remove(printChars, tmp.length());

	iV_DrawText(tmp.toUtf8().constData(), fx, fy, FontID);

	// Display the cursor if editing
#if CURSOR_BLINK
	bool blink = !(((wzGetTicks() - blinkOffset) / WEDB_BLINKRATE) % 2);
	if ((state & WEDBS_MASK) == WEDBS_INSERT && blink)
#else
	if ((state & WEDBS_MASK) == WEDBS_INSERT)
#endif
	{
		// insert mode
		QString tmp = aText;
		tmp.remove(insPos, tmp.length());         // Erase from the cursor on, to find where the cursor should be.
		tmp.remove(0, printStart);

		int cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData(), FontID);
		cx += iV_GetTextWidth("-", FontID);
		int cy = fy;
		iV_Line(cx, cy + iV_GetTextAboveBase(FontID), cx, cy - iV_GetTextBelowBase(FontID), WZCOL_FORM_CURSOR);
	}
#if CURSOR_BLINK
	else if ((state & WEDBS_MASK) == WEDBS_OVER && blink)
#else
	else if ((state & WEDBS_MASK) == WEDBS_OVER)
#endif
	{
		// overwrite mode
		QString tmp = aText;
		tmp.remove(insPos, tmp.length());         // Erase from the cursor on, to find where the cursor should be.
		tmp.remove(0, printStart);

		int cx = x0 + WEDB_XGAP + iV_GetTextWidth(tmp.toUtf8().constData(), FontID);
		int cy = fy;
		iV_Line(cx, cy, cx + WEDB_CURSORSIZE, cy, WZCOL_FORM_CURSOR);
	}

	if (pBoxDisplay == nullptr)
	{
		if ((state & WEDBS_HILITE) != 0)
		{
			/* Display the button hilite */
			iV_Box(x0 - 2, y0 - 2, x1 + 2, y1 + 2, WZCOL_FORM_HILITE);
		}
	}
}
Exemplo n.º 4
0
// -----------------------------------------------------------------------------------
static void drawStatBars(void)
{
UDWORD	index;
bool	bMoreBars;
UDWORD	x,y;
UDWORD	width,height;

	if(!bDispStarted)
	{
		bDispStarted = true;
		dispST = gameTime2;
		audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
	}

	fillUpStats();

	pie_UniTransBoxFill(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256+16, WZCOL_SCORE_BOX);
	iV_Box(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256+16, WZCOL_SCORE_BOX_BORDER);

	iV_DrawText( _("Unit Losses"), LC_X + D_W, 80 + 16 + D_H );
	iV_DrawText( _("Structure Losses"), LC_X + D_W, 140 + 16 + D_H );
	iV_DrawText( _("Force Information"), LC_X + D_W, 200 + 16 + D_H );

	index = 0;
	bMoreBars = true;
	while(bMoreBars)
	{
		/* Is it time to display this bar? */
		if( infoBars[index].bActive)
		{
			/* Has it been queued before? */
			if(infoBars[index].bQueued == false)
			{
				/* Don't do this next time...! */
				infoBars[index].bQueued = true;

				/* Play a sound */
//				audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
			}
			x = infoBars[index].topX+D_W;
			y = infoBars[index].topY+D_H;
			width = infoBars[index].width;
			height = infoBars[index].height;

			iV_Box(x, y, x + width, y + height, WZCOL_BLACK);

			/* Draw the background border box */
			pie_BoxFill(x - 1, y - 1, x + width + 1, y + height + 1, WZCOL_MENU_BACKGROUND);

			/* Draw the interior grey */
			pie_BoxFill(x, y, x + width, y + height, WZCOL_MENU_SCORES_INTERIOR);

			if( ((gameTime2 - dispST) > infoBars[index].queTime) )
			{
				/* Now draw amount filled */
				const float mul = (gameTime2 - dispST < BAR_CRAWL_TIME) ?
				                   (float)(gameTime2 - dispST) / (float)BAR_CRAWL_TIME
				                  : 1.f;

				const float length = (float)infoBars[index].percent / 100.f * (float)infoBars[index].width * mul;

				if((int)length > 4)
				{

					/* Black shadow */
					pie_BoxFill(x + 1, y + 3, x + length - 1, y + height - 1, WZCOL_MENU_SHADOW);

					/* Solid coloured bit */
					pie_BoxFill(x + 1, y + 2, x + length - 4, y + height - 4, getColour(index));
				}
			}
			/* Now render the text by the bar */
			sprintf(text, getDescription((MR_STRING)infoBars[index].stringID), infoBars[index].number);
			iV_DrawText(text, x + width + 16, y + 12);

			/* If we're beyond STAT_ROOKIE, then we're on rankings */
			if(index>=STAT_GREEN && index <= STAT_ACE)
			{
				iV_DrawImage(IntImages,(UWORD)(IMAGE_LEV_0 + (index - STAT_GREEN)),x-8,y+2);
			}


		}
		/* Move onto the next bar */
		index++;
		if(infoBars[index].topX == 0 && infoBars[index].topY == 0)
		{
			bMoreBars = false;
		}
	}
	dispAdditionalInfo();
}
Exemplo n.º 5
0
/* Draw top tabs */
static void formDisplayTTabs(W_TABFORM *psForm,SDWORD x0, SDWORD y0,
							 UDWORD width, UDWORD height,
							 UDWORD number, UDWORD selected, UDWORD hilite,
							 PIELIGHT *pColours,UDWORD TabType,UDWORD TabGap)
{
	SDWORD	x,x1, y1;
	UDWORD	i, drawnumber;

#if NO_DISPLAY_SINGLE_TABS
	if (number == 1)
	{
		/* Don't display single tabs */
		return;
	}
#endif

	x = x0 + 2;
	x1 = x + width - 2;
	y1 = y0 + height;
	if (number > psForm->maxTabsShown)  //we can display 8 tabs fine with no extra voodoo.
	{	// We do NOT want to draw all the tabs once we have drawn 7 tabs
		// Both selected & hilite are converted from virtual tab range, to a range
		// that is seen on the form itself.  This would be 0-6 (7 tabs)
		// We also fix drawnumber, so we don't display too many tabs since the pages
		// will be empty.
		drawnumber =  (number - (( psForm->TabMultiplier -1) * psForm->maxTabsShown));
		if (drawnumber > psForm->maxTabsShown) drawnumber = psForm->maxTabsShown ;
		selected = (selected % psForm->maxTabsShown);	//Go from Virtual range, to our range

		if(hilite != 65535)			//sigh.  Don't blame me for this!It is THEIR 'hack'.
		hilite = hilite % psForm->maxTabsShown; //we want to hilite tab 0 - 6.
	}
	else
	{	// normal draw
		drawnumber = number;
	}
	for (i=0; i < drawnumber; i++)
	{
		if(psForm->pTabDisplay) {
			psForm->pTabDisplay((WIDGET*)psForm,TabType,WFORM_TABTOP,i,i==selected,i==hilite,x,y0,width,height);
		} else {
			if (i == selected)
			{
				/* Fill in the tab */
				pie_BoxFill(x + 1, y0 + 1, x1 - 1, y1, pColours[WCOL_BKGRND]);
				/* Draw the outline */
				iV_Line(x,y0+2, x,y1-1, pColours[WCOL_LIGHT]);
				iV_Line(x,y0+2, x+2,y0, pColours[WCOL_LIGHT]);
				iV_Line(x+2,y0, x1-1,y0, pColours[WCOL_LIGHT]);
				iV_Line(x1,y0+1, x1,y1, pColours[WCOL_DARK]);
			}
			else
			{
				/* Fill in the tab */
				pie_BoxFill(x + 1, y0 + 2, x1 - 1, y1 - 1, pColours[WCOL_BKGRND]);
				/* Draw the outline */
				iV_Line(x,y0+3, x,y1-1, pColours[WCOL_LIGHT]);
				iV_Line(x,y0+3, x+2,y0+1, pColours[WCOL_LIGHT]);
				iV_Line(x+2,y0+1, x1-1,y0+1, pColours[WCOL_LIGHT]);
				iV_Line(x1,y0+2, x1,y1-1, pColours[WCOL_DARK]);
			}
			if (i == hilite)
			{
				/* Draw the hilite box */
				iV_Box(x+2,y0+4, x1-3, y1-3, pColours[WCOL_HILITE]);
			}
		}
		x += width + TabGap;
		x1 += width + TabGap;
	}
}
Exemplo n.º 6
0
/* Update and possibly display the tip */
void tipDisplay()
{
	SDWORD		newMX, newMY;
	SDWORD		currTime;
	SDWORD		fw, topGap;

	switch (tipState)
	{
	case TIP_WAIT:
		/* See if the tip has to be shown */
		newMX = mouseX();
		newMY = mouseY();
		currTime = wzGetTicks();
		if (newMX == mx &&
		    newMY == my &&
		    (currTime - startTime > TIP_PAUSE))
		{
			/* Activate the tip */
			tipState = TIP_ACTIVE;

			/* Calculate the size of the tip box */
			topGap = TIP_VGAP;
			iV_SetFont(FontID);

			lineHeight = iV_GetTextLineSize();

			fw = 0;
			for (int n = 0; n < pTip.size(); ++n)
			{
				fw = std::max<int>(fw, iV_GetTextWidth(pTip[n].toUtf8().constData()));
			}
			tw = fw + TIP_HGAP * 2;
			th = topGap * 2 + lineHeight * pTip.size() + iV_GetTextBelowBase();

			/* Position the tip box */
			tx = clip(wx + ww / 2, 0, screenWidth - tw - 1);
			ty = std::max(wy + wh + TIP_VGAP, 0);
			if (ty + th >= (int)screenHeight)
			{
				/* Position the tip above the button */
				ty = wy - th - TIP_VGAP;
			}

			/* Position the text */
			fx = tx + TIP_HGAP;
			fy = ty + (th - lineHeight * pTip.size()) / 2 - iV_GetTextAboveBase();

			/* Note the time */
			startTime = wzGetTicks();
		}
		else if (newMX != mx ||
		         newMY != my ||
		         mousePressed(MOUSE_LMB))
		{
			mx = newMX;
			my = newMY;
			startTime = currTime;
		}
		break;
	case TIP_ACTIVE:
		/* Draw the tool tip */
		pie_BoxFill(tx, ty, tx + tw, ty + th, WZCOL_FORM_TIP_BACKGROUND);
		iV_Line(tx + 1,  ty + th - 2, tx + 1,      ty + 1,  WZCOL_FORM_DARK);
		iV_Line(tx + 2,  ty + 1,      tx + tw - 2, ty + 1,  WZCOL_FORM_DARK);
		iV_Line(tx,      ty + th,     tx + tw,     ty + th, WZCOL_FORM_DARK);
		iV_Line(tx + tw, ty + th - 1, tx + tw,     ty,      WZCOL_FORM_DARK);
		iV_Box(tx, ty, tx + tw - 1, ty + th - 1, WZCOL_FORM_LIGHT);

		iV_SetFont(FontID);
		iV_SetTextColour(TipColour);
		for (int n = 0; n < pTip.size(); ++n)
		{
			iV_DrawText(pTip[n].toUtf8().constData(), fx, fy + lineHeight * n);
		}

		break;
	default:
		break;
	}
}
Exemplo n.º 7
0
void scoreDataToScreen(WIDGET *psWidget, ScoreDataToScreenCache& cache)
{
	int index, x, y, width, height;
	bool bMoreBars;

	if (!bDispStarted)
	{
		bDispStarted = true;
		dispST = realTime;
		audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
	}

	fillUpStats();

	pie_UniTransBoxFill(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256 + 16, WZCOL_SCORE_BOX);
	iV_Box(16 + D_W, MT_Y_POS - 16, pie_GetVideoBufferWidth() - D_W - 16, MT_Y_POS + 256 + 16, WZCOL_SCORE_BOX_BORDER);

	cache.wzLabelText_UnitLosses.setText(_("Unit Losses"), font_regular);
	cache.wzLabelText_UnitLosses.render(LC_X + D_W, 80 + 16 + D_H, WZCOL_FORM_TEXT);
	cache.wzLabelText_StructureLosses.setText(_("Structure Losses"), font_regular);
	cache.wzLabelText_StructureLosses.render(LC_X + D_W, 140 + 16 + D_H, WZCOL_FORM_TEXT);
	cache.wzLabelText_ForceInformation.setText(_("Force Information"), font_regular);
	cache.wzLabelText_ForceInformation.render(LC_X + D_W, 200 + 16 + D_H, WZCOL_FORM_TEXT);

	index = 0;
	bMoreBars = true;
	while (bMoreBars)
	{
		/* Is it time to display this bar? */
		if (infoBars[index].bActive)
		{
			/* Has it been queued before? */
			if (infoBars[index].bQueued == false)
			{
				/* Don't do this next time...! */
				infoBars[index].bQueued = true;

				/* Play a sound */
				audio_PlayTrack(ID_SOUND_BUTTON_CLICK_5);
			}
			x = infoBars[index].topX + D_W;
			y = infoBars[index].topY + D_H;
			width = infoBars[index].width;
			height = infoBars[index].height;

			iV_Box(x, y, x + width, y + height, WZCOL_BLACK);

			/* Draw the background border box */
			pie_BoxFill(x - 1, y - 1, x + width + 1, y + height + 1, WZCOL_MENU_BACKGROUND);

			/* Draw the interior grey */
			pie_BoxFill(x, y, x + width, y + height, WZCOL_MENU_SCORES_INTERIOR);

			if (((realTime - dispST) > infoBars[index].queTime))
			{
				/* Now draw amount filled */
				const float mul = (realTime - dispST < BAR_CRAWL_TIME) ?
				                  (float)(realTime - dispST) / (float)BAR_CRAWL_TIME
				                  : 1.f;

				const float length = (float)infoBars[index].percent / 100.f * (float)infoBars[index].width * mul;

				if ((int)length > 4)
				{

					/* Black shadow */
					pie_BoxFill(x + 1, y + 3, x + length - 1, y + height - 1, WZCOL_MENU_SHADOW);

					/* Solid coloured bit */
					pie_BoxFill(x + 1, y + 2, x + length - 4, y + height - 4, getColour(index));
				}
			}
			/* Now render the text by the bar */
			sprintf(text, getDescription((MR_STRING)infoBars[index].stringID), infoBars[index].number);
			if (index >= cache.wzInfoBarText.size())
			{
				cache.wzInfoBarText.resize(index + 1);
			}
			cache.wzInfoBarText[index].setText(text, font_regular);
			cache.wzInfoBarText[index].render(x + width + 16, y + 12, WZCOL_FORM_TEXT);

			/* If we're beyond STAT_ROOKIE, then we're on rankings */
			if (index >= STAT_GREEN && index <= STAT_ACE)
			{
				iV_DrawImage(IntImages, (UWORD)(IMAGE_LEV_0 + (index - STAT_GREEN)), x - 8, y + 2);
			}
		}
		/* Move onto the next bar */
		index++;
		if ((index > STAT_ACE) || (infoBars[index].topX == 0 && infoBars[index].topY == 0))
		{
			bMoreBars = false;
		}
	}

	/* We now need to display the mission time, game time, average unit experience level an number of artefacts found */

	/* Firstly, top of the screen, number of artefacts found */
	sprintf(text, _("ARTIFACTS RECOVERED: %d"), missionData.artefactsFound);
	cache.wzInfoText_ArtifactsFound.setText(text, font_regular);
	cache.wzInfoText_ArtifactsFound.render((pie_GetVideoBufferWidth() - cache.wzInfoText_ArtifactsFound.width()) / 2, 300 + D_H, WZCOL_FORM_TEXT);

	/* Get the mission result time in a string - and write it out */
	getAsciiTime((char *)&text2, gameTime - missionData.missionStarted);
	sprintf(text, _("Mission Time - %s"), text2);
	cache.wzInfoText_MissionTime.setText(text, font_regular);
	cache.wzInfoText_MissionTime.render((pie_GetVideoBufferWidth() - cache.wzInfoText_MissionTime.width()) / 2, 320 + D_H, WZCOL_FORM_TEXT);

	/* Write out total game time so far */
	getAsciiTime((char *)&text2, gameTime);
	sprintf(text, _("Total Game Time - %s"), text2);
	cache.wzInfoText_TotalGameTime.setText(text, font_regular);
	cache.wzInfoText_TotalGameTime.render((pie_GetVideoBufferWidth() - cache.wzInfoText_TotalGameTime.width()) / 2, 340 + D_H, WZCOL_FORM_TEXT);
	if (Cheated)
	{
		// A quick way to flash the text
		PIELIGHT cheatedTextColor = ((realTime / 250) % 2) ? WZCOL_RED : WZCOL_YELLOW;
		sprintf(text, "%s", _("You cheated!"));
		cache.wzInfoText_Cheated.setText(text, font_regular);
		cache.wzInfoText_Cheated.render((pie_GetVideoBufferWidth() - cache.wzInfoText_Cheated.width()) / 2, 360 + D_H, cheatedTextColor);
	}
}