The application is open-source with an MIT license. Download the source code here. The distribution contains the new source files and instructions on how to recreate the Unity project starting from the sample application P3SampleApp. This respects the SDK licensing terms, which state that the P3 libraries are proprietary, non-distributable files. It should also make it easier to adapt the application to current and future versions of the SDK.
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, similar to a hierarchical menu.
How to programmatically handle profiles is documented in the Feature Menu section of the SDK Developer Guide.
For example, send the Evt_ChooseProfile event to display a dialog to choose a profile. When a selection is made, the dialog sends the Evt_ProfileSelectorResult event with the chosen profile name in the event data. If the user exits the dialog without making a selection, the dialog sends the Evt_ProfileSelectorCancelled event.
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; } |
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).
The ConfirmationDialog offers a choice between two answers, typically Yes or No. This dialog is less documented in the SDK Developer 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 Evt_ConfirmationBoxConfirm event with the user’s decision: the event data equals 0 for a negative answer, and 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; } |
To allow the user to enter a new name, P3SavepointManager reuses the ProfileNameEditor.
SetSelectorData("ProfileNameTextSelector", new TextSelectorData("Enter new savepoint", new List<string>(), "")); OpenDialog("ProfileNameEditor"); |
When name entry is completed, the dialog sends the Evt_ProfileNameEntryCompleted event and the event data is the entered name. If the user cancels the dialog without entering a name, the dialog sends the Evt_ProfileNameEntryCancelled event. Your mode must have higher priority than ProfileManagerMode to receive 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; } |