P3SavepointManager

P3SavepointManager is a simple file manager to rename, copy or delete savepoints on the P3. This functionality is missing from the P3 feature menu in the P3 SDK V0.8

Overview

The application is open-source with an MIT license. Download the source code here. To satisfy the implied license of the P3 SDK, the distribution cannot contain any material from the SDK. The distribution contains the new source files and instructions how to recreate the Unity project starting from the sample application P3SampleApp. The steps are restricted to the bare minimum to simplify the task. The result may not be as clean as a self-contained Unity project, but that’s the necessary compromise.

Building the deployment package produces a certificate good for 3 days. Rebuild the package to get a new certificate good for another 3 days.

The application has a single scene with all the functionality implemented in P3SMAttractMode.

The implementation is a wizard going from one dialog to the next somewhat like a hierarchical menu.

Profile Selection

The SDK Guide documents how to programmatically handle profiles here file:///C:/P3/P3_SDK_V0.8/P3SampleApp/Documentation/html/_additional_platform_features.html#EventBasedPlayerProfileManagement 

For example, send the event Evt_ChooseProfile to display a dialog to choose the profile. When the selection is made, the dialog sends the event Evt_ProfileSelectorResult with the chosen profile name in the event object. If the user exits the dialog without making a selection, the dialog sends the event Evt_ProfileSelectorCancelled.

AddModeEventHandler("Evt_ProfileSelectorResult", ProfileSelectorResultEventHandler, Priority);

AddModeEventHandler("Evt_ProfileSelectorCancelled", ProfileSelectorCancelledEventHandler, Priority);

private bool ProfileSelectorResultEventHandler(string evtName, object evtData)

{

    string selection = (string)evtData;

    CloseDialog("ProfileDialog");

     …

     return EVENT_STOP;

}

private bool ProfileSelectorCancelledEventHandler(string evtName, object evtData)

{

    CloseDialog("ProfileDialog");

    …

    return EVENT_STOP;

}

Selection Dialog

A typical task is to create a list of items, set the list as selector data and then open the dialog to show the list of items. This can be implemented with a selector dialog. P3SavepointManager saves some work and reuses the ProfileDialog for this.

List<string> list = new List<string>();

list.Add("Choose Action");

list.Add(ACTION_RENAME);

list.Add(ACTION_COPY);

list.Add(ACTION_DELETE);

list.Add(ACTION_EXIT);

SetSelectorData("ProfileSelector", list);

OpenDialog("ProfileDialog");

The first list item is the window title. The remaining list items are the choices offered to the user. The response events are the same as above since it is the same dialog (Evt_ProfileSelectorResult and Evt_ProfileSelectorCancelled).

ConfirmationDialog

The ConfirmationDialog offers a choice between two answers, typically Yes or No. This dialog is less documented in the SDK guide.

private void PromptForConfirmation(string question)

{

    List<string> list = new List<string>();

    list.Add("Confirm");

    list.Add("Delete " + savepointName + "?");

    list.Add("No");

    list.Add("Yes");

    SetSelectorData("ConfirmationSelector", list);

    OpenDialog("ConfirmationDialog");

}

The first list item is the window title. The second item is the question to display. The third and fourth items are the negative and positive responses. The dialog sends the event Evt_ConfirmationBoxConfirm with the user’s decision: the event object equals 0 for a negative answer, or 1 for a positive answer.

AddModeEventHandler("Evt_ConfirmationBoxConfirm", ConfirmationBoxConfirmEventHandler, Priority);

private bool ConfirmationBoxConfirmEventHandler(string evtName, object evtData)

{

    bool confirmed = (int)evtData == 1;

    if (confirmed)

    {

       

    }

    else

    {

       

    }

    return EVENT_STOP;

}

ProfileNameEditor

To let the user enter a new name, P3SavepointManager reuses the ProfileNameEditor.

SetSelectorData("ProfileNameTextSelector",

    new TextSelectorData("Enter new savepoint", new List<string>(), ""));

OpenDialog("ProfileNameEditor");

When the entry is ended, the dialog sends the event Evt_ProfileNameEntryCompleted and the event object is the entered name. If the user cancels the dialog without entering a name, the dialog sends the event Evt_ProfileNameEntryCancelled. Your mode must have higher priority than ProfileManagerMode to catch those events (priority > 52110).

AddModeEventHandler("Evt_ProfileNameEntryCompleted", ProfileNameEntryCompletedEventHandler, Priority);

AddModeEventHandler("Evt_ProfileNameEntryCancelled", ProfileNameEntryCancelledEventHandler, Priority);

private bool ProfileNameEntryCompletedEventHandler(string evtName, object evtData)

{

    string enteredName = (string)evtData;

    CloseDialog("ProfileNameEditor");

    …

    return EVENT_STOP;

}

private bool ProfileNameEntryCancelledEventHandler(string evtName, object evtData)

{

    CloseDialog("ProfileNameEditor");

    …

    return EVENT_STOP;

}