x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Runtime Content Saves & Data Reads

Alright, so this one's for the slate & programming teams.

Would the team consider implementing a way to read and write in capture data for slate / UI menus to use, without having to go through the content browser? Or, if failing that, would the devs consider allowing for SceneCaptures, Matinee Movie Dumps and/or tiledshots to be stored in the content browser at runtime for slate and native access?

I was looking through FileManager.h and FileHelpers.h based on an old discussion I had with Bob Tellez. There are some functions in there related to file handling, but there doesn't appear to be much you can really do with the list of functions currently available. You have your basic move/copy stuff and accessor functions for file handling. But there's nothing really in terms of reading or direct writing to files, or the serialization (and encryption!) of data as might be expected from BasicSaveObject/BasicLoadObject. If it's handled somewhere else and I'm just unaware, I'd appreciate some insight.

Anyways, I'll point to an example of how this might be used in practice. in my DataHive project, I wanted to enhance my current save system by getting a snapshot of the current save area and reading them into my Flash save menu*. I would give the saved thumbnails a specific naming convention to distinguish them from other files. In this way, the thumbnail system would be completely procedural. Unfortunately that proved to be unworkable b/c of how UE3's content packaging system was designed.

Now in terms of implementation, one way is to provide accessor functions for reading in files and doing the usual vetting to check for bad or invalid content. Treat it almost like a content browser import, except this would operate at the native level.

Or if direct reads are too risky, then perhaps allowing for a new and improved screencapture2D, matinee dump, or shot command to save its captures into the content browser at runtime.

The basic premise here would be that you could create a file that is vetted by native architecture, and thus is assured to be clean (or as clean as this architecture can make a file...). All that's left is a way for slate menus, blueprints, etc. to read in the newly generated capture files.

  • (Yes, I'm aware Scaleform isn't supported anymore, I'm just talking about the general idea now as it pertains to Slate)

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '14 at 02:10 AM in C++ Programming

avatar image

ue4-archive ♦♦ STAFF
50k 3667 1996 9121

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:10 AM

seems very much like what I requested here, point no. 2, to which I was answered this. except I only asked for reading of files, and saving of such files seems needed as well. but if you keep reading further below, you'll see my intentions for this were for game save thumbnails (yeah, guess who I thought would benefit from it)

btw I still haven't tried that suggestion (I only know I can call GFileManager->CreateFileWriter() from anywhere, but I still haven't looked into how to actually use it), so maybe some example would be great.

anyway, looking forward to this answer

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:10 AM +

That's exactly my point. Where do you go from there? I looked at Archive.h too earlier before my first post. I don't see how it comes together, or it doesn't appear to be far enough along for you to write data line by line, or to otherwise serialize/deserialize it in a specific way.

Yeah, you can access the file, and manipulate it. But what else can you do with it? That's what I was getting at.

One other thing I'd add is how you might notice how in Archive.h that the FArchive class itself is absent. The FArchive class definition isn't anywhere to be found... and yet all the readers / writers extend from it. So there may be additional stuff inherent in the FArchive base class, but it's just not been made available. So that's another issue there...

show all comments (comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

SceneCapture2Ds write their data to a UTextureRenderTarget2D (you create in the content browser) which can be used directly in slate by making a brush then using it like so:

Do this once at startup:

 FSlateStyle& Style = FSlateStyle::GetInstance();
 Style.Set("MyGame.MyCaptureBrush", new FSlateImageBrush(TEXT("texture://Game/SomePath/SomeCaptureRenderTarget2D"), FVector2D(128,128), FLinearColor(1,1,1,1)));

Now just use the brush like so:

 SNew(SImage)
 .Image(FSlateStyle::GetBrush("MyGame.MyCaptureBrush"))

Matinee movie dumps and tiledshots were not meant to be used progamatically as they just write their output to disk. If you want to write some logic to work with thier output, you may want to start by using one of the techniques below.

Now, since you asked, here is some more general info about saving/loading:

Once you have an FArchive, you can serialize primitive types or UObjects into it by using the << operator like so:

 FArchive* SaveFile = GFileManager->CreateFileWriter(TEXT("test.txt"));
 if ( SaveFile )
 {
     FString MyString = TEXT("TestString");
     *SaveFile << MyString;
     SaveFile->Close();
     delete SaveFile;
     SaveFile = NULL;
 }

Loading with an FArchive is similar

 FArchive* FileReader = GFileManager->CreateFileReader(TEXT("test.txt"));
 if(FileReader != NULL)
 {
     FString MyString;
     *FileReader << MyString;
     FileReader->Close();
     delete FileReader;
     FileReader = NULL;
 }

As an alternative to dealing with data at this low level, you may want to use the package system. Here is saving.

 UPackage* MyDataPackage = CreatePackage(NULL, TEXT("/Temp/MyPackage"));
 UMyCoolObject* MyDataObject = NewObject(MyDataPackage);
 UPackage::SavePackage(MyDataPackage, MyDataObject, RF_Standalone, FPaths::GameSavedDir() + TEXT("SomeFile.uasset"));

Where MyCoolObject is a class containing all the data you care about. Now here is loading.

 UPackage* MyDataPackage = ::LoadPackage( NULL, FPaths::GameSavedDir() + TEXT("SomeFile.uasset"), LOAD_None );
 TArray ObjectsInPackage;
 GetObjectsWithOuter(MyDataPackage, ObjectsInPackage, false);
 if ( ObjectsInPackage.Num() > 0 )
 {
     UMyCoolObject* MyDataObject = Cast(ObjectsInPackage[0]);
 }

You will want to use the same UPackage returned from LoadPackage when calling UPackage::SavePackage.

Forgive me if there are any syntax errors in the code samples above, I just typed them out in this message.

Finally, you may want some more power over your saved objects. In this case you will want to make a custom asset type, then saving and loading is managed automatically for you. One of the easiest ways to do this is to make your data class extend UDataAsset. Then it can be created in the content browser and saved just like normal packages. If you want to get more involved in making an asset type, you can also make a UFactory class and IAssetTypeActions class to add extra content browser functionality. I do not see any doc pages about creating a new asset type, so I will ping the documentation team about adding one.

more ▼

answered Mar 11 '14 at 02:10 AM

avatar image

ue4-archive ♦♦ STAFF
50k 3667 1996 9121

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:10 AM

Awesome response. I'll try all of this stuff out. Thanks Bob!

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:10 AM +

Cool - good effort. That's an interesting thread. How do you feel about it now (few months later) ? Now there's the Eventgraph nodes under Function > SaveGame such as Create Save Game Object. And Save Game to Slot... I'd like to know more about all that.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question