Beispiel #1
0
// Add a slider control
CLTGUISliderCtrl *CMenuBase::AddSliderOption(HSTRING hText, CLTGUIFont *pFont, int nSliderOffset, HSURFACE hBarSurf, HSURFACE hTabSurf, int *pnValue)
{
	// Create the new menu option
	CLTGUISliderCtrl *pOption=new CLTGUISliderCtrl;
	if ( !pOption->Create(m_pClientDE, hText, pFont, nSliderOffset, hBarSurf, hTabSurf, pnValue) )
	{		
		delete pOption;

		return DNULL;
	}

	// Set the color
	pOption->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(96, 96, 96));

	// Set the text alignment
	pOption->SetTextAlignment(CF_JUSTIFY_RIGHT);

	// Add the option to the list
	m_listOption.AddControl(pOption);

	// Add the option to the list of controls to remove
	m_controlArray.Add(pOption);	

	return pOption;
}
Beispiel #2
0
CLTGUITextItemCtrl* CMenuCharacter::InitWeaponNumCtrl(int index, DWORD dwCommandID, int x, int y, DBOOL enable)
{
	char	str[5];

	HSTRING hString=m_pClientDE->CreateString("0");

	// Create the new menu option
	CLTGUITextItemCtrl *pOption = new CLTGUITextItemCtrl;
	if(!pOption->Create(m_pClientDE, dwCommandID, hString, m_pMainMenus->GetSmallFont(), 1, DTRUE, DNULL))
	{
		m_pClientDE->FreeString(hString);
		delete pOption;
		return DNULL;
	}
	m_pClientDE->FreeString(hString);

	for(int i = 1; i <= WEAP_LASTPLAYERWEAPON; i++)
	{
		itoa(g_WeaponDefaults[i - 1].m_dwStrengthReq, str, 10);

		hString=m_pClientDE->CreateString(str);
		pOption->AddString(hString);
		m_pClientDE->FreeString(hString);
	}

	pOption->SetColor(SETRGB(220,190,170), SETRGB(125,30,0));
	pOption->SetSelIndex(index);
	pOption->SetPos(x, y);
	pOption->Enable(enable);

	return pOption;
}
Beispiel #3
0
CLTGUITextItemCtrl* CMenuCharacter::InitNumberCtrl(int low, int high, int index, DWORD dwCommandID, int x, int y)
{
	char	str[5];

	itoa(low, str, 10);

	HSTRING hString=m_pClientDE->CreateString(str);

	// Create the new menu option
	CLTGUITextItemCtrl *pOption = new CLTGUITextItemCtrl;
	if(!pOption->Create(m_pClientDE, dwCommandID, hString, m_pMainMenus->GetSmallFont(), 1, DTRUE, DNULL))
	{
		m_pClientDE->FreeString(hString);
		delete pOption;
		return DNULL;
	}
	m_pClientDE->FreeString(hString);

	for(int i = low + 1; i <= high; i++)
	{		
		itoa(i, str, 10);

		hString=m_pClientDE->CreateString(str);
		pOption->AddString(hString);
		m_pClientDE->FreeString(hString);
	}

	pOption->SetColor(SETRGB(220,190,170), SETRGB(125,30,0));
	pOption->SetSelIndex(index);
	pOption->SetPos(x, y);

	return pOption;
}
Beispiel #4
0
R_API int r_cons_rgb_parse (const char *p, ut8 *r, ut8 *g, ut8 *b, int *is_bg) {
	const char *q = 0;
	int isbg = 0, bold=127;
	//const double k = (256/6);
	if (!p) return 0;
	if (*p==0x1b) p++;
	if (*p!='[') return 0;
	switch (p[1]) {
	case '1': bold=255; p+=2; break;
	case '3': isbg=0; break;
	case '4': isbg=1; break;
	}
#define SETRGB(x,y,z) if(r)*r=(x);if(g)*g=(y);if(b)*b=(z)
	if (bold != 255 && strchr (p, ';')) {
		if (p[4]=='5')  {
			const double k = (256.0/6.0);
			int x, y, z;
			int n = atoi (p+6);
			/* this is slow.. need to reverse search */
			/* bruteforce indexed rgb cube */
			SETRGB (0,0,0); // UNKNOWN

			for (x=0; x<6; x++)
				for (y=0; y<6; y++)
					for (z=0; z<6; z++)
						if (n== rgb (x*k, y*k, z*k)) {
							x++;y++;z++;// HACK
							SETRGB (x*k,y*k,z*k);
							break;
						}
		} else {
			/* truecolor */
			p += 6;
			/* complex rgb */
			if (r) *r = atoi (p);
			q = strchr (p, ';');
			if (!q) return 0;
			if (g) *g = atoi (q+1);
			q = strchr (q+1, ';');
			if (!q) return 0;
			if (b) *b = atoi (q+1);
		}
		return 1;
	} else {
		/* plain ansi */
		if (is_bg) *is_bg = isbg;
		switch (p[2]) {
		case '0': SETRGB (0,0,0); break;
		case '1': SETRGB (bold,0,0); break;
		case '2': SETRGB (0,bold,0); break;
		case '3': SETRGB (bold,bold,0); break;
		case '4': SETRGB (0,0,bold); break;
		case '5': SETRGB (bold,0,bold); break;
		case '6': SETRGB (0,bold,bold); break;
		case '7': SETRGB (bold,bold,bold); break;
		}
	}
	return 1;
}
Beispiel #5
0
// Draws the version string to the lower left hand corner of the surface
void CMainMenus::DrawVersionString(HSURFACE hSurf)
{
	// The small font
	CLTGUIFont *pFont=GetSmallFont();

	if ( !pFont || !m_hstrVersion )
	{		
		return;
	}

	DWORD dwScreenWidth=0;
	DWORD dwScreenHeight=0;
	m_pClientDE->GetSurfaceDims (hSurf, &dwScreenWidth, &dwScreenHeight);
		
	int y=dwScreenHeight-pFont->GetHeight();

	HSTRING hString=m_pClientDE->CreateString(version_string);
	pFont->DrawSolid(hString, hSurf, 0, y, CF_JUSTIFY_LEFT, SETRGB(100,0,0));	

	if (hString)
	{
		m_pClientDE->FreeString(hString);
	}

}
LTBOOL CInterfaceResMgr::SetupFont(CLTGUIFont *pFont, LTBOOL bBlend, uint32 dwFlags)
{

	LITHFONTCREATESTRUCT lithFont;
	lithFont.szFontBitmap = g_szFontName;
	lithFont.nGroupFlags = dwFlags;
	if (bBlend)
	{
		lithFont.bChromaKey = LTFALSE;
		lithFont.hTransColor = kBlack;
	}
	else
	{
		lithFont.bChromaKey = LTTRUE;
		lithFont.hTransColor = SETRGB(255,0,255);
	}
    if ( !pFont->Init(g_pLTClient, &lithFont) )
	{
		char szString[512];
		sprintf(szString, "Cannot load font: %s", g_szFontName);
        g_pLTClient->CPrint(szString);

        return LTFALSE;
	}

    return LTTRUE;
}
CInterfaceResMgr::CInterfaceResMgr()
{
	g_pInterfaceResMgr = this;

	m_hSurfLoading	 = NULL;
	m_hSurfCursor = NULL;
	m_hTransColor = SETRGB(255,0,255);

    m_pTitleFont = LTNULL;
    m_pLargeFont = LTNULL;
    m_pMediumFont = LTNULL;
    m_pSmallFont = LTNULL;
    m_pHelpFont = LTNULL;

    m_pMsgForeFont = LTNULL;
    m_pHUDForeFont = LTNULL;
    m_pAirFont = LTNULL;
    m_pChooserFont = LTNULL;

	m_Offset.x =  -1;
	m_Offset.y =  -1;

	m_dwScreenWidth = -1;
	m_dwScreenHeight = -1;

	m_fXRatio = 1.0f;
	m_fYRatio = 1.0f;

}
Beispiel #8
0
// Add a column text option
CLTGUIColumnTextCtrl *CMenuBase::AddColumnTextOption(DWORD dwCommandID, CLTGUIFont *pFont)
{
	// Create the new menu option
	CLTGUIColumnTextCtrl *pOption=new CLTGUIColumnTextCtrl;
	if ( !pOption->Create(m_pClientDE, dwCommandID, pFont, this) )
	{		
		delete pOption;

		return DNULL;
	}

	// Set the color
	pOption->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(96, 96, 96));

	// Add the option to the list
	m_listOption.AddControl(pOption);

	// Add the option to the list of controls to remove
	m_controlArray.Add(pOption);	

	return pOption;
}
Beispiel #9
0
// Add a text item option
CLTGUITextItemCtrl *CMenuBase::AddTextItemOption(HSTRING hText, DWORD dwCommandID, CLTGUIFont *pFontArray, int nNumFonts, DBOOL bDrawSolid, int *pnValue)
{	
	// Create the new menu option
	CLTGUITextItemCtrl *pOption=new CLTGUITextItemCtrl;
	if ( !pOption->Create(m_pClientDE, dwCommandID, hText, pFontArray, nNumFonts, bDrawSolid, this, pnValue) )
	{		
		delete pOption;

		return DNULL;
	}

	// Set the color
	pOption->SetColor(SETRGB(220,190,170), SETRGB(125,30,0));

	// Add the option to the list
	m_listOption.AddControl(pOption);

	// Add the option to the list of controls to remove
	m_controlArray.Add(pOption);	

	return pOption;
}
Beispiel #10
0
// Adds an on/off control
CLTGUIOnOffCtrl	*CMenuBase::AddOnOffOption(HSTRING hText, CLTGUIFont *pFont, int nRightColumnOffset, DBOOL *pnValue)
{
	// Create the new menu option
	CLTGUIOnOffCtrl *pOption=new CLTGUIOnOffCtrl;
	if ( !pOption->Create(m_pClientDE, hText, pFont, nRightColumnOffset, pnValue) )
	{		
		delete pOption;

		return DNULL;
	}

	// Set the color
	pOption->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(96, 96, 96));

	// Add the option to the list
	m_listOption.AddControl(pOption);

	// Add the option to the list of controls to remove
	m_controlArray.Add(pOption);	

	return pOption;
}
Beispiel #11
0
// Adds an edit control
CLTGUIEditCtrl *CMenuBase::AddEditOption(HSTRING hDescription, DWORD dwCommandID, CLTGUIFont *pFont, int nEditStringOffset, int nBufferSize, char *lpszValue)
{
	// Create the new menu option
	CLTGUIEditCtrl *pOption=new CLTGUIEditCtrl;

	if ( !pOption->Create(m_pClientDE, dwCommandID, hDescription, pFont, nEditStringOffset, nBufferSize, this, lpszValue) )
	{		
		delete pOption;

		return DNULL;
	}

	// Set the color
	pOption->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(96, 96, 96));

	// Add the option to the list
	m_listOption.AddControl(pOption);

	// Add the option to the list of controls to remove
	m_controlArray.Add(pOption);	

	return pOption;
}
void	CMissionText::Draw()
{
	if (!m_hText) return;

	int x = (int) ((float)m_pos.x * g_pInterfaceResMgr->GetXRatio());
	int y = (int) ((float)m_pos.y * g_pInterfaceResMgr->GetYRatio());

	uint8 nFade = (uint8)(255.0f * m_fAlpha);
	HLTCOLOR hColor = SETRGB(nFade,nFade,nFade);


	g_pLTClient->SetOptimized2DBlend(LTSURFACEBLEND_MASK);
	g_pLTClient->SetOptimized2DColor(hColor);
	g_pLTClient->DrawSurfaceToSurface(g_pLTClient->GetScreenSurface(), m_hForeSurf, NULL, x+1, y+1);
	g_pLTClient->SetOptimized2DBlend(LTSURFACEBLEND_ADD);
	g_pLTClient->DrawSurfaceToSurface(g_pLTClient->GetScreenSurface(), m_hForeSurf, NULL, x, y);
	g_pLTClient->SetOptimized2DColor(kWhite);
	g_pLTClient->SetOptimized2DBlend(LTSURFACEBLEND_ALPHA);

    
}
Beispiel #13
0
// Renders the menu to a surface
void CMenuBase::Render(HSURFACE hDestSurf)
{
	if (!hDestSurf)
	{
		return;
	}

	DDWORD dwDestinationWidth=0;
	DDWORD dwDestinationHeight=0;
			
	// Get the dims of the destination surface
	m_pClientDE->GetSurfaceDims (hDestSurf, &dwDestinationWidth, &dwDestinationHeight);	

	// Render the title
	if (m_pMainMenus->IsEnglish())
	{
		if ( m_hTitleSurf != DNULL )
		{
			m_pClientDE->DrawSurfaceToSurface(hDestSurf, m_hTitleSurf, DNULL, m_titlePos.x, m_titlePos.y);
		}
	}
	else
	{
		// The non-english version renders a text string instead of a title surface
		CLTGUIFont *pTitleFont=m_pMainMenus->GetTitleFont();

		if (pTitleFont && m_hTitleString)
		{
			pTitleFont->DrawSolid(m_hTitleString, hDestSurf, m_titlePos.x, m_titlePos.y, CF_JUSTIFY_LEFT, SETRGB(100,75,50));
		}
	}

	// Render the list of options
	m_listOption.EnableBoxFormat(m_bBoxFormat);
	m_listOption.Render(hDestSurf);
	
	// Render the arrows
	if (m_bShowArrows)
	{
		RenderArrows(hDestSurf);
	}		
}
void CClientInfoMgr::Draw (LTBOOL bDrawSingleFragCount, LTBOOL bDrawAllFragCounts, HSURFACE hDestSurf)
{
	if (!m_pClients || (!bDrawSingleFragCount && !bDrawAllFragCounts)) return;

	// make sure we're in a network game
	if (g_pGameClientShell->GetGameType() == SINGLE) return;

	HSURFACE hScreen = hDestSurf;
	if (!hScreen)
		hScreen = g_pLTClient->GetScreenSurface();
	if (!hScreen)
		return;

    uint32 nScreenWidth = 0;
    uint32 nScreenHeight = 0;
	g_pLTClient->GetSurfaceDims (hScreen, &nScreenWidth, &nScreenHeight);

	CLTGUIFont *pFont = g_pInterfaceResMgr->GetMsgForeFont();

	// should we draw our frag count?
	if (bDrawSingleFragCount)
	{
		
		if (m_hTeamScore)
		{
			pFont->Draw(m_hTeamScore,hScreen,nScreenWidth-m_TeamPos.x+1,m_TeamPos.y+1,LTF_JUSTIFY_LEFT);	
			pFont->Draw(m_hTeamScore,hScreen,nScreenWidth-m_TeamPos.x,m_TeamPos.y,LTF_JUSTIFY_LEFT,m_hTeamColor);	
		}
		if (m_hOppScore)
		{
			pFont->Draw(m_hOppScore,hScreen,nScreenWidth-m_OppPos.x+1,m_OppPos.y+1,LTF_JUSTIFY_LEFT);	
			pFont->Draw(m_hOppScore,hScreen,nScreenWidth-m_OppPos.x,m_OppPos.y,LTF_JUSTIFY_LEFT,m_hOppColor);	
		}
		if (m_hFragString)
		{
			pFont->Draw(m_hFragString,hScreen,nScreenWidth-m_FragPos.x+1,m_FragPos.y+1,LTF_JUSTIFY_LEFT);	
			pFont->Draw(m_hFragString,hScreen,nScreenWidth-m_FragPos.x,m_FragPos.y,LTF_JUSTIFY_LEFT,m_hTeamColor);	
		}
	}

	// should we draw all the frag counts?

	if (bDrawAllFragCounts)
	{
		int nHeight[2] = {0,0};
		int nClients = 0;
		int nTeams[2] = {0,0};
		int nLineHeight = pFont->GetHeight() + VERT_SPACING;

		int nMaxHeight = nScreenHeight - 16;

		CLIENT_INFO* pClient = m_pClients;
		while (pClient)
		{
			if (pClient->team == 2)
			{
				nHeight[1] += nLineHeight;
				nTeams[1]++;
			}
			else
			{
				nHeight[0] += nLineHeight;
				nTeams[0]++;
			}
			++nClients;
			pClient = pClient->pNext;
		}

		int nTotalHeight = Max(nHeight[0],nHeight[1]);
		if (nTotalHeight > nMaxHeight)
			nTotalHeight = nMaxHeight;

		int nY = ((int)nScreenHeight - nTotalHeight) / 2;
		if (nY < 0) nY = 0;
		int nY2 = nY;

		int nX  = 64;
		int nX2 = 32 + (int)nScreenWidth / 2;
		int nTab = ((int)nScreenWidth / 2) - 32;
		int nTab2 = (int)nScreenWidth - 64;

		
		if (g_pGameClientShell->GetGameType() == COOPERATIVE_ASSAULT)
		{
			LTRect rcBanner(nX-8,nY-8,nTab+8,nY+nTotalHeight);
			if (m_Teams[0].hBanner)
				g_pLTClient->ScaleSurfaceToSurface(hScreen, m_Teams[0].hBanner, &rcBanner, LTNULL);

			rcBanner = LTRect(nX2-8,nY-8,nTab2+8,nY+nTotalHeight);
			if (m_Teams[1].hBanner)
				g_pLTClient->ScaleSurfaceToSurface(hScreen, m_Teams[1].hBanner, &rcBanner, LTNULL);
		}

        LTBOOL filled[2] = {LTFALSE, LTFALSE};
		
		pClient = m_pClients;
		while (pClient)
		{
			char str[64];
			sprintf(str,"%d (%d)",pClient->nFrags,(uint32)pClient->m_Ping);
			LTBOOL bIsLocal = (pClient->nID == m_nLocalID);
			HLTCOLOR hColor = kWhite;
			if (bIsLocal)
			{
				hColor = SETRGB(255,255,0);
			}
			
			if (pClient->team == 2)
			{
				if (!filled[1])
				{
					// Ok.. draw.
					pFont->Draw(pClient->hstrName,hScreen,nX2+1,nY2+1,LTF_JUSTIFY_LEFT);	
					pFont->Draw(pClient->hstrName,hScreen,nX2,nY2,LTF_JUSTIFY_LEFT,hColor);
					pFont->Draw(str,hScreen,nTab2+1,nY2+1,LTF_JUSTIFY_RIGHT);	
					pFont->Draw(str,hScreen,nTab2,nY2,LTF_JUSTIFY_RIGHT,hColor);


					nY2 += nLineHeight;
					if (nY2 + nLineHeight > (int)nMaxHeight)
					{
                        filled[1] = LTTRUE;
					}

				}
			}
			else if (!filled[0])
			{
				// Ok.. draw.
				pFont->Draw(pClient->hstrName,hScreen,nX+1,nY+1,LTF_JUSTIFY_LEFT);	
				pFont->Draw(str,hScreen,nTab+1,nY+1,LTF_JUSTIFY_RIGHT);	
				pFont->Draw(pClient->hstrName,hScreen,nX,nY,LTF_JUSTIFY_LEFT,hColor);
				pFont->Draw(str,hScreen,nTab,nY,LTF_JUSTIFY_RIGHT,hColor);

				nY += nLineHeight;
				if (nY + nLineHeight > (int)nMaxHeight)
				{
                    filled[0] = LTTRUE;
				}

			}

			pClient = pClient->pNext;

		}
	}
}
Beispiel #15
0
/*
 * Read an image from a file and return its size, and an allocated buffer
 * with the Pixels.  The images are PixMap format.
 */
