Ejemplo n.º 1
0
        private void ItemUpdated(EResult Result)
        {
            bIsUploadInProgress = false;
            ulong bytesProcessed;
            ulong bytesTotal;

            CSteamInterface.GetUpdateItemProgress(out bytesProcessed, out bytesTotal);
            if (bytesTotal != 0)
            {
                workshopTextBox1.PrintLineAtLineStart(string.Format("  Uploaded {0:n0} of {1:n0} bytes", bytesProcessed, bytesTotal));
            }
            workshopTextBox1.PrintNewLine();
            if (Result == EResult.k_EResultOK)
            {
                workshopTextBox1.PrintLine("  Workshop item updated.");
            }
            else
            {
                workshopTextBox1.PrintLine(string.Format("  Steam error updating item: Error code = {0}", Result));
            }
            workshopTextBox1.PrintNewLine();
            if (!bDontDeleteTempFiles)
            {
                CConfig.DeleteDirectory(TempFolder);
            }
            workshopTextBox1.PrintPrompt();
        }
Ejemplo n.º 2
0
 private void ProcessArchiveExitStatus(int exitCode)
 {
     if (exitCode == -1)
     {
         workshopTextBox1.PrintNewLine();
         workshopTextBox1.PrintLine(string.Format("  Archive.exe failed."));
         if (!bDontDeleteTempFiles)
         {
             CConfig.DeleteDirectory(TempFolder);
         }
         workshopTextBox1.PrintPrompt();
     }
     else if (bIsExecutingCreateCommand)
     {
         if (!bDontDeleteTempFiles)
         {
             File.Delete(ArchiveCommands[archive_index].buildfilename);
         }
         archive_index++;
         if (archive_index < ArchiveCommands.Count)
         {
             RunArchiveForArchiveIndex();
         }
         else
         {
             workshopTextBox1.PrintNewLine();
             workshopTextBox1.PrintLine(string.Format("Creating new item on Steam Workshop..."));
             CSteamInterface.CreateItem(Game_AppId, ItemCreated);
         }
     }
     else
     {
         if (bIsExecutingUpdateCommand)
         {
             if (!bDontDeleteTempFiles)
             {
                 File.Delete(ArchiveCommands[archive_index].buildfilename);
             }
             archive_index++;
             if (archive_index < ArchiveCommands.Count)
             {
                 RunArchiveForArchiveIndex();
                 return;
             }
             workshopTextBox1.PrintNewLine();
             workshopTextBox1.PrintLine(string.Format("Updating item on Steam Workshop..."));
             if (CSteamInterface.UpdateItem(Game_AppId, updateItemFileId, false, TempFolder, CConfig.previewImageFilename, CConfig.title, CConfig.tags, CConfig.description, ItemUpdated))
             {
                 bIsUploadInProgress = true;
                 return;
             }
             workshopTextBox1.PrintLine(string.Format("  Steam update item failed: {0}", CSteamInterface.ErrorMessage));
             if (!bDontDeleteTempFiles)
             {
                 CConfig.DeleteDirectory(TempFolder);
             }
         }
         workshopTextBox1.PrintPrompt();
     }
 }
Ejemplo n.º 3
0
        public WorkshopTool(string[] args)
        {
            WorkshopToolForm = this;
            CmdlineArgs      = args;
            InitializeComponent();
            bIsUploadInProgress = false;
            previousTimer       = DateTime.Now;
            Workshop_AppId      = new AppId_t(347380u);
            Game_AppId          = new AppId_t(244160u);
            CSteamInterface.Init();
            bIsExecutingCreateCommand = false;
            bIsExecutingUpdateCommand = false;
            AutoResetEvent autoEvent = new AutoResetEvent(false);

            SteamCallbackTimer = new System.Threading.Timer(RunSteamCallbacks, autoEvent, 10, 10);
        }
