本文整理汇总了C++中IDesktopPlatform::SaveFileDialog方法的典型用法代码示例。如果您正苦于以下问题:C++ IDesktopPlatform::SaveFileDialog方法的具体用法?C++ IDesktopPlatform::SaveFileDialog怎么用?C++ IDesktopPlatform::SaveFileDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDesktopPlatform
的用法示例。
在下文中一共展示了IDesktopPlatform::SaveFileDialog方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PickFile
bool FRealSenseInspectorCustomization::PickFile(FString& OutPath, const void* ParentWindow, const FString& Title, const FString& Filter, bool SaveFlag)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform)
{
TArray<FString> OutFiles;
if (SaveFlag)
{
auto DefaultPath = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_SAVE);
if (DesktopPlatform->SaveFileDialog(ParentWindow, Title, DefaultPath, TEXT(""), Filter, EFileDialogFlags::None, OutFiles))
{
OutPath = OutFiles[0];
return true;
}
}
else
{
auto DefaultPath = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_OPEN);
if (DesktopPlatform->OpenFileDialog(ParentWindow, Title, DefaultPath, TEXT(""), Filter, EFileDialogFlags::None, OutFiles))
{
OutPath = OutFiles[0];
return true;
}
}
}
return false;
}
示例2: ExecuteExportAsJSON
void FAssetTypeActions_DataTable::ExecuteExportAsJSON(TArray< TWeakObjectPtr<UObject> > Objects)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);
for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
{
auto DataTable = Cast<UDataTable>((*ObjIt).Get());
if (DataTable)
{
const FText Title = FText::Format(LOCTEXT("DataTable_ExportJSONDialogTitle", "Export '{0}' as JSON..."), FText::FromString(*DataTable->GetName()));
const FString CurrentFilename = DataTable->AssetImportData->GetFirstFilename();
const FString FileTypes = TEXT("Data Table JSON (*.json)|*.json");
TArray<FString> OutFilenames;
DesktopPlatform->SaveFileDialog(
ParentWindowWindowHandle,
Title.ToString(),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetPath(CurrentFilename),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetBaseFilename(CurrentFilename) + TEXT(".json"),
FileTypes,
EFileDialogFlags::None,
OutFilenames
);
if (OutFilenames.Num() > 0)
{
FFileHelper::SaveStringToFile(DataTable->GetTableAsJSON(EDataTableExportFlags::UsePrettyPropertyNames | EDataTableExportFlags::UsePrettyEnumNames | EDataTableExportFlags::UseJsonObjectsForStructs), *OutFilenames[0]);
}
}
}
}
示例3: SaveFile
/**** @param Title The title of the dialog
* @param FileTypes Filter for which file types are accepted and should be shown
* @param InOutLastPath Keep track of the last location from which the user attempted an import
* @param DefaultFile Default file name to use for saving.
* @param OutOpenFilenames The list of filenames that the user attempted to open
*
* @return true if the dialog opened successfully and the user accepted; false otherwise.
*/
bool SaveFile( const FString& Title, const FString& FileTypes, FString& InOutLastPath, const FString& DefaultFile, FString& OutFilename )
{
OutFilename = FString();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bFileChosen = false;
TArray<FString> OutFilenames;
if (DesktopPlatform)
{
bFileChosen = DesktopPlatform->SaveFileDialog(
ChooseParentWindowHandle(),
Title,
InOutLastPath,
DefaultFile,
FileTypes,
EFileDialogFlags::None,
OutFilenames
);
}
bFileChosen = (OutFilenames.Num() > 0);
if (bFileChosen)
{
// User successfully chose a file; remember the path for the next time the dialog opens.
InOutLastPath = OutFilenames[0];
OutFilename = OutFilenames[0];
}
return bFileChosen;
}
示例4: HandleSaveCommandExecute
void SVisualLogger::HandleSaveCommandExecute()
{
TArray<TSharedPtr<class STimeline> > OutTimelines;
MainView->GetTimelines(OutTimelines, true);
if (OutTimelines.Num() == 0)
{
MainView->GetTimelines(OutTimelines);
}
if (OutTimelines.Num())
{
// Prompt the user for the filenames
TArray<FString> SaveFilenames;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bSaved = false;
if (DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultBrowsePath = FString::Printf(TEXT("%slogs/"), *FPaths::GameSavedDir());
bSaved = DesktopPlatform->SaveFileDialog(
ParentWindowWindowHandle,
LOCTEXT("NewProjectBrowseTitle", "Choose a project location").ToString(),
DefaultBrowsePath,
TEXT(""),
LogVisualizer::SaveFileTypes,
EFileDialogFlags::None,
SaveFilenames
);
}
if (bSaved)
{
if (SaveFilenames.Num() > 0)
{
TArray<FVisualLogDevice::FVisualLogEntryItem> FrameCache;
for (auto CurrentItem : OutTimelines)
{
FrameCache.Append(CurrentItem->GetEntries());
}
if (FrameCache.Num())
{
FArchive* FileArchive = IFileManager::Get().CreateFileWriter(*SaveFilenames[0]);
FVisualLoggerHelpers::Serialize(*FileArchive, FrameCache);
FileArchive->Close();
delete FileArchive;
FileArchive = NULL;
}
}
}
}
}
示例5: ExecuteExportAsCSV
void FAssetTypeActions_CurveTable::ExecuteExportAsCSV(TArray< TWeakObjectPtr<UObject> > Objects)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
void* ParentWindowWindowHandle = nullptr;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if ( MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid() )
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
{
auto CurTable = Cast<UCurveTable>((*ObjIt).Get());
if (CurTable)
{
const FText Title = FText::Format(LOCTEXT("CurveTable_ExportCSVDialogTitle", "Export '{0}' as CSV..."), FText::FromString(*CurTable->GetName()));
const FString CurrentFilename = (CurTable->ImportPath.IsEmpty()) ? TEXT("") : FReimportManager::ResolveImportFilename(CurTable->ImportPath, CurTable);
const FString FileTypes = TEXT("Curve Table CSV (*.csv)|*.csv");
TArray<FString> OutFilenames;
DesktopPlatform->SaveFileDialog(
ParentWindowWindowHandle,
Title.ToString(),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetPath(CurrentFilename),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetBaseFilename(CurrentFilename) + TEXT(".csv"),
FileTypes,
EFileDialogFlags::None,
OutFilenames
);
if (OutFilenames.Num() > 0)
{
FFileHelper::SaveStringToFile(CurTable->GetTableAsCSV(), *OutFilenames[0]);
}
}
}
}
示例6: OnGizmoExportButtonClicked
FReply FLandscapeEditorDetailCustomization_CopyPaste::OnGizmoExportButtonClicked()
{
FEdModeLandscape* LandscapeEdMode = GetEditorMode();
if (LandscapeEdMode != NULL)
{
ALandscapeGizmoActiveActor* Gizmo = LandscapeEdMode->CurrentGizmoActor.Get();
if (Gizmo && Gizmo->TargetLandscapeInfo && Gizmo->SelectedData.Num())
{
int32 TargetIndex = -1;
ULandscapeInfo* LandscapeInfo = Gizmo->TargetLandscapeInfo;
TArray<FString> Filenames;
// Local set for export
TSet<ULandscapeLayerInfoObject*> LayerInfoSet;
for (int i = 0; i < Gizmo->LayerInfos.Num(); i++)
{
if (LandscapeEdMode->CurrentToolTarget.TargetType == ELandscapeToolTargetType::Weightmap && LandscapeEdMode->CurrentToolTarget.LayerInfo == Gizmo->LayerInfos[i])
{
TargetIndex = i;
}
LayerInfoSet.Add(Gizmo->LayerInfos[i]);
}
for (int32 i = -1; i < Gizmo->LayerInfos.Num(); i++)
{
if (!LandscapeEdMode->UISettings->bApplyToAllTargets && i != TargetIndex)
{
continue;
}
FString SaveDialogTitle;
FString DefaultFilename;
FString FileTypes;
if (i < 0)
{
if (!(Gizmo->DataType & LGT_Height))
{
continue;
}
SaveDialogTitle = NSLOCTEXT("UnrealEd", "LandscapeExport_HeightmapFilename", "Choose filename for Heightmap Export").ToString();
DefaultFilename = TEXT("Heightmap.raw");
FileTypes = TEXT("Heightmap .raw files|*.raw|Heightmap .r16 files|*.r16|All files|*.*");
}
else
{
if (!(Gizmo->DataType & LGT_Weight))
{
continue;
}
FName LayerName = Gizmo->LayerInfos[i]->LayerName;
SaveDialogTitle = FText::Format(NSLOCTEXT("UnrealEd", "LandscapeExport_LayerFilename", "Choose filename for Layer {0} Export"), FText::FromString(LayerName.ToString())).ToString();
DefaultFilename = FString::Printf(TEXT("%s.raw"), *LayerName.ToString());
FileTypes = TEXT("Layer .raw files|*.raw|Layer .r8 files|*.r8|All files|*.*");
}
TArray<FString> SaveFilenames;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bSave = false;
if (DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
bSave = DesktopPlatform->SaveFileDialog(
ParentWindowWindowHandle,
SaveDialogTitle,
LandscapeEdMode->UISettings->LastImportPath,
DefaultFilename,
FileTypes,
EFileDialogFlags::None,
SaveFilenames
);
}
if (!bSave)
{
return FReply::Handled();
}
Filenames.Add(SaveFilenames[0]);
LandscapeEdMode->UISettings->LastImportPath = FPaths::GetPath(SaveFilenames[0]);
}
Gizmo->Export(TargetIndex, Filenames);
}
}
return FReply::Handled();
}