Pixel *
read_pnm_image(char *fn, int *dx, int *dy) {
	Pixel *image, *ip;
	char buf[100];
	int depth;
	int x, y;
	FILE *f = fopen(fn, "r");

	if (ferror(f)) {
		perror("Open PNM image");
		return 0;
	}

	if (fgets(buf, sizeof(buf), f) == NULL) {
		fprintf(stderr, "read_pnm_image: error reading magic number: %s\n",
			fn);
		return 0;
	}
	if (strcmp(buf, "P6\n")) {
		fprintf(stderr, "read_pnm_image: unexpected magic number: %s, file %s\n", buf, fn);
		return 0;
	}

	do {
		if (fgets(buf, sizeof(buf), f) == NULL) {
			fprintf(stderr, "read_pnm_image: EOF reading dimensions, file %s\n", fn);
			return 0;
		}
	} while (!isdigit(buf[0]));	// skip comments

	if (sscanf(buf, "%d %d\n", dx, dy) != 2) {
		fprintf(stderr, "read_pnm_image: error reading dimensions: %s\n", fn);
		return 0;
	}

	if (fscanf(f, "%d\n", &depth) != 1) {
		fprintf(stderr, "read_pnm_image: error reading depth: %s\n", fn);
		return 0;
	}
	if (depth != 255) {
		fprintf(stderr, "read_pnm_image: unexpected depth: %d in %s\n",
			depth, fn);
		return 0;
	}

	image = (Pixel *)malloc(*dx * *dy * sizeof(Pixel));
	assert(image);	// out of space allocating image

	/* Images are upside down for our layout, so lets fix that here. */

	ip = &image[*dx * *dy];

	for (y = *dy - 1; y>=0; y--) {
		Pixel *pp = &image[y * *dx];

		for (x=0; x < *dx; x++) {
			int r = fgetc(f);
			int g = fgetc(f);
			int b = fgetc(f);
			if (r == EOF || g == EOF || b == EOF) {
				fprintf(stderr, "read_pnm_image: unexpected EOF: %s\n", fn);
				return 0;
			}
			*pp++ = SETRGB(r,g,b);
		}
	}
	return image;
}
Beispiel #16
0
// Build the axis menus
void CMenuJoystick::BuildAxisMenus()
{
	// Add the menu options
	AddOnOffOption(IDS_MENU_JOYSTICK_USE, m_pMainMenus->GetSmallFont(), 100, &m_bUseJoystick);

	CLTGUITextItemCtrl *pTitleCtrl=DNULL;

	// Turn menu options
	pTitleCtrl=AddTextItemOption(IDS_MENU_JOYSTICK_TURNLEFTRIGHTAXIS, 0, m_pMainMenus->GetSmallFont());
	pTitleCtrl->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(0,255,255));
	if (pTitleCtrl) pTitleCtrl->Enable(DFALSE);

	m_pAxisTurn->Build(m_pClientDE, this);	

	// Look menu options
	pTitleCtrl=AddTextItemOption(IDS_MENU_JOYSTICK_LOOKUPDOWNAXIS, 0, m_pMainMenus->GetSmallFont());
	pTitleCtrl->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(0,255,255));
	if (pTitleCtrl) pTitleCtrl->Enable(DFALSE);

	m_pAxisLook->Build(m_pClientDE, this);

	// Move menu options
	pTitleCtrl=AddTextItemOption(IDS_MENU_JOYSTICK_MOVEFORWARDBACKWARDAXIS, 0, m_pMainMenus->GetSmallFont());
	pTitleCtrl->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(0,255,255));
	if (pTitleCtrl) pTitleCtrl->Enable(DFALSE);

	m_pAxisMove->Build(m_pClientDE, this);

	// Strafe menu options
	pTitleCtrl=AddTextItemOption(IDS_MENU_JOYSTICK_STRAFELEFTRIGHTAXIS, 0, m_pMainMenus->GetSmallFont());
	pTitleCtrl->SetColor(SETRGB(220,190,170), SETRGB(125,30,0), SETRGB(0,255,255));
	if (pTitleCtrl) pTitleCtrl->Enable(DFALSE);

	m_pAxisStrafe->Build(m_pClientDE, this);

	m_pUsePovHat = AddOnOffOption(IDS_MENU_JOYSTICK_HATONOFF, m_pMainMenus->GetSmallFont(), 100, &m_bUsePovHat);
}
Beispiel #17
0
///
// CTimedText::Render()
//
void CTimedText::Render()
{
	// bail if we are not set up (current state == none),
	//    or if we are finished
	//    or if we are not running
	if ( ( m_state == CTIMEDTEXT_NONE ) ||
		 ( m_state == CTIMEDTEXT_INITIAL_DELAY ) ||
	     ( m_state == CTIMEDTEXT_FINISHED ) ||
	       !TESTFLAG( m_flags, CTIMEDTEXTFLAG_DISPLAY ) )
	{
		return;
	}

	// if we are fading, setup the alpha
	uint8 alpha;
	alpha = ( uint8 ) ALPHA_OPAQUE;
	
	int startChar;
	int endChar;
	
	startChar = 0;
	endChar = 0;

	if ( m_state == CTIMEDTEXT_TIMING )
	{
		endChar = m_charactersProcessed;
	}
	else if ( m_state == CTIMEDTEXT_COMPLETE )
	{
		// just display everything like normal
		startChar = 0;
		endChar = m_textLen;
	}
	else if ( m_state == CTIMEDTEXT_FADING )
	{
		// just display everything like normal
		startChar = 0;
		endChar = m_textLen;
		
		alpha = ( uint8 ) (ALPHA_OPAQUE - ALPHA_OPAQUE * ( m_timeElapsed / m_fadeTime ));
	}
	else
	{
		// we are in the wrong state and shouldn't be here
		ASSERT( 0 );
	}
			
	// drop shadow if necessary
	if ( TESTFLAG( m_flags, CTIMEDTEXTFLAG_USE_DROPPED_SHADOW ) )
	{
		// change the text appearance to a drop shadow		
		m_text->SetColor( ( alpha << 24 ) | SETRGB( 0.0f, 0.0f, 0.0f ) );
		m_text->SetPosition( ( m_posX + 2 ), ( m_posY + 2 ) );
		
		// show the amount of text we should reveal so far
		if ( TESTFLAG( m_flags, CTIMEDTEXTFLAG_USE_CLIP_RECT ) )
		{
			m_text->RenderClipped( &m_clipRect, startChar, endChar );
		}
		else
		{
			m_text->Render( startChar, endChar );
		}

		// set the text back
		m_text->SetColor( ( alpha << 24 ) | m_color );
		m_text->SetPosition( m_posX, m_posY );
	}

	// show the amount of text we should reveal so far
	m_text->SetColor( ( alpha << 24 ) | m_color );
	if ( TESTFLAG( m_flags, CTIMEDTEXTFLAG_USE_CLIP_RECT ) )
	{
		m_text->RenderClipped( &m_clipRect, startChar, endChar );
	}
	else
	{
		m_text->Render( startChar, endChar );
	}
}
Beispiel #18
0
// Initialization
DBOOL CMainMenus::Init(CClientDE* pClientDE)
{
	if (!pClientDE)
	{
		return DFALSE;
	}
	
	m_pClientDE = pClientDE;

	// Set the English flag
	HSTRING hString=m_pClientDE->FormatString(IDS_BLOOD2_LANGUAGE);
	if (hString && _mbsicmp((const unsigned char*)"english", (const unsigned char*)m_pClientDE->GetStringData(hString)) != 0)
	{
		m_bEnglish=DFALSE;
	}
	else
	{
		m_bEnglish=DTRUE;
	}
	m_pClientDE->FreeString(hString);
	hString=DNULL;

	// Load the virtual key codes for yes responses
	hString=m_pClientDE->FormatString(IDS_MENU_VKEY_YES);
	if (hString)
	{
		m_nYesVKeyCode=atoi(m_pClientDE->GetStringData(hString));
		m_pClientDE->FreeString(hString);
		hString=DNULL;
	}

	// Load the virtual key codes for no responses
	hString=m_pClientDE->FormatString(IDS_MENU_VKEY_NO);
	if (hString)
	{
		m_nNoVKeyCode=atoi(m_pClientDE->GetStringData(hString));
		m_pClientDE->FreeString(hString);
		hString=DNULL;
	}

	// Init the SharedResourceMgr class
	m_sharedResourceMgr.Init(m_pClientDE);

	// Determine if we need to set the low resolution flag
	RMode currentMode;
	if (m_pClientDE->GetRenderMode(&currentMode) == LT_OK)
	{
		if (currentMode.m_Width < 512 || currentMode.m_Height < 384)
		{
			m_bLowResolution=DTRUE;
			m_nMenuHeight=180;
		}
	}

	// Initialize the surfaces
	if ( !InitSurfaces() )
	{
		return DFALSE;
	}

	// Initialize the fonts
	InitFonts();

	// Initialize the message box
	m_messageBox.Create(m_pClientDE, "interface/mainmenus/dialog.pcx", GetSmallFont(), DNULL, DNULL);
	m_messageBox.SetTextColor(SETRGB(220,190,170));

	// Initialize the individual menus
	m_mainMenu.Init				(m_pClientDE, this, DNULL,				MENU_ID_MAINMENU,		m_nMenuHeight);
	m_singlePlayerMenu.Init		(m_pClientDE, this, &m_mainMenu,		MENU_ID_SINGLEPLAYER,	m_nMenuHeight);	
	m_bloodBathMenu.Init		(m_pClientDE, this, &m_mainMenu,		MENU_ID_BLOODBATH,		m_nMenuHeight);
	m_optionsMenu.Init			(m_pClientDE, this, &m_mainMenu,		MENU_ID_OPTIONS,		m_nMenuHeight);
	m_difficultyMenu.Init		(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_DIFFICULTY,		m_nMenuHeight);	
	m_customLevelMenu.Init		(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CUSTOM_LEVEL,	m_nMenuHeight);
	m_loadGameMenu.Init			(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_LOAD_GAME,		m_nMenuHeight);	
	m_saveGameMenu.Init			(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_SAVE_GAME,		m_nMenuHeight);
	m_controlsMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_CONTROLS,		m_nMenuHeight);
	m_soundMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_SOUND,			m_nMenuHeight);
	m_displayMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_DISPLAY,		m_nMenuHeight);
	m_characterMenu.Init		(m_pClientDE, this, &m_bloodBathMenu,	MENU_ID_CHARACTER,		m_nMenuHeight);	
	m_characterFilesMenu.Init	(m_pClientDE, this, &m_characterMenu,	MENU_ID_CHARACTERFILES,	100);
	m_characterSelectMenu.Init	(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CHARACTERSELECT,m_nMenuHeight);
	m_mouseMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_MOUSE		   ,m_nMenuHeight);
	m_keyboardMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_KEYBOARD	   ,m_nMenuHeight);
	m_joystickMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_JOYSTICK	   ,m_nMenuHeight);

	// Add each menu to the array
	m_menuArray.SetSize(0);
	m_menuArray.Add(&m_mainMenu);
	m_menuArray.Add(&m_singlePlayerMenu);
	m_menuArray.Add(&m_bloodBathMenu);
	m_menuArray.Add(&m_optionsMenu);
	m_menuArray.Add(&m_difficultyMenu);
	m_menuArray.Add(&m_customLevelMenu);
	m_menuArray.Add(&m_loadGameMenu);
	m_menuArray.Add(&m_saveGameMenu);
	m_menuArray.Add(&m_controlsMenu);
	m_menuArray.Add(&m_soundMenu);	
	m_menuArray.Add(&m_characterMenu);
	m_menuArray.Add(&m_characterFilesMenu);
	m_menuArray.Add(&m_characterSelectMenu);	
	m_menuArray.Add(&m_mouseMenu);
	m_menuArray.Add(&m_keyboardMenu);
	m_menuArray.Add(&m_joystickMenu);

	// Build each menu
	unsigned int i;
	for (i=0; i < m_menuArray.GetSize(); i++)
	{
		m_menuArray[i]->Build();
	}	

	// This is done after the build above because it shouldn't be built until the user
	// actually wants to go into the menu.	
	m_menuArray.Add(&m_displayMenu);

	SetCurrentMenu(MENU_ID_MAINMENU, MENU_ID_MAINMENU);	
	
	// Load the version string
	m_hstrVersion = m_pClientDE->FormatString(IDS_VERSION);

	return DTRUE;
}