Esempio n. 1
0
_MEMBER_FUNCTION_IMPL(GUIFont, getFontHeight)
{
	CEGUI::Font * pFont = sq_getinstance<CEGUI::Font *>(pVM);

	if(!pFont)
	{
		sq_pushbool(pVM, false);
		return 1;
	}

	sq_pushfloat(pVM, pFont->getFontHeight());
	return 1;
}
Esempio n. 2
0
_MEMBER_FUNCTION_IMPL(GUIElement, setFont)
{
	CGUIFrameWindow * pWindow = sq_getinstance<CGUIFrameWindow *>(pVM);
	CEGUI::Font * pFont = sq_getinstance<CEGUI::Font *>(pVM, 2);

	if(!pWindow || !pFont)
	{
		sq_pushbool(pVM, false);
		return 1;
	}

	// Adjust the size of the element when the font is changed
	float fTextWidth = pFont->getTextExtent(pWindow->getText());
	float fTextHeight = pFont->getFontHeight();
	pWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0, fTextWidth), CEGUI::UDim(0, fTextHeight)));

	pWindow->setFont(pFont);
	return 1;
}
Esempio n. 3
0
_MEMBER_FUNCTION_IMPL(GUIText, setText)
{
	const char * text;
	sq_getstring(pVM, -1, (const char **)&text);
	CGUIFrameWindow * pWindow = sq_getinstance<CGUIFrameWindow *>(pVM);

	if(!pWindow)
	{
		sq_pushbool(pVM, false);
		return 1;
	}

	CClientScriptManager * pClientScriptManager = g_pClient->GetClientScriptManager();
	pClientScriptManager->GetGUIManager()->Add(pWindow, pClientScriptManager->GetScriptingManager()->Get(pVM));

	// We have to use the element's font to get the real extent 
	CEGUI::Font * pFont = pWindow->getFont (true);
	float fTextWidth = pFont->getTextExtent(text);
	float fTextHeight = pFont->getFontHeight();
	pWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0, fTextWidth), CEGUI::UDim(0, fTextHeight)));
	pWindow->setText(CGUI::AnsiToCeguiFriendlyString(text, strlen(text)));
	sq_pushbool(pVM, true);
	return 1;
}
Esempio n. 4
0
// Direct3DDevice9::Reset
void Direct3DReset()
{
	// If our GUI instance does not exist create it
	if(!g_pGUI)
	{
		g_pGUI = new CGUI(g_pDevice);

		if(g_pGUI->Initialize())
		{
			// Version identifier text
			g_pVersionIdentifier = g_pGUI->CreateGUIStaticText();
			g_pVersionIdentifier->setText(VERSION_IDENTIFIER);
			CEGUI::Font * pFont = g_pGUI->GetFont("tahoma-bold");
			float fTextWidth = pFont->getTextExtent(VERSION_IDENTIFIER);
			float fTextHeight = pFont->getFontHeight();
			g_pVersionIdentifier->setSize(CEGUI::UVector2(CEGUI::UDim(0, fTextWidth), CEGUI::UDim(0, fTextHeight)));
			float fTextX = pFont->getTextExtent("_");
			float fTextY = -(fTextX + fTextHeight);
			g_pVersionIdentifier->setPosition(CEGUI::UVector2(CEGUI::UDim(0, fTextX), CEGUI::UDim(1, fTextY)));
			g_pVersionIdentifier->setProperty("FrameEnabled", "false");
			g_pVersionIdentifier->setProperty("BackgroundEnabled", "false");
			g_pVersionIdentifier->setFont(pFont);
			g_pVersionIdentifier->setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF");
			g_pVersionIdentifier->setAlpha(0.6f);
			g_pVersionIdentifier->setVisible(true);

			/*#ifdef IVMP_WEBKIT
				g_pWebkit = new CD3D9WebKit();
			#endif
			*/

			// TODO: Make the default stuff (Chat window, main menu, e.t.c) a xml layout so it
			// can be edited by users
			// TODO: Also load the font from an xml layout so it can be edited by users
			// TODO: Ability to output all server messages to the client console?
			// TODO: A script console when client side scripts are implemented

			CLogFile::Printf("GUI initialized");
		}
		else
			CLogFile::Printf("GUI initialization failed");
	}
	else
	{
		// If our GUI class does exist inform it of the device reset
		g_pGUI->OnResetDevice();
	}

	// If our graphics instance does not exist create it
	if(!g_pGraphics && g_pDevice)
		g_pGraphics = new CGraphics(g_pDevice);
	else
		g_pGraphics->OnResetDevice();

	// If our main menu class does not exist create it
	if(!g_pMainMenu)
		g_pMainMenu = new CMainMenu();
	else
		g_pMainMenu->OnResetDevice();

	//// Show loading screen
	//if(!CGame::IsGameLoaded() && !CGame::IsMenuActive())
	//	g_pMainMenu->ShowLoadingScreen();

	// If our credits class does not exist create it
	if(!g_pCredits)
		g_pCredits = new CCredits(g_pGUI);

	// If our fps counter class does not exist create it
	if(!g_pFPSCounter)
		g_pFPSCounter = new CFPSCounter();

	// If our fps counter class does not exist create it
	if(!g_pChatWindow)
		g_pChatWindow = new CChatWindow();

	// If our input window class does not exist create it
	if(!g_pInputWindow)
	{
		g_pInputWindow = new CInputWindow();
		RegisterCommands();
	}

	// If our name tags class does not exist create it
	if(!g_pNameTags)
		g_pNameTags = new CNameTags();
}
Esempio n. 5
0
void CSpawnSelection::ProcessLocalPlayer(CLocalPlayer *pLocalPlayer)
{
	CCamera *pGameCamera;
	CPlayerPed *pGamePlayer;
	DWORD dwTicksSinceLastSelection;
	Vector3 vPlayerPos;
	float fDrawX=25.0f;
	float fDrawY=250.0f;
	char szMsg[256];

	if(FALSE == pLocalPlayer->IsActive() && !pLocalPlayer->IsWasted() && m_bClearedToSpawn)
	{
		// DONT ALLOW ANY ACTIONS IF WE'RE STILL FADING OR WAITING.
		if((GetTickCount() - m_dwInitialSelectionTick) < 2000) return;
		pGame->ToggleKeyInputsDisabled(TRUE);
		
		if(GetKeyState(VK_SHIFT)&0x8000) // SHIFT PRESSED SO SPAWN
		{		
			pGameCamera = pGame->GetCamera();
			pGamePlayer = pGame->FindPlayerPed();
			pGameCamera->Restore();
			pLocalPlayer->SpawnPlayer();
			pGame->DisplayHud(TRUE);
			pGame->ToggleHud(TRUE);
			pGame->HideRadar(FALSE);
			pGameCamera->SetBehindPlayer();
			pGamePlayer->GetPosition(&vPlayerPos);		
			pGame->PlaySound(10, vPlayerPos);
			pGame->ToggleKeyInputsDisabled(FALSE);
			pGamePlayer->TogglePlayerControllable(TRUE);
			m_pGUIText->setVisible(false);
			return;
		}
		else if(m_bClearedToSpawn) // WE ARE CLEARED TO SPAWN OR SELECT ANOTHER CLASS
		{
			pGame->ToggleHud(FALSE);
			pGame->HideRadar(TRUE);

			// SHOW INFO ABOUT THE SELECTED CLASS..
			szMsg[0] = '\0';
			strcat(szMsg, "> Use Left and Right arrow keys to select a class.\n");
			strcat(szMsg, "> Press Shift button when ready to spawn.\n");

			if(!m_pGUIText)
			{
				m_pGUIText = pGUI->CreateGUIStaticText();
				m_pGUIText->setText(szMsg);
				CEGUI::Font * pFont = pGUI->GetTahomaBold10Font();
				float fTextWidth = pFont->getTextExtent(szMsg);
				float fTextHeight = pFont->getFontHeight();
				m_pGUIText->setSize(CEGUI::UVector2(CEGUI::UDim(0, fTextWidth*3), CEGUI::UDim(0, fTextHeight*3)));
				float fTextX = pFont->getTextExtent("_");
				float fTextY = -(fTextX + fTextHeight);
				m_pGUIText->setPosition(CEGUI::UVector2(CEGUI::UDim(0, fTextX), CEGUI::UDim(0.8, fTextY)));
				m_pGUIText->setProperty("BackgroundEnabled", "false");
				m_pGUIText->setProperty("FrameEnabled", "false");
				m_pGUIText->setProperty("Font", "Tahoma-Bold-10");
				m_pGUIText->setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF");
				m_pGUIText->setAlpha(155);
				m_pGUIText->setVisible(true);
			}

			CD3DFont *pD3DFont = pChatWindow->m_pD3DFont;
			//pD3DFont->DrawText(fDrawX,fDrawY,0xFFFFFFFF,szMsg);

			// GRAB PLAYER MATRIX FOR SOUND POSITION
			pGamePlayer = pGame->FindPlayerPed();
			pGamePlayer->GetPosition(&vPlayerPos);

			pGame->DisplayHud(FALSE);
			pGamePlayer->ClearAllWeapons();
			pGamePlayer->TogglePlayerControllable(FALSE);
			dwTicksSinceLastSelection = GetTickCount() - m_dwLastSpawnSelectionTick; // used to delay reselection.

			// ALLOW ANOTHER SELECTION WITH LEFT KEY
			if( (GetKeyState(VK_LEFT)&0x8000) && (dwTicksSinceLastSelection > 250)) { // LEFT ARROW
				m_bClearedToSpawn = FALSE;
				m_dwLastSpawnSelectionTick = GetTickCount();
				m_iSelectedClass--;
		
				pGame->PlaySound(14, vPlayerPos);
				pLocalPlayer->RequestClass(m_iSelectedClass);
				return;
			}

			// ALLOW ANOTHER SELECTION WITH RIGHT KEY
			if( (GetKeyState(VK_RIGHT)&0x8000) && (dwTicksSinceLastSelection > 250)) { // RIGHT ARROW
	
				m_bClearedToSpawn = FALSE;
				m_dwLastSpawnSelectionTick = GetTickCount();
				m_iSelectedClass++;

				pGame->PlaySound(13, vPlayerPos);
				pLocalPlayer->RequestClass(m_iSelectedClass);
				return;
			}	
		}
	}
}