Exemplo n.º 1
0
        //private RenderTarget2D renderTarget;

        public ModMinimap(
            HashSet <CharacterMarker> npcMarkers,
            Dictionary <string, bool> conditionalNpcs,
            Dictionary <long, CharacterMarker> farmerMarkers,
            Dictionary <string, KeyValuePair <string, Vector2> > farmBuildings,
            Texture2D buildingMarkers,
            ModCustomizations customizations
            )
        {
            // renderTarget = new RenderTarget2D(Game1.graphics.GraphicsDevice,Game1.viewport.Width, Game1.viewport.Height);
            this.NpcMarkers      = npcMarkers;
            this.ConditionalNpcs = conditionalNpcs;
            this.FarmerMarkers   = farmerMarkers;
            this.FarmBuildings   = farmBuildings;
            this.BuildingMarkers = buildingMarkers;
            this.Customizations  = customizations;

            drawPamHouseUpgrade  = Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade");
            drawMovieTheaterJoja = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheaterJoja");
            drawMovieTheater     = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater");

            mmX      = ModMain.Config.MinimapX;
            mmY      = ModMain.Config.MinimapY;
            mmWidth  = ModMain.Config.MinimapWidth * Game1.pixelZoom;
            mmHeight = ModMain.Config.MinimapHeight * Game1.pixelZoom;
        }
Exemplo n.º 2
0
        //private RenderTarget2D renderTarget;



        public ModMinimap(
            HashSet <CharacterMarker> npcMarkers,
            Dictionary <string, bool> conditionalNpcs,
            Dictionary <long, CharacterMarker> farmerMarkers,
            Dictionary <string, KeyValuePair <string, Vector2> > farmBuildings,
            Texture2D buildingMarkers,
            ModCustomizations customizations
            )
        {
            // renderTarget = new RenderTarget2D(Game1.graphics.GraphicsDevice,Game1.viewport.Width, Game1.viewport.Height);
            this.NpcMarkers      = npcMarkers;
            this.ConditionalNpcs = conditionalNpcs;
            this.FarmerMarkers   = farmerMarkers;
            this.FarmBuildings   = farmBuildings;
            this.BuildingMarkers = buildingMarkers;
            this.Customizations  = customizations;

            map = Game1.content.Load <Texture2D>("LooseSprites\\map");
            drawPamHouseUpgrade = Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade");

            mmX      = ModMain.Config.MinimapX;
            mmY      = ModMain.Config.MinimapY;
            mmWidth  = ModMain.Config.MinimapWidth * Game1.pixelZoom;
            mmHeight = ModMain.Config.MinimapHeight * Game1.pixelZoom;
        }
Exemplo n.º 3
0
        public ModCheckbox(
            string label,
            int whichOption,
            int x,
            int y,
            ModCustomizations customizations
            ) : base(label, x, y, 9 * Game1.pixelZoom, 9 * Game1.pixelZoom, whichOption)
        {
            Customizations = customizations;
            this.label     = label;

            if (whichOption < 49)
            {
                orderedNames = customizations.Names.Keys.ToList();
                orderedNames.Sort();

                if (whichOption > 6 && whichOption < 49)
                {
                    isChecked = !ModMain.Config.NpcBlacklist.Contains(orderedNames[whichOption - 7]);
                    return;
                }
            }
            else if (whichOption > 48)
            {
                this.label = ModMain.Helper.Translation.Get(label);
            }

            switch (whichOption)
            {
            case 49:
                isChecked = ModMain.Config.OnlySameLocation;
                return;

            case 50:
                isChecked = ModMain.Config.ByHeartLevel;
                return;

            case 51:
                isChecked = ModMain.Config.MarkQuests;
                return;

            case 52:
                isChecked = ModMain.Config.ShowHiddenVillagers;
                return;

            case 53:
                isChecked = ModMain.Config.ShowTravelingMerchant;
                return;

            case 54:
                isChecked = ModMain.Config.ShowMinimap;
                return;

            default:
                return;
            }
        }
