Player Data Storage Sample

Overview of the Player Data Storage Sample

StartingScreen.png

Before You Begin

The sample application uses Epic Account Services to authenticate the local user for demonstration purposes. This requires that the Client Credentials used to initialize the SDK have been assigned to an Application used for Epic Account Services.

The demonstrated SDK functionality can be used with any of the supported identity providers for user authentication.

Exploring the Sample

The Player Data Storage Sample is a simple file explorer for the cloud storage associated with your user account. You can log in or out with your account. While logged in, you can browse through the files associated with your account, and upload, download, duplicate, or delete those files.

The Player Data Panel

To get started with the Player Data Storage Sample, locate the Player Data panel on the right side of the user interface and log in by entering your Host Address and User Credentials (from the Developer Authentication Tool) and pressing the Log In button.

LogIn.png

After logging in, the Player Data panel will display the list of files associated with your user account, if any exist. The Log In button will change to Log Out, and the buttons at the top of the panel will become active. The following features are available:

  • Save: Uploads the contents of the file you are currently editing to the cloud. If you close the program with unsaved changes, they will be lost.

  • Download: Downloads the selected file to the local cache and opens it in the text editor. This operation will discard any unsaved changes.

  • Duplicate: Copies the selected file. The copy will appear in the file list under the same name as the original file, with "_Copy" added to the end.

  • Delete: Deletes the selected file from the cloud.

  • Refresh: Refreshes the file list, but does not download any files.

Panel1.png

The Console Panel

Log output from the program's operation, including the results of console commands, will appear in the text area at the top of the Console panel, which appears on the lower-left side of the user interface. In addition to clicking the buttons in the Player Data panel, you can type in console commands at the bottom of the Console panel.

ConsolePanel.png

The following commands are supported:

Command

Arguments

Behavior

ADDFILE

FILE_NAME, FILE_DATA_PATH (optional)

Creates and uploads an empty file with the name FILE_NAME, or uploads a file from the local disk (if you specify FILE_DATA_PATH)

GETFILE

FILE_NAME

Downloads the specified file from the cloud

DUPFILE

SOURCE_FILE_NAME, DESTINATION_FILE_NAME

Makes a copy of SOURCE_FILE_NAME into a new file called DESTINATION_FILE_NAME

TESTFILE

FILE_NAME, FILE_PATH

Retrieves FILE_NAME from the Player Data Storage Interface and compares its contents to the local, unencrypted file at FILE_PATH

HELP

(none)

Prints help information about all the above commands to the console output.

You can add your own console commands in the Game::CreateConsoleCommands function in Game.cpp.

The File Panel

The File panel displays the contents of the currently-selected file (in the Player Data panel). You can edit file contents in this window before saving and uploading the file in the Player Data panel or the Console panel.

The Progress Bar Window

The file transfer operations that the Player Data Storage Sample performs are asynchronous. While performing these operations, the sample shows a the Progress Bar window, a popup with a progress bar and a Cancel button. Users can interrupt the transfer by clicking Cancel. The sample only runs one file transfer operation at a time, although the Player Data Storage Interface can suport multiple transfer operations at once.

Panel3.PNG

Exploring the Source Code

Most of the code that interacts with data files is in Samples/PlayerDataStorage/Source/PlayerDataStorage.cpp. The following functions interact with the Player Data Storage Interface directly:

Function Name

Behavior

QueryList

Refreshes the list of player data entries.

StartFileDataDownload

Retrieves the contents of a specific file.

StartFileDataUpload

Transmits the contents of a specific file to the cloud.

AddFile

Uploads a new file, or overwrites an existing one.

CopyFile

Makes a copy of a file.

RemoveFile

Deletes a file and clears out local cache data related to it.

CancelCurrentTransfer

Cancels the current file transfer (if any).

These functions don't use the Player Data Storage Interface directly, but do interact with related data on the local system. They can be helpful as basic guides when building your own systems to manage locally-cached information about files:

Function Name

Behavior

GetFileList

Returns the local file list.

SetFileList

Sets the local file list.

GetLocalData

Returns locally cached data for the file specified. The NoData flag is set to true when there is no data available locally.

SetLocalData

Sets local data for the specified file.

EraseLocalData

Erases local data for the specified file (if it exists).