Beispiel #1
0
        private static void OnItemCreated(CreateItemResult_t result, bool IOFailure)
        {
            if (IOFailure || result.m_eResult != EResult.k_EResultOK)
            {
                uploadingHook = null;
                Dialog_WorkshopOperationInProgress.CloseAll();
                Log.Error("Workshop: OnItemCreated failure. Result: " + result.m_eResult.GetLabel());
                Find.WindowStack.Add(new Dialog_MessageBox("WorkshopSubmissionFailed".Translate(GenText.SplitCamelCase(result.m_eResult.GetLabel()))));
            }
            else
            {
                uploadingHook.PublishedFileId = result.m_nPublishedFileId;
                if (Prefs.LogVerbose)
                {
                    Log.Message("Workshop: Item created. PublishedFileId: " + uploadingHook.PublishedFileId);
                }
                curUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), uploadingHook.PublishedFileId);
                SetWorkshopItemDataFrom(curUpdateHandle, uploadingHook, creating: true);
                curStage = WorkshopInteractStage.SubmittingItem;
                if (Prefs.LogVerbose)
                {
                    Log.Message("Workshop: Submitting item.");
                }
                SteamAPICall_t hAPICall = SteamUGC.SubmitItemUpdate(curUpdateHandle, "[Auto-generated text]: Initial upload.");
                submitResult = CallResult <SubmitItemUpdateResult_t> .Create(OnItemSubmitted);

                submitResult.Set(hAPICall);
                createResult = null;
            }
        }
 private static void OnItemSubmitted(SubmitItemUpdateResult_t result, bool IOFailure)
 {
     if (IOFailure || result.m_eResult != EResult.k_EResultOK)
     {
         Workshop.uploadingHook = null;
         Dialog_WorkshopOperationInProgress.CloseAll();
         Log.Error("Workshop: OnItemSubmitted failure. Result: " + result.m_eResult.GetLabel(), false);
         Find.WindowStack.Add(new Dialog_MessageBox("WorkshopSubmissionFailed".Translate(new object[]
         {
             GenText.SplitCamelCase(result.m_eResult.GetLabel())
         }), null, null, null, null, null, false, null, null));
     }
     else
     {
         SteamUtility.OpenWorkshopPage(Workshop.uploadingHook.PublishedFileId);
         Messages.Message("WorkshopUploadSucceeded".Translate(new object[]
         {
             Workshop.uploadingHook.Name
         }), MessageTypeDefOf.TaskCompletion, false);
         if (Prefs.LogVerbose)
         {
             Log.Message("Workshop: Item submit result: " + result.m_eResult, false);
         }
     }
     Workshop.curStage     = WorkshopInteractStage.None;
     Workshop.submitResult = null;
 }
Beispiel #3
0
        private static void SetWorkshopItemDataFrom(UGCUpdateHandle_t updateHandle, WorkshopItemHook hook, bool creating)
        {
            hook.PrepareForWorkshopUpload();
            SteamUGC.SetItemTitle(updateHandle, hook.Name);
            if (creating)
            {
                SteamUGC.SetItemDescription(updateHandle, hook.Description);
            }
            if (!File.Exists(hook.PreviewImagePath))
            {
                Log.Warning("Missing preview file at " + hook.PreviewImagePath);
            }
            else
            {
                SteamUGC.SetItemPreview(updateHandle, hook.PreviewImagePath);
            }
            IList <string> tags = hook.Tags;

            foreach (System.Version supportedVersion in hook.SupportedVersions)
            {
                tags.Add(supportedVersion.Major + "." + supportedVersion.Minor);
            }
            SteamUGC.SetItemTags(updateHandle, tags);
            SteamUGC.SetItemContent(updateHandle, hook.Directory.FullName);
        }
        internal static void Upload(WorkshopUploadable item)
        {
            if (Workshop.curStage != WorkshopInteractStage.None)
            {
                Messages.Message("UploadAlreadyInProgress".Translate(), MessageTypeDefOf.RejectInput, false);
            }
            else
            {
                Workshop.uploadingHook = item.GetWorkshopItemHook();
                if (Workshop.uploadingHook.PublishedFileId != PublishedFileId_t.Invalid)
                {
                    if (Prefs.LogVerbose)
                    {
                        Log.Message(string.Concat(new object[]
                        {
                            "Workshop: Starting item update for mod '",
                            Workshop.uploadingHook.Name,
                            "' with PublishedFileId ",
                            Workshop.uploadingHook.PublishedFileId
                        }), false);
                    }
                    Workshop.curStage        = WorkshopInteractStage.SubmittingItem;
                    Workshop.curUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), Workshop.uploadingHook.PublishedFileId);
                    Workshop.SetWorkshopItemDataFrom(Workshop.curUpdateHandle, Workshop.uploadingHook, false);
                    SteamAPICall_t hAPICall = SteamUGC.SubmitItemUpdate(Workshop.curUpdateHandle, "[Auto-generated text]: Update on " + DateTime.Now.ToString() + ".");
                    if (Workshop.< > f__mg$cache3 == null)
                    {
                        Workshop.< > f__mg$cache3 = new CallResult <SubmitItemUpdateResult_t> .APIDispatchDelegate(Workshop.OnItemSubmitted);
                    }
                    Workshop.submitResult = CallResult <SubmitItemUpdateResult_t> .Create(Workshop.< > f__mg$cache3);

                    Workshop.submitResult.Set(hAPICall, null);
                }
                else
                {
                    if (Prefs.LogVerbose)
                    {
                        Log.Message("Workshop: Starting item creation for mod '" + Workshop.uploadingHook.Name + "'.", false);
                    }
                    Workshop.curStage = WorkshopInteractStage.CreatingItem;
                    SteamAPICall_t hAPICall2 = SteamUGC.CreateItem(SteamUtils.GetAppID(), EWorkshopFileType.k_EWorkshopFileTypeFirst);
                    if (Workshop.< > f__mg$cache4 == null)
                    {
                        Workshop.< > f__mg$cache4 = new CallResult <CreateItemResult_t> .APIDispatchDelegate(Workshop.OnItemCreated);
                    }
                    Workshop.createResult = CallResult <CreateItemResult_t> .Create(Workshop.< > f__mg$cache4);

                    Workshop.createResult.Set(hAPICall2, null);
                }
                Find.WindowStack.Add(new Dialog_WorkshopOperationInProgress());
            }
        }
