/// <summary>Loads a favorite from the favorite list</summary>
        /// <param name="whichPosition">The position in the List</param>
        /// <param name="menu">The instance of GlamMenu</param>
        /// <param name="wasFavoriteApplied">Whether the favorite was applied</param>
        public void LoadFavorite(int whichPosition, GlamMenu menu, bool wasFavoriteApplied)
        {
            //Change gender, hair, accessories, and skin
            Game1.player.changeGender(Favorites[whichPosition].IsMale);
            Game1.player.hair.Set(Favorites[whichPosition].HairIndex);
            Game1.player.accessory.Set(Favorites[whichPosition].AccessoryIndex);
            Game1.player.skin.Set(Favorites[whichPosition].SkinIndex);

            //Change the color of the hair and the eyes
            Game1.player.newEyeColor.Set(Favorites[whichPosition].EyeColor);
            Game1.player.FarmerRenderer.recolorEyes(Favorites[whichPosition].EyeColor);
            Game1.player.hairstyleColor.Set(Favorites[whichPosition].HairColor);

            //Chnage the player base to the index in the favorites
            PackHelper.ChangePlayerBase(
                Favorites[whichPosition].IsMale,
                Favorites[whichPosition].BaseIndex,
                Favorites[whichPosition].FaceIndex,
                Favorites[whichPosition].NoseIndex,
                Favorites[whichPosition].ShoeIndex,
                Favorites[whichPosition].IsBald
                );

            //If the favorite was applied then update the GlamMenu
            if (wasFavoriteApplied)
            {
                menu.UpdateIndexes(
                    Favorites[whichPosition].BaseIndex,
                    Favorites[whichPosition].FaceIndex,
                    Favorites[whichPosition].NoseIndex,
                    Favorites[whichPosition].ShoeIndex,
                    Favorites[whichPosition].IsBald
                    );
            }
        }
        /// <summary>
        /// Loads the character layout from a json file.
        /// </summary>
        /// <param name="menu">The instance of Glam Menu used to update indexes</param>
        public void LoadCharacterLayout(GlamMenu menu)
        {
            // Read the config
            ConfigModel currentPlayerStyle = Entry.Helper.Data.ReadJsonFile <ConfigModel>(Path.Combine("Saves", $"{Constants.SaveFolderName}_current.json"));

            // Don't try to load if it doesn't find the json
            if (currentPlayerStyle is null)
            {
                return;
            }

            // Update the dresser
            UpdateDresser(currentPlayerStyle.DresserIndex);

            if (!currentPlayerStyle.IsDefault)
            {
                menu.UpdateIndexes(currentPlayerStyle.BaseIndex, currentPlayerStyle.FaceIndex, currentPlayerStyle.NoseIndex, currentPlayerStyle.ShoesIndex, currentPlayerStyle.IsBald, currentPlayerStyle.DresserIndex);
                SetPlayerStyle(currentPlayerStyle);
            }

            //Add the favorites to the favorites list
            AddFavoritesToFavoriteList(currentPlayerStyle);

            //Lastly, change the base, THIS NEEDS TO BE LAST OR ELSE IT WON'T LOAD THE PLAYER STYLE
            if (!currentPlayerStyle.IsDefault)
            {
                PlayerChanger.ChangePlayerBase(Game1.player.isMale, currentPlayerStyle.BaseIndex, currentPlayerStyle.FaceIndex, currentPlayerStyle.NoseIndex, currentPlayerStyle.ShoesIndex, currentPlayerStyle.IsBald);
            }
        }
        /// <summary>
        /// FavoriteMenu Constructor.
        /// </summary>
        /// <param name="entry">The instance of ModEntry</param>
        /// <param name="playerLoader">The instance of CharacterLoader</param>
        /// <param name="menu">The instance of the GlamMenu</param>
        public FavoriteMenu(ModEntry entry, CharacterLoader playerLoader, GlamMenu menu)
            : base((int)Utility.getTopLeftPositionForCenteringOnScreen(712, 712, 0, 0).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(712, 712, 0, 0).Y - IClickableMenu.borderWidth, 712, 712, false)
        {
            Entry        = entry;
            PlayerLoader = playerLoader;
            Menu         = menu;

            SetUpMenu();
        }
        /// <summary>FavoriteMenu Constructor</summary>
        /// <param name="entry">The instance of ModEntry</param>
        /// <param name="playerLoader">The instance of CharacterLoader</param>
        /// <param name="menu">The instance of the GlamMenu</param>
        public FavoriteMenu(ModEntry entry, CharacterLoader playerLoader, GlamMenu menu)
            : base((int)Utility.getTopLeftPositionForCenteringOnScreen(712, 712, 0, 0).X, (int)Utility.getTopLeftPositionForCenteringOnScreen(712, 712, 0, 0).Y - IClickableMenu.borderWidth, 712, 712, false)
        {
            //Set the fields
            Entry        = entry;
            PlayerLoader = playerLoader;
            Menu         = menu;

            //Set up the button layouts
            SetUpButtons();
        }
        /// <summary>
        /// Loads a favorite from the favorite list.
        /// </summary>
        /// <param name="whichPosition">The position in the List</param>
        /// <param name="menu">The instance of GlamMenu</param>
        /// <param name="wasFavoriteApplied">Whether the favorite was applied</param>
        public void LoadFavorite(int whichPosition, GlamMenu menu, bool wasFavoriteApplied)
        {
            SetPlayerGender(Favorites[whichPosition].IsMale);

            SetPlayerHairStyle(Favorites[whichPosition].HairIndex);

            SetPlayerAccessory(Favorites[whichPosition].AccessoryIndex);

            SetPlayerSkinColor(Favorites[whichPosition].SkinIndex);

            SetPlayerEyeColor(Favorites[whichPosition].EyeColor);

            SetPlayerHairColor(Favorites[whichPosition].HairColor);

            // Change the player base to the index in the favorites
            PlayerChanger.ChangePlayerBase(
                Favorites[whichPosition].IsMale,
                Favorites[whichPosition].BaseIndex,
                Favorites[whichPosition].FaceIndex,
                Favorites[whichPosition].NoseIndex,
                Favorites[whichPosition].ShoeIndex,
                Favorites[whichPosition].IsBald
                );

            // If the favorite was applied then update the GlamMenu
            if (wasFavoriteApplied)
            {
                menu.UpdateIndexes(
                    Favorites[whichPosition].BaseIndex,
                    Favorites[whichPosition].FaceIndex,
                    Favorites[whichPosition].NoseIndex,
                    Favorites[whichPosition].ShoeIndex,
                    Favorites[whichPosition].IsBald
                    );
            }
        }
        /// <summary>Loads the character layout from a json file</summary>
        /// <param name="menu">The instance of Glam Menu used ti update indexes</param>
        public void LoadCharacterLayout(GlamMenu menu)
        {
            //Read the config
            ConfigModel currentPlayerStyle = Entry.Helper.Data.ReadJsonFile <ConfigModel>(Path.Combine("Saves", $"{Constants.SaveFolderName}_current.json"));

            //Don't try to load if it doesn't find the json
            if (currentPlayerStyle is null)
            {
                return;
            }

            //Update the dresser
            if (Dresser.Texture.Height == 32)
            {
                Dresser.TextureSourceRect.Y = 0;
            }
            else
            {
                Dresser.TextureSourceRect.Y = currentPlayerStyle.DresserIndex.Equals(1) ? 0 : currentPlayerStyle.DresserIndex * 32 - 32;
            }

            Dresser.SetDresserTileSheetPoint(currentPlayerStyle.DresserIndex);

            if (!currentPlayerStyle.IsDefault)
            {
                menu.UpdateIndexes(currentPlayerStyle.BaseIndex, currentPlayerStyle.FaceIndex, currentPlayerStyle.NoseIndex, currentPlayerStyle.ShoesIndex, currentPlayerStyle.IsBald, currentPlayerStyle.DresserIndex);

                //Set the players gender, hair, accessory and skin
                Game1.player.changeGender(currentPlayerStyle.IsMale);
                Game1.player.hair.Set(currentPlayerStyle.HairIndex);
                Game1.player.accessory.Set(currentPlayerStyle.AccessoryIndex);
                Game1.player.FarmerRenderer.recolorSkin(currentPlayerStyle.SkinIndex);

                //Change the color of the hair and the eyes
                Game1.player.newEyeColor.Set(currentPlayerStyle.EyeColor);
                Game1.player.FarmerRenderer.recolorEyes(currentPlayerStyle.EyeColor);
                Game1.player.hairstyleColor.Set(currentPlayerStyle.HairColor);
            }

            //Add the favorites to the favorites list
            if (currentPlayerStyle.Favorites == null || currentPlayerStyle.Favorites.Count == 0)
            {
                FavoriteModel model = new FavoriteModel();
                for (int i = 0; i < 40; i++)
                {
                    currentPlayerStyle.Favorites = new List <FavoriteModel>();
                    currentPlayerStyle.Favorites.Add(model);
                    Favorites.Add(model);
                }
            }
            else
            {
                foreach (FavoriteModel model in currentPlayerStyle.Favorites)
                {
                    Favorites.Add(model);
                }
            }

            //Lastly, change the base, THIS NEEDS TO BE LAST OR ELSE IT WON'T LOAD THE PLAYER STYLE
            if (!currentPlayerStyle.IsDefault)
            {
                PackHelper.ChangePlayerBase(Game1.player.isMale, currentPlayerStyle.BaseIndex, currentPlayerStyle.FaceIndex, currentPlayerStyle.NoseIndex, currentPlayerStyle.ShoesIndex, currentPlayerStyle.IsBald);
            }
        }
Beispiel #7
0
 /// <summary>
 /// Sets The Glam Menu.
 /// </summary>
 /// <param name="menu"></param>
 public void SetMenu(GlamMenu menu)
 {
     Menu = menu;
 }