Example #1
0
 public AuthenticateController(
     IOptions <OpenIDHostOptions> options,
     IDataProtectionProvider dataProtectionProvider,
     ITranslationHelper translateHelper,
     IOAuthClientRepository oauthClientRepository,
     IAmrHelper amrHelper,
     ISmsAuthService smsAuthService,
     IOAuthUserRepository oauthUserCommandRepository) : base(options, dataProtectionProvider, oauthClientRepository, amrHelper, oauthUserCommandRepository)
 {
     _smsAuthService    = smsAuthService;
     _translationHelper = translateHelper;
 }
        /// <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)
        {
            //ModEntry is called once before SDV loads.In 3.0 its called even earlier than 2.x - things like Game1.objectInformation
            //aren't ready yet. If you need to run stuff when a save is ready use the save loaded event
            Translator = helper.Translation;
            helper.Events.Input.ButtonPressed += OnButtonPressed;

            modConfig = Helper.ReadConfig <ModConfig>();
            buttonToBringUpInterface = modConfig.button;
            Config = new ConfigOptions(modConfig.button, modConfig.ShowItemsFromLockedPlaces, modConfig.ShowAllFishFromCurrentSeason,
                                       modConfig.ShowAllRecipes, modConfig.AlwaysShowAllRecipes, modConfig.CommonAmount, modConfig.HighestQualityAmount);
        }
Example #3
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
        /// <param name="config">The data layer settings.</param>
        public BeeHouseLayer(ITranslationHelper translations, LayerConfig config)
            : base(translations.Get("bee-houses.name"), config)
        {
            this.Legend = new[]
            {
                this.Covered = new LegendEntry(translations, "bee-houses.range", Color.Green)
            };

            this.RelativeRange = BeeHouseLayer
                                 .GetRelativeCoverage()
                                 .ToArray();
        }
Example #4
0
        public static string GetTraitName(CropTrait trait)
        {
            ITranslationHelper trans = ModEntry.GetHelper().Translation;

            switch (trait)
            {
            case CropTrait.PestResistanceNo:
                return(trans.Get("cult.msg_trait_pestresno"));

            case CropTrait.PestResistanceI:
                return(trans.Get("cult.msg_trait_pestresI"));

            case CropTrait.PestResistanceII:
                return(trans.Get("cult.msg_trait_pestresII"));

            case CropTrait.QualityNo:
                return(trans.Get("cult.msg_trait_qualityno"));

            case CropTrait.QualityI:
                return(trans.Get("cult.msg_trait_qualityI"));

            case CropTrait.QualityII:
                return(trans.Get("cult.msg_trait_qualityII"));

            case CropTrait.WaterNo:
                return(trans.Get("cult.msg_trait_waterno"));

            case CropTrait.WaterI:
                return(trans.Get("cult.msg_trait_waterI"));

            case CropTrait.WaterII:
                return(trans.Get("cult.msg_trait_waterII"));

            case CropTrait.WaterIII:
                return(trans.Get("cult.msg_trait_waterIII"));

            case CropTrait.SpeedNo:
                return(trans.Get("cult.msg_trait_speedno"));

            case CropTrait.SpeedI:
                return(trans.Get("cult.msg_trait_speedI"));

            case CropTrait.SpeedII:
                return(trans.Get("cult.msg_trait_speedII"));

            case CropTrait.SpeedIII:
                return(trans.Get("cult.msg_trait_speedIII"));

            default:
                return("ERROR gettraitname");
            }
        }
Example #5
0
        public void OnDrawTick(ITranslationHelper i18n)
        {
            GameLocation location = Game1.currentLocation;

            bool inCave = location is MineShaft || location is FarmCave;
            bool frozen = (this.Config.FreezeTimeInside && !location.IsOutdoors && !inCave) || (this.Config.FreezeTimeCaves && inCave);

            frozen = frozen || this.Config.FreezeTime;
            if (frozen)
            {
                CJB.DrawTextBox(5, inCave ? 100 : 5, Game1.smallFont, i18n.Get("messages.time-frozen"));
            }
        }
