Example #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);
     }
 }
Example #2
0
        public static void AfterPrepareStagingArea(WorkshopAssetUploadPanel __instance)
        {
            var m_ContentPath   = __instance.GetType().GetField("m_ContentPath", RedirectorUtils.allFlags).GetValue(__instance) as string;
            var m_TargetAsset   = __instance.GetType().GetField("m_TargetAsset", RedirectorUtils.allFlags).GetValue(__instance) as Package.Asset;
            var rootAssetFolder = Path.GetDirectoryName(m_TargetAsset.package.packagePath);

            LogUtils.DoErrorLog($"rootAssetFolder2: {rootAssetFolder}; ");
            bool bundledAnyFile = false;

            if (!(CommonProperties.AssetExtraFileNames is null))
            {
                foreach (string filename in CommonProperties.AssetExtraFileNames)
                {
                    var targetFilename = Path.Combine(rootAssetFolder, filename);
                    if (File.Exists(targetFilename))
                    {
                        File.Copy(targetFilename, Path.Combine(m_ContentPath, filename));
                        bundledAnyFile = true;
                    }
                }
            }
            if (!(CommonProperties.AssetExtraDirectoryNames is null))
            {
                foreach (string directory in CommonProperties.AssetExtraDirectoryNames)
                {
                    var targetFolder = Path.Combine(rootAssetFolder, directory);
                    if (Directory.Exists(targetFolder))
                    {
                        WorkshopHelper.DirectoryCopy(targetFolder, Path.Combine(m_ContentPath, directory), true);
                        bundledAnyFile = true;
                    }
                }
            }

            if (bundledAnyFile)
            {
                var tagsField = (__instance.GetType().GetField("m_Tags", RedirectorUtils.allFlags));
                tagsField.SetValue(__instance, (tagsField.GetValue(__instance) as string[]).Union(new string[] { CommonProperties.ModName, $"K45 {CommonProperties.Acronym}" }).Distinct().ToArray());
            }
        }