Exemple #1
0
        public override void performHoverAction(int x, int y)
        {
            var f = points;

            hoveredLocationText = "";
            hoveredNames        = "";
            hasIndoorCharacter  = false;
            foreach (ClickableComponent current in points)
            {
                if (current.containsPoint(x, y))
                {
                    hoveredLocationText = current.name;
                    break;
                }
            }

            List <string> hoveredList = new List <string>();

            const int markerWidth  = 32;
            const int markerHeight = 30;

            // Have to use special character to separate strings for Chinese
            string separator = LocalizedContentManager.CurrentLanguageCode.Equals(LocalizedContentManager.LanguageCode.zh)
        ? ","
        : ", ";

            if (NpcMarkers != null)
            {
                foreach (var npcMarker in this.NpcMarkers)
                {
                    Vector2 npcLocation = new Vector2(mapX + npcMarker.Value.MapX, mapY + npcMarker.Value.MapY);
                    if (Game1.getMouseX() >= npcLocation.X && Game1.getMouseX() <= npcLocation.X + markerWidth &&
                        Game1.getMouseY() >= npcLocation.Y && Game1.getMouseY() <= npcLocation.Y + markerHeight)
                    {
                        if (!npcMarker.Value.IsHidden && !(npcMarker.Value.Type == Character.Horse))
                        {
                            if (Customizations.Names.TryGetValue(npcMarker.Key, out var name))
                            {
                                hoveredList.Add(name);
                            }
                        }

                        if (!LocationUtil.IsOutdoors(npcMarker.Value.LocationName) && !hasIndoorCharacter)
                        {
                            hasIndoorCharacter = true;
                        }
                    }
                }
            }

            if (Context.IsMultiplayer && FarmerMarkers != null)
            {
                foreach (var farMarker in FarmerMarkers.Values)
                {
                    Vector2 farmerLocation = new Vector2(mapX + farMarker.MapX, mapY + farMarker.MapY);
                    if (Game1.getMouseX() >= farmerLocation.X - markerWidth / 2 &&
                        Game1.getMouseX() <= farmerLocation.X + markerWidth / 2 &&
                        Game1.getMouseY() >= farmerLocation.Y - markerHeight / 2 &&
                        Game1.getMouseY() <= farmerLocation.Y + markerHeight / 2)
                    {
                        hoveredList.Add(farMarker.Name);

                        if (!LocationUtil.IsOutdoors(farMarker.LocationName) && !hasIndoorCharacter)
                        {
                            hasIndoorCharacter = true;
                        }
                    }
                }
            }

            if (hoveredList.Count > 0)
            {
                hoveredNames = hoveredList[0];
                for (int i = 1; i < hoveredList.Count; i++)
                {
                    var lines = hoveredNames.Split('\n');
                    if ((int)Game1.smallFont.MeasureString(lines[lines.Length - 1] + separator + hoveredList[i]).X >
                        (int)Game1.smallFont.MeasureString("Home of Robin, Demetrius, Sebastian & Maru").X) // Longest string
                    {
                        hoveredNames += separator + Environment.NewLine;
                        hoveredNames += hoveredList[i];
                    }
                    else
                    {
                        hoveredNames += separator + hoveredList[i];
                    }
                }
            }
        }