Example #6
0
        internal JournalButton(PageManager pageManager, ITranslationHelper translation) :
            base(Game1.uiViewport.Width - 88, 248, 44, 46)
        {
            _translation = translation;
            _pageManager = pageManager;
            _hoverText   = "";

            taskButton = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen, yPositionOnScreen, width, height),
                DeluxeJournalMod.UiTexture,
                new Rectangle(0, 16, 11, 14),
                4f);
        }
 public SearchNotificationsDetailsQueryHandler(
     ILogger <SearchNotificationsDetailsQueryHandler> logger,
     IAuthorizationHelper authorizationHelper,
     ILogicalPeopleGroupStore logicalPeopleGroupStore,
     ITranslationHelper translationHelper,
     INotificationInstanceQueryRepository notificationInstanceQueryRepository)
 {
     _logger = logger;
     _authorizationHelper                 = authorizationHelper;
     _logicalPeopleGroupStore             = logicalPeopleGroupStore;
     _translationHelper                   = translationHelper;
     _notificationInstanceQueryRepository = notificationInstanceQueryRepository;
 }
Example #8
0
        private static JToken TranslateToken(ITranslationHelper translation, JToken token)
        {
            if (token.Type == JTokenType.String)
            {
                return(Translate(token.Value <string>(), translation));
            }
            if (token.Type == JTokenType.Object)
            {
                return(Translate(translation, token.Value <JObject>()));
            }

            return(token);
        }
Example #9
0
 public static ITradicIterator GetInstance()
 {
     if (CurrentInstance == null)
     {
         CurrentInstance = new TradicIterator();
         TradicDataAccess access = TradicDataAccess.GetInstance();
         transHelper       = new TranslationHelper(access);
         wordHelper        = new WordHelper(access);
         languageHelper    = new LanguageHelper(access);
         descriptionHelper = new DescriptionHelper(access);
     }
     return(CurrentInstance);
 }
Example #10
0
        public override void Entry(IModHelper helper)
        {
            //Initialize the config
            _config = helper.ReadConfig <ModConfig>();

            //Initialize the translations
            _i18n = helper.Translation;


            //Events
            helper.Events.GameLoop.DayStarted += this.DayStarted;
            //helper.Events.Display.MenuChanged += this.MenuChanged;
        }
Example #11
0
        public override void Entry(IModHelper helper)
        {
            config    = helper.ReadConfig <ModConfig>();
            translate = helper.Translation;

            helper.Events.Input.ButtonPressed            += this.OnButtonPressed;
            helper.Events.GameLoop.DayStarted            += this.OnDayStarted;
            helper.Events.Display.Rendered               += this.Rendered;
            helper.Events.Display.MenuChanged            += this.OnMenuChanged;
            helper.Events.Display.RenderedActiveMenu     += this.OnRenderMenu;
            helper.Events.Display.RenderedActiveMenu     += GenericModConfigMenuIntegration;
            helper.Events.Multiplayer.ModMessageReceived += this.OnModMessageReceived;
        }
Example #12
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="bush">The lookup target.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public BushSubject(GameHelper gameHelper, Bush bush, ITranslationHelper translations)
     : base(gameHelper, translations)
 {
     this.Target = bush;
     if (this.IsBerryBush(bush))
     {
         this.Initialise(L10n.Bush.BerryName(), L10n.Bush.BerryDescription(), L10n.Types.Bush());
     }
     else
     {
         this.Initialise(L10n.Bush.PlainName(), L10n.Bush.PlainDescription(), L10n.Types.Bush());
     }
 }
Example #13
0
        public IEnumerable <string> GetTvText(ITranslationHelper t)
        {
            yield return($"{Name}{(NeedForCC?"=":"")}{(NeedForCollection ? "$" : "")}! {Description}");

            var or   = t.Get("fish_or");
            var locs = string.Join(or, Locations.Select(x =>
            {
                var trans = t.Get($"loc_{x}");
                return(trans.HasValue() ? trans.ToString() : t.Get("fish_default_preposition").ToString() + x);
            }));

            yield return($"{Name} {t.Get("fish_catch")} {locs} {t.Get("fish_from")} {string.Join(or, Times)}.");
        }