Exemplo n.º 4
0
        // Map menu that uses modified map page and modified component locations for hover
        public ModMapPage(
            HashSet <CharacterMarker> npcMarkers,
            Dictionary <string, bool> conditionalNpcs,
            Dictionary <long, CharacterMarker> farmerMarkers,
            Dictionary <string, KeyValuePair <string, Vector2> > farmBuildings,
            Texture2D buildingMarkers,
            ModCustomizations customizations
            ) : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2,
                     Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2,
                     600 + IClickableMenu.borderWidth * 2)
        {
            this.NpcMarkers      = npcMarkers;
            this.ConditionalNpcs = conditionalNpcs;
            this.FarmerMarkers   = farmerMarkers;
            this.FarmBuildings   = farmBuildings;
            this.BuildingMarkers = buildingMarkers;
            this.Customizations  = customizations;

            map = Game1.content.Load <Texture2D>("LooseSprites\\map");
            drawPamHouseUpgrade = Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade");
            Vector2 center = Utility.getTopLeftPositionForCenteringOnScreen(map.Bounds.Width * 4, 720, 0, 0);

            mapX = (int)center.X;
            mapY = (int)center.Y;

            var regionRects    = RegionRects().ToList();
            var customTooltips = Customizations.Tooltips.ToList();

            for (int i = 0; i < regionRects.Count; i++)
            {
                var rect = regionRects.ElementAtOrDefault(i);

                this.points[i].bounds = new Rectangle(
                    // Snaps the cursor to the center instead of bottom right (default)
                    (int)(mapX + ModMain.LocationToMap(rect.Key).X - rect.Value.Width / 2),
                    (int)(mapY + ModMain.LocationToMap(rect.Key).Y - rect.Value.Height / 2),
                    rect.Value.Width,
                    rect.Value.Height
                    );

                if (ModMain.IsSVE)
                {
                    // Adventure's Guild is in a different location in SVE
                    if (this.points[i].myID == 1025)
                    {
                        this.points[i].bounds = new Rectangle(mapX + 682, mapY + 451, 22, 30);
                    }
                    // Remove sewer which gets replaced by Adventure Guild
                    else if (this.points[i].myID == 1018)
                    {
                        this.points[i].bounds.Width  = 0;
                        this.points[i].bounds.Height = 0;
                    }
                    // So it doesn't cover up the other new points in the railroad
                    else if (this.points[i].myID == 1034)
                    {
                        this.points[i].bounds.Width /= 2;
                    }
                }
            }

            int idx = 0;

            // Add custom tooltips
            for (int i = regionRects.Count; i < regionRects.Count + customTooltips.Count; i++)
            {
                var tooltip = customTooltips.ElementAtOrDefault(idx);
                if (tooltip == null)
                {
                    break;
                }

                var point = new ClickableComponent(new Rectangle(
                                                       tooltip.bounds.X + mapX,
                                                       tooltip.bounds.Y + mapY,
                                                       tooltip.bounds.Width,
                                                       tooltip.bounds.Height
                                                       ), tooltip.name);

                if (this.points.Count <= i)
                {
                    this.points.Add(point);
                }
                else
                {
                    this.points[i] = point;
                }

                idx++;
            }
        }
