Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AlternativeTextures/Framework/Patches/PatchTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ internal static string GetTreeTypeString(Tree tree)
case Tree.palmTree2:
return "Palm_2";
default:
return String.Empty;
return tree.treeType.Value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardewValley;
using StardewValley.GameData.GiantCrops;
using StardewValley.TerrainFeatures;
using System;

Expand Down Expand Up @@ -71,7 +72,9 @@ private static bool DrawPrefix(GiantCrop __instance, float ___shakeTimer, Sprite

private static void GiantCropPostfix(GiantCrop __instance)
{
var instanceName = Game1.objectData.ContainsKey(__instance.Id) ? Game1.objectData[__instance.Id].Name : String.Empty;
if (__instance.GetData() is not GiantCropData data)
return;
var instanceName = Game1.objectData.ContainsKey(data.FromItemId) ? Game1.objectData[data.FromItemId].Name : String.Empty;
instanceName = $"{AlternativeTextureModel.TextureType.GiantCrop}_{instanceName}";
var instanceSeasonName = $"{instanceName}_{Game1.GetSeasonForLocation(__instance.Location)}";

Expand Down
134 changes: 68 additions & 66 deletions AlternativeTextures/Framework/UI/PaintBucketMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using StardewValley.BellsAndWhistles;
using StardewValley.Buildings;
using StardewValley.Characters;
using StardewValley.GameData.FloorsAndPaths;
using StardewValley.GameData.GiantCrops;
using StardewValley.Internal;
using StardewValley.Locations;
Expand Down Expand Up @@ -595,13 +596,6 @@ public override void receiveLeftClick(int x, int y, bool playSound = false)
_textureTarget.modData[key] = c.item.modData[key];
}
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is TerrainFeature feature)
{
foreach (string key in c.item.modData.Keys)
{
feature.modData[key] = c.item.modData[key];
}
}
else if (PatchTemplate.GetBuildingAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Building building)
{
foreach (string key in c.item.modData.Keys)
Expand Down Expand Up @@ -640,6 +634,13 @@ public override void receiveLeftClick(int x, int y, bool playSound = false)
PatchTemplate.AssignDefaultModData(farmerHouse, instanceSeasonName, true);
}
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is TerrainFeature feature)
{
foreach (string key in c.item.modData.Keys)
{
feature.modData[key] = c.item.modData[key];
}
}
else if (Game1.currentLocation is DecoratableLocation decoratableLocation && (string.IsNullOrEmpty(decoratableLocation.GetFloorID((int)_position.X, (int)_position.Y)) is false || string.IsNullOrEmpty(decoratableLocation.GetWallpaperID((int)_position.X, (int)_position.Y)) is false))
{
string room;
Expand Down Expand Up @@ -813,42 +814,6 @@ public override void draw(SpriteBatch b)
}
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Tree tree)
{
this.availableTextures[i].texture = tree.texture.Value;
this.availableTextures[i].sourceRect = GetTreeSourceRect(textureModel, tree, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is FruitTree fruitTree)
{
this.availableTextures[i].texture = fruitTree.texture;
this.availableTextures[i].sourceRect = GetFruitTreeSourceRect(textureModel, fruitTree, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Flooring flooring)
{
this.availableTextures[i].texture = Game1.GetSeasonForLocation(flooring.Location) is Season.Winter && (flooring.Location == null || !flooring.Location.isGreenhouse.Value) ? flooring.floorTextureWinter : flooring.floorTexture;
this.availableTextures[i].sourceRect = this.GetFlooringSourceRect(textureModel, flooring, this.availableTextures[i].sourceRect.Height, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is HoeDirt hoeDirt)
{
this.availableTextures[i].texture = Game1.cropSpriteSheet;
this.availableTextures[i].sourceRect = this.GetCropSourceRect(textureModel, hoeDirt.crop, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Grass grass)
{
this.availableTextures[i].texture = grass.texture.Value;
this.availableTextures[i].sourceRect = this.GetGrassSourceRect(textureModel, grass, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Bush bush)
{
this.availableTextures[i].texture = Bush.texture.Value;
this.availableTextures[i].sourceRect = this.GetBushSourceRect(textureModel, bush, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (Game1.currentLocation is Farm farm && farm.GetMainFarmHouse().occupiesTile(new Vector2(_position.X, _position.Y) / 64))
{
var farmerHouse = farm.GetMainFarmHouse();
Expand Down Expand Up @@ -885,6 +850,42 @@ public override void draw(SpriteBatch b)
b.Draw(Game1.mouseCursors, new Vector2(this.availableTextures[i].bounds.X + 4, this.availableTextures[i].bounds.Y - 20), new Rectangle(134, 226, 30, 25), colorOverlay, 0f, Vector2.Zero, _buildingScale, SpriteEffects.None, 1f);
}
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Tree tree)
{
this.availableTextures[i].texture = tree.texture.Value;
this.availableTextures[i].sourceRect = GetTreeSourceRect(textureModel, tree, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is FruitTree fruitTree)
{
this.availableTextures[i].texture = fruitTree.texture;
this.availableTextures[i].sourceRect = GetFruitTreeSourceRect(textureModel, fruitTree, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Flooring flooring)
{
this.availableTextures[i].texture = Game1.GetSeasonForLocation(flooring.Location) is Season.Winter && (flooring.Location == null || !flooring.Location.isGreenhouse.Value) ? flooring.floorTextureWinter : flooring.floorTexture;
this.availableTextures[i].sourceRect = this.GetFlooringSourceRect(textureModel, flooring, this.availableTextures[i].sourceRect.Height, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is HoeDirt hoeDirt)
{
this.availableTextures[i].texture = Game1.cropSpriteSheet;
this.availableTextures[i].sourceRect = this.GetCropSourceRect(textureModel, hoeDirt.crop, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Grass grass)
{
this.availableTextures[i].texture = grass.texture.Value;
this.availableTextures[i].sourceRect = this.GetGrassSourceRect(textureModel, grass, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Bush bush)
{
this.availableTextures[i].texture = Bush.texture.Value;
this.availableTextures[i].sourceRect = this.GetBushSourceRect(textureModel, bush, 0, -1);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (Game1.currentLocation is DecoratableLocation decoratableLocation && (string.IsNullOrEmpty(decoratableLocation.GetFloorID((int)_position.X, (int)_position.Y)) is false || string.IsNullOrEmpty(decoratableLocation.GetWallpaperID((int)_position.X, (int)_position.Y)) is false))
{
var which = variation;
Expand Down Expand Up @@ -924,6 +925,26 @@ public override void draw(SpriteBatch b)
this.availableTextures[i].sourceRect = new Rectangle(0, textureModel.GetTextureOffset(variation), 48, 63);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (Game1.currentLocation is Farm farm && farm.GetMainFarmHouse().occupiesTile(new Vector2(_position.X, _position.Y) / 64))
{
var farmerHouse = farm.GetMainFarmHouse();
var sourceRectangle = BuildingPatch.GetSourceRectReversePatch(farmerHouse);

b.Draw(BuildingPatch.GetBuildingTextureWithPaint(farmerHouse, textureModel, variation, true), new Vector2(this.availableTextures[i].bounds.X, this.availableTextures[i].bounds.Y), new Rectangle(0, 0, sourceRectangle.Width, sourceRectangle.Height), farmerHouse.color, 0f, new Vector2(0f, 0f), _buildingScale, SpriteEffects.None, 0.89f);
}
else if (Game1.currentLocation is Farm mailBoxFarm && mailBoxFarm.GetMainMailboxPosition() is Point mailboxPosition && PatchTemplate.IsPositionNearMailbox(Game1.currentLocation, mailboxPosition, (int)(_position.X / 64), (int)(_position.Y / 64)))
{
b.Draw(textureModel.GetTexture(variation), new Vector2(this.availableTextures[i].bounds.X, this.availableTextures[i].bounds.Y), new Rectangle(0, textureModel.GetTextureOffset(variation), 16, 32), Color.White, 0f, new Vector2(0f, 0f), 4f, SpriteEffects.None, 0.89f);
}
else if (PatchTemplate.GetBuildingAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Building building)
{
BuildingPatch.CondensedDrawInMenu(building, BuildingPatch.GetBuildingTextureWithPaint(building, textureModel, variation), b, this.availableTextures[i].bounds.X, this.availableTextures[i].bounds.Y, _buildingScale);

if (building is ShippingBin shippingBin)
{
b.Draw(textureModel.GetTexture(variation), new Vector2(this.availableTextures[i].bounds.X + 4, this.availableTextures[i].bounds.Y - 20), new Rectangle(32, textureModel.GetTextureOffset(variation), 30, 25), colorOverlay, 0f, Vector2.Zero, _buildingScale, SpriteEffects.None, 1f);
}
}
else if (PatchTemplate.GetTerrainFeatureAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Tree tree)
{
this.availableTextures[i].texture = textureModel.GetTexture(variation);
Expand Down Expand Up @@ -960,26 +981,6 @@ public override void draw(SpriteBatch b)
this.availableTextures[i].sourceRect = this.GetBushSourceRect(textureModel, bush, textureModel.TextureHeight, variation);
this.availableTextures[i].draw(b, colorOverlay, 0.87f);
}
else if (Game1.currentLocation is Farm farm && farm.GetMainFarmHouse().occupiesTile(new Vector2(_position.X, _position.Y) / 64))
{
var farmerHouse = farm.GetMainFarmHouse();
var sourceRectangle = BuildingPatch.GetSourceRectReversePatch(farmerHouse);

b.Draw(BuildingPatch.GetBuildingTextureWithPaint(farmerHouse, textureModel, variation, true), new Vector2(this.availableTextures[i].bounds.X, this.availableTextures[i].bounds.Y), new Rectangle(0, 0, sourceRectangle.Width, sourceRectangle.Height), farmerHouse.color, 0f, new Vector2(0f, 0f), _buildingScale, SpriteEffects.None, 0.89f);
}
else if (Game1.currentLocation is Farm mailBoxFarm && mailBoxFarm.GetMainMailboxPosition() is Point mailboxPosition && PatchTemplate.IsPositionNearMailbox(Game1.currentLocation, mailboxPosition, (int)(_position.X / 64), (int)(_position.Y / 64)))
{
b.Draw(textureModel.GetTexture(variation), new Vector2(this.availableTextures[i].bounds.X, this.availableTextures[i].bounds.Y), new Rectangle(0, textureModel.GetTextureOffset(variation), 16, 32), Color.White, 0f, new Vector2(0f, 0f), 4f, SpriteEffects.None, 0.89f);
}
else if (PatchTemplate.GetBuildingAt(Game1.currentLocation, (int)_position.X, (int)_position.Y) is Building building)
{
BuildingPatch.CondensedDrawInMenu(building, BuildingPatch.GetBuildingTextureWithPaint(building, textureModel, variation), b, this.availableTextures[i].bounds.X, this.availableTextures[i].bounds.Y, _buildingScale);

if (building is ShippingBin shippingBin)
{
b.Draw(textureModel.GetTexture(variation), new Vector2(this.availableTextures[i].bounds.X + 4, this.availableTextures[i].bounds.Y - 20), new Rectangle(32, textureModel.GetTextureOffset(variation), 30, 25), colorOverlay, 0f, Vector2.Zero, _buildingScale, SpriteEffects.None, 1f);
}
}
else if (Game1.currentLocation is DecoratableLocation decoratableLocation && (string.IsNullOrEmpty(decoratableLocation.GetFloorID((int)_position.X, (int)_position.Y)) is false || string.IsNullOrEmpty(decoratableLocation.GetWallpaperID((int)_position.X, (int)_position.Y)) is false))
{
var isFloor = _modelName.Contains("Floor");
Expand Down Expand Up @@ -1095,7 +1096,6 @@ private static Rectangle GetFenceSourceRect(AlternativeTextureModel textureModel

private Rectangle GetFlooringSourceRect(AlternativeTextureModel textureModel, Flooring flooring, int textureHeight, int variation)
{
int sourceRectOffset = variation == -1 ? int.Parse(flooring.whichFloor.Value) * 4 * 64 : textureModel.GetTextureOffset(variation);
byte drawSum = 0;
Vector2 surroundingLocations = flooring.Tile;
surroundingLocations.X += 1f;
Expand Down Expand Up @@ -1124,9 +1124,11 @@ private Rectangle GetFlooringSourceRect(AlternativeTextureModel textureModel, Fl

if (variation == -1)
{
return new Rectangle(int.Parse(flooring.whichFloor.Value) % 4 * 64 + sourceRectPosition * 16 % 256, sourceRectPosition / 16 * 16 + int.Parse(flooring.whichFloor.Value) / 4 * 64, 16, 16);
Point textureCorner = flooring.GetTextureCorner();
return new Rectangle(textureCorner.X + sourceRectPosition % 16 * 16, textureCorner.Y + sourceRectPosition / 16 * 16, 16, 16);
}

int sourceRectOffset = textureModel?.GetTextureOffset(variation) ?? 0;
return new Rectangle(sourceRectPosition % 16 * 16, sourceRectPosition / 16 * 16 + sourceRectOffset, 16, 16);
}

Expand Down Expand Up @@ -1216,4 +1218,4 @@ private Rectangle GetCharacterSourceRectangle(AlternativeTextureModel textureMod
return sourceRect;
}
}
}
}