Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Play button to CMainMenu and made a slight menu change #48

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions MTA10/core/CMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ CMainMenu::CMainMenu ( CGUI* pManager )
m_pVersion = reinterpret_cast < CGUIStaticImage* > ( pManager->CreateStaticImage () );
m_pVersion->LoadFromFile ( CORE_MTA_VERSION );
m_pVersion->SetParent ( m_pCanvas );
m_pVersion->SetPosition ( CVector2D(0.845f,0.528f), true);
m_pVersion->SetPosition ( CVector2D ( 0.845f, 0.544f ), true );
m_pVersion->SetSize ( CVector2D((32/NATIVE_RES_X)*m_iMenuSizeX,(32/NATIVE_RES_Y)*m_iMenuSizeY), false);
m_pVersion->SetProperty("InheritsAlpha", "False" );

Expand All @@ -181,22 +181,23 @@ CMainMenu::CMainMenu ( CGUI* pManager )
if ( CCore::GetSingleton().GetCommunity()->IsLoggedIn() && !strUsername.empty() )
ChangeCommunityState ( true, strUsername );

float fBase = 0.613f;
float fGap = 0.043f;
float fBase = 0.595f;
float fGap = 0.025f;
// Our disconnect item is shown/hidden dynamically, so we store it seperately
m_pDisconnect = CreateItem ( MENU_ITEM_DISCONNECT, "menu_disconnect.png", CVector2D ( 0.168f, fBase + fGap * 0 ) );
m_pDisconnect = CreateItem ( MENU_ITEM_DISCONNECT, "menu_disconnect.png", CVector2D ( 0.168f, fBase + (fGap * 0) ) );
m_pDisconnect->image->SetVisible(false);

// Create the menu items
//Filepath, Relative position, absolute native size
// And the font for the graphics is ?
m_menuItems.push_back ( CreateItem ( MENU_ITEM_QUICK_CONNECT, "menu_quick_connect.png", CVector2D ( 0.168f, fBase + fGap * 0 ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_BROWSE_SERVERS, "menu_browse_servers.png", CVector2D ( 0.168f, fBase + fGap * 1 ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_HOST_GAME, "menu_host_game.png", CVector2D ( 0.168f, fBase + fGap * 2 ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_MAP_EDITOR, "menu_map_editor.png", CVector2D ( 0.168f, fBase + fGap * 3 ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_SETTINGS, "menu_settings.png", CVector2D ( 0.168f, fBase + fGap * 4 ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_ABOUT, "menu_about.png", CVector2D ( 0.168f, fBase + fGap * 5 ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_QUIT, "menu_quit.png", CVector2D ( 0.168f, fBase + fGap * 6 ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_PLAY, "menu_play.png", CVector2D ( 0.168f, fBase + (fGap * 0) ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_QUICK_CONNECT, "menu_quick_connect.png", CVector2D ( 0.168f, fBase + (fGap * 1) ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_BROWSE_SERVERS, "menu_browse_servers.png", CVector2D ( 0.168f, fBase + (fGap * 2) ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_HOST_GAME, "menu_host_game.png", CVector2D ( 0.168f, fBase + (fGap * 3) ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_MAP_EDITOR, "menu_map_editor.png", CVector2D ( 0.168f, fBase + (fGap * 4) ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_SETTINGS, "menu_settings.png", CVector2D ( 0.168f, fBase + (fGap * 5) ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_ABOUT, "menu_about.png", CVector2D ( 0.168f, fBase + (fGap * 6) ) ) );
m_menuItems.push_back ( CreateItem ( MENU_ITEM_QUIT, "menu_quit.png", CVector2D ( 0.168f, fBase + (fGap * 7) ) ) );

// We store the position of the top item, and the second item. These will be useful later
float fFirstItemSize = m_menuItems.front()->image->GetSize(false).fY;
Expand Down Expand Up @@ -777,6 +778,7 @@ bool CMainMenu::OnMenuClick ( CGUIElement* pElement )
{
switch (m_pHoveredItem->menuType)
{
case MENU_ITEM_PLAY:
case MENU_ITEM_HOST_GAME:
case MENU_ITEM_MAP_EDITOR:
AskUserIfHeWantsToDisconnect( m_pHoveredItem->menuType );
Expand All @@ -787,6 +789,7 @@ bool CMainMenu::OnMenuClick ( CGUIElement* pElement )

switch (m_pHoveredItem->menuType)
{
case MENU_ITEM_PLAY: OnPlayButtonClick (); break;
case MENU_ITEM_DISCONNECT: OnDisconnectButtonClick (pElement); break;
case MENU_ITEM_QUICK_CONNECT: OnQuickConnectButtonClick (pElement); break;
case MENU_ITEM_BROWSE_SERVERS: OnBrowseServersButtonClick(pElement); break;
Expand Down Expand Up @@ -860,6 +863,14 @@ bool CMainMenu::OnDisconnectButtonClick ( CGUIElement* pElement )
return true;
}

bool CMainMenu::OnPlayButtonClick(void)
{
// Return if we haven't faded in yet
if (m_ucFade != FADE_VISIBLE) return false;

CModManager::GetSingleton().RequestLoad ( "deathmatch", "play" );
return true;
}

bool CMainMenu::OnHostGameButtonClick ( void )
{
Expand Down Expand Up @@ -1135,6 +1146,7 @@ void CMainMenu::WantsToDisconnectCallBack( void* pData, uint uiButton )
uchar menuType = (uchar)pData;
switch( menuType )
{
case MENU_ITEM_PLAY: OnPlayButtonClick (); break;
case MENU_ITEM_HOST_GAME: OnHostGameButtonClick (); break;
case MENU_ITEM_MAP_EDITOR: OnEditorButtonClick (); break;
default: break;
Expand Down
2 changes: 2 additions & 0 deletions MTA10/core/CMainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class CMainMenu
bool OnQuickConnectButtonClick ( CGUIElement* pElement );
bool OnResumeButtonClick ( CGUIElement* pElement );
bool OnBrowseServersButtonClick ( CGUIElement* pElement );
bool OnPlayButtonClick ( void );
bool OnHostGameButtonClick ( void );
bool OnDisconnectButtonClick ( CGUIElement* pElement );
bool OnEditorButtonClick ( void );
Expand Down Expand Up @@ -181,6 +182,7 @@ class CMainMenu

// Main menu items
enum eMenuItems {
MENU_ITEM_PLAY,
MENU_ITEM_DISCONNECT,
MENU_ITEM_QUICK_CONNECT,
MENU_ITEM_BROWSE_SERVERS,
Expand Down
12 changes: 11 additions & 1 deletion MTA10/mods/deathmatch/CClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,17 @@ int CClient::ClientInitialize ( const char* szArguments, CCoreInterface* pCore )
char* szPass = strtok ( NULL, " " );

// Are we supposed to launch the server and play locally?
if ( stricmp ( szArguments, "local" ) == 0 )
if ( stricmp ( szArguments, "play" ) == 0 )
{
// Create clientgame
g_pClientGame = new CClientGame( true );

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also plan to implement functionality to join the previous server connected to and have this behavior the default, then on launch, if the button is pressed, ask the user whether they would like to reconnect to the server they last connected to the last time they had MTA:SA open and if they have never joined a server simply start a local server as-is the case in this commit.

g_pClientGame->SetupLocalGame ( CClientGame::SERVER_TYPE_LOCAL );

// Connect
g_pClientGame->StartLocalGame ( CClientGame::SERVER_TYPE_LOCAL );
}
else if ( stricmp ( szArguments, "local" ) == 0 )
{
// Create clientgame
g_pClientGame = new CClientGame ( true );
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.