Exemplo n.º 1
0
 string[] GetTags()
 {
     return(WorkshopHelper.GetSubscribedItem(m_modId).Tags);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Publishes the mod to the workshop
        /// </summary>
        /// <returns></returns>
        public bool Publish()
        {
            bool newMod = false;

            if (MySteam.API == null)
            {
                MySandboxGame.Log.WriteLineAndConsole("Cannot publish, Steam not detected!");
                return(false);
            }

            // Upload/Publish
            if (m_modId == 0)
            {
                MySandboxGame.Log.WriteLineAndConsole(string.Format("Uploading new {0}: {1}", m_type.ToString(), m_title));
                newMod = true;
            }
            else
            {
                var title = m_title;
                var item  = WorkshopHelper.GetSubscribedItem(m_modId);

                if (item != null)
                {
                    title = item.Title;
                }

                // Check if the mod owner in the sbmi matches steam owner
                MyDebug.AssertDebug(item.SteamIDOwner == MySteam.UserId);
                if (item.SteamIDOwner != MySteam.UserId)
                {
                    MySandboxGame.Log.WriteLineAndConsole(string.Format("Owner mismatch! Mod owner: {0}; Current user: {1}", item.SteamIDOwner, MySteam.UserId));
                    MySandboxGame.Log.WriteLineAndConsole("Upload/Publish FAILED!");
                    return(false);
                }
                MySandboxGame.Log.WriteLineAndConsole(string.Format("Updating {0}: {1}; {2}", m_type.ToString(), m_modId, title));
            }

            // Process Tags
            ProcessTags();

            if (m_dryrun)
            {
                MySandboxGame.Log.WriteLineAndConsole("DRY-RUN; Publish skipped");
            }
            else
            {
                if (_publishMethod != null)
                {
                    var ret = _publishMethod.Invoke(null, new object[]
                    {
                        m_modPath,
                        m_title,
                        null,
                        new ulong?(m_modId),
                        m_visibility,
                        m_tags,
                        m_ignoredExtensions
                    });

                    MyDebug.AssertDebug(ret is ulong);
                    m_modId = (ulong)ret;
                }
                else
                {
                    MySandboxGame.Log.WriteLineAndConsole(string.Format(Constants.ERROR_Reflection, "PublishItemBlocking"));
                }
            }
            if (m_modId == 0)
            {
                MySandboxGame.Log.WriteLineAndConsole("Upload/Publish FAILED!");
                return(false);
            }
            else
            {
                MySandboxGame.Log.WriteLineAndConsole(string.Format("Upload/Publish success: {0}", m_modId));
                if (newMod)
                {
                    if (MySteamWorkshop.GenerateModInfo(m_modPath, m_modId, MySteam.UserId))
                    {
                        MySandboxGame.Log.WriteLineAndConsole(string.Format("Create modinfo.sbmi success: {0}", m_modId));
                    }
                    else
                    {
                        MySandboxGame.Log.WriteLineAndConsole(string.Format("Create modinfo.sbmi FAILED: {0}", m_modId));
                        return(false);
                    }
                }
            }
            return(true);
        }