Example #14
0
        /// <summary>Convert the blueprint data to a string stardew valley understands, and replace the name and description with the current language variants, if present.</summary>
        /// <param name="i18n"></param>
        /// <returns>The blueprint in the format Stardew Valley understands</returns>
        public string ToBlueprintString(ITranslationHelper i18n)
        {
            string s;

            string items = string.Join(" ", ItemsRequired);

#pragma warning disable CS8601 // Possible null reference assignment.
            s = string.Join("/", new string[] { items, Width, Height, HumanDoorX, HumanDoorY, AnimalDoorX, AnimalDoorY, MapToWarpTo, i18n.Get("industrial-furnace.name"), i18n.Get("industrial-furnace.description"),
                                                BlueprintType, NameOfBuildingToUpgrade, SourceRectForMenuViewX, SourceRectForMenuViewY, MaxOccupants, ActionBehaviour, NamesOfBuildingLocations, MoneyRequired, Magical, DaysToBuild });
#pragma warning restore CS8601 // Possible null reference assignment.

            return(s);
        }
Example #15
0
        public AssetEditor(IModHelper helper, IMonitor monitor, ITranslationHelper translate, Config config)
        {
            _helper    = helper;
            _monitor   = monitor;
            _translate = translate;
            _config    = config;

            /*
             * haxorSprinklerName = translate.Get("haxorsprinkler.name");
             * haxorSprinklerDescription = _translate.Get("haxorsprinkler.description");
             * haxorScarecrowName = translate.Get("haxorscarecrow.name");
             * haxorScarecrowDescription = translate.Get("haxorscarecrow.description");*/
        }
Example #16
0
        /*********
        ** Entry
        *********/
        public override void Entry(IModHelper helper)
        {
            this.i18n = helper.Translation;

            /* other methods */
            ContentPackData();

            /* Helper Events */
            helper.Events.GameLoop.SaveLoaded            += this.SaveLoaded;
            helper.Events.GameLoop.UpdateTicked          += this.UpdateTicked;
            helper.Events.Multiplayer.ModMessageReceived += this.ModMessageReceived;
            helper.Events.Input.ButtonPressed            += this.ButtonPressed;
        }
Example #17
0
 public SettingsLoaderBusiness(
     ITranslationHelper translationHelper,
     ISettingsMover settingsMover,
     IInstallationPathProvider installationPathProvider,
     IPrinterHelper printerHelper,
     EditionHelper editionHelper,
     IDefaultSettingsBuilder defaultSettingsBuilder,
     IMigrationStorageFactory migrationStorageFactory,
     ISharedSettingsLoader sharedSettingsLoader
     ) :
     base(translationHelper, settingsMover, installationPathProvider, printerHelper, editionHelper, defaultSettingsBuilder, migrationStorageFactory)
 {
     _sharedSettingsLoader = sharedSettingsLoader;
 }
Example #18
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="directoryPath">The full path to the content pack's folder.</param>
        /// <param name="manifest">The content pack's manifest.</param>
        /// <param name="content">Provides an API for loading content assets.</param>
        /// <param name="translation">Provides translations stored in the content pack's <c>i18n</c> folder.</param>
        /// <param name="jsonHelper">Encapsulates SMAPI's JSON file parsing.</param>
        public ContentPack(string directoryPath, IManifest manifest, IContentHelper content, ITranslationHelper translation, JsonHelper jsonHelper)
        {
            this.DirectoryPath = directoryPath;
            this.Manifest      = manifest;
            this.Content       = content;
            this.Translation   = translation;
            this.JsonHelper    = jsonHelper;

            foreach (string path in Directory.EnumerateFiles(this.DirectoryPath, "*", SearchOption.AllDirectories))
            {
                string relativePath = path.Substring(this.DirectoryPath.Length + 1);
                this.RelativePaths[relativePath] = relativePath;
            }
        }
Example #19
0
        public MuseumInteractionDialogService()
        {
            gunther = Game1.getCharacterFromName(StardewMods.Common.StardewValley.Constants.NPC_GUNTHER_NAME);
            if (gunther == null)
            {
                ModEntry.CommonServices.Monitor.Log("Error: NPC [Gunther] not found!", LogLevel.Error);
                throw new Exception("Error: NPC [Gunther] not found!");
            }

            translationHelper = ModEntry.CommonServices.TranslationHelper;
            monitor           = ModEntry.CommonServices.Monitor;

            running = false;
        }
