Skip to content

How to Create a new Destination

James Veugelaers edited this page Apr 5, 2025 · 3 revisions

A destination is a where a build will be uploaded to after succeeding retrieving sources and modifying.

The Build Uploader uses reflection to find all classes inheriting from ABuildDestination and displays them in a dropdown to be chosen.

using System.Collections.Generic;
using System.Threading.Tasks;

namespace Wireframe
{
    internal class ExampleDestination : ABuildDestination
    {
        public ExampleDestination(BuildUploaderWindow window) : base(window)
        {
        }

        public override string DisplayName { get; } // Name displayed in dropdowns
        public override async Task<UploadResult> Upload(string filePath, string buildDescription)
        {
            // Start uploading content from filePath.
            // This will always be a directory with contents in it
            // Use ProgressUtils to show progress
            // return UploadResult.Success if uploaded successfully
            // return UploadResult.Failed("reason") if failed to upload
            return UploadResult.Success();
        }

        public override string ProgressTitle()
        {
            // Return the title of the progress
            // eg: "Uploading to Steam"
            return "Uploading to Example";
        }

        public override bool IsSetup(out string reason)
        {
            // Return true if the destination is ready to be used
            // eg: A service is setup correctly
            // If not, return false and set the reason as to why eg: "MyService not setup"
            reason = "";
            return true;
        }

        public override Dictionary<string, object> Serialize()
        {
            // Save the source data to a save
            return new Dictionary<string, object>
            {
                { "exampleKey", "exampleValue" }
            };
        }

        public override void Deserialize(Dictionary<string, object> data)
        {
            // Load the source data from a save
            if (data.TryGetValue("exampleKey", out var value))
            {
                // Do something with the value
            }
        }

        public override void OnGUIExpanded(ref bool isDirty)
        {
            // User expanded the collapsed view to edit all the fields
        }

        public override void OnGUICollapsed(ref bool isDirty, float maxWidth)
        {
            // Shortened version of the GUI to be displayed on 1 line
        }
    }
}

Clone this wiki locally