public static bool Create(Mod mod) { // start async call var call = SteamUGC.CreateItem(RIMWORLD, 0); createResultCallback = CallResult <CreateItemResult_t> .Create(OnItemCreated); createResultCallback.Set(call); // keep checking for async call to complete var loading = new LoadingIndicator(); while (!ready.WaitOne(50)) { SteamAPI.RunCallbacks(); ClearLine(); Console.Write("Waiting for item creation to complete... " + loading); } // we have completed! if (createResult.m_eResult != EResult.k_EResultOK) { Console.WriteLine(createResult.m_eResult); } else { mod.PublishedFileId = createResult.m_nPublishedFileId; Console.WriteLine("\nNew mod created (" + mod.PublishedFileId + ")"); } return(createResult.m_eResult == EResult.k_EResultOK); }
public static bool Upload(Mod mod, string changenote) { bool creating = false; if (mod.PublishedFileId == PublishedFileId_t.Invalid) { // create item first. creating = true; Console.WriteLine("no PublishedFileId found, creating new mod..."); if (!Create(mod)) { throw new Exception("mod creation failed!"); } } // create timestamp to force steam to accept the update as a change mod.TimeStamp(); // set up steam API call var handle = SteamUGC.StartItemUpdate(RIMWORLD, mod.PublishedFileId); SetItemAttributes(handle, mod, creating); // start async call var call = SteamUGC.SubmitItemUpdate(handle, changenote); submitResultCallback = CallResult <SubmitItemUpdateResult_t> .Create(OnItemSubmitted); submitResultCallback.Set(call); // keep checking for async call to complete var loading = new LoadingIndicator(); while (!ready.WaitOne(50)) { var status = SteamUGC.GetItemUpdateProgress(handle, out ulong done, out ulong total); SteamAPI.RunCallbacks(); ClearLine(); if (status != EItemUpdateStatus.k_EItemUpdateStatusInvalid) { if (total > 0) { Console.Write(status + ": " + (done / total).ToString("P") + " completed. " + loading); } else { Console.Write(status + "... " + loading); } } } // we have completed! if (submitResult.m_eResult != EResult.k_EResultOK) { Console.WriteLine("\n" + submitResult.m_eResult); } else { Console.WriteLine(""); } return(submitResult.m_eResult == EResult.k_EResultOK); }