Example #20
0
        private void GenericModConfigMenuIntegration(object sender, RenderedActiveMenuEventArgs e)     //Generic Mod Config Menu API
        {
            Helper.Events.Display.RenderedActiveMenu -= GenericModConfigMenuIntegration;
            if (Context.IsSplitScreen)
            {
                return;
            }
            translate = Helper.Translation;
            var GenericMC = Helper.ModRegistry.GetApi <IGenericModConfigMenuApi>("spacechase0.GenericModConfigMenu");

            if (GenericMC != null)
            {
                GenericMC.Register(ModManifest, () => config = new ModConfig(), () => Helper.WriteConfig(config));
                GenericMC.AddSectionTitle(ModManifest, () => translate.Get("GenericMC.barLabel")); //All of these strings are stored in the traslation files.
                GenericMC.AddParagraph(ModManifest, () => translate.Get("GenericMC.barDescription"));
                GenericMC.AddParagraph(ModManifest, () => translate.Get("GenericMC.barDescription2"));

                try
                {
                    GenericMCPerScreen(GenericMC, 0);
                    GenericMC.AddPageLink(ModManifest, "colors", () => translate.Get("GenericMC.barColors"), () => translate.Get("GenericMC.barColors"));

                    GenericMC.AddPageLink(ModManifest, "s2", () => translate.Get("GenericMC.SplitScreen2"), () => translate.Get("GenericMC.SplitScreenDesc"));
                    GenericMC.AddPageLink(ModManifest, "s3", () => translate.Get("GenericMC.SplitScreen3"), () => translate.Get("GenericMC.SplitScreenDesc"));
                    GenericMC.AddPageLink(ModManifest, "s4", () => translate.Get("GenericMC.SplitScreen4"), () => translate.Get("GenericMC.SplitScreenDesc"));
                    GenericMCPerScreen(GenericMC, 1);
                    GenericMCPerScreen(GenericMC, 2);
                    GenericMCPerScreen(GenericMC, 3);

                    GenericMC.AddPage(ModManifest, "colors", () => translate.Get("GenericMC.barColors"));
                    GenericMC.AddSectionTitle(ModManifest, () => translate.Get("GenericMC.barBackgroundColor"));
                    GenericMC.AddNumberOption(ModManifest, () => config.BarBackgroundColorRGBA[0], (int val) => config.BarBackgroundColorRGBA[0] = val, () => "R", null, 0, 255);
                    GenericMC.AddNumberOption(ModManifest, () => config.BarBackgroundColorRGBA[1], (int val) => config.BarBackgroundColorRGBA[1] = val, () => "G", null, 0, 255);
                    GenericMC.AddNumberOption(ModManifest, () => config.BarBackgroundColorRGBA[2], (int val) => config.BarBackgroundColorRGBA[2] = val, () => "B", null, 0, 255);
                    GenericMC.AddNumberOption(ModManifest, () => config.BarBackgroundColorRGBA[3], (int val) => config.BarBackgroundColorRGBA[3] = val, () => "A", null, 0, 255);
                    GenericMC.AddSectionTitle(ModManifest, () => translate.Get("GenericMC.barTextColor"));
                    GenericMC.AddNumberOption(ModManifest, () => config.BarTextColorRGBA[0], (int val) => config.BarTextColorRGBA[0] = val, () => "R", null, 0, 255);
                    GenericMC.AddNumberOption(ModManifest, () => config.BarTextColorRGBA[1], (int val) => config.BarTextColorRGBA[1] = val, () => "G", null, 0, 255);
                    GenericMC.AddNumberOption(ModManifest, () => config.BarTextColorRGBA[2], (int val) => config.BarTextColorRGBA[2] = val, () => "B", null, 0, 255);
                    GenericMC.AddNumberOption(ModManifest, () => config.BarTextColorRGBA[3], (int val) => config.BarTextColorRGBA[3] = val, () => "A", null, 0, 255);

                    //dummy value validation trigger - must be the last thing, so all values are saved before validation
                    GenericMC.AddComplexOption(ModManifest, () => "", () => "", (SpriteBatch b, Vector2 pos) => { }, () => UpdateConfig(true));
                }
                catch (Exception)
                {
                    this.Monitor.Log("Error parsing config data. Please either fix your config.json, or delete it to generate a new one.", LogLevel.Error);
                }
            }
        }
