Skip to content

Game.UI.Menu.ParadoxBindings

Assembly: Assembly-CSharp
Namespace: Game.UI.Menu

Type: class ParadoxBindings

Base: CompositeBinding

Summary:
ParadoxBindings is a UI binding helper used by the game's menu to integrate with the Paradox / PDX SDK platform (authentication, account linking, legal documents, PS mods flows, etc.). It exposes a set of ValueBindings, TriggerBindings and a StackBinding for dialogs so the UI can show login/registration forms, confirmation/error dialogs and handle account linking flows. The class listens to PlatformManager/ PdxSdkPlatform events (login/logout, account link changes, status changes, legal document changes and connectivity) and translates them into bound values and dialog pushes/pops. It also centralizes calls to the PdxSdkPlatform and uses RunForegroundRequest to throttle and mark active requests.


Fields

  • private const string kGroup = "paradox"
    This constant is the binding group prefix used when creating bindings.

  • private readonly ValueBinding<bool> m_RequestActiveBinding
    Tracks whether there is a currently running foreground request to the PDX SDK (used to disable re-entrant requests and block some UI actions).

  • private readonly ValueBinding<bool> m_LoggedInBinding
    Binding representing whether a user is currently logged in.

  • private readonly ValueBinding<AccountLinkProvider> m_AccountLinkProviderBinding
    Binding exposing the currently configured account link provider (enum). Written using EnumNameWriter.

  • private readonly ValueBinding<int> m_AccountLinkStateBinding
    Binding exposing the numeric account link state.

  • private readonly ValueBinding<string> m_UserNameBinding
    Binding for the logged in user's username (nullable).

  • private readonly ValueBinding<string> m_EmailBinding
    Binding for the logged in user's email (nullable).

  • private readonly ValueBinding<string> m_AvatarBinding
    Binding for the logged in user's avatar URL (nullable).

  • private readonly ValueBinding<bool> m_HasInternetConnection
    Binding for current connectivity status; initialized from PlatformManager.instance.hasConnectivity.

  • private readonly ValueBinding<bool> m_IsPDXSDKEnabled
    Binding indicating whether the PDX SDK integration has been initialized.

  • private readonly StackBinding<ParadoxDialog> m_ActiveDialogsBinding
    Stack-binding containing the currently active dialogs shown to the user (Login, Registration, Error, Multiselect, LegalDocumentDialog, etc.).

  • private PdxSdkPlatform m_PdxPlatform
    Cached reference to the PdxSdkPlatform PSI integration. May be updated when the platform is registered.

  • private static readonly string kTermsOfUse = "TERMS_OF_USE"
    Key used when showing the Terms of Use special link.

  • private static readonly string kPrivacyPolicy = "PRIVACY_POLICY"
    Key used when showing the Privacy Policy special link.

Properties

  • None. The class exposes bindings via CompositeBinding but does not declare public C# properties.

Constructors

  • public ParadoxBindings()
    Initializes all the UI bindings (ValueBinding, TriggerBinding, GetterValueBinding, StackBinding) under the "paradox" group, wires up handlers for PlatformManager events and, if already available, subscribes to PdxSdkPlatform events (onLoggedIn, onLoggedOut, onAccountLinkChanged, onLegalDocumentStatusChanged, onStatusChanged). The constructor also initializes m_PdxPlatform from PlatformManager.instance.GetPSI("PdxSdk"). The bindings created include triggers for login, logout, link/unlink, showing forms/links, submitting forms, marking legal docs viewed and more.

