Exemple #1
0
 private void mButton2_Click(object sender, EventArgs e)
 {
     if (Validator != null)
     {
         var val = Validator.Validate(InputBox.Text);
         if (val != null)
         {
             CUMessageBox.Show(this, val, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
     }
     this.DialogResult = DialogResult.OK;
 }
Exemple #2
0
        private void CUButtonBorderless1_Click(object sender, EventArgs e)
        {
            string source = CUInputWindow.Ask(this, "Asset Replacement: from", "Enter the asset name which you want to replace", new ARValidator());

            if (source != null)
            {
                if (Collect().Where(item => item.Key.ToLowerInvariant() == source.ToLowerInvariant()).Count() > 0)
                {
                    CUMessageBox.Show("ARList already contains item with key: " + source, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string target = CUInputWindow.Ask(this, "Asset Replacement: to", $"Replacement: {source}{Environment.NewLine}Enter the target asset name", new ARValidator());
                if (target != null)
                {
                    Append(source, target);
                    CallOnUpdateEvent();
                }
            }
        }
Exemple #3
0
        private static void OnItemSubmitted(SubmitItemUpdateResult_t param, bool bIOFailure)
        {
            if (bIOFailure)
            {
                SetStatus("Error: I/O Failure!");
                return;
            }

            switch (param.m_eResult)
            {
            case EResult.k_EResultOK:
                SetStatus("SUCCESS! Item submitted!");
                ugcUpdateHandle = UGCUpdateHandle_t.Invalid;
                success         = true;
                break;

            default:
                SetStatus("Item upload failed! Result code: " + param.m_eResult.ToString());
                CUMessageBox.Show("Item upload failed! Result code: " + param.m_eResult.ToString());
                ugcUpdateHandle = UGCUpdateHandle_t.Invalid;
                success         = false;
                break;
            }
        }
Exemple #4
0
 private void cuButton3_Click(object sender, EventArgs e)
 {
     CUMessageBox.Show("test");
 }
Exemple #5
0
        public void UploadMod(ModObject mod, string changelog, string[] tags, bool keepUnCooked, bool keepScripts, int visibility, string description, string iconPath)
        {
            if (IsUploaderRunning)
            {
                MainWindow.Instance.Invoke(new MethodInvoker(() => {
                    CUMessageBox.Show(MainWindow.Instance, "Only one uploader instance can run at once!");
                }));
                return;
            }

            Toggle(true);
            ResetUploader();

            success           = true;
            IsUploaderRunning = true;
            try
            {
                ERemoteStoragePublishedFileVisibility fileVisibility
                    = (ERemoteStoragePublishedFileVisibility)Enum.ToObject(typeof(ERemoteStoragePublishedFileVisibility), visibility);;

                mod.Refresh();
                SetStatus("Preparing the uploader...");
                var tmpDir = Path.Combine(Program.GetAppRoot(), "uploader_tmp");
                if (Directory.Exists(tmpDir))
                {
                    Directory.Delete(tmpDir, true);
                }
                Directory.CreateDirectory(tmpDir);

                Utils.DirectoryCopy(mod.RootPath, tmpDir, true);
                if (!keepScripts)
                {
                    if (Directory.Exists(Path.Combine(tmpDir, "CompiledScripts")))
                    {
                        Directory.Delete(Path.Combine(tmpDir, "CompiledScripts"), true);
                    }
                    if (Directory.Exists(Path.Combine(tmpDir, "Classes")))
                    {
                        Directory.Delete(Path.Combine(tmpDir, "Classes"), true);
                    }
                }

                if (!keepUnCooked)
                {
                    if (Directory.Exists(Path.Combine(tmpDir, "Maps")))
                    {
                        Directory.Delete(Path.Combine(tmpDir, "Maps"), true);
                    }
                    if (Directory.Exists(Path.Combine(tmpDir, "Content")))
                    {
                        Directory.Delete(Path.Combine(tmpDir, "Content"), true);
                    }
                }

                //var description = mod.GetDescription();

                var modid = mod.GetUploadedId();

                SetStatus("Creating callback...");

                m_itemCreated = CallResult <CreateItemResult_t> .Create(OnItemCreated);

                var appId = new AppId_t(uint.Parse(GameFinder.AppID));

                if (modid <= 100)
                {
                    SteamAPICall_t call = SteamUGC.CreateItem(appId, EWorkshopFileType.k_EWorkshopFileTypeCommunity);
                    m_itemCreated.Set(call);
                }
                else
                {
                    publishID = modid < 0 ? (ulong)(modid * -1) : (ulong)modid;
                }

                while (publishID == 0)
                {
                    SteamAPI.RunCallbacks();
                    Thread.Sleep(1000);
                }

                Thread.Sleep(1000);

                if (modid == 0)
                {
                    SetStatus("Uploading an new mod " + mod.Name + " with WorkshopID: " + publishID);
                    mod.SetUploadedId((long)publishID);
                }
                else
                {
                    SetStatus("Updating the mod " + mod.Name + " with WorkshopID: " + publishID);
                }

                //throw new Exception("F**K YOU WOKRSHOPID!!!!!!!!!!\nBtw, id: " + publishID);

                var publishFileID_t = new PublishedFileId_t(publishID);

                ugcUpdateHandle = SteamUGC.StartItemUpdate(appId, publishFileID_t);

                SteamUGC.SetItemTitle(ugcUpdateHandle, mod.Name);
                SteamUGC.SetItemDescription(ugcUpdateHandle, description);
                SteamUGC.SetItemVisibility(ugcUpdateHandle, fileVisibility);
                if (tags != null)
                {
                    SteamUGC.SetItemTags(ugcUpdateHandle, tags);
                }

                SteamUGC.SetItemPreview(ugcUpdateHandle, iconPath);
                SteamUGC.SetItemContent(ugcUpdateHandle, tmpDir);

                SteamAPICall_t t = SteamUGC.SubmitItemUpdate(ugcUpdateHandle, changelog);
                m_itemSubmitted = CallResult <SubmitItemUpdateResult_t> .Create(OnItemSubmitted);

                m_itemSubmitted.Set(t);

                while (true)
                {
                    Thread.Sleep(1000);
                    if (ugcUpdateHandle == UGCUpdateHandle_t.Invalid)
                    {
                        break;
                    }
                    SteamAPI.RunCallbacks();
                    ulong             bytesDone, bytesTotal;
                    EItemUpdateStatus status = SteamUGC.GetItemUpdateProgress(ugcUpdateHandle, out bytesDone, out bytesTotal);
                    if (status == EItemUpdateStatus.k_EItemUpdateStatusInvalid && !success)
                    {
                        break;
                    }


                    var percent = bytesTotal > 0 ? Math.Floor(((double)bytesDone / (double)bytesTotal) * (double)100) : 100;
                    SetStatus(string.Format("[{3}%] Status: {0}    {1}/{2}", TranslateStatus(status), BytesToString(bytesDone), BytesToString(bytesTotal), percent));
                    SetProgress((int)percent);
                }

                DialogResult res = DialogResult.No;

                if (success)
                {
                    MainWindow.Instance.Invoke(new MethodInvoker(() => {
                        res = CUMessageBox.Show(MainWindow.Instance, "Done, mod url:" + "\nhttps://steamcommunity.com/sharedfiles/filedetails/?id=" + publishID + "\n\nOpen it in the browser?", "Uploader", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                        if (res == DialogResult.Yes)
                        {
                            Process.Start("steam://openurl/https://steamcommunity.com/sharedfiles/filedetails/?id=" + publishID);
                        }
                    }));

                    SetStatus("Item uploaded successfully!");
                    Thread.Sleep(1000);
                }

                SetStatus("Cleanup");
                if (Directory.Exists(tmpDir))
                {
                    Directory.Delete(tmpDir, true);
                }

                Toggle(false);

                IsUploaderRunning = false;
            }
            catch (Exception e)
            {
                MainWindow.Instance.Invoke(new MethodInvoker(() => {
                    CUMessageBox.Show(MainWindow.Instance, e.Message + "\n" + e.ToString());
                }));
                IsUploaderRunning = false;
                SetStatus("");
                Toggle(false);
            }
        }