Example #21
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <param name="item">The underlying target.</param>
 /// <param name="context">The context of the object being looked up.</param>
 /// <param name="knownQuality">Whether the item quality is known. This is <c>true</c> for an inventory item, <c>false</c> for a map object.</param>
 /// <param name="fromCrop">The crop associated with the item (if applicable).</param>
 public ItemSubject(ITranslationHelper translations, Item item, ObjectContext context, bool knownQuality, Crop fromCrop = null)
     : base(translations)
 {
     this.Target      = item;
     this.DisplayItem = this.GetMenuItem(item);
     this.FromCrop    = fromCrop;
     if ((item as SObject)?.Type == "Seeds")
     {
         this.SeedForCrop = new Crop(item.ParentSheetIndex, 0, 0);
     }
     this.Context      = context;
     this.KnownQuality = knownQuality;
     this.Initialise(this.DisplayItem.DisplayName, this.GetDescription(this.DisplayItem), this.GetTypeValue(this.DisplayItem));
 }
        private void CheckForQueenOfSauce(ITranslationHelper Trans)
        {
            if (!StardewNotification.Config.NotifyQueenOfSauce)
            {
                return;
            }
            var dayName = Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);

            if (!dayName.Equals("Sun"))
            {
                return;
            }
            Util.ShowMessage(Trans.Get("queenSauce"));
        }
Example #23
0
        public SDVMoon(MoonConfig config, MersenneTwister rng, ITranslationHelper Trans)
        {
            Dice         = rng;
            ModConfig    = config;
            IsBloodMoon  = false;
            Translations = Trans;

            //set chances.
            CropGrowthChance   = .09;
            CropNoGrowthChance = .09;
            BeachRemovalChance = .09;
            BeachSpawnChance   = .35;
            GhostChance        = .02;
        }
Example #24
0
 public AuthenticateController(
     IOptions <OpenIDHostOptions> options,
     IPasswordAuthService passwordAuthService,
     ITranslationHelper translationHelper,
     IAuthenticationSchemeProvider authenticationSchemeProvider,
     IDataProtectionProvider dataProtectionProvider,
     IAmrHelper amrHelper,
     IOAuthClientRepository oauthClientRepository,
     IOAuthUserRepository oauthUserCommandRepository) : base(options, dataProtectionProvider, oauthClientRepository, amrHelper, oauthUserCommandRepository)
 {
     _passwordAuthService          = passwordAuthService;
     _translationHelper            = translationHelper;
     _authenticationSchemeProvider = authenticationSchemeProvider;
 }
Example #25
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="tractorID">The tractor's unique horse ID.</param>
 /// <param name="tileX">The initial tile X position.</param>
 /// <param name="tileY">The initial tile Y position.</param>
 /// <param name="config">The mod settings.</param>
 /// <param name="attachments">The tractor attachments to apply.</param>
 /// <param name="textureName">The texture asset name to load.</param>
 /// <param name="translation">Provides translations from the mod's i18n folder.</param>
 /// <param name="reflection">Simplifies access to private game code.</param>
 public Tractor(Guid tractorID, int tileX, int tileY, ModConfig config, IEnumerable <IAttachment> attachments, string textureName, ITranslationHelper translation, IReflectionHelper reflection)
     : base(tractorID, tileX, tileY)
 {
     this.Name   = typeof(Tractor).Name;
     this.Sprite = new AnimatedSprite(textureName, 0, 32, 32)
     {
         textureUsesFlippedRightForLeft = true,
         loop = true
     };
     this.Config      = config;
     this.Attachments = attachments.ToArray();
     this.Translation = translation;
     this.Reflection  = reflection;
 }
