MCPcopy Create free account
hub / github.com/NotYetGames/DlgSystem / ImportFromFileFormat

Method ImportFromFileFormat

Source/DlgSystem/Private/DlgDialogue.cpp:371–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371void UDlgDialogue::ImportFromFileFormat(EDlgDialogueTextFormat TextFormat)
372{
373 const bool bHasExtension = UDlgSystemSettings::HasTextFileExtension(TextFormat);
374 const FString& TextFileName = GetTextFilePathName(TextFormat);
375
376 // Nothing to do
377 IFileManager& FileManager = IFileManager::Get();
378 if (!bHasExtension)
379 {
380 // Useful For debugging
381 if (TextFormat == EDlgDialogueTextFormat::All)
382 {
383 // Import from all
384 const int32 TextFormatsNum = static_cast<int32>(EDlgDialogueTextFormat::NumTextFormats);
385 for (int32 TextFormatIndex = static_cast<int32>(EDlgDialogueTextFormat::StartTextFormats);
386 TextFormatIndex < TextFormatsNum; TextFormatIndex++)
387 {
388 const EDlgDialogueTextFormat CurrentTextFormat = static_cast<EDlgDialogueTextFormat>(TextFormatIndex);
389 const FString& CurrentTextFileName = GetTextFilePathName(CurrentTextFormat);
390 if (FileManager.FileExists(*CurrentTextFileName))
391 {
392 ImportFromFileFormat(CurrentTextFormat);
393 }
394 }
395 }
396 return;
397 }
398
399 // File does not exist abort
400 if (!FileManager.FileExists(*TextFileName))
401 {
402 FDlgLogger::Get().Errorf(TEXT("Reloading data for Dialogue = `%s` FROM file = `%s` FAILED, because the file does not exist"), *GetPathName(), *TextFileName);
403 return;
404 }
405
406 // Clear data first
407 StartNode = nullptr;
408 Nodes.Empty();
409
410 // TODO handle Name == NAME_None or invalid filename
411 FDlgLogger::Get().Infof(TEXT("Reloading data for Dialogue = `%s` FROM file = `%s`"), *GetPathName(), *TextFileName);
412
413 // TODO(vampy): Check for errors
414 check(TextFormat != EDlgDialogueTextFormat::None);
415 switch (TextFormat)
416 {
417 case EDlgDialogueTextFormat::JSON:
418 {
419 FDlgJsonParser JsonParser;
420 JsonParser.InitializeParser(TextFileName);
421 JsonParser.ReadAllProperty(GetClass(), this, this);
422 break;
423 }
424 case EDlgDialogueTextFormat::DialogueDEPRECATED:
425 {
426 FDlgConfigParser Parser(TEXT("Dlg"));
427 Parser.InitializeParser(TextFileName);
428 Parser.ReadAllProperty(GetClass(), this, this);

Callers

nothing calls this directly

Calls 6

GetDialogueFNameFunction · 0.85
IsValidFunction · 0.50
RegenerateGUIDFunction · 0.50
InitializeParserMethod · 0.45
ReadAllPropertyMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected