예제 #1
0
 private void ShareRoutine()
 {
     if (this.pluginInfo != null)
     {
         WorkshopModUploadPanel workshopModUploadPanel = UIView.library.ShowModal <WorkshopModUploadPanel>("WorkshopModUploadPanel");
         if ((Object)workshopModUploadPanel == (Object)null)
         {
             return;
         }
         //begin mod
         try
         {
             var instances = pluginInfo.GetInstances <IUserMod>();
             if (instances.Length == 1)
             {
                 WorkshopModUploadPanelDetour.Title       = instances[0].Name;
                 WorkshopModUploadPanelDetour.Description = $"[h1]{instances[0].Description}[/h1]";
             }
             else
             {
                 DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Multiple or no IUserMod implemented for the mod. Only one IUserMod is accepted per mod. " + pluginInfo.ToString());
             }
         }
         catch (UnityException ex)
         {
             Debug.LogException((Exception)ex);
             UIView.ForwardException((Exception) new ModException("A Mod caused an error", (Exception)ex));
         }
         catch (Exception ex)
         {
             Debug.LogException(ex);
             UIView.ForwardException((Exception) new ModException("A Mod caused an error", ex));
         }
         //end mod
         workshopModUploadPanel.SetAsset(this.pluginInfo.modPath, this.publishedFileId);
     }
     else
     {
         if (!(this.asset != (Package.Asset)null) || !(this.asset.type == UserAssetType.MapMetaData) && !(this.asset.type == UserAssetType.ScenarioMetaData) && (!(this.asset.type == UserAssetType.SaveGameMetaData) && !(this.asset.type == UserAssetType.CustomAssetMetaData)) && (!(this.asset.type == UserAssetType.ColorCorrection) && !(this.asset.type == UserAssetType.DistrictStyleMetaData) && (!(this.asset.type == UserAssetType.MapThemeMetaData) && !(this.asset.type == UserAssetType.ScenarioMetaData))))
         {
             return;
         }
         WorkshopAssetUploadPanel assetUploadPanel = UIView.library.ShowModal <WorkshopAssetUploadPanel>("WorkshopAssetUploadPanel");
         if ((Object)assetUploadPanel == (Object)null)
         {
             return;
         }
         assetUploadPanel.SetAsset(this.asset, this.publishedFileId);
     }
 }
        public static void Bootstrap()
        {
            if (thisGameObject == null)
            {
                thisGameObject = new GameObject();
                thisGameObject.name = "ImprovedWorkshopIntegration";
                thisGameObject.AddComponent<ImprovedWorkshopIntegration>();
                thisGameObject.transform.parent = ModTools.Instance.gameObject.transform;
            }

            if (bootstrapped)
            {
                return;
            }

            var go = GameObject.Find("(Library) WorkshopModUploadPanel");
            if (go == null)
            {
                return;
            }

            workshopModUploadPanel = go.GetComponent<WorkshopModUploadPanel>();

            if (workshopModUploadPanel == null)
            {
                return;
            }

            UITabContainer categoryContainer = GameObject.Find("CategoryContainer").GetComponent<UITabContainer>();
            var modsList = categoryContainer.Find("Mods").Find("Content");
            if (modsList == null)
            {
                return;
            }

            m_StagingPath = Util.FindField(workshopModUploadPanel, "m_StagingPath");
            m_PreviewPath = Util.FindField(workshopModUploadPanel, "m_PreviewPath");
            m_ContentPath = Util.FindField(workshopModUploadPanel, "m_ContentPath");
            m_CurrentHandle = Util.FindField(workshopModUploadPanel, "m_CurrentHandle");
            m_ShareButton = Util.FindField(workshopModUploadPanel, "m_ShareButton");
            m_TargetFolder = Util.FindField(workshopModUploadPanel, "m_TargetFolder");
            m_ShareButton = Util.FindField(workshopModUploadPanel, "m_ShareButton");
            m_Title = Util.FindField(workshopModUploadPanel, "m_Title");
            m_Desc = Util.FindField(workshopModUploadPanel, "m_Desc");
            m_ChangeNote = Util.FindField(workshopModUploadPanel, "m_ChangeNote");
            m_DefaultModPreviewTexture = Util.FindField(workshopModUploadPanel, "m_DefaultModPreviewTexture");

            reloadPreviewImage = typeof(WorkshopModUploadPanel).GetMethod("ReloadPreviewImage",
                BindingFlags.Instance | BindingFlags.NonPublic);

            startWatchingPath = typeof(WorkshopModUploadPanel).GetMethod("StartWatchingPath",
                BindingFlags.Instance | BindingFlags.NonPublic);

            revertState = RedirectionHelper.RedirectCalls
            (
                typeof(WorkshopModUploadPanel).GetMethod("SetAssetInternal",
                    BindingFlags.Instance | BindingFlags.NonPublic),
                typeof(ImprovedWorkshopIntegration).GetMethod("SetAssetInternal",
                    BindingFlags.Instance | BindingFlags.NonPublic)
            );

            bootstrapped = true;
        }
        public static void Bootstrap()
        {
            if (thisGameObject == null)
            {
                thisGameObject = new GameObject();
                thisGameObject.name = "ImprovedWorkshopIntegration";
                thisGameObject.AddComponent<ImprovedWorkshopIntegration>();
                thisGameObject.transform.parent = ModTools.Instance.gameObject.transform;
            }

            improvedModsPanelExists = CheckForImprovedModsPanel();

            if (!improvedModsPanelExists)
            {
                InitializeModSortDropDown();
            }

            if (bootstrapped)
            {
                return;
            }

            var go = GameObject.Find("(Library) WorkshopModUploadPanel");
            if (go == null)
            {
                return;
            }

            workshopModUploadPanel = go.GetComponent<WorkshopModUploadPanel>();

            if (workshopModUploadPanel == null)
            {
                return;
            }

            var modsList = GameObject.Find("ModsList");
            if (modsList == null)
            {
                return;
            }

            m_StagingPath = Util.FindField(workshopModUploadPanel, "m_StagingPath");
            m_PreviewPath = Util.FindField(workshopModUploadPanel, "m_PreviewPath");
            m_ContentPath = Util.FindField(workshopModUploadPanel, "m_ContentPath");
            m_CurrentHandle = Util.FindField(workshopModUploadPanel, "m_CurrentHandle");
            m_ShareButton = Util.FindField(workshopModUploadPanel, "m_ShareButton");
            m_TargetFolder = Util.FindField(workshopModUploadPanel, "m_TargetFolder");
            m_ShareButton = Util.FindField(workshopModUploadPanel, "m_ShareButton");
            m_Title = Util.FindField(workshopModUploadPanel, "m_Title");
            m_Desc = Util.FindField(workshopModUploadPanel, "m_Desc");
            m_ChangeNote = Util.FindField(workshopModUploadPanel, "m_ChangeNote");
            m_DefaultModPreviewTexture = Util.FindField(workshopModUploadPanel, "m_DefaultModPreviewTexture");

            reloadPreviewImage = typeof(WorkshopModUploadPanel).GetMethod("ReloadPreviewImage",
                BindingFlags.Instance | BindingFlags.NonPublic);

            startWatchingPath = typeof(WorkshopModUploadPanel).GetMethod("StartWatchingPath",
                BindingFlags.Instance | BindingFlags.NonPublic);

            revertState = RedirectionHelper.RedirectCalls
            (
                typeof(WorkshopModUploadPanel).GetMethod("SetAssetInternal",
                    BindingFlags.Instance | BindingFlags.NonPublic),
                typeof(ImprovedWorkshopIntegration).GetMethod("SetAssetInternal",
                    BindingFlags.Instance | BindingFlags.NonPublic)
            );

            if (!improvedModsPanelExists)
            {
                modsPanelBootstrapped = true;
                revertState2 = RedirectionHelper.RedirectCalls
                (
                    typeof(PackageEntry).GetMethod("FormatPackageName",
                        BindingFlags.Static | BindingFlags.NonPublic),
                    typeof(ImprovedWorkshopIntegration).GetMethod("FormatPackageName",
                        BindingFlags.Static | BindingFlags.NonPublic)
                );

                revertState3 = RedirectionHelper.RedirectCalls
                (
                    typeof(CustomContentPanel).GetMethod("RefreshPlugins",
                        BindingFlags.Instance | BindingFlags.NonPublic),
                    typeof(ImprovedWorkshopIntegration).GetMethod("RefreshPlugins",
                        BindingFlags.Static | BindingFlags.Public)
                );
            }
            else
            {
                modsPanelBootstrapped = false;
            }

            bootstrapped = true;
        }