Methods

  • public void OnPSModsUIOpened(Action onContinue)
    Pushes a MultiOptionDialog into the dialog stack to show the PS Mods disclaimer. onContinue is invoked if the user selects the OK option.

  • public void OnPSModsUIClosed(Action onKeepMods, Action onDisableMods, Action onBack)
    Pushes a MultiOptionDialog to confirm the user choice when closing PS Mods UI. Options map to the provided callbacks.

  • public void PushDialog(ParadoxDialog dialog)
    Utility to push an arbitrary ParadoxDialog instance onto the active dialog stack.

  • private void OnOptionSelected(int index)
    Called from bindings when the UI notifies an option selection. If the top dialog is a MultiOptionDialog, it pops it and invokes the selected option's callback.

  • private void OnAccountLinkChanged(AccountLinkState state, AccountLinkProvider provider)
    Updates the account link provider/state bindings when the PdxSdkPlatform signals a change.

  • private async void Logout()
    Asynchronously calls PdxSdkPlatform.Logout via RunForegroundRequest and awaits it. (Uses async void as it's invoked by a TriggerBinding.)

  • private List<string> GetCountryCodes()
    Returns a list of Country enum names (strings), with Country.Undefined removed. Used by a GetterValueBinding for the registration country selector.

  • private void OnInternetConnectionStatusChanged(bool connected)
    Updates m_HasInternetConnection binding when PlatformManager signals connectivity changes.

  • private void OnStatusChanged(IPlatformServiceIntegration psi)
    Handles PDX SDK initialization state changes: updates m_IsPDXSDKEnabled and account link bindings when the PdxSdkPlatform status changes.

  • private async void OnUserLoggedIn(string firstName, string lastName, string email, AccountLinkState accountLinkState, bool firstTime)
    Handles user login event: updates logged in state, account link state and email, then attempts to fetch creator profile (username and avatar) from the platform and updates bindings accordingly.

  • private void OnUserLoggedOut(string id)
    Clears username, email and avatar bindings and sets logged-in binding to false.

  • private void OnLegalDocumentStatusChanged(LegalDocument doc, int remainingCount)
    If a legal document status change occurs it will pop any active LegalDocumentDialog then push a new LegalDocumentDialog for the provided doc (if not null). This is used to prompt the user to view/agree to legal text.

  • private void CloseActiveDialog()
    Pops the top dialog (unless certain conditions are met, e.g., a required LegalDocumentDialog), and re-enables sharing if the dialog stack becomes empty.

  • public void ShowLoginForm()
    Public trigger that opens the login form dialog if there is connectivity. It disables "sharing" via PlatformManager while the dialog is active. If no connectivity, pushes an ErrorDialog.

  • private async void SubmitLoginForm(LoginFormData data)
    Handles login form submission. If no other request is active, it calls PdxSdkPlatform.Login via RunForegroundRequest, handles request results: on success clears dialogs and may prompt account linking; on failure pushes ErrorDialog with report details.

  • private async void SubmitPasswordReset(string email)
    Calls PdxSdkPlatform.ResetPassword and pushes a ConfirmationDialog on success or ErrorDialog on failure.

  • private void ShowRegistrationForm()
    Clears the dialog stack and pushes the registration dialog.

  • private async void ShowLink(string link)
    If link equals kTermsOfUse or kPrivacyPolicy, requests the corresponding LegalDocument from the platform and pushes a LegalDocumentDialog with agreementRequired = false; otherwise opens link with Application.OpenURL.

  • private async void SubmitRegistrationForm(RegistrationFormData data)
    Handles registration submission: validates country and date formats, then calls PdxSdkPlatform.CreateParadoxAccount via RunForegroundRequest, and on success clears dialogs, potentially initiates account linking and pushes a registration confirmation. On failure pushes ErrorDialog. If parse fails, pushes an ErrorDialog indicating invalid input format.

  • private async void ConfirmAccountLink()
    Starts account link confirmation. If there is no account link mismatch, attempts LinkAccount() via PdxSdkPlatform.LinkAccount; on success updates state and pushes confirmation dialog. If mismatch exists, pushes an AccountLinkOverwriteDialog with the appropriate message id depending on the mismatch type.

  • private async void ConfirmAccountLinkOverwrite()
    Attempts to overwrite account links by calling PdxSdkPlatform.OverwriteAccountLinks. On success behaves similar to ConfirmAccountLink; on failure pushes ErrorDialog.

  • private void LinkAccount()
    Pushes an AccountLinkDialog prompting the user to confirm account linking for the configured provider.

  • private async void UnlinkAccount()
    Calls PdxSdkPlatform.UnlinkThirdPartyAccount via RunForegroundRequest; on success updates account link state, on failure pushes ErrorDialog.

  • private void ShowTermsOfUse()
    Helper that calls ShowLink(kTermsOfUse).

  • private void ShowPrivacyPolicy()
    Helper that calls ShowLink(kPrivacyPolicy).

  • private string GetAccountLinkProviderIcon()
    Returns the path to the provider icon used in dialogs: e.g. "Media/Menu/Platforms/{provider}.svg".

  • private async void MarkLegalDocumentAsViewed()
    If the current top dialog is a LegalDocumentDialog, calls PdxSdkPlatform.MarkLegalDocumentAsViewed for that document via RunForegroundRequest.

  • private async Task<T> RunForegroundRequest<T>(Task<T> task)
    Generic helper that sets m_RequestActiveBinding to true, awaits the given task, and resets m_RequestActiveBinding to false in a finally block. Used to show the UI that a foreground request is active and to prevent concurrent operations.


  • ParadoxDialog (abstract) — base dialog type implementing IJsonWritable. Default Write writes only the runtime type.
  • LoginFormData (IJsonReadable) — contains email and password, used to read a submitted login form from JSON.
  • RegistrationFormData (IJsonReadable) — contains email, password, country, dateOfBirth (yyyy-MM-dd) and marketingPermission.
  • MessageDialog : ParadoxDialog — base for dialogs with icon/title/message/messageArgs and custom Write implementation.
  • LoginDialog, RegistrationDialog — simple marker dialogs for showing login/registration forms.
  • AccountLinkDialog / AccountLinkOverwriteDialog — MessageDialog variants for account linking flows.
  • LegalDocumentDialog — dialog that shows a legal document (text, confirmLabel) and whether agreement is required.
  • ConfirmationDialog / ErrorDialog — small dialogs for confirmations and errors (ErrorDialog exposes messageId and message).
  • MultiOptionDialog — dialog with a title, message and multiple selectable Option items. Option implements IJsonWritable and stores an id and an Action callback.

Usage Example

Example: show the login dialog or push a custom dialog into ParadoxBindings. In practice ParadoxBindings is created and registered as part of the UI binding system; the following demonstrates direct usage.

// create and use ParadoxBindings (typically created by the menu system)
var paradoxBindings = new ParadoxBindings();

// Show the login form (will check connectivity and push a LoginDialog)
paradoxBindings.ShowLoginForm();

// Push a custom MultiOptionDialog and handle selection
paradoxBindings.PushDialog(new ParadoxBindings.MultiOptionDialog(
    "Menu.PDX_MODS",
    "Paradox.PS_MODS_DISCLAIMER",
    new ParadoxBindings.MultiOptionDialog.Option {
        m_Id = "Common.OK",
        m_OnSelect = () => Debug.Log("User accepted")
    }
));

Notes: - Many methods are invoked via TriggerBindings from UI markup/JS, so in-game you typically don't call them directly but trigger the bindings from the UI layer. - RunForegroundRequest toggles the m_RequestActiveBinding to prevent concurrent requests; respect that flag in custom flows if you interact with PdxSdkPlatform. - Login/registration date parsing expects yyyy-MM-dd format and country must match the Country enum names.