Пример #1
0
void PlayerDeadMessage (void)
{
if (gameOpts->render.cockpit.bHUDMsgs && gameStates.app.bPlayerExploded) {
	CHUDMessage	*pMsgs = gameData.hud.msgs;

   if (LOCALPLAYER.lives < 2) {
      int x, y, w, h, aw;
      fontManager.SetCurrent (HUGE_FONT);
      fontManager.Current ()->StringSize (TXT_GAME_OVER, w, h, aw);
      w += 20;
      h += 8;
      x = (CCanvas::Current ()->Width () - w) / 2;
      y = (CCanvas::Current ()->Height () - h) / 2;
      gameStates.render.grAlpha =	 (2 * 7);
      CCanvas::Current ()->SetColorRGB (0, 0, 0, 255);
      OglDrawFilledRect (x, y, x + w, y + h);
      gameStates.render.grAlpha = 1.0f;
      GrString (0x8000, (CCanvas::Current ()->Height () - CCanvas::Current ()->Font ()->Height ()) / 2 + h / 8, TXT_GAME_OVER, NULL);
#if 0
      // Automatically exit death after 10 secs
      if (gameData.time.xGame > gameStates.app.nPlayerTimeOfDeath + I2X (10)) {
               SetFunctionMode (FMODE_MENU);
               gameData.app.nGameMode = GM_GAME_OVER;
               __asm int 3; longjmp (gameExitPoint, 1);        // Exit out of game loop
	      }
Пример #2
0
//for text itemP, constantly redraw cursor (to achieve flash)
void CMenuItem::UpdateCursor (void)
{
	int w, h, aw;
	fix time = TimerGetApproxSeconds ();
	int x, y;
	char* text = m_text;

	Assert (m_nType == NM_TYPE_INPUT_MENU || m_nType == NM_TYPE_INPUT);

while (*text) {
	fontManager.Current ()->StringSize (text, w, h, aw);
	if (w > m_w - 10)
		text++;
	else
		break;
	}
if (!*text) 
	w = 0;
x = m_x + w; 
y = m_y;
if (time & 0x8000)
	GrString (x, y, CURSOR_STRING, NULL);
else {
	CCanvas::Current ()->SetColorRGB (0, 0, 0, 255);
	OglDrawFilledRect (x, y, x + CCanvas::Current ()->Font ()->Width () - 1, y + CCanvas::Current ()->Font ()->Height () - 1);
	}
}
Пример #3
0
void CHUD::DrawEnergyBar (void)
{
if (cockpit->Hide ())
	return;

if (!gameOpts->render.cockpit.bTextGauges) {
	static int		bFlash = 0, bShow = 1;
	static time_t	tToggle;
	time_t			t;
	ubyte				c;

	int h = m_info.nEnergy;
	int nLineSpacing = 5 * GAME_FONT->Height () / 4;
	if ((t = FlashGauge (h, &bFlash, (int) tToggle))) {
		tToggle = t;
		bShow = !bShow;
		}
	int y = CCanvas::Current ()->Height () - (int) (((IsMultiGame ? 5 : 1) * nLineSpacing - 1) * m_info.yGaugeScale);
	CCanvas::Current ()->SetColorRGB (255, 255, (ubyte) ((h > 100) ? 255 : 0), 255);
	glLineWidth (1);
	OglDrawEmptyRect (6, y, 6 + (int) (100 * m_info.xGaugeScale), y + (int) (9 * m_info.yGaugeScale));
	if (bFlash) {
		if (!bShow)
			return;
		h = 100;
		}
	else
		bShow = 1;
	c = (h > 100) ? 224 : 224;
	CCanvas::Current ()->SetColorRGB (c, c, (ubyte) ((h > 100) ? c : 0), 128);
	OglDrawFilledRect (6, y, 6 + (int) (((h > 100) ? h - 100 : h) * m_info.xGaugeScale), y + (int) (9 * m_info.yGaugeScale));
	}
}
Пример #4
0
void CHUD::DrawAfterburnerBar (void)
{
if (cockpit->Hide ())
	return;
	
	int h, y;

if (!(LOCALPLAYER.flags & PLAYER_FLAGS_AFTERBURNER))
	return;		//don't draw if don't have
h = FixMul (gameData.physics.xAfterburnerCharge, 100);
if (!gameOpts->render.cockpit.bTextGauges) {
	y = CCanvas::Current ()->Height () - (int) ((((gameData.app.nGameMode & GM_MULTI) ? 8 : 3) * m_info.nLineSpacing - 1) * m_info.yGaugeScale);
	CCanvas::Current ()->SetColorRGB (255, 0, 0, 255);
	glLineWidth (1);
	OglDrawEmptyRect (6, y, 6 + (int) (100 * m_info.xGaugeScale), y + (int) (9 * m_info.yGaugeScale));
	CCanvas::Current ()->SetColorRGB (224, 0, 0, 128);
	OglDrawFilledRect (6, y, 6 + (int) (h * m_info.xGaugeScale), y + (int) (9 * m_info.yGaugeScale));
	}
if (gameData.demo.nState == ND_STATE_RECORDING) {
	if (gameData.physics.xAfterburnerCharge != m_history [gameStates.render.vr.nCurrentPage].afterburner) {
		NDRecordPlayerAfterburner (m_history [gameStates.render.vr.nCurrentPage].afterburner, gameData.physics.xAfterburnerCharge);
		m_history [gameStates.render.vr.nCurrentPage].afterburner = gameData.physics.xAfterburnerCharge;
	 	}
	}
}
Пример #5
0
void CHUD::DrawShieldBar (void)
{
if (cockpit->Hide ())
	return;

	static int		bShow = 1;
	static time_t	tToggle = 0, nBeep = -1;

	time_t			t = gameStates.app.nSDLTicks;
	int				bLastFlash = gameStates.render.cockpit.nShieldFlash;

//	CCanvas::SetCurrent (&gameStates.render.vr.buffers.subRender [0]);	//render off-screen
if (!gameOpts->render.cockpit.bTextGauges) {

	int h = m_info.nShields;
	if ((t = FlashGauge (h, &gameStates.render.cockpit.nShieldFlash, (int) tToggle))) {
		tToggle = t;
		bShow = !bShow;
		}

	int nLineSpacing = 5 * GAME_FONT->Height () / 4;
	int y = CCanvas::Current ()->Height () - (int) (((IsMultiGame ? 6 : 2) * nLineSpacing - 1) * m_info.yGaugeScale);
	CCanvas::Current ()->SetColorRGB (0, (ubyte) ((h > 100) ? 255 : 64), 255, 255);
	glLineWidth (1);
	OglDrawEmptyRect (6, y, 6 + (int) (100 * m_info.xGaugeScale), y + (int) (9 * m_info.yGaugeScale));
	if (bShow) {
		CCanvas::Current ()->SetColorRGB (0, (ubyte) ((h > 100) ? 224 : 64), 224, 128);
		OglDrawFilledRect (6, y, 6 + (int) (((h > 100) ? h - 100 : h) * m_info.xGaugeScale), y + (int) (9 * m_info.yGaugeScale));
		}
	}
if (gameStates.render.cockpit.nShieldFlash) {
	if (gameOpts->gameplay.bShieldWarning && gameOpts->sound.bUseSDLMixer) {
		if ((nBeep < 0) || (bLastFlash != gameStates.render.cockpit.nShieldFlash)) {
			if (nBeep >= 0)
				audio.StopSound ((int) nBeep);
			nBeep = audio.StartSound (-1, SOUNDCLASS_GENERIC, I2X (2) / 3, 0xFFFF / 2, -1, -1, -1, -1, I2X (1),
											  AddonSoundName ((gameStates.render.cockpit.nShieldFlash == 1) ? SND_ADDON_LOW_SHIELDS1 : SND_ADDON_LOW_SHIELDS2));
			}
		}
	else if (nBeep >= 0) {
		audio.StopSound ((int) nBeep);
		nBeep = -1;
		}
	}
else {
	bShow = 1;
	if (nBeep >= 0) {
		audio.StopSound ((int) nBeep);
		nBeep = -1;
		}
	}
}
Пример #6
0
void CMenuItem::DrawBlackBox (int w1, int x, int y, const char* s, int bTiny)
{
	int w, h, aw;

fontManager.Current ()->StringSize (s, w, h, aw);
if (bTiny) {
	h += 4;
	y -= 2;
	}
if (w1 == 0) 
	w1 = w;

CCanvas::Current ()->SetColorRGBi (RGBA_PAL2 (2, 2, 2));
OglDrawFilledRect (x - 1, y - 1, x - 1, y + h - 1);
OglDrawFilledRect (x - 1, y - 1, x + w1 - 1, y - 1);
CCanvas::Current ()->SetColorRGBi (RGBA_PAL2 (5, 5, 5));
OglDrawFilledRect (x, y + h, x + w1, y + h);
OglDrawFilledRect (x + w1, y - 1, x + w1, y + h);
CCanvas::Current ()->SetColorRGB (0, 0, 0, 255);
OglDrawFilledRect (x, y, x + w1 - 1, y + h - 1);
GrString (x + 1, y + 1, s, NULL);
}
Пример #7
0
void CMenuItem::DrawGauge (int w, int x, int y, int val, int maxVal, int current)
{
	int w1, h, aw;

fontManager.Current ()->StringSize (" ", w1, h, aw);
if (!w) 
	w = w1 * 30;
#if DBG
if (val > maxVal)
	val = maxVal;
#endif
w1 = (val > maxVal) ? w : w * val / maxVal;
if (w1 < w) {
	CCanvas::Current ()->SetColorRGB (0, 0, 0, 255);
	OglDrawFilledRect (x + w1 + 1, y, x + w, y + h - 2);
	}
CCanvas::Current ()->SetColorRGB (200, 0, 0, 255);
if (w1)
	OglDrawFilledRect (x + 1, y, x + w1, y + h - 2);
glLineWidth (float (screen.Width ()) / 640.0f);
OglDrawEmptyRect (x, y, x + w - 1, y + h - 1);
glLineWidth (1);
}
Пример #8
0
//-----------------------------------------------------------------------
//draw the subtitles for this frame
void CSubTitles::Draw (int nFrame)
{
	static int activeSubTitleList [MAX_ACTIVE_SUBTITLES];
	static int nActiveSubTitles, nNextSubTitle, nLineSpacing;
	int t, y;
	int bMustErase = 0;

if (nFrame == 0) {
	nActiveSubTitles = 0;
	nNextSubTitle = 0;
	fontManager.SetCurrent (GAME_FONT);
	nLineSpacing = CCanvas::Current ()->Font ()->Height () + (CCanvas::Current ()->Font ()->Height () / 4);
	fontManager.SetColorRGBi (WHITE_RGBA, 1, 0, 0);
	}

//get rid of any subtitles that have expired
for (t = 0; t <nActiveSubTitles; )
	if (nFrame > m_captions [activeSubTitleList [t]].last_frame) {
		int t2;
		for (t2 = t; t2 < nActiveSubTitles - 1; t2++)
			activeSubTitleList [t2] = activeSubTitleList [t2+1];
		nActiveSubTitles--;
		bMustErase = 1;
	}
	else
		t++;

//get any subtitles new for this frame 
while (nNextSubTitle < m_nCaptions && nFrame >= m_captions [nNextSubTitle].first_frame) {
	if (nActiveSubTitles >= MAX_ACTIVE_SUBTITLES)
		Error ("Too many active subtitles!");
	activeSubTitleList [nActiveSubTitles++] = nNextSubTitle;
	nNextSubTitle++;
	}

//find y coordinate for first line of subtitles
y = CCanvas::Current ()->Height () - ((nLineSpacing + 1) * MAX_ACTIVE_SUBTITLES + 2);

//erase old subtitles if necessary
if (bMustErase) {
	CCanvas::Current ()->SetColorRGB (0, 0, 0, 255);
	OglDrawFilledRect (0, y, CCanvas::Current ()->Width () - 1, CCanvas::Current ()->Height () - 1);
	}
//now draw the current subtitles
for (t = 0; t < nActiveSubTitles; t++)
	if (activeSubTitleList [t] != -1) {
		GrString (0x8000, y, m_captions [activeSubTitleList [t]].msg, NULL);
		y += nLineSpacing + 1;
	}
}
Пример #9
0
void ShowPauseMessage (const char* msg)
{
	int w, h, aw;
	int x, y;

CCanvas::SetCurrent (NULL);
fontManager.SetCurrent (SMALL_FONT);
fontManager.Current ()->StringSize (msg, w, h, aw);
x = (screen.Width () - w) / 2;
y = (screen.Height () - h) / 2;
CCanvas::Current ()->SetColorRGB (0, 0, 0, 255);
OglDrawFilledRect (x-BOX_BORDER/2, y-BOX_BORDER/2, x+w+BOX_BORDER/2-1, y+h+BOX_BORDER/2-1);
fontManager.SetColor (255, -1);
GrUString (0x8000, y, msg);
GrUpdate (0);
}
Пример #10
0
void CStatusBar::ClearBombCount (int bgColor)
{
CCanvas::Push ();
CCanvas::SetCurrent (CurrentGameScreen ());
CCanvas::Current ()->SetColorRGBi (bgColor);
if (!gameStates.video.nDisplayMode) {
	Rect (169, 189, 189, 196);
	CCanvas::Current ()->SetColorRGBi (RGB_PAL (128, 128, 128));
	OglDrawLine (ScaleX (168), ScaleY (189), ScaleX (189), ScaleY (189));
	}
else {
	OglDrawFilledRect (ScaleX (338), ScaleY (453), ScaleX (378), ScaleY (470));
	CCanvas::Current ()->SetColorRGBi (RGB_PAL (128, 128, 128));
	OglDrawLine (ScaleX (336), ScaleY (453), ScaleX (378), ScaleY (453));
	}
CCanvas::Pop ();
}
Пример #11
0
void CBackgroundManager::DrawBox (int left, int top, int right, int bottom, int nLineWidth, float fAlpha, int bForce)
{
gameStates.render.nFlashScale = 0;
if (bForce || (MODERN_STYLE == 1)) {
	if (left <= 0)
		left = 1;
	if (top <= 0)
		top = 1;
	if (right >= screen.Width ())
		right = screen.Width () - 1;
	if (bottom >= screen.Height ())
		bottom = screen.Height () - 1;
	CCanvas::Current ()->SetColorRGB (PAL2RGBA (22), PAL2RGBA (22), PAL2RGBA (38), (ubyte) (gameData.menu.alpha * fAlpha));
	glDisable (GL_TEXTURE_2D);
	OglDrawFilledRect (left, top, right, bottom);
	CCanvas::Current ()->SetColorRGB (PAL2RGBA (22), PAL2RGBA (22), PAL2RGBA (38), 255);
	glLineWidth (GLfloat (nLineWidth) * GLfloat (screen.Width ()) / 640.0f);
	OglDrawEmptyRect (left, top, right, bottom);
	glLineWidth (1);
	}
}
Пример #12
0
void CBackground::DrawArea (int left, int top, int right, int bottom)
{
#if 0
if (MODERN_STYLE) 
	Draw ();
else 
#endif
	{
	if (left < 0) 
		left = 0;
	if (top < 0)
		top = 0;
	int width = right - left + 1;
	int height = bottom - top + 1;
	//if (width > nmBackground.Width ()) width = nmBackground.Width ();
	//if (height > nmBackground.Height ()) height = nmBackground.Height ();
	right = left + width - 1;
	bottom = top + height - 1;
	glDisable (GL_BLEND);
	if (!backgroundManager.Shadow ()) {
		CCanvas::Current ()->SetLeft (CCanvas::Current ()->Left () + LHX (10));
		CCanvas::Current ()->SetTop (CCanvas::Current ()->Top () + LHX (10));
		m_background->RenderFixed (NULL, left, top, width, height); //, LHX (10), LHY (10));
		CCanvas::Current ()->SetLeft (CCanvas::Current ()->Left () - LHX (10));
		CCanvas::Current ()->SetTop (CCanvas::Current ()->Top () - LHX (10));
		}
	else {
		m_background->RenderFixed (NULL, left, top, width, height); //, 0, 0);
		gameStates.render.grAlpha = GrAlpha (2 * 7);
		glEnable (GL_BLEND);
		glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		CCanvas::Current ()->SetColorRGB (0, 0, 0, 200);
		OglDrawFilledRect (right - 5, top + 5, right - 6, bottom - 5);
		OglDrawFilledRect (right - 4, top + 4, right - 5, bottom - 5);
		OglDrawFilledRect (right - 3, top + 3, right - 4, bottom - 5);
		OglDrawFilledRect (right - 2, top + 2, right - 3, bottom - 5);
		OglDrawFilledRect (right - 1, top + 1, right - 2, bottom - 5);
		OglDrawFilledRect (right + 0, top + 0, right - 1, bottom - 5);
		OglDrawFilledRect (left + 5, bottom - 5, right, bottom - 6);
		OglDrawFilledRect (left + 4, bottom - 4, right, bottom - 5);
		OglDrawFilledRect (left + 3, bottom - 3, right, bottom - 4);
		OglDrawFilledRect (left + 2, bottom - 2, right, bottom - 3);
		OglDrawFilledRect (left + 1, bottom - 1, right, bottom - 2);
		OglDrawFilledRect (left + 0, bottom - 0, right, bottom - 1);

		CCanvas::Current ()->SetColorRGB (255, 255, 255, 50);
		OglDrawFilledRect (left, top + 0, right - 1, top + 1);
		OglDrawFilledRect (left, top + 1, right - 2, top + 2);
		OglDrawFilledRect (left, top + 2, right - 3, top + 3);
		OglDrawFilledRect (left, top + 3, right - 4, top + 4);
		OglDrawFilledRect (left, top + 4, right - 5, top + 5);
		OglDrawFilledRect (left, top + 5, right - 6, top + 6);
		OglDrawFilledRect (left + 0, top + 6, left + 1, bottom - 1);
		OglDrawFilledRect (left + 1, top + 6, left + 2, bottom - 2);
		OglDrawFilledRect (left + 2, top + 6, left + 3, bottom - 3);
		OglDrawFilledRect (left + 3, top + 6, left + 4, bottom - 4);
		OglDrawFilledRect (left + 4, top + 6, left + 5, bottom - 5);
		OglDrawFilledRect (left + 5, top + 6, left + 6, bottom - 6);
		glDisable (GL_BLEND);
		}
	//GrUpdate (0);
	}
gameStates.render.grAlpha = 1.0f;
}
Пример #13
0
void CCanvas::Clear (uint color)
{
SetColorRGBi (color);
OglDrawFilledRect (0, 0, CCanvas::Current ()->Width () - 1, CCanvas::Current ()->Height () - 1);
}