Ejemplo n.º 4
0
 private void ItemCreated(EResult Result, bool bNeedsToAcceptWorkshopLegalAgreement, PublishedFileId_t NewItemCreated)
 {
     if (Result == EResult.k_EResultOK)
     {
         workshopTextBox1.PrintLine(string.Format("  Workshop item created.  Item Id = {0}", NewItemCreated.m_PublishedFileId));
         CConfig.UpdateWorkshopItemNumber(NewItemCreated.m_PublishedFileId);
         if (bNeedsToAcceptWorkshopLegalAgreement)
         {
             workshopTextBox1.PrintNewLine();
             workshopTextBox1.PrintLine("You will need to agree to the Steam Workshop Terms of Service agreement at:");
             workshopTextBox1.PrintNewLine();
             workshopTextBox1.PrintLine("http://steamcommunity.com/sharedfiles/workshoplegalagreement");
             workshopTextBox1.PrintNewLine();
             workshopTextBox1.PrintLine("...before this Workshop item can be updated or set to 'public' visibility.");
             workshopTextBox1.PrintLine("After agreeing to the Terms of Service agreement, you will need to use the 'update' command to update this Workshop item.");
             ProcessStartInfo startInfo = new ProcessStartInfo("explorer.exe", "http://steamcommunity.com/sharedfiles/workshoplegalagreement");
             Process.Start(startInfo);
             if (!bDontDeleteTempFiles)
             {
                 CConfig.DeleteDirectory(TempFolder);
             }
             workshopTextBox1.PrintPrompt();
             return;
         }
         if (CSteamInterface.UpdateItem(Game_AppId, NewItemCreated, true, TempFolder, CConfig.previewImageFilename, CConfig.title, CConfig.tags, CConfig.description, ItemUpdated))
         {
             bIsUploadInProgress = true;
             return;
         }
         workshopTextBox1.PrintLine(string.Format("  Steam update item failed: {0}", CSteamInterface.ErrorMessage));
         workshopTextBox1.PrintLine("  You should manually update the item again or delete the item from the Steam Workshop web page.");
         if (!bDontDeleteTempFiles)
         {
             CConfig.DeleteDirectory(TempFolder);
         }
     }
     else
     {
         workshopTextBox1.PrintLine(string.Format("  Steam error creating item: Error code = {0}", Result));
         if (!bDontDeleteTempFiles)
         {
             CConfig.DeleteDirectory(TempFolder);
         }
     }
     workshopTextBox1.PrintPrompt();
 }
Ejemplo n.º 5
0
 private void RunSteamCallbacks(object stateInfo)
 {
     SteamAPI.RunCallbacks();
     if (bIsUploadInProgress && DateTime.Now.Subtract(previousTimer).Milliseconds > 100)
     {
         ulong bytesProcessed;
         ulong bytesTotal;
         CSteamInterface.GetUpdateItemProgress(out bytesProcessed, out bytesTotal);
         if (bytesTotal != 0)
         {
             BeginInvoke((MethodInvoker) delegate
             {
                 workshopTextBox1.PrintLineAtLineStart(string.Format("  Uploaded {0:n0} of {1:n0} bytes", bytesProcessed, bytesTotal));
             });
         }
         previousTimer = DateTime.Now;
     }
 }