Example #26
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)
        {
            INSTANCE  = this;
            modhelper = helper;
            i18n      = helper.Translation;

            Monitor.Log("Mod Entry", LogLevel.Trace);

            modhelper.Events.GameLoop.GameLaunched += OnGameLaunched;
            //modhelper.Events.Input.ButtonPressed += OnButtonPressed;
            modhelper.Events.Player.Warped += OnPlayerWarped;

            modhelper.Events.Display.Rendered += OnRendered;
        }
Example #27
0
        /// <summary>Get the enabled data layers.</summary>
        /// <param name="config">The mod configuration.</param>
        /// <param name="translation">Provides translations for the mod.</param>
        /// <param name="mods">Handles access to the supported mod integrations.</param>
        private IEnumerable <ILayer> GetLayers(ModConfig config, ITranslationHelper translation, ModIntegrations mods)
        {
            ModConfig.LayerConfigs layers = config.Layers;

            if (layers.Accessible.IsEnabled())
            {
                yield return(new AccessibleLayer(translation, layers.Accessible));
            }
            if (layers.Buildable.IsEnabled())
            {
                yield return(new BuildableLayer(translation, layers.Buildable));
            }
            if (layers.CoverageForBeeHouses.IsEnabled())
            {
                yield return(new BeeHouseLayer(translation, layers.CoverageForBeeHouses, hasBeeHouseFlowerRangeFix: mods.HasMod("kirbylink.beehousefix")));
            }
            if (layers.CoverageForScarecrows.IsEnabled())
            {
                yield return(new ScarecrowLayer(translation, layers.CoverageForScarecrows, mods));
            }
            if (layers.CoverageForSprinklers.IsEnabled())
            {
                yield return(new SprinklerLayer(translation, layers.CoverageForSprinklers, mods));
            }
            if (layers.CoverageForJunimoHuts.IsEnabled())
            {
                yield return(new JunimoHutLayer(translation, layers.CoverageForJunimoHuts, mods));
            }
            if (layers.CropWater.IsEnabled())
            {
                yield return(new CropWaterLayer(translation, layers.CropWater));
            }
            if (layers.CropFertilizer.IsEnabled())
            {
                yield return(new CropFertilizerLayer(translation, layers.CropFertilizer));
            }
            if (layers.CropHarvest.IsEnabled())
            {
                yield return(new CropHarvestLayer(translation, layers.CropHarvest));
            }
            if (layers.Machines.IsEnabled() && mods.Automate.IsLoaded)
            {
                yield return(new MachineLayer(translation, layers.Machines, mods));
            }
            if (layers.Tillable.IsEnabled())
            {
                yield return(new TillableLayer(translation, layers.Tillable));
            }
        }
