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 CTilegenLayoutSystemPage::OnFileSelected( const char *pFullPath )
{
	if ( g_pFullFileSystem->FileExists( pFullPath ) )
	{
		VGUIMessageBox( this, "Save Error", "A layout system already exists with filename %s.", pFullPath );
		return;
	}
	// create new keys
	KeyValues *pNewKeys = new KeyValues( "Mission" );
	// save them at the full path
	if ( !pNewKeys->SaveToFile( g_pFullFileSystem, pFullPath ) )
	{
		VGUIMessageBox( this, "Save Error", "Failed to save new file %s.", pFullPath );
		return;
	}
	m_pEditor->SetMissionData( pNewKeys );

	m_pReloadMissionButton->SetVisible( true );
	m_pSaveButton->SetVisible( true );
	m_pGenerateButton->SetVisible( true );
	bool bConverted = g_pFullFileSystem->FullPathToRelativePath( pFullPath, m_szFilename, MAX_PATH );
	if ( !bConverted )
	{
		Warning( "Failed to convert this to a relative path: %s\n", pFullPath );
		return;
	}
	m_pFilenameLabel->SetText( m_szFilename + Q_strlen( "tilegen/" ) );	
	m_pNewMissionDatabase->AddFile( pNewKeys, m_szFilename );
	UpdateList();

	if ( p4 )
	{
		MessageBox *pMessage = new MessageBox( "Add to P4?", "Would you like to add this mission to perforce?", this );
		pMessage->SetCancelButtonVisible( true );
		pMessage->SetOKButtonText( "#MessageBox_Yes" );
		pMessage->SetCancelButtonText( "#MessageBox_No" );
		pMessage->SetCommand( new KeyValues( "AddToP4", "file", pFullPath ) );
		pMessage->DoModal();
	}
}
Exemplo n.º 3
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 );
}
Exemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: Parse commands coming in from the VGUI dialog
//-----------------------------------------------------------------------------
void CTileGenDialog::OnCommand( const char *command )
{
	if ( Q_stricmp( command, "Themes" ) == 0 )
	{
		// Launch the theme editing window
		CThemesDialog *pDialog = new CThemesDialog( this, "ThemesDialog", true );

		pDialog->AddActionSignalTarget( this );
		pDialog->DoModal();
	}
	else if ( Q_stricmp( command, "NewRoomTemplate" ) == 0 )
	{
		if (!CLevelTheme::s_pCurrentTheme)
		{
			MessageBox *pMessage = new MessageBox ("No theme selected", "You must select a theme before creating a new room template.", this);
			pMessage->DoModal();
			return;
		}
		CRoomTemplate *pRoomTemplate = new CRoomTemplate(CLevelTheme::s_pCurrentTheme);
		if (pRoomTemplate)
		{
			// Launch the room template editing window
			CRoomTemplateEditDialog *pDialog = new CRoomTemplateEditDialog( this, "RoomTemplateEditDialog", pRoomTemplate, true );

			pDialog->AddActionSignalTarget( this );
			pDialog->DoModal();
		}
	}
	else if ( Q_stricmp( command, "ExportVMF" ) == 0 )
	{
		if (!m_VMFExporter->ExportVMF( GetMapLayout(), "output.vmf", true ) )
		{			
			MessageBox *pMessage = new MessageBox ("VMF Export Error", m_VMFExporter->m_szLastExporterError, this);
			pMessage->DoModal();
			return;
		}
		if ( !m_VMFExporter->ShowExportErrors() )
		{
			MessageBox *pMessage = new MessageBox ("VMF Export", "Output.vmf exported okay!", this);
			pMessage->DoModal();
		}
		return;
	}
	else if ( Q_stricmp( command, "ExportAndPlay" ) == 0 || Q_stricmp( command, "ExportAndPlayClean" ) == 0 )
	{
		m_pMapLayout->SaveMapLayout( "maps/output.layout" );
		if ( engine )
		{
			char buffer[512];
			if ( Q_stricmp( command, "ExportAndPlayClean" ) == 0 )
			{
				Q_snprintf(buffer, sizeof(buffer), "asw_spawning_enabled 0;  asw_build_map %s", "output.layout" );
			}
			else
			{
				Q_snprintf(buffer, sizeof(buffer), "asw_spawning_enabled 1;  asw_build_map %s", "output.layout" );
			}
			engine->ClientCmd_Unrestricted( buffer );
		}
		else
		{
			MessageBox *pMessage = new MessageBox ("Map Exported", "To build and play map, enter into the console:\n\nasw_build_map output", this);
			pMessage->DoModal();
		}
	}
	else if ( Q_stricmp( command, "NewMapLayout" ) == 0 )
	{
		// todo: check the current map is saved, print a warning if not?
		delete m_pMapLayout;
		m_pMapLayout = new CMapLayout();
		return;
	}
	else if ( Q_stricmp( command, "OpenMapLayout" ) == 0 )
	{
		// todo: check the current map is saved, print a warning if not?
		DoFileOpen();
		return;
	}
	else if ( Q_stricmp( command, "OpenCurrentMapLayout" ) == 0 )
	{
		// todo: check the current map is saved, print a warning if not?
		
		// clear the current map layout, if any
		delete m_pMapLayout;
		m_pMapLayout = new CMapLayout();
		char mapname[ 255 ];
		Q_snprintf( mapname, sizeof( mapname ), "maps/%s.layout", engine->GetLevelNameShort() );
		// load in the new one
		if ( !m_pMapLayout->LoadMapLayout( mapname ) )
		{
			MessageBox *pMessage = new MessageBox ("Error", "Error loading map layout", this);
			pMessage->DoModal();
			return;
		}

		// make sure each placed CRoom has a UI panel
		GetMapLayoutPanel()->CreateAllUIPanels();

		return;
	}	
	else if ( Q_stricmp( command, "SaveMapLayout" ) == 0 )
	{
		if (Q_strlen(m_pMapLayout->m_szFilename) <= 0)
		{
			DoFileSaveAs();
		}
		else
		{
			m_pMapLayout->SaveMapLayout(m_pMapLayout->m_szFilename);
		}
		return;
	}
	else if ( Q_stricmp( command, "SaveMapLayoutAs" ) == 0 )
	{
		DoFileSaveAs();
		return;
	}
	else if ( Q_stricmp( command, "GenerateThumbnails" ) == 0 )
	{
		if ( p4 )
		{
			MessageBox *pMessage = new MessageBox( "Add to P4?", "Would you like to add the thumbnails to perforce?", this );
			pMessage->SetCancelButtonVisible( true );
			pMessage->SetOKButtonText( "#MessageBox_Yes" );
			pMessage->SetCancelButtonText( "#MessageBox_No" );
			pMessage->SetCommand( new KeyValues( "AddToP4", "add", "1" ) );
			pMessage->SetCancelCommand( new KeyValues( "AddToP4", "add", "0" ) );
			pMessage->DoModal();
			return;
		}

		GenerateRoomThumbnails();
		return;
	}
	else if ( !Q_stricmp( command, "PushEncountersApart" ) )
	{
		CASWMissionChooserNPCs::PushEncountersApart( m_pMapLayout );
	}
	else if ( Q_stricmp( command, "LocationLayoutEditor" ) == 0 )
	{
		vgui::Frame *pFrame = new CLocation_Editor_Frame( this, "LocationEditorFrame" );
		pFrame->MoveToCenterOfScreen();
		pFrame->Activate();
		return;
	}
	else if ( Q_stricmp( command, "ZoomIn" ) == 0 )
	{
		Zoom( 10 );
		return;
	}
	else if ( Q_stricmp( command, "ZoomOut" ) == 0 )
	{
		Zoom( -10 );
		return;
	}
	else if ( !Q_stricmp( command, "TileCheck" ) )
	{
		vgui::Frame *pFrame = new CTile_Check_Frame( this, "TileCheckFrame" );
		pFrame->MoveToCenterOfScreen();
		pFrame->Activate();
		return;
	}
	else if ( !Q_stricmp( command, "ShowOptionalParameters" ) )
	{
		m_pLayoutSystemPage->GetEditor()->ShowOptionalValues( m_pToolsMenu->IsChecked( m_nShowDefaultParametersMenuItemID ) );
		return;
	}
	else if ( !Q_stricmp( command, "ShowAddButtons" ) )
	{
		m_pLayoutSystemPage->GetEditor()->ShowAddButtons( m_pToolsMenu->IsChecked( m_nShowAddButtonsMenuItemID ) );
		return;
	}

	BaseClass::OnCommand( command );
}