void CTilegenKVEditorPage::OnCommand( const char *command )
{
	if ( !Q_stricmp( command, "Save" ) )
	{
		KeyValues *pKV = GetKeyValues();
						
		char fullFilePathBuffer [512];
		Q_snprintf(fullFilePathBuffer, sizeof(fullFilePathBuffer),"C:\\Program Files\\Steam\\steamapps\\sourcemods\\alienswarmdirectormod\\%s", m_szFilename);
		Msg("Saving to [%s]", fullFilePathBuffer);

		//if ( pKV != NULL && !pKV->SaveToFile( g_pFullFileSystem, m_szFilename, "GAME" ) )
		if ( pKV != NULL && !pKV->SaveToFile( g_pFullFileSystem, fullFilePathBuffer ) )
		{
			if ( p4 )
			{
				char fullPath[MAX_PATH];
				g_pFullFileSystem->RelativePathToFullPath( m_szFilename, "GAME", fullPath, MAX_PATH );
				if ( p4->IsFileInPerforce( fullPath ) )
				{
					MessageBox *pMessage = new MessageBox( "Check Out?", "File is not writeable. Would you like to check it out from Perforce?", this );
					pMessage->SetCancelButtonVisible( true );
					pMessage->SetOKButtonText( "#MessageBox_Yes" );
					pMessage->SetCancelButtonText( "#MessageBox_No" );
					pMessage->SetCommand( new KeyValues( "CheckOutFromP4", "file", fullPath ) );
					pMessage->DoModal();
					return;
				}
			}
			else
			{
				VGUIMessageBox( this, "Save Error", "Failed to save %s.  Make sure file is checked out from Perforce.", m_szFilename );
			}
		}
		UpdateList();
		return;
	}
	else if ( !Q_stricmp( command, "New" ) )
	{
		SaveNew();
		return;
	}
	BaseClass::OnCommand( command );
}
Exemplo n.º 2
0
void CTilegenKVEditorPage::OnCommand( const char *command )
{
	if ( !Q_stricmp( command, "Save" ) )
	{
		KeyValues *pKV = GetKeyValues();

		if ( pKV != NULL && !pKV->SaveToFile( g_pFullFileSystem, m_szFilename, "MOD" ) )
		{
			if ( p4 )
			{
				char fullPath[MAX_PATH];
				g_pFullFileSystem->RelativePathToFullPath( m_szFilename, "MOD", fullPath, MAX_PATH );
				if ( p4->IsFileInPerforce( fullPath ) )
				{
					MessageBox *pMessage = new MessageBox( "Check Out?", "File is not writeable. Would you like to check it out from Perforce?", this );
					pMessage->SetCancelButtonVisible( true );
					pMessage->SetOKButtonText( "#MessageBox_Yes" );
					pMessage->SetCancelButtonText( "#MessageBox_No" );
					pMessage->SetCommand( new KeyValues( "CheckOutFromP4", "file", fullPath ) );
					pMessage->DoModal();
					return;
				}
			}
			else
			{
				VGUIMessageBox( this, "Save Error", "Failed to save %s.  Make sure file is checked out from Perforce.", m_szFilename );
			}
		}
		UpdateList();
		return;
	}
	else if ( !Q_stricmp( command, "New" ) )
	{
		SaveNew();
		return;
	}
	BaseClass::OnCommand( command );
}