예제 #1
0
        // Load config and other one-off data
        private void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            this.Helper.Data.WriteJsonFile($"config/default.json", Config);
            Config = Helper.Data.ReadJsonFile <ModConfig>($"config/{Constants.SaveFolderName}.json") ?? Config;
            CustomHandler.LoadConfig(Config);
            CustomMapLocations = CustomHandler.GetCustomMapLocations();
            Season             = Config.UseSeasonalMaps ? Game1.currentSeason : "spring";
            DEBUG_MODE         = Config.DEBUG_MODE;
            shouldShowMinimap  = Config.ShowMinimap;

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

            SecondaryNpcs = new Dictionary <string, bool>
            {
                { "Kent", false },
                { "Marlon", false },
                { "Merchant", false },
                { "Sandy", false },
                { "Wizard", false }
            };
            CustomHandler.UpdateCustomNpcs();
            CustomNames       = CustomHandler.GetNpcNames();
            MarkerCropOffsets = CustomHandler.GetMarkerCropOffsets();
            MapVectors        = ModConstants.MapVectors;

            foreach (var locVectors in CustomMapLocations)
            {
                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 this.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 and updated.", LogLevel.Warn);
                }
            }
        }
예제 #2
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 and updated.", LogLevel.Warn);
                }
            }
        }
