本文整理汇总了C++中CGUI类的典型用法代码示例。如果您正苦于以下问题:C++ CGUI类的具体用法?C++ CGUI怎么用?C++ CGUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CGUI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _MEMBER_FUNCTION_IMPL
_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;
}
示例2: AddReportLog
////////////////////////////////////////////////////
//
// 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;
}
示例3: LoadLayoutAndImages
////////////////////////////////////////////////////
//
// 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);
}
示例4: UpdateCursor
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;
}
}
}
示例5: main
int main(int argc, char *argv[])
{
CApplication application(argc, argv);
CGUI w;
w.showMaximized();
int i = application.exec();
return i;
}
示例6: OnResetDevice
// (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)));
}
示例7: Draw
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;
}
}
}
示例8: OnResetDevice
// (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)));
}
示例9: SAFE_DELETE
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);
}
示例10: Invalidate
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!" );
}
}
示例11: DrawText
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;
}
示例12: Restore
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!" );
}
}
示例13: CVector2D
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 ) );
}
示例14: GetCurrentDirectory
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 );
}
示例15: assert
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;
}