public static bool receiveLeftClick(CollectionsPage __instance, int x, int y)
        {
            int currentTab = MailFrameworkModEntry.ModHelper.Reflection.GetField <int>(__instance, "currentTab").GetValue();

            if (__instance.letterviewerSubMenu == null && currentTab == 7)
            {
                int currentPage = MailFrameworkModEntry.ModHelper.Reflection.GetField <int>(__instance, "currentPage").GetValue();
                foreach (ClickableTextureComponent clickableComponent in __instance.collections[currentTab][currentPage])
                {
                    if (clickableComponent.containsPoint(x, y))
                    {
                        Letter letter = MailDao.FindLetter(clickableComponent.name.Split(' ')[0]);
                        if (letter != null && !letter.AutoOpen)
                        {
                            LetterViewerMenuExtended letterViewerMenu = new LetterViewerMenuExtended(letter.Text.Replace("@", Game1.player.Name), letter.Id, true);
                            MailFrameworkModEntry.ModHelper.Reflection.GetField <int>(letterViewerMenu, "whichBG").SetValue(letter.WhichBG);
                            if (letter.LetterTexture != null)
                            {
                                letterViewerMenu.letterTexture = letter.LetterTexture;
                            }
                            letterViewerMenu.TextColor     = letter.TextColor;
                            __instance.letterviewerSubMenu = letterViewerMenu;
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
        private static void CollectionsPage_Postfix(CollectionsPage __instance)
        {
            if (!Config.EnableMod)
            {
                return;
            }

            int widthUsed = __instance.collections[5][0].Count;
            int baseX     = __instance.xPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearSideBorder;
            int baseY     = __instance.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - 16;

            using var dict = Helper.Content.Load <Dictionary <string, CustomAcheivementData> >(ModEntry.dictPath, ContentSource.GameContent).GetEnumerator();
            while (dict.MoveNext())
            {
                var a    = dict.Current.Value;
                int hash = a.name.GetHashCode();
                ModEntry.currentAchievements[hash] = a;

                int xPos = baseX + widthUsed % 10 * 68;
                int yPos = baseY + widthUsed / 10 * 68;
                if (a.iconPath.Length > 0)
                {
                    var icon = Game1.content.Load <Texture2D>(Helper.Content.GetActualAssetKey(a.iconPath, ContentSource.GameContent));
                    __instance.collections[5][0].Add(new ClickableTextureComponent($"{hash} {a.achieved}", new Rectangle(xPos, yPos, 64, 64), null, "", icon, a.iconRect == null ? new Rectangle(0, 0, icon.Width, icon.Height) : a.iconRect.Value, 1f, false));
                }
                else
                {
                    __instance.collections[5][0].Add(new ClickableTextureComponent($"{hash} {a.achieved}", new Rectangle(xPos, yPos, 64, 64), null, "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 25, -1, -1), 1f, false));
                }
                widthUsed++;
            }
        }
Exemple #3
0
            public static void Postfix(CollectionsPage __instance, ref string __result, int index)
            {
                if (!Game1.objectInformation.TryGetValue(index, out string itemData)) // Break if it's not an item - dodges weird edge cases
                {
                    return;
                }

                string[] split = itemData.Split(new char[] { '/' });

                if (!split[3].Contains("Fish"))
                {
                    return;
                }                                           //break if it isn't a fish

                if (ModEntry.FishInfo.TryGetValue(index, out FishData loadedData))
                {
                    __result += loadedData.InfoLocation;

                    if (!loadedData.IsCrabPot)
                    {
                        __result += loadedData.InfoSeason;
                        __result += loadedData.InfoTime;
                        __result += loadedData.InfoWeather;
                    }
                }
            }
Exemple #4
0
            public static void Postfix(CollectionsPage __instance, ref string ___hoverText, int ___currentTab, int ___currentPage, int x, int y)
            {
                foreach (ClickableTextureComponent c in __instance.collections[___currentTab][___currentPage])
                {
                    if (!c.containsPoint(x, y))
                    {
                        c.scale = Math.Max(c.scale - 0.02f, c.baseScale);
                    }
                    else
                    {
                        c.scale = Math.Min(c.scale + 0.02f, c.baseScale + 0.1f);
                        if (___currentTab == 1) // We only care about the fish tab
                        {
                            int FishID = Convert.ToInt32(c.name.Split(new char[] { ' ' })[0]);
                            if (!ModEntry.FishInfo.TryGetValue(FishID, out FishData fishData))
                            {
                                ___hoverText = "???";
                                continue;
                            }

                            if (!Convert.ToBoolean(c.name.Split(new char[] { ' ' })[1])) //Isn't unlocked
                            {
                                if (!ModEntry.Config.RequireFishCaughtForFullInfo)       //if we require fish to be caught to show the info
                                {
                                    ___hoverText = fishData.ToString();
                                    continue;
                                }
                                else
                                {
                                    ___hoverText = "";
                                    StringBuilder sb = new StringBuilder();
                                    if (ModEntry.Config.UncaughtFishAlwaysShowName)
                                    {
                                        sb.Append(fishData.FishName);
                                    }
                                    if (ModEntry.Config.UncaughtFishAlwaysShowLocation)
                                    {
                                        sb.AppendLine(fishData.InfoLocation);
                                    }
                                    if (ModEntry.Config.UncaughtFishAlwaysShowSeason)
                                    {
                                        sb.AppendLine(fishData.InfoSeason);
                                    }
                                    if (ModEntry.Config.UncaughtFishAlwaysShowTime)
                                    {
                                        sb.AppendLine(fishData.InfoTime);
                                    }
                                    if (ModEntry.Config.UncaughtFishAlwaysShowWeather)
                                    {
                                        sb.AppendLine(fishData.InfoWeather);
                                    }

                                    ___hoverText = sb.ToString().Trim();
                                }
                            }
                        }
                    }
                }
            }
 public CollectionsPageDrawEvent(CollectionsPage instance, int currentTab, int currentPage, string hoverText, Dictionary <int, List <List <ClickableTextureComponent> > > collections)
 {
     this.instance    = instance;
     this.currentTab  = currentTab;
     this.currentPage = currentPage;
     this.hoverText   = hoverText;
     this.collections = collections;
 }
 private static bool CollectionsPage_createDescription_Prefix(CollectionsPage __instance, int index, ref string __result)
 {
     if (!Config.EnableMod || __instance.currentTab != 5 || !ModEntry.currentAchievements.ContainsKey(index))
     {
         return(true);
     }
     __result = ModEntry.currentAchievements[index].name + "\n\n" + ModEntry.currentAchievements[index].description;
     return(false);
 }
Exemple #7
0
            public static void Postfix(CollectionsPage __instance, ref string __result, int index)
            {
                if (!Game1.objectInformation.TryGetValue(index, out string itemData)) // Break if it's not an item - dodges weird edge cases
                {
                    return;
                }

                string[] split = itemData.Split(new char[] { '/' });

                if (!split[3].Contains("Fish"))
                {
                    return;
                }                                           //break if it isn't a fish

                if (ModEntry.FishInfo.TryGetValue(index, out FishData loadedData))
                {
                    if (!loadedData.IsCrabPot)
                    {
                        __result += Environment.NewLine;
                        if (ModEntry.Config.CaughtFishData.AlwaysShowSeason && ModEntry.Config.CaughtFishData.AlwaysShowLocation)
                        {
                            __result += loadedData.InfoSeasonsWithLocations;
                        }
                        else if (!ModEntry.Config.CaughtFishData.AlwaysShowSeason && ModEntry.Config.CaughtFishData.AlwaysShowLocation)
                        {
                            __result += loadedData.InfoLocation;
                        }
                        else if (ModEntry.Config.CaughtFishData.AlwaysShowSeason && !ModEntry.Config.CaughtFishData.AlwaysShowLocation)
                        {
                            __result += loadedData.InfoSeason;
                        }
                        if (ModEntry.Config.CaughtFishData.AlwaysShowTime)
                        {
                            __result += loadedData.InfoTime;
                        }
                        if (ModEntry.Config.CaughtFishData.AlwaysShowWeather)
                        {
                            __result += loadedData.InfoWeather;
                        }
                    }
                    else
                    {
                        if (ModEntry.Config.CaughtFishData.AlwaysShowLocation)
                        {
                            __result += loadedData.InfoLocation;
                        }
                    }
                }
            }
Exemple #8
0
        public static void Prefix(ref SpriteBatch b, ref CollectionsPage __instance)
        {
            FieldInfo currentTab  = __instance.GetType().GetField("currentTab", BindingFlags.NonPublic | BindingFlags.Instance);
            FieldInfo currentPage = __instance.GetType().GetField("currentPage", BindingFlags.NonPublic | BindingFlags.Instance);
            FieldInfo hoverText   = __instance.GetType().GetField("hoverText", BindingFlags.NonPublic | BindingFlags.Instance);

            int    currentTabVal  = (int)currentTab.GetValue(__instance);
            int    currentPageVal = (int)currentPage.GetValue(__instance);
            string hoverTextVal   = (string)hoverText.GetValue(__instance);

            CollectionsPageDrawEvent evt = new CollectionsPageDrawEvent(__instance, currentTabVal, currentPageVal, hoverTextVal, __instance.collections);

            BookcaseEvents.CollectionsPageDrawEvent.Post(evt);

            currentTab.SetValue(__instance, evt.currentTab);
            currentPage.SetValue(__instance, evt.currentPage);
            hoverText.SetValue(__instance, evt.hoverText);
        }
Exemple #9
0
        public static void Serialize_CollectionsPage(dynamic menu, CollectionsPage page, Point mousePosition)
        {
            menu.menuType = "collectionsPage";
            int currentPageNumber = page.currentPage;
            var currentCollection = page.collections[page.currentTab];
            var currentPage       = currentCollection[currentPageNumber];

            if (currentPageNumber > 0)
            {
                menu.backButton = page.backButton;
            }
            if (currentPageNumber < currentCollection.Count - 1)
            {
                menu.forwardButton = page.forwardButton;
            }
            menu.currentPage = currentPage;
            menu.tabs        = page.sideTabs.Values.ToList();
        }
Exemple #10
0
        /// <summary>Draw hover text on main game menu > collections tab > fish collections page is up.</summary>
        internal static void DrawFishHover(RenderedActiveMenuEventArgs args)
        {
            if (!(Game1.activeClickableMenu is GameMenu MainMenu) ||
                MainMenu.currentTab != GameMenu.collectionsTab)
            {
                return;
            }

            CollectionsPage colTab = (CollectionsPage)ModMain.Reflection.GetField <List <IClickableMenu> >
                                         (MainMenu, "pages").GetValue()[GameMenu.collectionsTab];

            int currentTab = ModMain.Reflection.GetField <int>(colTab, "currentTab").GetValue();

            if (currentTab != CollectionsPage.fishTab)
            {
                return;
            }

            var fishTab = colTab.collections[CollectionsPage.fishTab][0]; // no 2nd page
            var item    = fishTab.FirstOrDefault(comp => comp.containsPoint(Game1.getMouseX(), Game1.getMouseY()));

            if (item == null || item.name == null ||
                (!item.name.Contains("True") && !ModMain.Config.UnknownFishCheat))
            {
                return;
            }

            int objId = Convert.ToInt32(item.name.Split(' ')[0]);

            if (!ExtraFishDesc.ContainsKey(objId))
            {
                return;
            }

            int    value;
            string hoverText = CreateDescription(objId, out value);

            // value = ModMain.Reflection.GetField<int>(colTab, "value").GetValue();

            IClickableMenu.drawHoverText(args.SpriteBatch, hoverText, Game1.smallFont, 0, 0, value);

            return;
        }