Esempio n. 1
2
void CLocalGUI::SetMainMenuVisible ( bool bVisible )
{
    if ( m_pMainMenu )
    {
        // This code installs the original CCore mouseclick handlers when the ingame menu
        // is shown, and restores the mod mouseclick handlers when the menu is hidden again.
        // This is needed to prevent a crash when double clicking a server in the server browser
        // while already ingame: the mod module gets unloaded while its doubleclick handler is
        // still running.

        m_pMainMenu->SetVisible ( bVisible );

        CGUI* pGUI = CCore::GetSingleton ().GetGUI ();
        if ( bVisible )
        {
            pGUI->SelectInputHandlers ( INPUT_CORE );
        }
        else
        {
            pGUI->SelectInputHandlers ( INPUT_MOD );
        }
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::SetMainMenuVisible() called, but CLocalGUI::CreateObjects() isn't" );
    }
}
Esempio n. 2
0
_MEMBER_FUNCTION_IMPL(GUIElement, constructor)
{
	const char * name;
	sq_getstring(pVM, -1, &name);
	String szName = name;

	if(szName.IsEmpty())
		_SET_RELEASE_HOOK(GUIElement);

	// Get our GUI instance
	CGUI * pGUI = g_pClient->GetGUI();

	try
	{
		pGUI->GetWindowManager()->getWindow(szName.C_String());
	}
	catch(CEGUI::Exception &e)
	{
		e;
		_SET_RELEASE_HOOK(GUIElement);
	}

	CEGUI::Window * pWindow = pGUI->GetWindowManager()->getWindow(szName.C_String());
	if(!pWindow || SQ_FAILED(sq_setinstance(pVM, pWindow)))
	{
		CLogFile::Printf("Can't create GUIElement.");
		sq_pushbool(pVM, false);
		return 1;
	}

	SubscribeGuiEvents(pWindow);

	sq_pushbool(pVM, true);
	return 1;
}
Esempio n. 3
0
////////////////////////////////////////////////////
//
//  CNewsBrowser::LoadLayoutAndImages
//
//
//
////////////////////////////////////////////////////
CGUIWindow* CNewsBrowser::LoadLayoutAndImages(CGUIElement* pParent, const SNewsItem& newsItem)
{
    CGUI* pManager = g_pCore->GetGUI();

    // Make sure we have the layout filename
    if (newsItem.strLayoutFilename.empty())
    {
        AddReportLog(3302, SString("CNewsBrowser::LoadLayout: Problem loading %s", *newsItem.strContentFullDir));
        return NULL;
    }

    // Load any imagesets
    for (uint i = 0; i < newsItem.imagesetFilenameList.size(); i++)
    {
        if (!pManager->LoadImageset(newsItem.imagesetFilenameList[i]))
        {
            AddReportLog(
                3303, SString("CNewsBrowser::LoadLayout: Problem with LoadImageset [%s] %s", *newsItem.strContentFullDir, *newsItem.imagesetFilenameList[i]));
            return NULL;
        }
    }

    // Load layout
    CGUIWindow* pWindow = pManager->LoadLayout(pParent, newsItem.strLayoutFilename);
    if (!pWindow)
    {
        AddReportLog(3304, SString("CNewsBrowser::LoadLayout: Problem with LoadLayout [%s] %s", *newsItem.strContentFullDir, *newsItem.strLayoutFilename));
        return NULL;
    }
    return pWindow;
}
Esempio n. 4
0
////////////////////////////////////////////////////
//
//  CNewsBrowser::AddNewsTab
//
//
//
////////////////////////////////////////////////////
void CNewsBrowser::AddNewsTab(const SNewsItem& newsItem)
{
    CGUI* pManager = g_pCore->GetGUI();

    CGUITab* pTab = m_pTabPanel->CreateTab("News");
    m_TabList.push_back(pTab);

    // Create everything under a scrollpane
    CGUIScrollPane* m_pScrollPane = reinterpret_cast<CGUIScrollPane*>(pManager->CreateScrollPane(pTab));
    m_pScrollPane->SetProperty("ContentPaneAutoSized", "True");
    m_pScrollPane->SetPosition(CVector2D(3, 3), 0);
    m_pScrollPane->SetSize(CVector2D(618.0f, 390.0f));
    m_pScrollPane->SetVerticalScrollStepSize(0.15f);
    m_pScrollPane->SetVerticalScrollBar(true);

    // Switch cwd
    pManager->PushGuiWorkingDirectory(newsItem.strContentFullDir);

    // Load files
    CGUIWindow* pWindow = LoadLayoutAndImages(m_pScrollPane, newsItem);
    m_TabContentList.push_back(pWindow);

    // Set tab name from content window title
    if (pWindow)
    {
        SString strTitle = pWindow->GetText();
        if (!strTitle.empty())
            pTab->SetText(strTitle);
    }

    // Restore cwd
    pManager->PopGuiWorkingDirectory(newsItem.strContentFullDir);
}
Esempio n. 5
0
// GUIText
_MEMBER_FUNCTION_IMPL(GUIText, constructor)
{
	// Get our GUI
	CGUI * pGUI = g_pClient->GetGUI();

	CEGUI::Window * pWindow = pGUI->CreateGUIStaticText();

	if(!pWindow || SQ_FAILED(sq_setinstance(pVM, pWindow)))
	{
		CLogFile::Printf("Can't create GUIText.");
		sq_pushbool(pVM, false);
		return 1;
	}

	//_SET_RELEASE_HOOK(GUIElement);
	CClientScriptManager * pClientScriptManager = g_pClient->GetClientScriptManager();
	pClientScriptManager->GetGUIManager()->Add(pWindow, pClientScriptManager->GetScriptingManager()->Get(pVM));
	pWindow->setVisible(true);
	pWindow->setProperty("FrameEnabled", "false");
	pWindow->setProperty("BackgroundEnabled", "false");
	pWindow->setFont(pGUI->GetFont("tahoma-bold"));
	pWindow->setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF");
	
	SubscribeGuiEvents(pWindow);

	sq_pushbool(pVM, true);
	return 1;
}
Esempio n. 6
0
_MEMBER_FUNCTION_IMPL(GUIFont, drawText)
{
	CEGUI::Font * pFont = sq_getinstance<CEGUI::Font *>(pVM);

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

	const char* text;
	SQBool sbRelative;
	float x, y;
	sq_getfloat(pVM, -4, &x);
	sq_getfloat(pVM, -3, &y);
	sq_getstring(pVM, -2, &text);
	sq_getbool(pVM, -1, &sbRelative);

	// Get our GUI instance
	CGUI * pGUI = g_pClient->GetGUI();
	
	if(sbRelative != 0) 
	{
		x *= pGUI->GetDisplayWidth();
		y *= pGUI->GetDisplayHeight();
	}

	pGUI->DrawText(text, CEGUI::Vector2( x, y ), (CEGUI::colour)D3DCOLOR_RGBA(255, 255, 255, 255), pFont, true, true);
	sq_pushbool(pVM, true);
	return 1;
}
Esempio n. 7
0
void CLocalGUI::UpdateCursor ( void )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    static DWORD dwWidth = CDirect3DData::GetSingleton().GetViewportWidth();
    static DWORD dwHeight = CDirect3DData::GetSingleton().GetViewportHeight();
    static POINT pointStoredPosition;
    static bool bFirstRun = true;

    if ( bFirstRun )
    {
        pointStoredPosition.x = dwWidth / 2;
        pointStoredPosition.y = dwHeight / 2;
        bFirstRun = false;
    }
    // Called in each frame to make sure the mouse is only visible when a GUI control that uses the
    // mouse requires it.
    if ( InputGoesToGUI () )
    {
        // We didn't have focus last pulse?
        if ( !m_bGUIHasInput )
        {
            /* Store if the controller was enabled or not and disable it
            CCore::GetSingleton ().GetGame ()->GetPad ()->Disable ( true );
            CCore::GetSingleton ().GetGame ()->GetPad ()->Clear ();*/

            // Restore the mouse cursor to its old position
            SetCursorPos ( pointStoredPosition.x, pointStoredPosition.y );

            // Enable our mouse cursor
            CSetCursorPosHook::GetSingleton ( ).DisableSetCursorPos ();
            pGUI->SetCursorEnabled ( true );

            m_bGUIHasInput = true;
        }
    }
    else
    {
        // We had focus last frame?
        if ( m_bGUIHasInput )
        {
            /* Restore the controller state
            CCore::GetSingleton ().GetGame ()->GetPad ()->Disable ( false );
            CCore::GetSingleton ().GetGame ()->GetPad ()->Clear ();*/

            // Save the mouse cursor position
            GetCursorPos ( &pointStoredPosition );

            // Set the mouse back to the center of the screen (to prevent the game from reacting to its movement)
            SetCursorPos ( dwWidth / 2, dwHeight / 2 );

            // Disable our mouse cursor
            CSetCursorPosHook::GetSingleton ( ).EnableSetCursorPos ();
            pGUI->SetCursorEnabled ( false );

            m_bGUIHasInput = false;
        }
    }
}
Esempio n. 8
0
int main(int argc, char *argv[])
{
	CApplication application(argc, argv);
	CGUI w;
	w.showMaximized();
	int i = application.exec();
	return i;
}
// (John): Do we really need to re-position the GUI every time the D3D device resets?
void CQuickConnect::OnResetDevice()
{
        CGUI * pGUI = g_pClient->GetGUI();
        
        float fWidth = (float)pGUI->GetDisplayWidth();
        float fHeight = (float)pGUI->GetDisplayHeight();
        
        m_GUIElements.pWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, fWidth/2-150.0f), CEGUI::UDim(0, fHeight/2-120.0f)));
}
Esempio n. 10
0
void CLocalGUI::Draw ( void )
{
    // Get the game interface
    CGame* pGame = CCore::GetSingleton ().GetGame ();
    eSystemState SystemState = pGame->GetSystemState ();
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    // Update mainmenu stuff
    m_pMainMenu->Update ();

	// Make sure our version labels are always visible
	static short WaitForMenu = 0;
	if ( SystemState == 7 || SystemState == 9 ) {
		if ( WaitForMenu < 250 ) {
			WaitForMenu++;
		} else {
			m_pLabelVersionTag->SetVisible ( true );
		}
	}

    // If we're ingame, make sure the chatbox is drawn
    bool bChatVisible = ( SystemState == 9 /* GS_INGAME */ && m_pMainMenu->GetIsIngame () && m_bChatboxVisible && !CCore::GetSingleton ().IsOfflineMod() );
    if ( m_pChat->IsVisible () != bChatVisible )
        m_pChat->SetVisible ( bChatVisible );
    bool bDebugVisible = ( SystemState == 9 /* GS_INGAME */ && m_pMainMenu->GetIsIngame () && m_pDebugViewVisible && !CCore::GetSingleton ().IsOfflineMod() );
    if ( m_pDebugView->IsVisible () != bDebugVisible )
        m_pDebugView->SetVisible ( bDebugVisible );

    // Make sure the cursor is displayed only when needed
    UpdateCursor ();

	// Draw the chat
    m_pChat->Draw ();
    // Draw the debugger
    m_pDebugView->Draw ();

    // If we're not at the loadingscreen
    static bool bDelayedFrame = false;
    if ( SystemState != 8 || !bDelayedFrame /* GS_INIT_PLAYING_GAME */ )
    {
        // If we have a GUI manager, draw the GUI
        if ( pGUI )
        {
            pGUI->Draw ( );
        }
        else
        {
            WriteDebugEvent ( "WARNING: CLocalGUI::Draw() called, but CLocalGUI::CreateObjects() isn't!" );
        }

        // If the system state was 8, make sure we don't do another delayed frame
        if ( SystemState == 8 )
        {
            bDelayedFrame = true;
        }
    }
}
Esempio n. 11
0
// GUIImage
_MEMBER_FUNCTION_IMPL(GUIImage, constructor)
{
	const char * filename;
	sq_getstring(pVM, -1, &filename);

	// check file size
	/*FILE* pFile = fopen(filename, "rb");
	fseek(pFile, 0L, SEEK_END);
	int len = ftell(pFile);
	if(len == 0) {
		sq_pushbool(pVM, false);
		fclose(pFile);
		return 1;
	}
	fclose(pFile);*/

	// Get our GUI
	CGUI * pGUI = g_pClient->GetGUI();

	String szName = pGUI->GetUniqueName();

	// Try to load the image
	try
	{

		CEGUI::ImagesetManager::getSingleton().createFromImageFile(szName.C_String(), filename, "resources");
		CGUIStaticImage * pImage = pGUI->CreateGUIStaticImage(CEGUI::String(szName.C_String()));
		
		pImage->setProperty("FrameEnabled", "false");
		pImage->setProperty("BackgroundEnabled", "false");
		pImage->setProperty("Image", String("set:%s image:full_image", szName.C_String()).C_String());

		if(!pImage || SQ_FAILED(sq_setinstance(pVM, pImage)))
		{
			CLogFile::Printf("Can't create GUIImage.");
			sq_pushbool(pVM, false);
			return 1;
		}

		//_SET_RELEASE_HOOK(GUIElement);
		CClientScriptManager * pClientScriptManager = g_pClient->GetClientScriptManager();
		pClientScriptManager->GetGUIManager()->Add(pImage, pClientScriptManager->GetScriptingManager()->Get(pVM));

		SubscribeGuiEvents(pImage);

		pImage->setVisible(true);
		sq_pushbool(pVM, true);
		return 1;
	}
	catch(CEGUI::Exception e)
	{
		// Failed to load, might not exist
		CLogFile::Printf("Can't create GUIImage (%s does not exist)", filename);
		sq_pushbool(pVM, false);
		return 1;
	}
}
Esempio n. 12
0
// (John): Do we really need to re-position the GUI every time the D3D device resets?
void CSettingsMenu::OnResetDevice()
{
	CGUI * pGUI = g_pClient->GetGUI();
	
	float fWidth = (float)pGUI->GetDisplayWidth();
	float fHeight = (float)pGUI->GetDisplayHeight();
	
	m_GUIElements.pWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, fWidth/2-260), CEGUI::UDim(0, fHeight/2-190)));
}
CServerBrowser::~CServerBrowser(void)
{
	// Delete the query instances
	SAFE_DELETE(m_pServerQuery);
	SAFE_DELETE(m_pMasterListQuery);

	// Delete the GUI elements
	CGUI * pGUI = g_pClient->GetGUI();
	pGUI->RemoveGUIWindow(m_GUIElements.pWindow);
}
Esempio n. 14
0
void CLocalGUI::Invalidate ( void )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    // Invalidate the GUI
    if ( pGUI )
    {
        pGUI->Invalidate ( );
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::Invalidate() called, but CLocalGUI::CreateObjects() isn't!" );
    }
}
Esempio n. 15
0
void CDebugView::DrawText(String strText, DWORD dwColor)
{
	// Get our GUI
	CGUI * pGUI = g_pClient->GetGUI();

	// Get the font
	CEGUI::Font * pFont = pGUI->GetFont("tahoma", 10);

	// Draw the text
	pGUI->DrawText(strText, CEGUI::Vector2((float)pGUI->GetDisplayWidth()-400.0f, m_fDebugTextTop), CEGUI::colour(dwColor), pFont);

	// Increment the text top
	m_fDebugTextTop += 14.0f;
}
Esempio n. 16
0
void CLocalGUI::Restore ( void )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    if ( pGUI )
    {
        // Restore the GUI
        pGUI->Restore ();
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::Restore() called, but CLocalGUI::CreateObjects() isn't!" );
    }
}
Esempio n. 17
0
CFavouritesAddByIP::CFavouritesAddByIP ( void )
{
    CGUI *pManager = g_pCore->GetGUI ();
    CMainMenu *pMainMenu = CLocalGUI::GetSingleton ().GetMainMenu ();

    // Create the window
    m_pWindow = reinterpret_cast < CGUIWindow* > ( pManager->CreateWnd ( NULL, "Add to favourites" ) );
    m_pWindow->SetCloseButtonEnabled ( false );

    CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
    m_pWindow->SetPosition ( CVector2D ( resolution.fX / 2 - 280.0f / 2, resolution.fY / 2 - 90.0f / 2  ), false );
    m_pWindow->SetSize ( CVector2D ( 280.0f, 90.0f ), false );
    m_pWindow->SetSizingEnabled ( false );
	m_pWindow->SetAlwaysOnTop ( true );

    // Create the controls
    float fPosX = 0.0f;
    float fButtonWidth = (280.0f - 30.0f) / 2;

    //  Host label
    m_pLabelHost = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, "Host:" ) );
    m_pLabelHost->SetPosition ( CVector2D ( fPosX + 12.0f, 28.0f ), false );
    m_pLabelHost->AutoSize ( "Host:" );
    fPosX += 12.0f + m_pLabelHost->GetSize ().fX;

    //  Host edit
    m_pEditHost = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pWindow ) );
    m_pEditHost->SetPosition ( CVector2D ( fPosX + 5.0f, 24.0f ), false );
    m_pEditHost->SetSize ( CVector2D ( 154.0f, 24.0f ), false );
    m_pEditHost->SetMaxLength ( 128 );          // Just to prevent entering a huge hostname size.. no-one has a hostname over 128 chars i believe
    fPosX += 5.0f + 154.0f;

    //  Port label
    m_pLabelPort = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, ":" ) );
    m_pLabelPort->SetPosition ( CVector2D ( fPosX + 3.0f, 28.0f ), false );
    m_pLabelPort->AutoSize ( ":" );
    fPosX += 3.0f + m_pLabelPort->GetSize ().fX;

    //  Port edit
    m_pEditPort = reinterpret_cast < CGUIEdit* > ( pManager->CreateEdit ( m_pWindow ) );
    m_pEditPort->SetPosition ( CVector2D ( fPosX + 3.0f, 24.0f ), false );
    m_pEditPort->SetSize ( CVector2D ( 59.0f, 24.0f ), false );
    m_pEditPort->SetMaxLength ( 5 );
    fPosX += 3.0f + 59.0f;

    //  Add button
    m_pButtonAdd = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pWindow, "Add" ) );
    m_pButtonAdd->SetPosition ( CVector2D ( 12.0f, 60.0f ), false );
    m_pButtonAdd->SetSize ( CVector2D ( fButtonWidth, 20.0f ), false );

    //  Cancel button
    m_pButtonBack = reinterpret_cast < CGUIButton* > ( pManager->CreateButton ( m_pWindow, "Back" ) );
    m_pButtonBack->SetPosition ( CVector2D ( 12.0f + fButtonWidth + 6.0f, 60.0f ), false );
    m_pButtonBack->SetSize ( CVector2D ( fButtonWidth, 20.0f ), false );

    // Register button events
    m_pButtonBack->SetClickHandler ( GUI_CALLBACK ( &CFavouritesAddByIP::OnButtonBackClick, this ) );
}
Esempio n. 18
0
void CLocalGUI::CreateWindows ( void )
{
    CFilePathTranslator     FileTranslator;
    string                  WorkingDirectory;
    char                    szCurDir [ 1024 ];

    // Set the current directory.
    FileTranslator.SetCurrentWorkingDirectory ( "MTA" );
    FileTranslator.GetCurrentWorkingDirectory ( WorkingDirectory );
    GetCurrentDirectory ( sizeof ( szCurDir ), szCurDir );
    SetCurrentDirectory ( WorkingDirectory.c_str ( ) );

    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    // Create chatbox
    m_pChat = new CChat ( pGUI, CVector2D ( 0.0125f, 0.015f ) );
    m_pChat->SetVisible ( false );

    // Create the debug view
    m_pDebugView = new CDebugView ( pGUI, CVector2D ( 0.23f, 0.785f ) );
    m_pDebugView->SetVisible ( false );

	// Create the overlayed version labels
	CVector2D ScreenSize = pGUI->GetResolution ();
    m_pLabelVersionTag = reinterpret_cast < CGUILabel* > ( pGUI->CreateLabel ( "MTA:SA " MTA_DM_BUILDTAG_SHORT ) );
	m_pLabelVersionTag->SetSize ( CVector2D ( m_pLabelVersionTag->GetTextExtent() + 5, 18 ) );
	m_pLabelVersionTag->SetPosition ( CVector2D ( ScreenSize.fX - m_pLabelVersionTag->GetTextExtent() - 5, ScreenSize.fY - 15 ) );
	m_pLabelVersionTag->SetAlpha ( 0.5f );
	m_pLabelVersionTag->SetTextColor ( 255, 255, 255 );
	m_pLabelVersionTag->SetZOrderingEnabled ( false );
    m_pLabelVersionTag->MoveToBack ();
    m_pLabelVersionTag->SetVisible ( false );

    // Create mainmenu
    m_pMainMenu = new CMainMenu ( pGUI );
    m_pMainMenu->SetVisible ( false );

    // Create console
    m_pConsole = new CConsole ( pGUI );
    m_pConsole->SetVisible ( false );

    // Create community registration window
    m_CommunityRegistration.CreateWindows ();
    m_CommunityRegistration.SetVisible ( false );

	// Return the old current dir.
    SetCurrentDirectory ( szCurDir );
}
CServerBrowser::CServerBrowser(void)
{
	assert(!m_pSingleton);

	// Set our singleton
	m_pSingleton = this;

	// Create the master list query instance and set its handler
	m_pMasterListQuery = new CMasterListQuery(MASTERLIST_ADDRESS, MASTERLIST_VERSION);
	m_pMasterListQuery->SetMasterListQueryHandler(MasterListQueryHandler);

	// Create the server query instance and set its handler
	m_pServerQuery = new CServerQuery();
	m_pServerQuery->SetServerQueryHandler(ServerQueryHandler);

	// Setup the GUI
	CGUI * pGUI = g_pClient->GetGUI();

	float fWidth = (float)pGUI->GetDisplayWidth();
	float fHeight = (float)pGUI->GetDisplayHeight();

	m_GUIElements.pWindow = pGUI->CreateGUIFrameWindow();
	m_GUIElements.pWindow->setText("Server Browser");
	m_GUIElements.pWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0, 900.0f), CEGUI::UDim(0, 500.0f)));
	m_GUIElements.pWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0, fWidth/2-450.0f), CEGUI::UDim(0, fHeight/2-250.0f)));
	m_GUIElements.pWindow->subscribeEvent(CEGUI::FrameWindow::EventCloseClicked, CEGUI::Event::Subscriber(&CServerBrowser::OnCloseClick, this));
	m_GUIElements.pWindow->setVisible(false);

	m_GUIElements.pServerMultiColumnList = pGUI->CreateGUIMultiColumnList(m_GUIElements.pWindow);
	m_GUIElements.pServerMultiColumnList->setText("Server Browser");
	m_GUIElements.pServerMultiColumnList->setSize(CEGUI::UVector2(CEGUI::UDim(0.950f, 0), CEGUI::UDim(0.8250f, 0)));
	m_GUIElements.pServerMultiColumnList->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0250f, 0), CEGUI::UDim(0.0250f, 0)));
	m_GUIElements.pServerMultiColumnList->setProperty("ColumnHeader", "text:Name width:{0.5,0} id:0");
	m_GUIElements.pServerMultiColumnList->setProperty("ColumnHeader", "text:Host width:{0.2,0} id:1");
	m_GUIElements.pServerMultiColumnList->setProperty("ColumnHeader", "text:Players width:{0.1,0} id:2");
	m_GUIElements.pServerMultiColumnList->setProperty("ColumnHeader", "text:Ping width:{0.1,0} id:3");
	m_GUIElements.pServerMultiColumnList->setProperty("ColumnHeader", "text:Locked width:{0.09,0} id:4");
	m_GUIElements.pServerMultiColumnList->setFont(pGUI->GetFont("tahoma-bold", 10));
	m_GUIElements.pServerMultiColumnList->subscribeEvent(CEGUI::Window::EventMouseClick, CEGUI::Event::Subscriber(&CServerBrowser::OnRowClick, this));

	m_GUIElements.pRefreshButton = pGUI->CreateGUIButton(m_GUIElements.pWindow);
	m_GUIElements.pRefreshButton->setText("Refresh");
	m_GUIElements.pRefreshButton->setSize(CEGUI::UVector2(CEGUI::UDim(0.20f, 0), CEGUI::UDim(0.10f, 0)));
	m_GUIElements.pRefreshButton->setPosition(CEGUI::UVector2(CEGUI::UDim(0.550f, 0), CEGUI::UDim(0.8750f, 0)));
	m_GUIElements.pRefreshButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CServerBrowser::OnRefreshButtonClick, this));

	m_GUIElements.pConnectButton = pGUI->CreateGUIButton(m_GUIElements.pWindow);
	m_GUIElements.pConnectButton->setText("Connect");
	m_GUIElements.pConnectButton->setSize(CEGUI::UVector2(CEGUI::UDim(0.20f, 0), CEGUI::UDim(0.10f, 0)));
	m_GUIElements.pConnectButton->setPosition(CEGUI::UVector2(CEGUI::UDim(0.7750f, 0), CEGUI::UDim(0.8750f, 0)));
	m_GUIElements.pConnectButton->setEnabled(false);
	m_GUIElements.pConnectButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&CServerBrowser::OnConnectButtonClick, this));

	m_bVisible = false;
}
Esempio n. 20
0
bool CLocalGUI::InputGoesToGUI ( void )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();
    if ( !pGUI ) return false;

    // Here we're supposed to check if things like menues are up, console is up or the chatbox is expecting input
    // If the console is visible OR the chat is expecting input OR the mainmenu is visible
    return ( IsConsoleVisible () || IsMainMenuVisible () || IsChatBoxInputEnabled () || m_bForceCursorVisible || pGUI->GetGUIInputEnabled () || !CCore::GetSingleton ().IsFocused () );
}
Esempio n. 21
0
void CChatWindow::InitFontAndBackground()
{
	// Get our GUI
	CGUI * pGUI = g_pClient->GetGUI();

	// Load our chat font
	m_pFont = pGUI->GetFont(CVAR_GET_STRING("chatfont").Get(), CVAR_GET_INTEGER("chatsize"));

	// Do we not have a valid font?
	if(!m_pFont)
		pGUI->ShowMessageBox("Invalid chat font.\nPlease set a valid font in the Chat tab of the Settings menu.", "Warning");

	// Set our background colors
	m_ulBackgroundColor = D3DCOLOR_ARGB(CVAR_GET_INTEGER("chatbga"), 
										CVAR_GET_INTEGER("chatbgr"), 
										CVAR_GET_INTEGER("chatbgg"), 
										CVAR_GET_INTEGER("chatbgb"));
}
Esempio n. 22
0
void CLocalGUI::SetSkin( const char* szName )
{
    bool guiWasLoaded = m_pMainMenu != NULL;
    if(guiWasLoaded)
        DestroyWindows();

    std::string error;

    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    try 
    {
        pGUI->SetSkin(szName);
        m_LastSkinName = szName;
    }
    catch (...)
    {
        try
        {
            pGUI->SetSkin(DEFAULT_SKIN_NAME);

            error = "The skin '" + std::string(szName) + "' that you have selected could not be loaded. MTA is now using the default skin instead.";
            
            CVARS_SET("current_skin", std::string(DEFAULT_SKIN_NAME));    
            m_LastSkinName = DEFAULT_SKIN_NAME;
        }
        catch(...)
        {
            // Even the default skin doesn't work, so give up
            MessageBoxUTF8 ( 0, _("The skin you selected could not be loaded, and the default skin also could not be loaded, please reinstall MTA."), _("Error")+_E("CC51"), MB_OK | MB_ICONERROR | MB_TOPMOST );
            TerminateProcess ( GetCurrentProcess (), 9 );
        }
    }

    CClientVariables* cvars = CCore::GetSingleton().GetCVars();
    m_LastSettingsRevision = cvars->GetRevision();

    if(guiWasLoaded)
        CreateWindows(guiWasLoaded);

    if(CCore::GetSingleton().GetConsole() && !error.empty())
        CCore::GetSingleton().GetConsole()->Echo(error.c_str());

}
Esempio n. 23
0
void CLocalGUI::CreateWindows ( bool bGameIsAlreadyLoaded )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    // Create chatbox
    m_pChat = new CChat ( pGUI, CVector2D ( 0.0125f, 0.015f ) );
    m_pChat->SetVisible ( false );

    // Create the debug view
    m_pDebugView = new CDebugView ( pGUI, CVector2D ( 0.23f, 0.785f ) );
    m_pDebugView->SetVisible ( false );

    // Create the overlayed version labels
    CVector2D ScreenSize = pGUI->GetResolution ();
    SString strText = "MTA:SA " MTA_DM_BUILDTAG_SHORT;
    if ( _NETCODE_VERSION_BRANCH_ID != 0x04 )
        strText += SString( " (%X)", _NETCODE_VERSION_BRANCH_ID );
    m_pLabelVersionTag = reinterpret_cast < CGUILabel* > ( pGUI->CreateLabel ( strText ) );
    m_pLabelVersionTag->SetSize ( CVector2D ( m_pLabelVersionTag->GetTextExtent() + 5, 18 ) );
    m_pLabelVersionTag->SetPosition ( CVector2D ( ScreenSize.fX - m_pLabelVersionTag->GetTextExtent() - 5, ScreenSize.fY - 15 ) );
    m_pLabelVersionTag->SetAlpha ( 0.5f );
    m_pLabelVersionTag->SetTextColor ( 255, 255, 255 );
    m_pLabelVersionTag->SetZOrderingEnabled ( false );
    m_pLabelVersionTag->MoveToBack ();
    m_pLabelVersionTag->SetVisible ( false );

    // Create mainmenu
    m_pMainMenu = new CMainMenu ( pGUI );
    m_pMainMenu->SetVisible ( bGameIsAlreadyLoaded, !bGameIsAlreadyLoaded, false );

    // Create console
    m_pConsole = new CConsole ( pGUI );
    m_pConsole->SetVisible ( false );

    // Create community registration window
    m_CommunityRegistration.CreateWindows ();
    m_CommunityRegistration.SetVisible ( false );

    // Create our news headlines if we're already ingame
    if ( bGameIsAlreadyLoaded )
        m_pMainMenu->GetNewsBrowser()->CreateHeadlines();
}
Esempio n. 24
0
void CLocalGUI::Restore ( void )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    if ( pGUI )
    {
        CFilePathTranslator     FileTranslator;
        string                  WorkingDirectory;
        char                    szCurDir [ 1024 ];

        // We must change the current directory here!
        // This is necessary because if we don't, CLocalGUI will try to load
        // files from the wrong path!

        // Set the current directory.
        FileTranslator.SetCurrentWorkingDirectory ( "MTA" );
        FileTranslator.GetCurrentWorkingDirectory ( WorkingDirectory );
        GetCurrentDirectory ( sizeof ( szCurDir ), szCurDir );
        SetCurrentDirectory ( WorkingDirectory.c_str ( ) );

        // Restore the GUI
        pGUI->Restore ();

	    // Restore our renderer.
        if ( m_pRendererLibrary )
        {
	        m_pRendererLibrary->OnRestoreDevice ( );
        }
        else
        {
            WriteDebugEvent ( "WARNING: CLocalGUI::Restore() called, but CLocalGUI::CreateObjects() isn't!" );
        }

        // Restore the current directory to default.
        SetCurrentDirectory ( szCurDir );
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::Restore() called, but CLocalGUI::CreateObjects() isn't!" );
    }
}
Esempio n. 25
0
void CLocalGUI::SetMainMenuVisible ( bool bVisible )
{
    if ( m_pMainMenu )
    {
        // This code installs the original CCore input handlers when the ingame menu
        // is shown, and restores the mod input handlers when the menu is hidden again.
        // This is needed for things like pressing escape when changing a key bind

        m_pMainMenu->SetVisible ( bVisible );

        CGUI* pGUI = CCore::GetSingleton ().GetGUI ();
        if ( bVisible )
        {
            pGUI->SelectInputHandlers ( INPUT_CORE );
        }
        else
        {
            pGUI->SelectInputHandlers ( INPUT_MOD );
        }

        if ( bVisible )
            pGUI->SetCursorAlpha ( 1.0f );
        else
            pGUI->SetCursorAlpha ( pGUI->GetCurrentServerCursorAlpha () );
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::SetMainMenuVisible() called, but CLocalGUI::CreateObjects() isn't" );
    }
}
Esempio n. 26
0
void CLocalGUI::SetConsoleVisible ( bool bVisible )
{
    if ( m_pConsole )
    {
        // Only allow the console if the chat doesn't take input
        if ( m_pChat->IsInputVisible () )
            bVisible = false;
        
        // Set the visible state
        m_pConsole->SetVisible ( bVisible );

        CGUI* pGUI = CCore::GetSingleton ().GetGUI ();
        if ( bVisible )
	        pGUI->SetCursorAlpha ( 1.0f );
        else
	        pGUI->SetCursorAlpha ( pGUI->GetCurrentServerCursorAlpha () );
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::HideConsole() called, but CLocalGUI::CreateObjects() isn't!" );
    }
}
Esempio n. 27
0
CQuestionBox::CQuestionBox ( void )
{
    m_pWindow = NULL;
    m_pMessage = NULL;
    m_uiLastButton = -1;
    m_Callback = NULL;
    m_CallbackParameter = 0;
    m_uiActiveButtons = 0;
    m_uiActiveEditboxes = 0;

    CGUI *pManager = g_pCore->GetGUI ();

    // Create the window
    m_pWindow = reinterpret_cast < CGUIWindow* > ( pManager->CreateWnd ( NULL, "" ) );
    m_pWindow->SetCloseButtonEnabled ( false );
    m_pWindow->SetVisible ( false );
    m_pWindow->SetSizingEnabled ( false );
    m_pWindow->SetAlwaysOnTop ( true );

    // Message label
    m_pMessage = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( m_pWindow, "" ) );
}
Esempio n. 28
0
////////////////////////////////////////////////////
//
//  CNewsBrowser::CreateGUI
//
//
//
////////////////////////////////////////////////////
void CNewsBrowser::CreateGUI(void)
{
    CreateHeadlines();
    CGUI* pManager = g_pCore->GetGUI();

    // Create the window
    m_pWindow = reinterpret_cast<CGUIWindow*>(pManager->CreateWnd(NULL, "NEWS"));
    m_pWindow->SetCloseButtonEnabled(true);
    m_pWindow->SetMovable(true);

    CVector2D resolution = CCore::GetSingleton().GetGUI()->GetResolution();
    float     yoff = resolution.fY > 600 ? resolution.fY / 12 : 0.0f;
    m_pWindow->SetPosition(CVector2D(resolution.fX / 2 - 640.0f / 2, resolution.fY / 2 - 480.0f / 2 + yoff), false);
    m_pWindow->SetSize(CVector2D(640.0f, 480.0f));
    m_pWindow->SetSizingEnabled(false);
    m_pWindow->SetAlwaysOnTop(true);

    // Create buttons
    //  OK button
    m_pButtonOK = reinterpret_cast<CGUIButton*>(pManager->CreateButton(m_pWindow, "OK"));
    m_pButtonOK->SetPosition(CVector2D(560.0f - 60, 480.0f - 30));
    m_pButtonOK->SetZOrderingEnabled(false);

    // Set up the events
    m_pWindow->SetEnterKeyHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this));
    m_pButtonOK->SetClickHandler(GUI_CALLBACK(&CNewsBrowser::OnOKButtonClick, this));

    // Create the tab panel and necessary tabs
    m_pTabPanel = reinterpret_cast<CGUITabPanel*>(pManager->CreateTabPanel(m_pWindow));
    m_pTabPanel->SetPosition(CVector2D(0, 20.0f));
    m_pTabPanel->SetSize(CVector2D(640.0f, 480.0f - 60));

    for (uint i = 0; i < m_NewsitemList.size(); i++)
    {
        AddNewsTab(m_NewsitemList[i]);
    }
}
Esempio n. 29
0
void CLocalGUI::Invalidate ( void )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    // Invalidate the GUI
    if ( pGUI )
    {
        pGUI->Invalidate ( );
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::Invalidate() called, but CLocalGUI::CreateObjects() isn't!" );
    }

    // Invalidate the renderer library
    if ( m_pRendererLibrary )
    {
        m_pRendererLibrary->OnInvalidateDevice ( );
    }
    else
    {
        WriteDebugEvent ( "WARNING: CLocalGUI::Invalidate() called, but CLocalGUI::CreateObjects() isn't!" );
    }
}
Esempio n. 30
0
void CChatWindow::Draw()
{
	// Get our GUI
	CGUI * pGUI = g_pClient->GetGUI();

	// Are we enabled and do we have a valid GUI instance?
	if(m_bEnabled && pGUI)
	{
		// Draw the chat background
		g_pClient->GetGraphics()->DrawRect(5, 5, 500, 30 + MAX_DISPLAYED_MESSAGES * 20, m_ulBackgroundColor);

		// Do we have a valid font?
		if(m_pFont)
		{
			int iCurrentMessage = (m_iCurrentPage * MAX_DISPLAYED_MESSAGES) - 1;
			float fY = 30;

			for(int x = 0; x < MAX_DISPLAYED_MESSAGES; x++)
			{
				// Draw the text
				if(m_chatMessages[iCurrentMessage - x].fNameExtent)
				{
					// Draw a name shadow
					pGUI->DrawText(m_chatMessages[iCurrentMessage - x].szName, CEGUI::Vector2(26.0f, fY + 1), MESSAGE_BACKGROUND_COLOR, m_pFont, m_chatMessages[iCurrentMessage - x].bAllowFormatting, false);

					// Draw the name
					pGUI->DrawText(m_chatMessages[iCurrentMessage - x].szName, CEGUI::Vector2(25.0f, fY), m_chatMessages[iCurrentMessage - x].nameColor, m_pFont, m_chatMessages[iCurrentMessage - x].bAllowFormatting);

					// Draw a text shadow
					pGUI->DrawText(m_chatMessages[iCurrentMessage - x].szMessage, CEGUI::Vector2(26.0f + m_chatMessages[iCurrentMessage - x].fNameExtent, fY + 1), MESSAGE_BACKGROUND_COLOR, m_pFont, m_chatMessages[iCurrentMessage - x].bAllowFormatting);

					// Draw the text
					pGUI->DrawText(m_chatMessages[iCurrentMessage - x].szMessage, CEGUI::Vector2(25.0f + m_chatMessages[iCurrentMessage - x].fNameExtent, fY), m_chatMessages[iCurrentMessage - x].messageColor, m_pFont, m_chatMessages[iCurrentMessage - x].bAllowFormatting);
				}
				else
				{
					// Draw a shadow
					pGUI->DrawText(m_chatMessages[iCurrentMessage - x].szMessage, CEGUI::Vector2(26.0f, fY + 1), MESSAGE_BACKGROUND_COLOR, m_pFont, m_chatMessages[iCurrentMessage - x].bAllowFormatting, false);

					// Draw the text
					pGUI->DrawText(m_chatMessages[iCurrentMessage - x].szMessage, CEGUI::Vector2(25.0f, fY), m_chatMessages[iCurrentMessage - x].messageColor, m_pFont, m_chatMessages[iCurrentMessage - x].bAllowFormatting);
				}

				fY += 20;
			}
		}
	}
}