Exemplo n.º 5
0
        public ModMenu(
            Dictionary <string, bool> conditionalNpcs,
            ModCustomizations customizations
            ) : base(Game1.viewport.Width / 2 - (1000 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 1000 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, true)
        {
            var topLeftPositionForCenteringOnScreen =
                Utility.getTopLeftPositionForCenteringOnScreen(ModMain.Map.Bounds.Width * Game1.pixelZoom, 180 * Game1.pixelZoom,
                                                               0, 0);

            mapX     = (int)topLeftPositionForCenteringOnScreen.X;
            mapY     = (int)topLeftPositionForCenteringOnScreen.Y;
            okButton = new ClickableTextureComponent("OK",
                                                     new Rectangle(xPositionOnScreen + width - Game1.tileSize * 2,
                                                                   yPositionOnScreen + height - 7 * Game1.tileSize / 4, Game1.tileSize, Game1.tileSize), null, null,
                                                     Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
            upArrow = new ClickableTextureComponent(new Rectangle(xPositionOnScreen + width + Game1.tileSize / 4,
                                                                  yPositionOnScreen + Game1.tileSize,
                                                                  11 * Game1.pixelZoom, 12 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(421, 459, 11, 12),
                                                    Game1.pixelZoom);
            downArrow = new ClickableTextureComponent(
                new Rectangle(xPositionOnScreen + width + Game1.tileSize / 4,
                              yPositionOnScreen + height - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom),
                Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom);
            scrollBar = new ClickableTextureComponent(
                new Rectangle(upArrow.bounds.X + Game1.pixelZoom * 3,
                              upArrow.bounds.Y + upArrow.bounds.Height + Game1.pixelZoom, 6 * Game1.pixelZoom,
                              10 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(435, 463, 6, 10), Game1.pixelZoom);
            scrollBarRunner = new Rectangle(scrollBar.bounds.X,
                                            upArrow.bounds.Y + upArrow.bounds.Height + Game1.pixelZoom, scrollBar.bounds.Width,
                                            height - Game1.tileSize * 2 - upArrow.bounds.Height - Game1.pixelZoom * 2);
            for (var i = 0; i < 7; i++)
            {
                optionSlots.Add(new ClickableComponent(
                                    new Rectangle(xPositionOnScreen + Game1.tileSize / 4,
                                                  yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * ((height - Game1.tileSize * 2) / 7),
                                                  width - Game1.tileSize / 2, (height - Game1.tileSize * 2) / 7 + Game1.pixelZoom), string.Concat(i)));
            }

            // Translate labels and initialize buttons to handle button press
            string minimapLabel   = ModMain.Helper.Translation.Get("minimap.label");
            string immersionLabel = ModMain.Helper.Translation.Get("immersion.label");
            string villagersLabel = ModMain.Helper.Translation.Get("villagers.label");

            immersionButton1 = new MapModButton("immersion.option1", 4, -1, -1, -1, -1);
            immersionButton2 = new MapModButton("immersion.option2", 5, -1, -1, -1, -1);
            immersionButton3 = new MapModButton("immersion.option3", 6, -1, -1, -1, -1);

            //this.options.Add(new OptionsElement("Menu Key:"));
            //this.options.Add(new MapModInputListener("Change menu key", 37, this.optionSlots[0].bounds.Width, -1, -1));
            options.Add(new OptionsElement("NPC Map Locations"));

            var widths = new List <int>();

            for (var i = 0; i < 16; i++)
            {
                widths.Add(75 + i * 15);
            }

            var heights = new List <int>();

            for (var j = 0; j < 10; j++)
            {
                heights.Add(45 + j * 15);
            }

            var percentages = new List <int>();

            for (var k = 0; k < 11; k++)
            {
                percentages.Add(50 + k * 5);
            }

            options.Add(new OptionsElement(minimapLabel));
            options.Add(new ModCheckbox("minimap.option1", 54, -1, -1, customizations));
            options.Add(new ModPlusMinus("minimap.plusMinus1", 55, widths));
            options.Add(new ModPlusMinus("minimap.plusMinus2", 56, heights));
            //options.Add(new ModPlusMinus("minimap.plusMinus3", 57, percentages));

            options.Add(new OptionsElement(immersionLabel));
            options.Add(immersionButton1);
            options.Add(immersionButton2);
            options.Add(immersionButton3);
            options.Add(new ModCheckbox("immersion.option4", 49, -1, -1, customizations));
            options.Add(new ModCheckbox("immersion.option5", 50, -1, -1, customizations));
            options.Add(new MapModSlider("immersion.slider1", 0, -1, -1, 0, 12));
            options.Add(new MapModSlider("immersion.slider2", 1, -1, -1, 0, 12));

            options.Add(new ModCheckbox("extra.option1", 51, -1, -1, customizations));
            options.Add(new ModCheckbox("extra.option2", 52, -1, -1, customizations));
            options.Add(new ModCheckbox("extra.option3", 53, -1, -1, customizations));
            options.Add(new OptionsElement(villagersLabel));

            // Villagers + up to 10 custom NPCs
            var orderedNames = customizations.Names.Keys.ToList();

            orderedNames.Sort();
            var idx = 7;

            foreach (var name in orderedNames)
            {
                if (conditionalNpcs.ContainsKey(name))
                {
                    if (conditionalNpcs[name])
                    {
                        options.Add(new ModCheckbox(name, idx++, -1, -1, customizations));
                    }
                    else
                    {
                        idx++;
                    }
                }
                else
                {
                    options.Add(new ModCheckbox(name, idx++, -1, -1, customizations));
                }
            }
        }
Exemplo n.º 6
0
        // Load config and other one-off data
        private void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            Config         = Helper.Data.ReadJsonFile <ModConfig>($"config/{Constants.SaveFolderName}.json") ?? Config;
            IsSVE          = Helper.ModRegistry.IsLoaded("FlashShifter.StardewValleyExpandedCP");
            Customizations = new ModCustomizations(Monitor)
            {
                LocationTextures = File.Exists(@"assets/customLocations.png") ? Helper.Content.Load <Texture2D>(@"assets/customLocations.png") : null
            };
            Season = Config.UseSeasonalMaps ? Game1.currentSeason : "spring";
            Helper.Content.InvalidateCache("LooseSprites/Map");

            DEBUG_MODE        = Config.DEBUG_MODE;
            shouldShowMinimap = Config.ShowMinimap;

            locationContexts = new Dictionary <string, LocationContext>();
            foreach (var location in Game1.locations)
            {
                MapRootLocations(location, null, false);
            }

            ConditionalNpcs = new Dictionary <string, bool>
            {
                { "Kent", false },
                { "Marlon", false },
                { "Merchant", false },
                { "Sandy", false },
                { "Wizard", false }
            };

            MapVectors = ModConstants.MapVectors;

            foreach (var locVectors in Customizations.MapVectors)
            {
                if (MapVectors.TryGetValue(locVectors.Key, out var mapVectors))
                {
                    MapVectors[locVectors.Key] = locVectors.Value;
                }
                else
                {
                    MapVectors.Add(locVectors.Key, locVectors.Value);
                }
            }

            UpdateFarmBuildingLocs();
            alertFlags = new List <string>();

            // Log warning if host does not have mod installed
            if (Context.IsMultiplayer)
            {
                var hostHasMod = false;

                foreach (IMultiplayerPeer peer in Helper.Multiplayer.GetConnectedPlayers())
                {
                    if (peer.GetMod("Bouhm.NPCMapLocations") != null && peer.IsHost)
                    {
                        hostHasMod = true;
                        break;
                    }
                }

                if (!hostHasMod && !Context.IsMainPlayer)
                {
                    Monitor.Log("Since the server host does not have NPCMapLocations installed, NPC locations cannot be synced.", LogLevel.Warn);
                }
            }
        }
Exemplo n.º 7
0
        // Map menu that uses modified map page and modified component locations for hover
        public ModMapPage(
            Dictionary <string, NpcMarker> npcMarkers,
            Dictionary <string, bool> conditionalNpcs,
            Dictionary <long, FarmerMarker> farmerMarkers,
            Dictionary <string, KeyValuePair <string, Vector2> > farmBuildings,
            Texture2D buildingMarkers,
            ModCustomizations customizations
            ) : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2,
                     Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2,
                     600 + IClickableMenu.borderWidth * 2)
        {
            this.NpcMarkers      = npcMarkers;
            this.ConditionalNpcs = conditionalNpcs;
            this.FarmerMarkers   = farmerMarkers;
            this.FarmBuildings   = farmBuildings;
            this.BuildingMarkers = buildingMarkers;
            this.Customizations  = customizations;

            Vector2 center = Utility.getTopLeftPositionForCenteringOnScreen(ModMain.Map.Bounds.Width * 4, 720);

            drawPamHouseUpgrade  = Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade");
            drawMovieTheaterJoja = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheaterJoja");
            drawMovieTheater     = Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater");
            mapX = (int)center.X;
            mapY = (int)center.Y;

            var regionRects = RegionRects().ToList();

            for (int i = 0; i < regionRects.Count; i++)
            {
                var rect         = regionRects.ElementAtOrDefault(i);
                var locationName = rect.Key;

                // Special cases where the name is not an ingame location
                switch (locationName)
                {
                case "Spa":
                    locationName = "BathHouse_Entry";
                    break;

                case "SewerPipe":
                    locationName = "Sewer";
                    break;

                default:
                    break;
                }

                var locVector = ModMain.LocationToMap(locationName);

                this.points[i].bounds = new Rectangle(
                    // Snaps the cursor to the center instead of bottom right (default)
                    (int)(mapX + locVector.X - rect.Value.Width / 2),
                    (int)(mapY + locVector.Y - rect.Value.Height / 2),
                    rect.Value.Width,
                    rect.Value.Height
                    );
            }

            var customTooltips = Customizations.Tooltips.ToList();

            foreach (var tooltip in customTooltips)
            {
                var vanillaTooltip = this.points.Find(x => x.name == tooltip.name);
                var customTooltip  = new ClickableComponent(new Rectangle(
                                                                mapX + tooltip.bounds.X,
                                                                mapY + tooltip.bounds.Y,
                                                                tooltip.bounds.Width,
                                                                tooltip.bounds.Height
                                                                ), tooltip.name);

                // Replace vanilla with custom
                if (vanillaTooltip != null)
                {
                    vanillaTooltip = customTooltip;
                }
                else
                // If new custom location, add it
                {
                    this.points.Add(customTooltip);
                }
            }

            // If two tooltip areas overlap, the one earlier in the list takes precendence
            // Reversing order allows custom tooltips to take precendence
            this.points.Reverse();
        }