Esempio n. 1
0
void DoUnloadCamera() {
	if ( !GetCurrentCam() ) {
		return;
	}

	if ( !GetCurrentCam()->HasBeenSaved() ) {
		char buf[PATH_MAX + 64];
		sprintf( buf, "Do you want to save the changes for camera '%s'?", GetCurrentCam()->GetCam()->getName() );
		if ( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", MB_YESNO, NULL ) == IDYES ) {
			DoSaveCamera();
		}
	}
	else if ( GetCurrentCam()->HasBeenSaved() == 2 ) {
		char buf[PATH_MAX + 64];
		sprintf( buf, "Do you want to save the changes made to camera file '%s'?", GetCurrentCam()->GetFileName() );
		if ( g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, buf, "Warning", MB_YESNO, NULL ) == IDYES ) {
			DoSaveCamera();
		}
	}

	if ( g_pCurrentEditCam ) {
		DoStopEdit();
		g_pCurrentEditCam = NULL;
	}

	FreeCam( GetCurrentCam() );
	SetCurrentCam( NULL );
	RefreshCamListCombo();
}
Esempio n. 2
0
static void DoNewCamera( idCameraPosition::positionType type ){
	CCamera *cam = AllocCam();

	if ( cam ) {
		char buf[128];
		sprintf( buf, "camera%i", cam->GetCamNum() );

		cam->GetCam()->startNewCamera( type );
		cam->GetCam()->setName( buf );
		cam->GetCam()->buildCamera();

		sprintf( buf, "Unsaved Camera %i", cam->GetCamNum() );
		cam->SetFileName( buf, false );

		SetCurrentCam( cam );
		RefreshCamListCombo();

		// Go to editmode Add
		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( g_pEditModeAddRadioButton ), TRUE );

		// Show the camera inspector
		DoCameraInspector();

		// Start edit mode (if not initiated by DoCameraInspector)
		if ( !g_bEditOn ) {
			DoStartEdit( GetCurrentCam() );
		}
	}
	else {
		g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "No free cameras available.", "Create Camera Error", MB_OK, NULL );
	}
}
Esempio n. 3
0
void DoLoadCamera(){
	char basepath[PATH_MAX];

	if ( firstCam && firstCam->HasBeenSaved() ) {
		CAMERA_ExtractFilePath( firstCam->GetFileName(), basepath );
	}
	else{
		strcpy( basepath, g_FuncTable.m_pfnGetGamePath() );
	}

	const gchar *filename = g_FuncTable.m_pfnFileDialog( (GtkWidget *)g_pRadiantWnd, TRUE, "Open Camera File", basepath, "camera", NULL );

	if ( filename ) {
		CCamera *cam = AllocCam();
		char fullpathtofile[PATH_MAX];

		if ( cam ) {
			Q_realpath( filename, fullpathtofile, PATH_MAX );

			// see if this camera file was already loaded
			CCamera *checkCam = firstCam->GetNext(); // not the first one as we just allocated it
			while ( checkCam ) {
				if ( !strcmp( fullpathtofile, checkCam->GetFileName() ) ) {
					char error[PATH_MAX + 64];
					FreeCam( cam );
					sprintf( error, "Camera file \'%s\' is already loaded", fullpathtofile );
					g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL );
					//g_free( filename );
					return;
				}
				checkCam = checkCam->GetNext();
			}

			if ( loadCamera( cam->GetCamNum(), fullpathtofile ) ) {
				cam->GetCam()->buildCamera();
				cam->SetFileName( filename, true );
				SetCurrentCam( cam );
				RefreshCamListCombo();
				g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
			}
			else {
				char error[PATH_MAX + 64];
				FreeCam( cam );
				sprintf( error, "An error occured during the loading of \'%s\'", fullpathtofile );
				g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, error, "Load error", MB_OK, NULL );
			}

			//g_free( filename );
		}
		else {
			g_FuncTable.m_pfnMessageBox( (GtkWidget *)g_pRadiantWnd, "No free camera slots available", "Load error", MB_OK, NULL );
		}
	}
}
Esempio n. 4
0
static gint ci_camlist_changed( GtkWidget *widget, gpointer data )
{
  const char *str = gtk_entry_get_text( GTK_ENTRY(widget) );

  CCamera *combo_cam = firstCam;
  while( str && combo_cam ) {
    //if( !strcmp( str, combo_cam->GetCam()->getName() ) )
		//if( combo_cam->HasBeenSaved() ) {
			if( !strcmp( str, combo_cam->GetFileName() ) )
				break;
		/*} else {
			char buf[128];
			sprintf( buf, "Unsaved Camera %i", combo_cam->GetCamNum() );
			if( !strcmp( str, buf ) )
			//if( !strcmp( str, combo_cam->GetCam()->getName() ) )
				break;
		}*/

    combo_cam = combo_cam->GetNext();
  }

  SetCurrentCam( combo_cam );

	if( g_pCamType ) {
		if( GetCurrentCam() ) {
			// Fill in our widgets fields for this camera
			char buf[128];

			// Set Name
			gtk_entry_set_text( GTK_ENTRY(g_pCamName), GetCurrentCam()->GetCam()->getName() );

			// Set type
			gtk_label_set_text( g_pCamType, GetCurrentCam()->GetCam()->getPositionObj()->typeStr() );

			// Set duration
			sprintf( buf, "%.2f", GetCurrentCam()->GetCam()->getBaseTime() );
			gtk_entry_set_text( GTK_ENTRY(g_pSecondsEntry), buf );

			sprintf( buf, "%.2f", GetCurrentCam()->GetCam()->getTotalTime() );
			gtk_label_set_text( g_pCurrentTime, "0.00" );
			gtk_label_set_text( g_pTotalTime, buf );

			gtk_adjustment_set_value( g_pTimeLine, 0.f );
			g_pTimeLine->upper = GetCurrentCam()->GetCam()->getTotalTime() * 1000;
		} else {
			// Set Name
			gtk_entry_set_text( GTK_ENTRY(g_pCamName), "" );

			// Set type
			gtk_label_set_text( g_pCamType, "" );

			// Set duration
			gtk_entry_set_text( GTK_ENTRY(g_pSecondsEntry), "30.00" );

			gtk_label_set_text( g_pCurrentTime, "0.00" );
			gtk_label_set_text( g_pTotalTime, "30.00" );

			gtk_adjustment_set_value( g_pTimeLine, 0.f );
			g_pTimeLine->upper = 30000;
		}

		// Refresh event list
		RefreshEventList();
	}

  RefreshPathListCombo();

  // start edit mode
  g_iActiveTarget = -1;
  if( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) )
    DoStartEdit( GetCurrentCam() );

  return TRUE;
}