/// <summary> /// Updates Dresser SourceRect and Sets TileSheetPoint. /// </summary> /// <param name="dresserIndex">Index of the Dresser.</param> private void UpdateDresser(int dresserIndex) { if (Dresser.PackHelper.DresserTextureHeight == 32) { Dresser.TextureSourceRect.Y = 0; } else { Dresser.TextureSourceRect.Y = dresserIndex * 32 - 32; } Dresser.SetDresserTileSheetPoint(dresserIndex); Dresser.UpdateDresserInFarmHouse(); }
/// <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); } }
/// <summary>Handles which index to move and by what direction</summary> /// <param name="name">The name of the button</param> /// <param name="direction">Which direction to move the indexes</param> private void SelectionClick(string name, int direction) { //Switch statement of the different button names switch (name) { case "LeftBase": if (!NewLeftButtonsList[0].visible) { return; } if (BaseIndex + direction > -1) { BaseIndex += direction; } else { BaseIndex = Game1.player.isMale ? PackHelper.MaleBaseTextureList.Count : PackHelper.FemaleBaseTextureList.Count; } FaceIndex = 0; NoseIndex = 0; PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "RightBase": if (!NewRightButtonsList[0].visible) { return; } if (BaseIndex + direction > (Game1.player.isMale ? PackHelper.MaleBaseTextureList.Count : PackHelper.FemaleBaseTextureList.Count)) { BaseIndex = 0; } else { BaseIndex += direction; } FaceIndex = 0; NoseIndex = 0; PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "LeftNose": if (NoseIndex + direction > -1) { NoseIndex += direction; } else { NoseIndex = PackHelper.GetNumberOfFacesAndNoses(Game1.player.isMale, BaseIndex, false); } PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "RightNose": if (NoseIndex + direction > PackHelper.GetNumberOfFacesAndNoses(Game1.player.isMale, BaseIndex, false)) { NoseIndex = 0; } else { NoseIndex += direction; } PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "LeftFace": if (FaceIndex + direction > -1) { FaceIndex += direction; } else { FaceIndex = PackHelper.GetNumberOfFacesAndNoses(Game1.player.isMale, BaseIndex, true); } PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "RightFace": if (FaceIndex + direction > PackHelper.GetNumberOfFacesAndNoses(Game1.player.isMale, BaseIndex, true)) { FaceIndex = 0; } else { FaceIndex += direction; } PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "LeftShoe": if (ShoeIndex + direction > -1) { ShoeIndex += direction; } else { ShoeIndex = Game1.player.isMale ? PackHelper.MaleShoeTextureList.Count: PackHelper.FemaleShoeTextureList.Count; } PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "RightShoe": if (ShoeIndex + direction > (Game1.player.isMale ? PackHelper.MaleShoeTextureList.Count : PackHelper.FemaleShoeTextureList.Count)) { ShoeIndex = 0; } else { ShoeIndex += direction; } PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "LeftDresser": if (!NewLeftButtonsList[7].visible) { return; } if (DresserIndex + direction > 0) { DresserIndex += direction; } else { DresserIndex = Dresser.GetNumberOfDressers(); } //Change the Dressers source rect and update the dresser in the farmhouse Dresser.TextureSourceRect.Y = DresserIndex.Equals(1) ? 0 : DresserIndex * 32 - 32; Dresser.SetDresserTileSheetPoint(DresserIndex); Dresser.UpdateDresserInFarmHouse(); break; case "RightDresser": if (!NewRightButtonsList[7].visible) { return; } if (DresserIndex + direction <= Dresser.GetNumberOfDressers()) { DresserIndex += direction; } else { DresserIndex = 1; } //Change the Dressers source rect and update the dresser in the farmhouse Dresser.TextureSourceRect.Y = DresserIndex.Equals(1) ? 0 : DresserIndex * 32 - 32; Dresser.SetDresserTileSheetPoint(DresserIndex); Dresser.UpdateDresserInFarmHouse(); break; case "Male": Game1.player.changeGender(true); //Reset the BaseIndex, ShoeIndex to prevent crashing BaseIndex = 0; ShoeIndex = 0; PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "Female": Game1.player.changeGender(false); //Reset the BaseIndex, ShoeIndex to prevent crashing BaseIndex = 0; ShoeIndex = 0; PackHelper.ChangePlayerBase(Game1.player.isMale, BaseIndex, FaceIndex, NoseIndex, ShoeIndex, IsBald); break; case "LeftChangeHair": if (Game1.player.hair.Get().Equals(0) && PackHelper.NumberOfHairstlyesAdded == 56) { Game1.player.hair.Set(FarmerRenderer.hairStylesTexture.Height / 96 * 8 - 1); } else if (Game1.player.hair.Get().Equals(0) && PackHelper.NumberOfHairstlyesAdded != 56) { Game1.player.hair.Set(PackHelper.NumberOfHairstlyesAdded - 1); } else { Game1.player.hair.Set(Game1.player.hair.Value + direction); } break; case "RightChangeHair": if (PackHelper.NumberOfHairstlyesAdded == 56 && Game1.player.hair.Value + 1 > FarmerRenderer.hairStylesTexture.Height / 96 * 8 - 1) { Game1.player.hair.Set(0); } else if (PackHelper.NumberOfHairstlyesAdded != 56 && Game1.player.hair.Value.Equals(PackHelper.NumberOfHairstlyesAdded - 1)) { Game1.player.hair.Set(0); } else { Game1.player.hair.Set(Game1.player.hair.Value + direction); } break; case "LeftChangeSkin": case "RightChangeSkin": Game1.player.changeSkinColor(Game1.player.skin.Value + direction); break; case "LeftChangeAcc": case "RightChangeAcc": Game1.player.changeAccessory(Game1.player.accessory.Value + direction); break; case "LeftDirection": case "RightDirection": Game1.player.faceDirection((Game1.player.FacingDirection - direction + 4) % 4); Game1.player.FarmerSprite.StopAnimation(); Game1.player.completelyStopAnimatingOrDoingAction(); break; } }