Beispiel #5
0
        internal static void Upload(WorkshopUploadable item)
        {
            if (curStage != 0)
            {
                Messages.Message("UploadAlreadyInProgress".Translate(), MessageTypeDefOf.RejectInput, historical: false);
            }
            else
            {
                uploadingHook = item.GetWorkshopItemHook();
                if (uploadingHook.PublishedFileId != PublishedFileId_t.Invalid)
                {
                    if (Prefs.LogVerbose)
                    {
                        Log.Message("Workshop: Starting item update for mod '" + uploadingHook.Name + "' with PublishedFileId " + uploadingHook.PublishedFileId);
                    }
                    curStage        = WorkshopInteractStage.SubmittingItem;
                    curUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), uploadingHook.PublishedFileId);
                    SetWorkshopItemDataFrom(curUpdateHandle, uploadingHook, creating: false);
                    SteamAPICall_t hAPICall = SteamUGC.SubmitItemUpdate(curUpdateHandle, "[Auto-generated text]: Update on " + DateTime.Now.ToString() + ".");
                    submitResult = CallResult <SubmitItemUpdateResult_t> .Create(OnItemSubmitted);

                    submitResult.Set(hAPICall);
                }
                else
                {
                    if (Prefs.LogVerbose)
                    {
                        Log.Message("Workshop: Starting item creation for mod '" + uploadingHook.Name + "'.");
                    }
                    curStage = WorkshopInteractStage.CreatingItem;
                    SteamAPICall_t hAPICall2 = SteamUGC.CreateItem(SteamUtils.GetAppID(), EWorkshopFileType.k_EWorkshopFileTypeFirst);
                    createResult = CallResult <CreateItemResult_t> .Create(OnItemCreated);

                    createResult.Set(hAPICall2);
                }
                Find.WindowStack.Add(new Dialog_WorkshopOperationInProgress());
            }
        }
        private static void OnItemCreated(CreateItemResult_t result, bool IOFailure)
        {
            if (IOFailure || result.m_eResult != EResult.k_EResultOK)
            {
                Workshop.uploadingHook = null;
                Dialog_WorkshopOperationInProgress.CloseAll();
                Log.Error("Workshop: OnItemCreated failure. Result: " + result.m_eResult.GetLabel(), false);
                Find.WindowStack.Add(new Dialog_MessageBox("WorkshopSubmissionFailed".Translate(new object[]
                {
                    GenText.SplitCamelCase(result.m_eResult.GetLabel())
                }), null, null, null, null, null, false, null, null));
            }
            else
            {
                Workshop.uploadingHook.PublishedFileId = result.m_nPublishedFileId;
                if (Prefs.LogVerbose)
                {
                    Log.Message("Workshop: Item created. PublishedFileId: " + Workshop.uploadingHook.PublishedFileId, false);
                }
                Workshop.curUpdateHandle = SteamUGC.StartItemUpdate(SteamUtils.GetAppID(), Workshop.uploadingHook.PublishedFileId);
                Workshop.SetWorkshopItemDataFrom(Workshop.curUpdateHandle, Workshop.uploadingHook, true);
                Workshop.curStage = WorkshopInteractStage.SubmittingItem;
                if (Prefs.LogVerbose)
                {
                    Log.Message("Workshop: Submitting item.", false);
                }
                SteamAPICall_t hAPICall = SteamUGC.SubmitItemUpdate(Workshop.curUpdateHandle, "[Auto-generated text]: Initial upload.");
                if (Workshop.< > f__mg$cache6 == null)
                {
                    Workshop.< > f__mg$cache6 = new CallResult <SubmitItemUpdateResult_t> .APIDispatchDelegate(Workshop.OnItemSubmitted);
                }
                Workshop.submitResult = CallResult <SubmitItemUpdateResult_t> .Create(Workshop.< > f__mg$cache6);

                Workshop.submitResult.Set(hAPICall, null);
                Workshop.createResult = null;
            }
        }