Example #28
0
 /***************************
  ** Mod Injection Methods **
  ***************************/
 
 /// <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)
 {
     try
     {
         myMonitor = this.Monitor;
         myInput = this.Helper.Input;
         str = this.Helper.Translation;
         Config = this.Helper.ReadConfig<ModConfig>();
         
         helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
         helper.Events.Input.ButtonPressed += this.OnButtonPressed;
         helper.Events.Input.CursorMoved += this.OnCursorMoved;
         
         Harmony harmonyInstance = new Harmony(this.ModManifest.UniqueID);
         
         patchPrefix(harmonyInstance, typeof(Farmer), nameof(Farmer.useTool),
                     typeof(ModEntry), nameof(ModEntry.Prefix_useTool));
         
         patchPrefix(harmonyInstance, typeof(Utility), nameof(Utility.isWithinTileWithLeeway),
                     typeof(ModEntry), nameof(ModEntry.Prefix_isWithinTileWithLeeway));
         
         patchPrefix(harmonyInstance, typeof(Game1), nameof(Game1.pressUseToolButton),
                     typeof(ModEntry), nameof(ModEntry.Prefix_pressUseToolButton));
         
         patchPrefix(harmonyInstance, typeof(Farmer), nameof(Farmer.draw),
                     typeof(ModEntry), nameof(ModEntry.Prefix_draw),
                     new Type[] { typeof(SpriteBatch) });
         
         patchPostfix(harmonyInstance, typeof(Farmer), nameof(Farmer.draw),
                      typeof(ModEntry), nameof(ModEntry.Postfix_draw),
                      new Type[] { typeof(SpriteBatch) });
         
         if (helper.ModRegistry.IsLoaded("furyx639.ExpandedStorage")) // Additional methods to fix Expanded Storage conflict
         {
             patchPrefix(harmonyInstance, typeof(Utility), nameof(Utility.playerCanPlaceItemHere),
                         typeof(ModEntry), nameof(ModEntry.Prefix_playerCanPlaceItemHere));
             
             patchPostfix(harmonyInstance, typeof(Utility), nameof(Utility.playerCanPlaceItemHere),
                          typeof(ModEntry), nameof(ModEntry.Postfix_playerCanPlaceItemHere));
             
             patchPrefix(harmonyInstance, typeof(Utility), nameof(Utility.withinRadiusOfPlayer),
                         typeof(ModEntry), nameof(ModEntry.Prefix_withinRadiusOfPlayer));
         }
     }
     catch (Exception e)
     {
         Log("Error in mod setup: " + e.Message + Environment.NewLine + e.StackTrace);
     }
 }
        public DataLoader(IModHelper helper)
        {
            Helper    = helper;
            ModConfig = helper.ReadConfig <ModConfig>();
            i18n      = Helper.Translation;

            LooseSpritesName = Helper.Content.GetActualAssetKey("common/LooseSprites.png", ContentSource.ModFolder);
            LooseSprites     = Helper.Content.Load <Texture2D>("common/LooseSprites.png");

            // load tools
            ToolsSprites = Helper.Content.Load <Texture2D>("tools/Tools.png");
            ToolsLoader  = new ToolsLoader(ToolsSprites, Helper.Content.Load <Texture2D>("tools/MenuTiles.png"), Helper.Content.Load <Texture2D>("common/CustomLetterBG.png"));
            ToolsLoader.LoadMail();

            // load recipes
            if (!ModConfig.DisableMeat)
            {
                RecipeLoader = new RecipesLoader();
                RecipeLoader.LoadMails();
            }

            // load animal data
            AnimalBuildingData = DataLoader.Helper.Data.ReadJsonFile <AnimalBuildingData>("data\\animalBuilding.json") ?? new AnimalBuildingData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animalBuilding.json", AnimalBuildingData);
            AnimalData = DataLoader.Helper.Data.ReadJsonFile <AnimalData>("data\\animals.json") ?? new AnimalData();
            DataLoader.Helper.Data.WriteJsonFile("data\\animals.json", AnimalData);

            // look cooking data
            CookingData = Helper.Data.ReadJsonFile <CookingData>("data\\cooking.json") ?? new CookingData();
            if (CookingData.Meatloaf.Recipe == null)
            {
                CookingData.CloneRecipeAndAmount(new CookingData());
            }
            Helper.Data.WriteJsonFile("data\\cooking.json", CookingData);

            // load TV channel
            LivingWithTheAnimalsChannel = new LivingWithTheAnimalsChannel();

            // add editors (must happen *after* data is initialised above, since SMAPI may reload affected assets immediately)
            var editors = Helper.Content.AssetEditors;

            //editors.Add(new EventsLoader());
            editors.Add(ToolsLoader);
            if (!ModConfig.DisableMeat)
            {
                editors.Add(this);
                editors.Add(RecipeLoader);
            }
        }
Example #30
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="label">A short field label.</param>
 /// <param name="drops">The possible drops.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 /// <param name="defaultText">The text to display if there are no items (or <c>null</c> to hide the field).</param>
 public ItemDropListField(string label, IEnumerable <ItemDropData> drops, ITranslationHelper translations, string defaultText = null)
     : base(label)
 {
     this.Drops =
         (
             from drop in drops
             let item = GameHelper.GetObjectBySpriteIndex(drop.ItemID)
                        orderby drop.Probability descending, item.Name ascending
             select Tuple.Create(drop, item)
         )
         .ToArray();
     this.DefaultText  = defaultText;
     this.HasValue     = defaultText != null || this.Drops.Any();
     this.Translations = translations;
 }