Ejemplo n.º 6
0
        private void WorkshopTextBox_CommandEntered(object sender, EventArgs e)
        {
            Console.WriteLine("cmd = {0}", workshopTextBox1.Command);
            string command = workshopTextBox1.Command;

            string[] args = GetCommandArguments(command);
            bIsExecutingCreateCommand = false;
            bIsExecutingUpdateCommand = false;
            if (args != null && args.Length != 0)
            {
                switch (args[0].ToLower())
                {
                case "quit":
                case "exit":
                    Application.Exit();
                    return;

                case "help":
                    workshopTextBox1.PrintLine("help:");
                    workshopTextBox1.PrintLine("  Use 'quit' or 'exit' to exit WorkshopTool.");
                    workshopTextBox1.PrintLine("  Use 'list' to print out a list of Workshop items that you have uploaded to Workshop.");
                    workshopTextBox1.PrintLine("  Use 'create <foldername>' to create and upload a new Workshop item.");
                    workshopTextBox1.PrintLine("  Use 'update <foldername>' to update an existing Workshop item.");
                    break;

                case "list":
                    CSteamInterface.GetPublishedItems(accountId, Workshop_AppId, Game_AppId, PublishedItems);
                    return;

                case "create":
                    if (args.Length > 1)
                    {
                        MODFolder = args[1];
                        MODFolder = MODFolder.Trim();
                        MODFolder = MODFolder.TrimEnd('\\');
                        if (!CConfig.ValidateFolderContents(MODFolder))
                        {
                            workshopTextBox1.PrintLine(string.Format("  {0}", CConfig.ValidationErrorMessage));
                        }
                        else
                        {
                            workshopTextBox1.PrintNewLine();
                            workshopTextBox1.PrintLine(string.Format("Using the following settings from the config.txt file in MOD folder '{0}'", MODFolder));
                            workshopTextBox1.PrintLine(string.Format("  Title: {0}", CConfig.title));
                            workshopTextBox1.PrintLine(string.Format("  Tags: {0}", CConfig.tags));
                            workshopTextBox1.PrintLine(string.Format("  BigFilename: {0}.big", CConfig.bigfilename));
                            bIsExecutingCreateCommand = true;
                            TempFolder = CArchive.CreateArchiveTempFolder();
                            if (TempFolder != null)
                            {
                                if (bDontDeleteTempFiles)
                                {
                                    workshopTextBox1.PrintNewLine();
                                    workshopTextBox1.PrintLine(string.Format("TEMP folder is: '{0}'", TempFolder));
                                }
                                CConfig.CopyConfigFilesToFolder(TempFolder);
                                workshopTextBox1.PrintNewLine();
                                workshopTextBox1.PrintLine(string.Format("Running Archive.exe on MOD folder..."));
                                if (RunArchiveOnModFolder(MODFolder, CConfig.bigfilename))
                                {
                                    return;
                                }
                                workshopTextBox1.PrintLine("  There was a problem creating the .big file(s) for your mod.  You may need to set the WorkshopTool to 'Run this program as an Administrator'");
                            }
                            else
                            {
                                workshopTextBox1.PrintLine(string.Format("  {0}", CArchive.ArchiveErrorMessage));
                            }
                        }
                    }
                    else
                    {
                        workshopTextBox1.PrintLine("  Usage: 'create <foldername>' - You must provide the folder name that contains your MOD files.");
                    }
                    break;

                case "update":
                    if (args.Length > 1)
                    {
                        MODFolder = args[1];
                        MODFolder = MODFolder.Trim();
                        MODFolder = MODFolder.TrimEnd('\\');
                        if (!CConfig.ValidateFolderContents(MODFolder))
                        {
                            workshopTextBox1.PrintLine(string.Format("  {0}", CConfig.ValidationErrorMessage));
                        }
                        else
                        {
                            if (CConfig.workshopId != 0)
                            {
                                bIsExecutingUpdateCommand = true;
                                workshopTextBox1.PrintNewLine();
                                workshopTextBox1.PrintLine("Retrieving list of published Workshop items...");
                                CSteamInterface.GetPublishedItems(accountId, Workshop_AppId, Game_AppId, PublishedItems);
                                return;
                            }
                            workshopTextBox1.PrintLine(string.Format("  The Workshop item in the folder '{0}' doesn't have a valid Steam Workshop ID number.  You need to use the 'create' command to create the Workshop item first before you can update it.", MODFolder));
                        }
                    }
                    else
                    {
                        workshopTextBox1.PrintLine("  Usage: 'update <foldername>' - You must provide the folder name that contains your MOD files.");
                    }
                    break;

                default:
                    workshopTextBox1.PrintLine(string.Format("  unknown command: {0}", command));
                    break;
                }
            }
            workshopTextBox1.PrintPrompt();
        }