예제 #1
0
 /// <summary>
 /// Handles actually adding the image replacement
 /// If the image doesn't exist, sleep for 0.1 second increments until it does
 /// </summary>
 /// <param name="imageBuilder">The image builder</param>
 /// <param name="xnbPath">The path to the xnb image to replace</param>
 private void HandleImageReplacement(ImageBuilder imageBuilder, string xnbPath)
 {
     if (imageBuilder.ShouldSaveImage())
     {
         while (!File.Exists(imageBuilder.OutputFileFullPath))
         {
             Thread.Sleep(100);
         }
         AddReplacement(xnbPath, imageBuilder.SMAPIOutputFilePath);
     }
 }
예제 #2
0
        /// <summary>The mod entry point, called after the mod is first loaded</summary>
        /// <param name="helper">Provides simplified APIs for writing mods</param>
        public override void Entry(IModHelper helper)
        {
            ImageBuilder.CleanUpReplacementFiles();

            _helper        = helper;
            Globals.ModRef = this;
            Globals.Config = Helper.ReadConfig <ModConfig>();

            this._modAssetLoader = new AssetLoader(this);
            this._modAssetEditor = new AssetEditor(this);
            helper.Content.AssetLoaders.Add(this._modAssetLoader);
            helper.Content.AssetEditors.Add(this._modAssetEditor);

            this.PreLoadReplacments();
            helper.Events.GameLoop.SaveLoaded             += (sender, args) => this.CalculateAllReplacements();
            helper.Events.Multiplayer.PeerContextReceived += (sender, args) => FixParsnipSeedBox();

            helper.Events.Display.RenderingActiveMenu += (sender, args) => _modAssetLoader.TryReplaceTitleScreen();
            helper.Events.Display.MenuChanged         += BundleMenuAdjustments.FixRingSelection;
            helper.Events.Display.RenderingActiveMenu += (sender, args) => BundleMenuAdjustments.FixRingDeposits();
            helper.Events.GameLoop.ReturnedToTitle    += (sender, args) => _modAssetLoader.ReplaceTitleScreenAfterReturning();
            helper.Events.GameLoop.ReturnedToTitle    += (sender, args) => ImageBuilder.CleanUpReplacementFiles();

            if (Globals.Config.RandomizeMusic)
            {
                helper.Events.GameLoop.UpdateTicked += (sender, args) => this.TryReplaceSong();
            }
            if (Globals.Config.RandomizeRain)
            {
                helper.Events.GameLoop.DayEnding += _modAssetLoader.ReplaceRain;
            }
            if (Globals.Config.RandomizeCrops || Globals.Config.RandomizeFish)
            {
                helper.Events.Display.RenderingActiveMenu += (sender, args) => CraftingRecipeAdjustments.HandleCraftingMenus();
            }

            helper.Events.GameLoop.DayStarted += (sender, args) => UseOverriddenSubmarine();
            helper.Events.GameLoop.DayEnding  += (sender, args) => RestoreSubmarineLocation();
        }
예제 #3
0
        /// <summary>The mod entry point, called after the mod is first loaded</summary>
        /// <param name="helper">Provides simplified APIs for writing mods</param>
        public override void Entry(IModHelper helper)
        {
            ImageBuilder.CleanUpReplacementFiles();

            _helper        = helper;
            Globals.ModRef = this;
            Globals.Config = Helper.ReadConfig <ModConfig>();

            this._modAssetLoader = new AssetLoader(this);
            this._modAssetEditor = new AssetEditor(this);
            helper.Content.AssetLoaders.Add(this._modAssetLoader);
            helper.Content.AssetEditors.Add(this._modAssetEditor);

            this.PreLoadReplacments();
            helper.Events.GameLoop.SaveLoaded         += (sender, args) => this.CalculateAllReplacements();
            helper.Events.Display.RenderingActiveMenu += (sender, args) => _modAssetLoader.TryReplaceTitleScreen();
            helper.Events.GameLoop.ReturnedToTitle    += (sender, args) => _modAssetLoader.ReplaceTitleScreenAfterReturning();

            if (Globals.Config.RandomizeMusic)
            {
                helper.Events.GameLoop.UpdateTicked += (sender, args) => this.TryReplaceSong();
            }
            if (Globals.Config.RandomizeRain)
            {
                helper.Events.GameLoop.DayEnding += _modAssetLoader.ReplaceRain;
            }

            if (Globals.Config.Crops.Randomize)
            {
                helper.Events.Multiplayer.PeerContextReceived += (sender, args) => FixParsnipSeedBox();
            }

            if (Globals.Config.Crops.Randomize || Globals.Config.Fish.Randomize)
            {
                helper.Events.Display.RenderingActiveMenu += (sender, args) => CraftingRecipeAdjustments.HandleCraftingMenus();

                // Fix for the Special Orders causing crashes
                // Re-instate the object info when the save is first loaded for the session, and when saving so that the
                // items have the correct names on the items sold summary screen
                helper.Events.GameLoop.DayEnding  += (sender, args) => _modAssetEditor.UndoObjectInformationReplacements();
                helper.Events.GameLoop.SaveLoaded += (sender, args) => _modAssetEditor.RedoObjectInformationReplacements();
                helper.Events.GameLoop.Saving     += (sender, args) => _modAssetEditor.RedoObjectInformationReplacements();
            }

            if (Globals.Config.RandomizeForagables)
            {
                helper.Events.GameLoop.GameLaunched += (sender, args) => WildSeedAdjustments.ReplaceGetRandomWildCropForSeason();
            }

            if (Globals.Config.Fish.Randomize)
            {
                helper.Events.GameLoop.DayStarted += (sender, args) => OverriddenSubmarine.UseOverriddenSubmarine();
                helper.Events.GameLoop.DayEnding  += (sender, args) => OverriddenSubmarine.RestoreSubmarineLocation();
            }

            if (Globals.Config.Bundles.Randomize)
            {
                helper.Events.Display.MenuChanged         += BundleMenuAdjustments.FixRingSelection;
                helper.Events.Display.RenderingActiveMenu += (sender, args) => BundleMenuAdjustments.FixRingDeposits();

                if (Globals.Config.Bundles.ShowDescriptionsInBundleTooltips)
                {
                    helper.Events.Display.RenderedActiveMenu += (sender, args) => BundleMenuAdjustments.AddDescriptionsToBundleTooltips();
                }
            }
        }