Esempio n. 1
0
        /*********
        ** Public 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)
        {
            Config      = helper.ReadConfig <ModConfig>();
            Reflection  = helper.Reflection;
            Translation = helper.Translation;
            Logger      = Monitor;

            Enum.TryParse(Config.FishingPracticeKey, true, out FishingPracticeKey);

            helper.Events.GameLoop.SaveLoaded +=
                (sender, e) => { Config = helper.ReadConfig <ModConfig>(); };

            if (!Config.DisableFishingSpotInfo)
            {
                helper.Events.Display.RenderedHud += FishingSpotInfo.OnRenderedHud;
            }

            if (!Config.DisableExtraInfo)
            {
                ExtraInfo.SetupExtraInfo(helper);
            }

            if (!Config.DisableCatchInfo || !Config.DisableExtraInfo)
            {
                helper.Events.Display.RenderedActiveMenu += CatchInfo.OnRenderedActiveMenu;
            }

            helper.Events.Display.RenderedWorld += OnRenderedWorld;

            // Build list of fish to practice fishing.
            string[]   fishnames = Config.PracticeFishes.Select(s => s.ToLower()).ToArray();
            List <int> fishids   = new List <int>();

            int[] exclude = { 152, 153, 157 }; // Algae, Seaweed
            foreach (var kv in Game1.content.Load <Dictionary <int, string> >("Data\\Fish"))
            {
                string[] data = kv.Value.ToLower().Split('/');
                string   id   = kv.Key.ToString();
                if (data[1] != "trap" && !exclude.Contains(kv.Key) && (fishnames.Length == 0 || fishnames.Contains(data[0]) ||
                                                                       (data.Count() >= 14 && fishnames.Contains(data[13])) || fishnames.Contains(id)))
                {
                    // Monitor.Log($"{id} {data[0]}\t\t{data[13]}");
                    fishids.Add(kv.Key);
                }
            }
            PracticeList = fishids.ToArray();

            helper.Events.Input.ButtonPressed += OnButtonPressed;

            Config.EasyFish = Math.Min(Math.Max(Config.EasyFish, -90), 90);
            Config.SlowReel = Math.Min(Math.Max(Config.SlowReel, 0), 100);

            helper.Events.GameLoop.UpdateTicked  += OnUpdateTicked;
            helper.Events.GameLoop.UpdateTicking += OnUpdateTicking;
        }
Esempio n. 2
0
        internal static void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs args)
        {
            if (!ModMain.Config.DisableCatchInfo && Game1.activeClickableMenu is BobberBar)
            {
                ShowCatchInfo();
            }

            if (!ModMain.Config.DisableExtraInfo)
            {
                ExtraInfo.DrawFishHover(args);
            }
        }