Game.UI.Menu.AssetUploadPanelUISystem
Assembly: Assembly-CSharp
Namespace: Game.UI.Menu
Type: class
Base: UISystemBase
Summary:
UI system that implements the Asset Upload panel used by the in-game editor/upload workflow. Manages the full upload flow for user assets: collecting metadata (name, descriptions, links, tags), selecting previews & screenshots, showing DLC requirements, syncing with the platform (Paradox/Steam-like service) via PdxAssetUploadHandle, reporting progress and results through notifications and the UI, and providing controls to submit, cancel or finalize uploads. Handles validation, local-data retrieval for existing published items, and interactions with other UI pieces (pickers, lists, popups).
Fields
-
private enum State { Ready, Processing, Success, Failure, Disabled }
Internal state machine for the upload flow and UI (ready, in-process, succeeded, failed, disabled when no social profile). -
private static readonly string kNotificationID
Notification identifier used for upload progress notifications ("AssetUpload"). -
private static readonly LocalizedString kNone
Localized constant representing "None" in pickers. -
private static readonly string kFailureLabel
Localized key for failure label displayed in the UI. -
private static readonly string kSubmittingLabel
Localized key shown while submitting. -
private static readonly string kCompleteLabel
Localized key shown when upload completes. -
private static readonly string kSubmitLabel
Localized key for the submit button in its default state. -
private static readonly string kNoInternetConnectionLabel
Localized key shown when there is no network connectivity. -
private static readonly string kNotLoggedInLabel
Localized key shown when user is not logged in. -
private static readonly string kNoSocialProfile
Localized key shown when the user has no social profile linked. -
private static readonly string kOpenProfilePage
Localized key for button to open profile page. -
private static readonly string kDLCListLabel
Localized key for DLC list/group heading. -
private static readonly float kNotificationDelay
Delay used when removing/adding notifications (4 seconds). -
private NotificationUISystem m_NotificationUISystem
Reference to the notification system used to show upload progress/errors. -
private AssetPickerAdapter m_PreviewPickerAdapter
Adapter used to populate the preview/screenshot picker UI. -
private PdxAssetUploadHandle m_UploadHandle
Core upload handle managing platform interactions, metadata and local file operations. -
private bool m_AllowManualFileCopy
Flag indicating whether the user can manually copy files before finalizing upload. -
private State m_State
Current UI/upload state (uses the internal State enum). -
private IWidget[] m_MainPanel
Widget array representing the main panel contents. -
private LargeIconButton m_PreviewPickerButton
Button that opens preview picker and shows currently selected preview. -
private ExternalLinkField m_ExternalLinkField
Widget used to edit external links for the asset. -
private IconButtonGroup m_Screenshots
UI group showing screenshot thumbnails and a "plus" button to add more. -
private LayoutContainer m_PlatformResult
Container used to display platform-specific status/results (errors, success info). -
private ItemPickerPopup<int> m_ExistingModPopup
Popup to pick existing published mods when updating an existing item. -
private PopupValueField<int> m_ExistingModField
Field controlling the existing-mod selection UI. -
private Button m_SubmitButton
Submit button widget. -
[CanBeNull] private ListField m_AssetList
Optional widget listing assets included in the upload (main + additional). -
[CanBeNull] private PopupValueField<PrefabBase> m_AssetListPopup
Optional popup field used to add prefabs/assets to the asset list. -
private ListField m_TagsList
Widget that lists tags for the asset. -
private PopupValueField<string> m_TagsListPopup
Popup used to add tags. -
private LayoutContainer m_DLCInfo
Container showing DLC dependency info (icons/names). -
private bool m_DLCInfoVisible
Visibility flag for the DLC info area. -
private IWidget[] m_PreviewPickerPanel
Widget array for the preview picker panel UI. -
private Button m_SelectPreviewButton
Button used to confirm selection in preview picker. -
public Action<IList<IWidget>> onChildrenChange
Event invoked when the visible children widgets are changed (used by parent UI to update screen). -
private IList<IWidget> m_Children
Current children widgets being displayed by this system. -
private PdxAssetUploadHandle.ModInfo-related boolean properties (private)
Several private boolean getter properties are present to validate individual fields (nameError, shortDescirptionError, longDescipriontError, forumLinkError, externalLinkError, changelogError, versionError) — used to enable/disable submit and show inline validation. -
private bool noInternetConnection
Private getter that returns PlatformManager.instance.hasConnectivity negated. -
private bool notLoggedIn
Private getter that delegates to m_UploadHandle.LoggedIn(). -
private bool anyError
Private computed getter that aggregates per-field validation and connectivity/login checks. -
private bool disableSubmit
Private computed getter used by the submit button to determine enabled/disabled state based on current state and anyError.
Properties
-
public IList<IWidget> children { get; }
Exposes the currently active child widget collection. Read-only property that returns m_Children. onChildrenChange is raised when this value changes. -
private bool nameError { get; }
True if the display name is null or empty. -
private bool shortDescirptionError { get; }
True if the short description is null or empty. -
private bool longDescipriontError { get; }
True if the long description is null or empty. -
private bool forumLinkError { get; }
True if the forum link does not validate (uses AssetUploadUtils.ValidateForumLink). -
private bool externalLinkError { get; }
True if external links do not validate (uses AssetUploadUtils.ValidateExternalLinks). -
private bool changelogError { get; }
True if updateExisting is set and changelog is null/whitespace. -
private bool versionError { get; }
True if updateExisting is set and UserModVersion is null/whitespace. -
private bool noInternetConnection { get; }
True if the platform reports no connectivity. -
private bool notLoggedIn { get; }
True if the upload handle indicates the user is not logged in. -
private bool anyError { get; }
Aggregate of validation flags — true if any required field or precondition is missing. -
private bool disableSubmit { get; }
True if the submit button should be disabled (based on state and anyError).
Constructors
[Preserve] public AssetUploadPanelUISystem()
Default constructor (preserved for Unity serialization). The class does most initialization in OnCreate.
Methods
-
protected override void OnCreate()
Builds the widget tree for the main panel and preview picker, sets up callbacks and adapters, wires events (tag removal, asset removal), initializes m_NotificationUISystem and other UI references. This method constructs the fields, input widgets, groups, popups and binds them to m_UploadHandle via DelegateAccessor delegates. -
protected override void OnUpdate()
Called every frame; updates dynamic UI states like the submit button label by calling RefreshSubmitButtonLabel. -
private void RefreshSubmitButtonLabel()
Updates m_SubmitButton.displayName (and forces properties changed) if the computed label differs from current. -
private void ReportError(IModsUploadSupport.ModOperationResult result)
Sets state to Failure, populates m_PlatformResult with error labels (including lines from result.m_Error), and posts a failure notification via m_NotificationUISystem. -
private void ReportSuccess()
Sets state to Success, shows completion UI including published ID, provides a copy-ID button and posts a success notification that can copy the ID on completion. -
private void ReportLocalDataNotFound()
Shows a message in m_PlatformResult indicating expected local preview/screenshot data couldn't be found. -
private void ClearState()
Resets the internal state to Ready and clears platform result UI. -
private void ReportSubmitting()
Puts the UI into Processing state, sets platform result to "submitting" label, and adds/updates an indeterminate notification. -
private void ReportSyncing()
Puts UI into Processing state and shows a "retrieving data" label while platform sync occurs. -
private void ReportNoSocial()
Puts UI into Disabled state and replaces platform result with a message telling the user to open profile page; wire up button to open profile and refresh social status once synced. -
private string GetSubmitButtonLabel()
Returns the correct localized label for the submit button depending on state, connectivity and login status. -
private void SetChildren(IWidget[] newChildren)
Helper to set m_Children and invoke onChildrenChange when the visible widgets change. -
public void Show(AssetData mainAsset, bool allowManualFileCopy = false)
Initialize the panel for the provided main asset: reset upload handle, refresh UI pieces (links, screenshots, preview, asset list, DLC list), clear state and begin platform data sync. -
private async void SyncPlatformData()
Async method that calls m_UploadHandle.SyncPlatformData(), reports syncing state, and after completion updates social/profile info, author mods, tags and DLC list on the main thread. -
public bool Close()
Handles closing/escape behavior for nested UI: closes preview picker if open, collapses existing-mod field and asset-list popup if expanded, returns true if the system can be closed entirely. -
private void RefreshSocialProfileStatus()
Checks upload handle's social profile name and either shows the "no social" UI or clears disabled state. -
private void Submit()
Entry point for submit button: shows submitting UI and calls BeginSubmit(). -
private async void BeginSubmit()
Calls m_UploadHandle.BeginSubmit() (async). If successful and manual file copy is allowed, prompts the user to copy files and either finalize or cancel. Otherwise it calls FinalizeSubmit. On failure, reports error on main thread. -
private async void FinalizeSubmit()
Calls m_UploadHandle.FinalizeSubmit() (async) and reports success or error on the main thread. -
private async void Cancel()
Removes notifications, calls m_UploadHandle.Cleanup() (async) to clean temporary data and clears the UI state. -
private void RefreshExternalLinks()
Updates m_ExternalLinkField.links from the upload handle and marks the widget changed. -
private void RefreshScreenshots()
Rebuilds the screenshot icon buttons from m_UploadHandle.screenshots and adds a "plus" button that opens the preview picker to add a screenshot. -
private void RefreshPreview()
Updates the preview picker button icon based on the current preview in m_UploadHandle. -
private void RefreshAssetList()
Rebuilds m_AssetList items from m_UploadHandle.assets and additionalAssets and updates the widget. -
private void RefreshDLCList()
Clears and repopulates the DLC info area from m_UploadHandle.modInfo.m_DLCDependencies and availableDLCs, toggles m_DLCInfoVisible accordingly. -
private bool TryMatchDLC(string internalName, out IModsUploadSupport.DLCTag dlc)
Searches m_UploadHandle.availableDLCs for a matching internal name and returns the tag if found. -
private static ListField.Item GetItem(AssetData asset, bool removable, bool mainAsset)
Creates a ListField.Item for an asset, collects prefab dependencies (using AssetUploadUtils) and sets subitems for display dependencies when applicable. -
private static string GetLabel(AssetData asset)
Returns a display label for an asset including platform ID or package name when relevant. -
private void OnAddPrefab(PrefabBase prefab)
Callback when a prefab is picked from popup: adds it to upload handle additional assets, refreshes asset & DLC lists. -
private void OnRemoveAdditionalAsset(int index)
Removes an additional asset (by list index) from the upload handle and refreshes lists. -
private bool ShouldShowInPrefabPicker(PrefabBase prefab)
Predicate used to filter prefabs shown in the picker (user database and not already part of cached dependencies). -
private void RefreshTags()
Rebuilds the tags list widget and repopulates the tag add popup with available tags excluding already selected ones. -
private void OnAddTag(string tag)
Handles adding a selected tag from popup to the upload handle and refreshes tags. -
private void OnRemoveTag(int index)
Removes an additional tag from m_UploadHandle by index and refreshes tag list. -
private void OpenPreviewPickerPanel(Action<Colossal.Hash128> callback, Colossal.Hash128 defaultSelection = default, bool excludeScreenshots = false)
Sets up the preview picker adapter with available previews (optionally excluding screenshots), selects a default item and switches displayed children to the preview picker panel. Sets up select button to call ClosePreviewPickerPanel. -
private void ClosePreviewPickerPanel(Action<Colossal.Hash128> callback)
Restores main panel children and invokes callback with the selected preview GUID. -
private void SetPreview(Colossal.Hash128 guid)
If an asset matches the supplied guid, sets it as the preview in the upload handle and refreshes the preview button. -
private void AddScreenshot(Colossal.Hash128 guid)
Adds the selected asset as a screenshot in m_UploadHandle and refreshes the screenshot UI. -
private void RemoveScreenshot(int index)
Removes screenshot at index from the upload handle and refreshes screenshot UI. -
private IEnumerable<AssetItem> GetPreviews(bool excludeScreenshots = false)
Iterator that yields preview candidates: original previews from the upload handle first, then image assets from the global database that are screenshots (filters by subPath). Optionally excludes assets already used as screenshots. -
private void RefreshAuthorMods()
Populates the existing-mods picker via m_ExistingModPopup.SetItems using GetExistingMods(). -
private IEnumerable<ItemPickerPopup<int>.Item> GetExistingMods()
Yields a "None" item followed by items for each author mod in m_UploadHandle.authorMods (including search terms and localized display names). -
private async void SetInfoFromExisting()
Async flow used when the user chooses to update an existing published asset: fetches existing info and local data, then updates m_UploadHandle.modInfo and (if local data found) sets previews/screenshots and refreshes UI, otherwise displays a local-data-not-found message.
Usage Example
// Show the upload panel for a given AssetData
var uploadSystem = world.GetOrCreateSystemManaged<Game.UI.Menu.AssetUploadPanelUISystem>();
AssetData myAsset = AssetDatabase.global.GetAsset<AssetData>(someGuid);
// Open the panel and allow manual file copy before finalizing (optional)
uploadSystem.Show(myAsset, allowManualFileCopy: true);