예제 #3
0
        public ModMenu(
            Dictionary <string, bool> secondaryNpcs,
            Dictionary <string, object> customNpcs,
            Dictionary <string, string> npcNames,
            Dictionary <string, int> markerCrop,
            IModHelper helper,
            ModConfig config
            ) : base(Game1.viewport.Width / 2 - (1100 + IClickableMenu.borderWidth * 2) / 2,
                     Game1.viewport.Height / 2 - (725 + IClickableMenu.borderWidth * 2) / 2,
                     1100 + IClickableMenu.borderWidth * 2,
                     650 + IClickableMenu.borderWidth * 2, false)
        {
            this.Helper = helper;
            this.Config = config;
            this.map    = Game1.content.Load <Texture2D>("LooseSprites\\map");
            Vector2 topLeftPositionForCenteringOnScreen =
                Utility.getTopLeftPositionForCenteringOnScreen(this.map.Bounds.Width * Game1.pixelZoom, 180 * Game1.pixelZoom,
                                                               0, 0);

            this.mapX     = (int)topLeftPositionForCenteringOnScreen.X;
            this.mapY     = (int)topLeftPositionForCenteringOnScreen.Y;
            this.okButton = new ClickableTextureComponent("OK",
                                                          new Rectangle(this.xPositionOnScreen + width - Game1.tileSize * 2,
                                                                        this.yPositionOnScreen + height - (int)(7 * Game1.tileSize / 4), Game1.tileSize, Game1.tileSize), null, null,
                                                          Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
            this.upArrow = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + width + Game1.tileSize / 4,
                                                                       this.yPositionOnScreen + Game1.tileSize,
                                                                       11 * Game1.pixelZoom, 12 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(421, 459, 11, 12),
                                                         (float)Game1.pixelZoom);
            this.downArrow = new ClickableTextureComponent(
                new Rectangle(this.xPositionOnScreen + width + Game1.tileSize / 4,
                              this.yPositionOnScreen + height - Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom),
                Game1.mouseCursors, new Rectangle(421, 472, 11, 12), (float)Game1.pixelZoom);
            this.scrollBar = new ClickableTextureComponent(
                new Rectangle(this.upArrow.bounds.X + Game1.pixelZoom * 3,
                              this.upArrow.bounds.Y + this.upArrow.bounds.Height + Game1.pixelZoom, 6 * Game1.pixelZoom,
                              10 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(435, 463, 6, 10), (float)Game1.pixelZoom);
            this.scrollBarRunner = new Rectangle(this.scrollBar.bounds.X,
                                                 this.upArrow.bounds.Y + this.upArrow.bounds.Height + Game1.pixelZoom, this.scrollBar.bounds.Width,
                                                 height - Game1.tileSize * 2 - this.upArrow.bounds.Height - Game1.pixelZoom * 2);
            for (int i = 0; i < 7; i++)
            {
                this.optionSlots.Add(new ClickableComponent(
                                         new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4,
                                                       this.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 immersionLabel = helper.Translation.Get("immersion.label");
            string extraLabel     = helper.Translation.Get("extra.label");
            string villagersLabel = helper.Translation.Get("villagers.label");

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

            //this.options.Add(new OptionsElement("Menu Key:"));
            //this.options.Add(new MapModInputListener("Change menu key", 37, this.optionSlots[0].bounds.Width, -1, -1));
            this.options.Add(new OptionsElement("NPC Map Locations"));
            this.options.Add(new OptionsElement(immersionLabel));
            this.options.Add(immersionButton1);
            this.options.Add(immersionButton2);
            this.options.Add(immersionButton3);
            this.options.Add(new ModCheckbox("immersion.option4", 44, -1, -1, customNpcs, npcNames, markerCrop, helper,
                                             config));
            this.options.Add(new ModCheckbox("immersion.option5", 45, -1, -1, customNpcs, npcNames, markerCrop, helper,
                                             config));
            this.options.Add(new MapModSlider("immersion.slider1", 0, -1, -1, helper, config));
            this.options.Add(new MapModSlider("immersion.slider2", 1, -1, -1, helper, config));
            this.options.Add(new OptionsElement(extraLabel));
            this.options.Add(new ModCheckbox("extra.option1", 46, -1, -1, customNpcs, npcNames, markerCrop, helper, config));
            this.options.Add(new ModCheckbox("extra.option2", 47, -1, -1, customNpcs, npcNames, markerCrop, helper, config));
            this.options.Add(new ModCheckbox("extra.option3", 48, -1, -1, customNpcs, npcNames, markerCrop, helper, config));
            this.options.Add(new OptionsElement(villagersLabel));
            // Custom Npcs
            if (customNpcs != null)
            {
                for (int i = 0; i < customNpcs.Count; i++)
                {
                    this.options.Add(new ModCheckbox(customNpcs.Keys.ElementAt(i), 39 + i, -1, -1, customNpcs, npcNames,
                                                     markerCrop, helper, config));
                }
            }

            // Villagers
            var orderedNames = npcNames.Keys.ToList();

            orderedNames.Sort();
            int idx = 7;

            foreach (var name in orderedNames)
            {
                if (secondaryNpcs.ContainsKey(name))
                {
                    if (secondaryNpcs[name])
                    {
                        this.options.Add(new ModCheckbox(name, idx++, -1, -1, customNpcs, npcNames, markerCrop, helper, config));
                    }
                    else
                    {
                        idx++;
                        continue;
                    }
                }
                else
                {
                    this.options.Add(new ModCheckbox(name, idx++, -1, -1, customNpcs, npcNames, markerCrop, helper, config));
                }
            }
        }
예제 #4
0
        public ModCheckbox(
            string label,
            int whichOption,
            int x,
            int y,
            Dictionary <string, object> customNpcs,
            Dictionary <string, string> npcNames,
            Dictionary <string, int> markerCrop,
            IModHelper helper,
            ModConfig config
            ) : base(label, x, y, 9 * Game1.pixelZoom, 9 * Game1.pixelZoom, whichOption)
        {
            this.Helper     = helper;
            this.Config     = config;
            this.MarkerCrop = markerCrop;
            this.NpcNames   = npcNames;
            this.CustomNpcs = customNpcs;
            this.label      = label;

            if (whichOption < 44)
            {
                orderedNames = npcNames.Keys.ToList();
                orderedNames.Sort();

                if (whichOption > 6 && whichOption < 39)
                {
                    this.isChecked = !this.Config.NpcBlacklist.Contains(orderedNames[whichOption - 7]);
                    return;
                }
                else if (whichOption > 38 && whichOption < 44)
                {
                    this.isChecked = !this.Config.CustomNpcBlacklist.Contains(customNpcs.Keys.ElementAt(whichOption - 39));
                    return;
                }
            }
            else if (whichOption > 43)
            {
                this.label = this.Helper.Translation.Get(label);
            }

            switch (whichOption)
            {
            case 44:
                this.isChecked = this.Config.OnlySameLocation;
                return;

            case 45:
                this.isChecked = this.Config.ByHeartLevel;
                return;

            case 46:
                this.isChecked = this.Config.MarkQuests;
                return;

            case 47:
                this.isChecked = this.Config.ShowHiddenVillagers;
                return;

            case 48:
                this.isChecked = this.Config.ShowTravelingMerchant;
                return;

            default:
                return;
            }
        }
예제 #5
0
        // Map menu that uses modified map page and modified component locations for hover
        public ModMapPage(HashSet <NPCMarker> npcMarkers, Dictionary <string, string> npcNames, Dictionary <long, FarmerMarker> farmerMarkers, IModHelper helper, ModConfig config)
        {
            this.Helper   = helper;
            this.Config   = config;
            this.NpcNames = npcNames;
            this.RecieveMarkerUpdates(npcMarkers, farmerMarkers);

            okButton            = new ClickableTextureComponent(Game1.content.LoadString("Strings\\StringsFromCSFiles:MapPage.cs.11059", new object[0]), new Rectangle(this.xPositionOnScreen + width + Game1.tileSize, this.yPositionOnScreen + height - IClickableMenu.borderWidth - Game1.tileSize / 4, Game1.tileSize, Game1.tileSize), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false);
            map                 = Game1.content.Load <Texture2D>("LooseSprites\\map");
            drawPamHouseUpgrade = Game1.MasterPlayer.mailReceived.Contains("pamHouseUpgrade");
            HandleResize();
        }