예제 #4
0
        public static void Bootstrap()
        {
            if (thisGameObject == null)
            {
                thisGameObject      = new GameObject();
                thisGameObject.name = "ImprovedWorkshopIntegration";
                thisGameObject.AddComponent <ImprovedWorkshopIntegration>();
                thisGameObject.transform.parent = ModTools.Instance.gameObject.transform;
            }

            improvedModsPanelExists = CheckForImprovedModsPanel();

            if (!improvedModsPanelExists)
            {
                InitializeModSortDropDown();
            }

            if (bootstrapped)
            {
                return;
            }

            var go = GameObject.Find("(Library) WorkshopModUploadPanel");

            if (go == null)
            {
                return;
            }

            workshopModUploadPanel = go.GetComponent <WorkshopModUploadPanel>();

            if (workshopModUploadPanel == null)
            {
                return;
            }

            var modsList = GameObject.Find("ModsList");

            if (modsList == null)
            {
                return;
            }

            m_StagingPath              = Util.FindField(workshopModUploadPanel, "m_StagingPath");
            m_PreviewPath              = Util.FindField(workshopModUploadPanel, "m_PreviewPath");
            m_ContentPath              = Util.FindField(workshopModUploadPanel, "m_ContentPath");
            m_CurrentHandle            = Util.FindField(workshopModUploadPanel, "m_CurrentHandle");
            m_ShareButton              = Util.FindField(workshopModUploadPanel, "m_ShareButton");
            m_TargetFolder             = Util.FindField(workshopModUploadPanel, "m_TargetFolder");
            m_ShareButton              = Util.FindField(workshopModUploadPanel, "m_ShareButton");
            m_Title                    = Util.FindField(workshopModUploadPanel, "m_Title");
            m_Desc                     = Util.FindField(workshopModUploadPanel, "m_Desc");
            m_ChangeNote               = Util.FindField(workshopModUploadPanel, "m_ChangeNote");
            m_DefaultModPreviewTexture = Util.FindField(workshopModUploadPanel, "m_DefaultModPreviewTexture");

            reloadPreviewImage = typeof(WorkshopModUploadPanel).GetMethod("ReloadPreviewImage",
                                                                          BindingFlags.Instance | BindingFlags.NonPublic);

            startWatchingPath = typeof(WorkshopModUploadPanel).GetMethod("StartWatchingPath",
                                                                         BindingFlags.Instance | BindingFlags.NonPublic);

            revertState = RedirectionHelper.RedirectCalls
                          (
                typeof(WorkshopModUploadPanel).GetMethod("SetAssetInternal",
                                                         BindingFlags.Instance | BindingFlags.NonPublic),
                typeof(ImprovedWorkshopIntegration).GetMethod("SetAssetInternal",
                                                              BindingFlags.Instance | BindingFlags.NonPublic)
                          );

            if (!improvedModsPanelExists)
            {
                modsPanelBootstrapped = true;
                revertState2          = RedirectionHelper.RedirectCalls
                                        (
                    typeof(PackageEntry).GetMethod("FormatPackageName",
                                                   BindingFlags.Static | BindingFlags.NonPublic),
                    typeof(ImprovedWorkshopIntegration).GetMethod("FormatPackageName",
                                                                  BindingFlags.Static | BindingFlags.NonPublic)
                                        );

                revertState3 = RedirectionHelper.RedirectCalls
                               (
                    typeof(CustomContentPanel).GetMethod("RefreshPlugins",
                                                         BindingFlags.Instance | BindingFlags.NonPublic),
                    typeof(ImprovedWorkshopIntegration).GetMethod("RefreshPlugins",
                                                                  BindingFlags.Static | BindingFlags.Public)
                               );
            }
            else
            {
                modsPanelBootstrapped = false;
            }

            bootstrapped = true;
        }