diff --git a/Revitalize/Revitalize/Revitalize/Aesthetics/Paint/Objects/Canvas.cs b/Revitalize/Revitalize/Revitalize/Aesthetics/Paint/Objects/Canvas.cs new file mode 100644 index 00000000..d50d1834 --- /dev/null +++ b/Revitalize/Revitalize/Revitalize/Aesthetics/Paint/Objects/Canvas.cs @@ -0,0 +1,1008 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Revitalize.Resources; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Menus; +using StardewValley.Objects; +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; + +namespace Revitalize.Objects +{ + /// + /// Original Stardew Furniture Class but rewritten to be placed anywhere. + /// + public class Canvas : CoreObject + { + public new bool flipped; + + [XmlIgnore] + public bool flaggedForPickUp; + + private bool lightGlowAdded; + + public string texturePath; + + public bool isPainted; + + public static string blankTexture = Path.Combine("Revitalize", "Paint", "ModAssets", "blankPixel"); + public static string whiteTexture = Path.Combine("Revitalize", "Paint", "ModAssets", "whitePixel"); + + public override string Name + { + get + { + return this.name; + } + set + { + this.name = value; + } + } + + public Canvas() + { + this.updateDrawPosition(); + } + + public Canvas(bool f) + { + //does nothng + } + + public Canvas(int which, Vector2 tile, string TexturePath) + { + + this.tileLocation = tile; + this.InitializeBasics(0, tile); + if (TextureSheet == null) + { + TextureSheet = Game1.content.Load(TexturePath); + texturePath = TexturePath; + } + Dictionary dictionary = Game1.content.Load>("Data\\Furniture"); + string[] array = dictionary[which].Split(new char[] + { + '/' + }); + this.name = array[0]; + this.Decoration_type = this.getTypeNumberFromName(array[1]); + this.description = "Can be placed inside your house."; + this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 1, 1); + if (array[2].Equals("-1")) + { + this.sourceRect = this.getDefaultSourceRectForType(which, this.Decoration_type); + this.defaultSourceRect = this.sourceRect; + } + else + { + this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[0]); + this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[] + { + ' ' + })[1]); + this.sourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); + this.defaultSourceRect = this.sourceRect; + } + this.defaultBoundingBox = new Rectangle((int)this.tileLocation.X, (int)this.tileLocation.Y, 1, 1); + if (array[3].Equals("-1")) + { + this.boundingBox = this.getDefaultBoundingBoxForType(this.Decoration_type); + this.defaultBoundingBox = this.boundingBox; + } + else + { + this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[0]); + this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[] + { + ' ' + })[1]); + this.boundingBox = new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize); + this.defaultBoundingBox = this.boundingBox; + } + this.updateDrawPosition(); + this.rotations = Convert.ToInt32(array[4]); + this.price = Convert.ToInt32(array[5]); + this.parentSheetIndex = which; + } + + public override string getDescription() + { + return this.description; + } + + public override bool performDropDownAction(Farmer who) + { + this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation); + return false; + } + + public override void hoverAction() + { + base.hoverAction(); + if (!Game1.player.isInventoryFull()) + { + Game1.mouseCursor = 2; + } + } + + public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) + { + var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) + { + //ACTIVATE PAINT MODE HERE!!! + Game1.activeClickableMenu = new Revitalize.Menus.PaintMenu(this); + // Game1.showRedMessage("YOOO"); + //do some stuff when the right button is down + // Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(this.inventory); + // rotate(); + // Game1.playSound("coin"); + return true; + } + else + { + //Game1.showRedMessage("CRY"); + } + + if (justCheckingForActivity) + { + return true; + } + + return this.clicked(who); + } + + public override bool clicked(Farmer who) + { + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + Game1.haltAfterCheck = false; + if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) + { + // Game1.showRedMessage("Why1?"); + return false; + } + if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Canvas))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // Game1.showRedMessage("Why2?"); + //this.heldObject = new Canvas(parentSheetIndex, Vector2.Zero); + Util.addItemToInventoryAndCleanTrackedList(this); + this.flaggedForPickUp = true; + this.thisLocation = null; + return true; + } + else + { + // return true; + + this.flaggedForPickUp = true; + if (this is TV) + { + this.heldObject = new TV(parentSheetIndex, Vector2.Zero); + } + else + { + // this.heldObject = new Canvas(parentSheetIndex, Vector2.Zero); + Util.addItemToInventoryAndCleanTrackedList(this); + // this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + // this.heldObject = null; + Game1.playSound("coin"); + this.thisLocation = null; + return true; + } + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Util.addItemToInventoryAndCleanTrackedList(this); + Game1.playSound("coin"); + this.thisLocation = null; + return true; + } + + + + return false; + } + + public override void DayUpdate(GameLocation location) + { + base.DayUpdate(location); + this.lightGlowAdded = false; + if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining)) + { + this.removeLights(location); + return; + } + this.addLights(location); + } + + public void resetOnPlayerEntry(GameLocation environment) + { + this.removeLights(environment); + if (Game1.isDarkOut()) + { + this.addLights(environment); + } + } + + public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, Farmer who) + { + if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is Canvas) || ((dropIn as Canvas).getTilesWide() == 1 && (dropIn as Canvas).getTilesHigh() == 1))) + { + this.heldObject = (StardewValley.Object)dropIn.getOne(); + this.heldObject.tileLocation = this.tileLocation; + this.heldObject.boundingBox.X = this.boundingBox.X; + this.heldObject.boundingBox.Y = this.boundingBox.Y; + // Log.AsyncO(getDefaultBoundingBoxForType((dropIn as Canvas).Decoration_type)); + this.heldObject.performDropDownAction(who); + if (!probe) + { + Game1.playSound("woodyStep"); + // Log.AsyncC("HUH?"); + if (who != null) + { + who.reduceActiveItemByOne(); + } + } + return true; + } + return false; + } + + private void addLights(GameLocation environment) + { + // this.lightSource.lightTexture = Game1.content.Load("LooseSprites\\Lighting\\lantern"); + + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightSource == null) + { + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, Color.Black, (int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + Game1.currentLightSources.Add(this.lightSource); + return; + } + } + else if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 0) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + } + this.sourceIndexOffset = 1; + if (this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + } + } + + private void removeLights(GameLocation environment) + { + if (this.Decoration_type == 7) + { + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + Utility.removeLightSource((int)(this.tileLocation.X * 2000f + this.tileLocation.Y)); + this.lightSource = null; + return; + } + if (this.Decoration_type == 13) + { + if (this.sourceIndexOffset == 1) + { + this.sourceRect = this.defaultSourceRect; + } + this.sourceIndexOffset = 0; + if (Game1.isRaining) + { + this.sourceRect = this.defaultSourceRect; + this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; + this.sourceIndexOffset = 1; + return; + } + if (!this.lightGlowAdded && !environment.lightGlows.Contains(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)))) + { + environment.lightGlows.Add(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + } + this.lightGlowAdded = true; + } + } + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + if (Game1.isDarkOut()) + { + this.addLights(environment); + } + else + { + this.removeLights(environment); + } + return false; + } + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + this.removeLights(environment); + if (this.Decoration_type == 13 && this.lightGlowAdded) + { + environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); + this.lightGlowAdded = false; + } + base.performRemoveAction(tileLocation, environment); + } + + public void rotate() + { + if (this.rotations < 2) + { + return; + } + int num = (this.rotations == 4) ? 1 : 2; + this.currentRotation += num; + this.currentRotation %= 4; + this.flipped = false; + Point point = default(Point); + int num2 = this.Decoration_type; + switch (num2) + { + case 2: + point.Y = 1; + point.X = -1; + break; + case 3: + point.X = -1; + point.Y = 1; + break; + case 4: + break; + case 5: + point.Y = 0; + point.X = -1; + break; + default: + if (num2 == 12) + { + point.X = 0; + point.Y = 0; + } + break; + } + bool flag = this.Decoration_type == 5 || this.Decoration_type == 12 || this.parentSheetIndex == 724 || this.parentSheetIndex == 727; + bool flag2 = this.defaultBoundingBox.Width != this.defaultBoundingBox.Height; + if (flag && this.currentRotation == 2) + { + this.currentRotation = 1; + } + if (flag2) + { + int height = this.boundingBox.Height; + switch (this.currentRotation) + { + case 0: + case 2: + this.boundingBox.Height = this.defaultBoundingBox.Height; + this.boundingBox.Width = this.defaultBoundingBox.Width; + break; + case 1: + case 3: + this.boundingBox.Height = this.boundingBox.Width + point.X * Game1.tileSize; + this.boundingBox.Width = height + point.Y * Game1.tileSize; + break; + } + } + Point point2 = default(Point); + int num3 = this.Decoration_type; + if (num3 == 12) + { + point2.X = 1; + point2.Y = -1; + } + if (flag2) + { + switch (this.currentRotation) + { + case 0: + this.sourceRect = this.defaultSourceRect; + break; + case 1: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); + break; + case 2: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width + this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + break; + case 3: + this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); + this.flipped = true; + break; + } + } + else + { + this.flipped = (this.currentRotation == 3); + if (this.rotations == 2) + { + this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 2) ? 1 : 0) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + } + else + { + this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 3) ? 1 : this.currentRotation) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); + } + } + if (flag && this.currentRotation == 1) + { + this.currentRotation = 2; + } + this.updateDrawPosition(); + } + + public bool isGroundFurniture() + { + return this.Decoration_type != 13 && this.Decoration_type != 6 && this.Decoration_type != 13; + } + + public override bool canBeGivenAsGift() + { + return false; + } + + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + if ((l is FarmHouse)) + { + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + foreach (KeyValuePair something in l.objects) + { + StardewValley.Object obj = something.Value; + if ((obj.GetType()).ToString().Contains("Canvas")) + { + Canvas current = (Canvas)obj; + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + } + } + } + return base.canBePlacedHere(l, tile); + } + else + { + // Game1.showRedMessage("NOT FARMHOUSE"); + for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++) + { + for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++) + { + Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize; + vector.X += (float)(Game1.tileSize / 2); + vector.Y += (float)(Game1.tileSize / 2); + /* + foreach (Canvas current in (l as FarmHouse).Canvas) + { + if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1) + { + bool result = true; + return result; + } + if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y)) + { + bool result = false; + return result; + } + } + */ + } + } + return base.canBePlacedHere(l, tile); + } + } + + public void updateDrawPosition() + { + this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height))); + } + + public int getTilesWide() + { + return this.boundingBox.Width / Game1.tileSize; + } + + public int getTilesHigh() + { + return this.boundingBox.Height / Game1.tileSize; + } + + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + // Log.AsyncC(x); + // Log.AsyncM(y); + if (isPainted == false) + { + Game1.activeClickableMenu = new Revitalize.Menus.PaintMenu(this); + + return false; + } + + if (location is FarmHouse) + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + foreach (KeyValuePair c in location.objects) + { + StardewValley.Object ehh = c.Value; + if (((ehh.GetType()).ToString()).Contains("Canvas")) + { + Canvas current2 = (Canvas)ehh; + if (current2.Decoration_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + } + foreach (Farmer current3 in location.getFarmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + + for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++) + { + base.placementAction(location, x + 1, y, who); + } + for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++) + { + base.placementAction(location, x, y + 1, who); + } + return true; + } + else + { + Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); + // List walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); + this.tileLocation = new Vector2((float)point.X, (float)point.Y); + bool flag = false; + if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293) + { + int num = (this.parentSheetIndex == 1293) ? 3 : 0; + bool flag2 = false; + /* + foreach (Rectangle current in walls) + { + if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num)) + { + flag2 = true; + break; + } + } + */ + if (!flag2) + { + Game1.showRedMessage("Must be placed on wall"); + return false; + } + flag = true; + } + for (int i = point.X; i < point.X + this.getTilesWide(); i++) + { + for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++) + { + if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null) + { + Game1.showRedMessage("Furniture can't be placed here"); + return false; + } + /* + if (!flag && Utility.pointInRectangles(walls, i, j)) + { + Game1.showRedMessage("Can't place on wall"); + return false; + } + */ + if (location.getTileIndexAt(i, j, "Buildings") != -1) + { + return false; + } + } + } + this.boundingBox = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + /* + foreach (Furniture current2 in (location as FarmHouse).furniture) + { + if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox)) + { + current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); + bool result = true; + return result; + } + } + */ + foreach (Farmer current3 in location.getFarmers()) + { + if (current3.GetBoundingBox().Intersects(this.boundingBox)) + { + Game1.showRedMessage("Can't place on top of a person."); + bool result = false; + return result; + } + } + this.updateDrawPosition(); + this.thisLocation = Game1.player.currentLocation; + return Util.placementAction(this, location, x, y, who); + } + + } + + public override bool isPlaceable() + { + return true; + } + + public override Rectangle getBoundingBox(Vector2 tileLocation) + { + return this.boundingBox; + } + + private Rectangle getDefaultSourceRectForType(int tileIndex, int type) + { + int num; + int num2; + switch (type) + { + case 0: + num = 1; + num2 = 2; + goto IL_94; + case 1: + num = 2; + num2 = 2; + goto IL_94; + case 2: + num = 3; + num2 = 2; + goto IL_94; + case 3: + num = 2; + num2 = 2; + goto IL_94; + case 4: + num = 2; + num2 = 2; + goto IL_94; + case 5: + num = 5; + num2 = 3; + goto IL_94; + case 6: + num = 2; + num2 = 2; + goto IL_94; + case 7: + num = 1; + num2 = 3; + goto IL_94; + case 8: + num = 1; + num2 = 2; + goto IL_94; + case 10: + num = 2; + num2 = 3; + goto IL_94; + case 11: + num = 2; + num2 = 3; + goto IL_94; + case 12: + num = 3; + num2 = 2; + goto IL_94; + case 13: + num = 1; + num2 = 2; + goto IL_94; + } + num = 1; + num2 = 2; + IL_94: + return new Rectangle(tileIndex * 16 % TextureSheet.Width, tileIndex * 16 / TextureSheet.Width * 16, num * 16, num2 * 16); + } + + private Rectangle getDefaultBoundingBoxForType(int type) + { + int num; + int num2; + switch (type) + { + case 0: + num = 1; + num2 = 1; + goto IL_94; + case 1: + num = 2; + num2 = 1; + goto IL_94; + case 2: + num = 3; + num2 = 1; + goto IL_94; + case 3: + num = 2; + num2 = 1; + goto IL_94; + case 4: + num = 2; + num2 = 1; + goto IL_94; + case 5: + num = 5; + num2 = 2; + goto IL_94; + case 6: + num = 2; + num2 = 2; + goto IL_94; + case 7: + num = 1; + num2 = 1; + goto IL_94; + case 8: + num = 1; + num2 = 1; + goto IL_94; + case 10: + num = 2; + num2 = 1; + goto IL_94; + case 11: + num = 2; + num2 = 2; + goto IL_94; + case 12: + num = 3; + num2 = 2; + goto IL_94; + case 13: + num = 1; + num2 = 2; + goto IL_94; + } + num = 1; + num2 = 1; + IL_94: + return new Rectangle((int)this.tileLocation.X * Game1.tileSize, (int)this.tileLocation.Y * Game1.tileSize, num * Game1.tileSize, num2 * Game1.tileSize); + } + + private int getTypeNumberFromName(string typeName) + { + string key; + switch (key = typeName.ToLower()) + { + case "chair": + return 0; + case "bench": + return 1; + case "couch": + return 2; + case "armchair": + return 3; + case "dresser": + return 4; + case "long table": + return 5; + case "painting": + return 6; + case "lamp": + return 7; + case "decor": + return 8; + case "bookcase": + return 10; + case "table": + return 11; + case "rug": + return 12; + case "window": + return 13; + } + return 9; + } + + public override int salePrice() + { + return this.price; + } + + public override int maximumStackSize() + { + return 1; + } + + public override int getStack() + { + return this.stack; + } + + public override int addToStack(int amount) + { + return 1; + } + + private float getScaleSize() + { + int num = this.sourceRect.Width / 16; + int num2 = this.sourceRect.Height / 16; + if (num >= 5) + { + return 0.75f; + } + if (num2 >= 3) + { + return 1f; + } + if (num <= 2) + { + return 2f; + } + if (num <= 4) + { + return 1f; + } + return 0.1f; + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber) + { + spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), this.drawColor * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize, SpriteEffects.None, layerDepth); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) + { + if (x == -1) + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + else + { + spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)))), new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); + } + if (this.heldObject != null) + { + if (this.heldObject is Canvas) + { + (this.heldObject as Canvas).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as Canvas).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha); + return; + } + spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), this.drawColor * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f); + spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f); + } + } + + public void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) + { + spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); + } + + public override Item getOne() + { + Canvas Canvas = new Canvas(this.parentSheetIndex, this.tileLocation, this.texturePath); + + /* + drawPosition = this.drawPosition; + defaultBoundingBox = this.defaultBoundingBox; + boundingBox = this.boundingBox; + currentRotation = this.currentRotation - 1; + rotations = this.rotations; + rotate(); + */ + return Canvas; + } + + public override string getCategoryName() + { + return "Canvas"; + // return base.getCategoryName(); + } + + public override Color getCategoryColor() + { + return Util.invertColor(LightColors.Indigo); + } + } +} diff --git a/Revitalize/Revitalize/Revitalize/Aesthetics/Paint/PaintMenu.cs b/Revitalize/Revitalize/Revitalize/Aesthetics/Paint/PaintMenu.cs new file mode 100644 index 00000000..260163fb --- /dev/null +++ b/Revitalize/Revitalize/Revitalize/Aesthetics/Paint/PaintMenu.cs @@ -0,0 +1,545 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using StardewValley; +using StardewValley.Menus; +using StardewValley.Minigames; +using System.Collections.Generic; +using System.Linq; +using System; +using Revitalize.Objects; +using StardewModdingAPI; + +namespace Revitalize.Menus +{ + public class Pixel + { + public Color color; + public ClickableTextureComponent component; + + public Pixel(ClickableTextureComponent newComponent, Color newColor) + { + component = newComponent; + color = newColor; + } + + public Pixel(ClickableTextureComponent newComponent, int Red = 255, int Green = 255, int Blue = 255, int Alpha = 255) + { + component = newComponent; + color = new Color(Red, Green, Blue, Alpha); + } + } + + + public class PaintMenu : IClickableMenu + { + public const int colorPickerTimerDelay = 100; + + private int colorPickerTimer; + + private ColorPicker lightColorPicker; + + private List labels = new List(); + + private List leftSelectionButtons = new List(); + + private List rightSelectionButtons = new List(); + + public List pixels = new List(); + + + public bool colorChanged; + + private ClickableTextureComponent okButton; + + private ClickableTextureComponent cancelButton; + + private ClickableTextureComponent randomButton; + + private TextBox nameBox; + + private TextBox farmnameBox; + + private TextBox favThingBox; + + private bool skipIntro; + + private bool wizardSource; + + private string hoverText; + + private string hoverTitle; + + private ColorPicker lastHeldColorPicker; + + public Canvas CanvasObject; + + private int timesRandom; + + public bool once; + + public PaintMenu(Canvas Obj) : base(Game1.viewport.Width / 2 - (632 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 - Game1.tileSize, 632 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2 + Game1.tileSize, false) + { + this.setUpPositions(); + this.CanvasObject = Obj; + colorChanged = false; + // this.height = this.height ; + } + + public override void gameWindowSizeChanged(Rectangle oldBounds, Rectangle newBounds) + { + base.gameWindowSizeChanged(oldBounds, newBounds); + this.xPositionOnScreen = Game1.viewport.Width / 2 - (632 + IClickableMenu.borderWidth * 2) / 2; + this.yPositionOnScreen = Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2 - Game1.tileSize; + this.setUpPositions(); + } + + private void setUpPositions() + { + + this.labels.Clear(); + + this.leftSelectionButtons.Clear(); + this.rightSelectionButtons.Clear(); + this.pixels = new List(); + this.okButton = new ClickableTextureComponent("OK", new Rectangle(this.xPositionOnScreen + this.width - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize, (this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 4) / 3, Game1.tileSize, Game1.tileSize), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false); + + this.cancelButton = new ClickableTextureComponent("Cancel", new Rectangle(this.xPositionOnScreen + this.width / 4 - IClickableMenu.borderWidth - IClickableMenu.spaceToClearSideBorder - Game1.tileSize, (this.yPositionOnScreen + this.height - IClickableMenu.borderWidth - IClickableMenu.spaceToClearTopBorder + Game1.tileSize / 4) / 3, Game1.tileSize, Game1.tileSize), null, null, Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47, -1, -1), 1f, false); + this.randomButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.pixelZoom * 12, this.yPositionOnScreen + Game1.tileSize + Game1.pixelZoom * 14, Game1.pixelZoom * 10, Game1.pixelZoom * 10), Game1.mouseCursors, new Rectangle(381, 361, 10, 10), (float)Game1.pixelZoom, false); + int num = Game1.tileSize * 2; + this.leftSelectionButtons.Add(new ClickableTextureComponent("Direction", new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize / 4, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + num, Game1.tileSize, Game1.tileSize), null, "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 44, -1, -1), 1f, false)); + this.rightSelectionButtons.Add(new ClickableTextureComponent("Direction", new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 2, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + num, Game1.tileSize, Game1.tileSize), null, "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 33, -1, -1), 1f, false)); + if (!this.wizardSource) + { + //this.labels.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 + 8, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 8 + Game1.tileSize * 3, 1, 1), Game1.content.LoadString("Strings\\UI:Character_Animal", new object[0]))); + } + this.labels.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize / 4 + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth + Game1.tileSize * 3 + 8, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder + 16, 1, 1), "Color")); + this.lightColorPicker = new ColorPicker(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + Game1.tileSize * 5 + Game1.tileSize * 3 / 4 + IClickableMenu.borderWidth, this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder); + num += Game1.tileSize + 8; + for(int x=1; x<=8; x++) + { + for(int y=1; y<=8; y++) + { + this.pixels.Add(new Pixel(new ClickableTextureComponent("pixel", new Rectangle((int)(this.xPositionOnScreen*1.2f) + ((Game1.tileSize/2) * x),(int)( this.yPositionOnScreen *-2.0f)+ ((Game1.tileSize/2) * y) , Game1.tileSize/2, Game1.tileSize/2), null, null, Game1.content.Load(Canvas.whiteTexture), new Rectangle(0, 0, 8, 8), 4f, false), Color.White)); + } + + } + + + once = false; + this.lightColorPicker.setColor(Color.White); + } + + private void optionButtonClick(string name) + { + + if (name == "Cancel") + { + Game1.exitActiveMenu(); + return; + } + + if (name == "OK") + { + if (colorChanged == false) + { + Game1.exitActiveMenu(); + return; + } + // StardewModdingAPI.Log.AsyncC(this.LightObject.lightColor); + + this.lightColorPicker.setColor(CanvasObject.drawColor); + + // StardewModdingAPI.Log.AsyncC(this.LightObject.lightColor); + + + //UTIL FUNCTION TO GET CORRECT COLOR + CanvasObject.drawColor = this.lightColorPicker.getSelectedColor(); + //LightObject.lightColor = Util.invertColor(LightObject.lightColor); + + if (!this.canLeaveMenu()) + { + return; + } + //Game1.player.Name = this.nameBox.Text.Trim(); + // Game1.player.favoriteThing = this.favThingBox.Text.Trim(); + + this.CanvasObject.isPainted = true; + Game1.exitActiveMenu(); + if (Game1.currentMinigame != null && Game1.currentMinigame is Intro) + { + (Game1.currentMinigame as Intro).doneCreatingCharacter(); + } + else if (this.wizardSource) + { + Game1.flashAlpha = 1f; + Game1.playSound("yoba"); + } + + } + + Game1.playSound("coin"); + } + + + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + using (List.Enumerator enumerator = pixels.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + ClickableTextureComponent clickableTextureComponent3 = (ClickableTextureComponent)enumerator.Current.component; + if (clickableTextureComponent3.containsPoint(x, y)) + { + enumerator.Current.color = lightColorPicker.getSelectedColor(); + // Log.AsyncM("WOOOOOO"); + // clickableTextureComponent3.scale = Math.Min(clickableTextureComponent3.scale + 0.02f, clickableTextureComponent3.baseScale + 0.1f); + } + else + { + + // clickableTextureComponent3.scale = Math.Max(clickableTextureComponent3.scale - 0.02f, clickableTextureComponent3.baseScale); + } + } + } + + if (this.okButton.containsPoint(x, y) && this.canLeaveMenu()) + { + this.optionButtonClick(this.okButton.name); + this.okButton.scale -= 0.25f; + this.okButton.scale = Math.Max(0.75f, this.okButton.scale); + } + + if (this.cancelButton.containsPoint(x, y)) + { + this.optionButtonClick(this.cancelButton.name); + this.cancelButton.scale -= 0.25f; + this.cancelButton.scale = Math.Max(0.75f, this.cancelButton.scale); + } + + else if (this.lightColorPicker.containsPoint(x, y)) + { + + CanvasObject.drawColor = this.lightColorPicker.click(x, y); + CanvasObject.drawColor = Util.invertColor(CanvasObject.drawColor); + // LightObject.lightColor = Util.invertColor(LightObject.lightColor); + this.lastHeldColorPicker = this.lightColorPicker; + colorChanged = true; + } + + if (this.randomButton.containsPoint(x, y)) + { + string cueName = "drumkit6"; + if (this.timesRandom > 0) + { + switch (Game1.random.Next(15)) + { + case 0: + cueName = "drumkit1"; + break; + case 1: + cueName = "dirtyHit"; + break; + case 2: + cueName = "axchop"; + break; + case 3: + cueName = "hoeHit"; + break; + case 4: + cueName = "fishSlap"; + break; + case 5: + cueName = "drumkit6"; + break; + case 6: + cueName = "drumkit5"; + break; + case 7: + cueName = "drumkit6"; + break; + case 8: + cueName = "junimoMeep1"; + break; + case 9: + cueName = "coin"; + break; + case 10: + cueName = "axe"; + break; + case 11: + cueName = "hammer"; + break; + case 12: + cueName = "drumkit2"; + break; + case 13: + cueName = "drumkit4"; + break; + case 14: + cueName = "drumkit3"; + break; + } + } + Game1.playSound(cueName); + this.timesRandom++; + if (Game1.random.NextDouble() < 0.33) + { + if (Game1.player.isMale) + { + // Game1.player.changeAccessory(Game1.random.Next(19)); + } + else + { + // Game1.player.changeAccessory(Game1.random.Next(6, 19)); + } + } + else + { + // Game1.player.changeAccessory(-1); + } + if (Game1.player.isMale) + { + //Game1.player.changeHairStyle(Game1.random.Next(16)); + } + else + { + // Game1.player.changeHairStyle(Game1.random.Next(16, 32)); + } + Color c = new Color(Game1.random.Next(25, 254), Game1.random.Next(25, 254), Game1.random.Next(25, 254)); + if (Game1.random.NextDouble() < 0.5) + { + c.R /= 2; + c.G /= 2; + c.B /= 2; + } + if (Game1.random.NextDouble() < 0.5) + { + c.R = (byte)Game1.random.Next(15, 50); + } + if (Game1.random.NextDouble() < 0.5) + { + c.G = (byte)Game1.random.Next(15, 50); + } + if (Game1.random.NextDouble() < 0.5) + { + c.B = (byte)Game1.random.Next(15, 50); + } + + if (Game1.random.NextDouble() < 0.25) + { + //Game1.player.changeSkinColor(Game1.random.Next(24)); + } + Color color = new Color(Game1.random.Next(25, 254), Game1.random.Next(25, 254), Game1.random.Next(25, 254)); + if (Game1.random.NextDouble() < 0.5) + { + color.R /= 2; + color.G /= 2; + color.B /= 2; + } + if (Game1.random.NextDouble() < 0.5) + { + color.R = (byte)Game1.random.Next(15, 50); + } + if (Game1.random.NextDouble() < 0.5) + { + color.G = (byte)Game1.random.Next(15, 50); + } + if (Game1.random.NextDouble() < 0.5) + { + color.B = (byte)Game1.random.Next(15, 50); + } + //Game1.player.changePants(color); + Color c2 = new Color(Game1.random.Next(25, 254), Game1.random.Next(25, 254), Game1.random.Next(25, 254)); + c2.R /= 2; + c2.G /= 2; + c2.B /= 2; + if (Game1.random.NextDouble() < 0.5) + { + c2.R = (byte)Game1.random.Next(15, 50); + } + if (Game1.random.NextDouble() < 0.5) + { + c2.G = (byte)Game1.random.Next(15, 50); + } + if (Game1.random.NextDouble() < 0.5) + { + c2.B = (byte)Game1.random.Next(15, 50); + } + //Game1.player.changeEyeColor(c2); + this.randomButton.scale = (float)Game1.pixelZoom - 0.5f; + + + // c2 = Util.invertColor(c2); + colorChanged = true; + this.lightColorPicker.setColor(c2); + this.CanvasObject.drawColor = Util.invertColor(c2); + + } + } + + public override void leftClickHeld(int x, int y) + { + this.colorPickerTimer -= Game1.currentGameTime.ElapsedGameTime.Milliseconds; + if (this.colorPickerTimer <= 0) + { + if (this.lastHeldColorPicker != null) + { + + if (this.lastHeldColorPicker.Equals(this.lightColorPicker)) + { + colorChanged = true; + this.CanvasObject.drawColor = Util.invertColor(this.lightColorPicker.clickHeld(x, y)); + } + } + this.colorPickerTimer = 100; + } + } + + public override void releaseLeftClick(int x, int y) + { + + this.lightColorPicker.releaseClick(); + this.lastHeldColorPicker = null; + } + + public override void receiveRightClick(int x, int y, bool playSound = true) + { + } + + public override void receiveKeyPress(Keys key) + { + if (!this.wizardSource && key == Keys.Tab) + { + if (this.nameBox.Selected) + { + this.farmnameBox.SelectMe(); + this.nameBox.Selected = false; + return; + } + if (this.farmnameBox.Selected) + { + this.farmnameBox.Selected = false; + this.favThingBox.SelectMe(); + return; + } + this.favThingBox.Selected = false; + this.nameBox.SelectMe(); + } + } + + public override void performHoverAction(int x, int y) + { + this.hoverText = ""; + this.hoverTitle = ""; + using (List.Enumerator enumerator = this.leftSelectionButtons.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + ClickableTextureComponent clickableTextureComponent = (ClickableTextureComponent)enumerator.Current; + if (clickableTextureComponent.containsPoint(x, y)) + { + clickableTextureComponent.scale = Math.Min(clickableTextureComponent.scale + 0.02f, clickableTextureComponent.baseScale + 0.1f); + } + else + { + clickableTextureComponent.scale = Math.Max(clickableTextureComponent.scale - 0.02f, clickableTextureComponent.baseScale); + } + } + } + using (List.Enumerator enumerator = this.rightSelectionButtons.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + ClickableTextureComponent clickableTextureComponent2 = (ClickableTextureComponent)enumerator.Current; + if (clickableTextureComponent2.containsPoint(x, y)) + { + clickableTextureComponent2.scale = Math.Min(clickableTextureComponent2.scale + 0.02f, clickableTextureComponent2.baseScale + 0.1f); + } + else + { + clickableTextureComponent2.scale = Math.Max(clickableTextureComponent2.scale - 0.02f, clickableTextureComponent2.baseScale); + } + } + } + + + if (this.okButton.containsPoint(x, y) && this.canLeaveMenu()) + { + this.okButton.scale = Math.Min(this.okButton.scale + 0.02f, this.okButton.baseScale + 0.1f); + } + else + { + this.okButton.scale = Math.Max(this.okButton.scale - 0.02f, this.okButton.baseScale); + } + + + if (this.cancelButton.containsPoint(x, y)) + { + this.cancelButton.scale = Math.Min(this.cancelButton.scale + 0.02f, this.cancelButton.baseScale + 0.1f); + } + else + { + this.cancelButton.scale = Math.Max(this.cancelButton.scale - 0.02f, this.cancelButton.baseScale); + } + this.randomButton.tryHover(x, y, 0.25f); + this.randomButton.tryHover(x, y, 0.25f); + } + + public bool canLeaveMenu() + { + return this.wizardSource || (Game1.player.name.Length > 0 && Game1.player.farmName.Length > 0 && Game1.player.favoriteThing.Length > 0); + } + + public override void draw(SpriteBatch b) + { + Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true, null, false); + foreach (ClickableComponent current in this.labels) + { + string text = ""; + Color color = Game1.textColor; + + Utility.drawTextWithShadow(b, current.name, Game1.smallFont, new Vector2((float)current.bounds.X, (float)current.bounds.Y), color, 1f, -1f, -1, -1, 1f, 3); + if (text.Length > 0) + { + Utility.drawTextWithShadow(b, text, Game1.smallFont, new Vector2((float)(current.bounds.X + Game1.tileSize / 3) - Game1.smallFont.MeasureString(text).X / 2f, (float)(current.bounds.Y + Game1.tileSize / 2)), color, 1f, -1f, -1, -1, 1f, 3); + } + } + + foreach(var v in this.pixels) + { + v.component.draw(b,v.color,1f); + } + this.cancelButton.draw(b, Color.White, 0.75f); + + if (this.canLeaveMenu()) + { + this.okButton.draw(b, Color.White, 0.75f); + } + else + { + this.okButton.draw(b, Color.White, 0.75f); + this.okButton.draw(b, Color.Black * 0.5f, 0.751f); + } + + this.lightColorPicker.draw(b); + + if (this.hoverText != null && this.hoverTitle != null && this.hoverText.Count() > 0) + { + IClickableMenu.drawHoverText(b, Game1.parseText(this.hoverText, Game1.smallFont, Game1.tileSize * 4), Game1.smallFont, 0, 0, -1, this.hoverTitle, -1, null, null, 0, -1, -1, -1, -1, 1f, null); + } + this.randomButton.draw(b); + + if (once == false) + { + Color c = Util.invertColor(CanvasObject.drawColor); + + this.lightColorPicker.setColor(c); + once = true; + } + + base.drawMouse(b); + } + } +} diff --git a/Revitalize/Revitalize/Revitalize/Class1.cs b/Revitalize/Revitalize/Revitalize/Class1.cs index 120704fc..f36dd019 100644 --- a/Revitalize/Revitalize/Revitalize/Class1.cs +++ b/Revitalize/Revitalize/Revitalize/Class1.cs @@ -341,6 +341,7 @@ namespace Revitalize objShopList.Add(new StardewValley.Object(498, 1)); objShopList.Add(new StardewValley.Object(770, 1)); + objShopList.Add(new Canvas(0, Vector2.Zero, Canvas.blankTexture)); objShopList.Add(new StardewValley.Object(475, 1)); foreach (var v in objShopList) diff --git a/Revitalize/Revitalize/Revitalize/Magic/MagicFunctions.cs b/Revitalize/Revitalize/Revitalize/Magic/MagicFunctions.cs index 95fbf826..be720d98 100644 --- a/Revitalize/Revitalize/Revitalize/Magic/MagicFunctions.cs +++ b/Revitalize/Revitalize/Revitalize/Magic/MagicFunctions.cs @@ -42,8 +42,22 @@ namespace Revitalize.Magic.MagicFunctions Game1.warpFarmer("Farm", 64, 16, false); MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } + public static void warpHorse(Spell s) + { + NPC horse= Utility.findHorse(); + if (horse == null) return; + const int baseCost = 20; + //calculate all costs then factor in player proficiency + int cost = (int)(((((baseCost) + s.spellCostModifierInt) * s.spellCostModifierPercent) * (1f - PlayerVariables.MagicProficiency)) - PlayerVariables.MagicLevel); //+s.extraCostInt-s.spellSaveInt * (1f- PlayerVariables.MagicProficiency) / s.extraCostPercent* s.spellSavePercent; + MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); + Game1.warpCharacter(horse, Game1.player.currentLocation.name, Game1.player.getTileLocationPoint(), false, true); + } + + public static void sunnyWeather(Spell s) { const int baseCost = 35; @@ -54,12 +68,13 @@ namespace Revitalize.Magic.MagicFunctions { Game1.weatherForTomorrow = Game1.weather_sunny; MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } else { Game1.showGlobalMessage("It's already going to be sunny tomorrow."); } - + } public static void rainyWeather(Spell s) @@ -72,12 +87,13 @@ namespace Revitalize.Magic.MagicFunctions { Game1.weatherForTomorrow = Game1.weather_rain; MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } else { Game1.showGlobalMessage("It's already going to be rainy tomorrow."); } - + } public static void stormyWeather(Spell s) @@ -90,12 +106,13 @@ namespace Revitalize.Magic.MagicFunctions { Game1.weatherForTomorrow = Game1.weather_lightning; MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } else { Game1.showGlobalMessage("It's already going to be stormy tomorrow."); } - + } } @@ -109,6 +126,7 @@ namespace Revitalize.Magic.MagicFunctions int cost = (int)(((((baseCost) + s.spellCostModifierInt) * s.spellCostModifierPercent) * (1f - PlayerVariables.MagicProficiency)) - PlayerVariables.MagicLevel); //+s.extraCostInt-s.spellSaveInt * (1f- PlayerVariables.MagicProficiency) / s.extraCostPercent* s.spellSavePercent; Game1.showRedMessage("MAGIC WORKS"); MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } @@ -131,6 +149,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.health += healAmount; MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } /// @@ -148,6 +167,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.health += healAmount; MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } /// @@ -165,7 +185,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.health += healAmount; MagicMonitor.consumeMagic(cost); - + MagicMonitor.consumeUsage(s); } /// /// Restore 70% of health. @@ -182,7 +202,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.health += healAmount; MagicMonitor.consumeMagic(cost); - + MagicMonitor.consumeUsage(s); } /// /// Restore 10% of stamina. @@ -199,7 +219,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.stamina += healAmount; MagicMonitor.consumeMagic(cost); - + MagicMonitor.consumeUsage(s); } /// @@ -217,7 +237,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.stamina += healAmount; MagicMonitor.consumeMagic(cost); - + MagicMonitor.consumeUsage(s); } /// /// Restore 50% of stamina. @@ -234,7 +254,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.stamina += healAmount; MagicMonitor.consumeMagic(cost); - + MagicMonitor.consumeUsage(s); } /// /// Restore 70% of stamina. @@ -251,7 +271,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.stamina += healAmount; MagicMonitor.consumeMagic(cost); - + MagicMonitor.consumeUsage(s); } /// /// Restore 100% of stamina. @@ -268,7 +288,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.player.stamina += healAmount; MagicMonitor.consumeMagic(cost); - + MagicMonitor.consumeUsage(s); } } @@ -296,6 +316,7 @@ namespace Revitalize.Magic.MagicFunctions } MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } catch (Exception e) { @@ -327,6 +348,7 @@ namespace Revitalize.Magic.MagicFunctions Game1.playSound("slosh"); DelayedAction.playSoundAfterDelay("glug", 250); MagicMonitor.consumeMagic(cost); + MagicMonitor.consumeUsage(s); } } catch (Exception e) diff --git a/Revitalize/Revitalize/Revitalize/Magic/MagicMonitor.cs b/Revitalize/Revitalize/Revitalize/Magic/MagicMonitor.cs index 2822ce8e..216f0333 100644 --- a/Revitalize/Revitalize/Revitalize/Magic/MagicMonitor.cs +++ b/Revitalize/Revitalize/Revitalize/Magic/MagicMonitor.cs @@ -119,6 +119,23 @@ namespace Revitalize.Magic } + public static void consumeUsage(Spell s) + { + if (s.usesRemaining == -1) return; + else + { + s.usesRemaining -= 1; + if (s.usesRemaining == 0) + { + Game1.player.reduceActiveItemByOne(); + } + else + { + s.description = s.vanillaDescription += "\nUses Remaining: " + s.usesRemaining; + } + } + } + public static void gainMagicExperience(int f) { PlayerVariables.MagicExperience += f; diff --git a/Revitalize/Revitalize/Revitalize/Magic/Spell.cs b/Revitalize/Revitalize/Revitalize/Magic/Spell.cs index 3c7c8c89..68051c8b 100644 --- a/Revitalize/Revitalize/Revitalize/Magic/Spell.cs +++ b/Revitalize/Revitalize/Revitalize/Magic/Spell.cs @@ -27,6 +27,11 @@ namespace Revitalize.Objects public float spellCostModifierPercent; public int spellIndex; + + public string vanillaDescription; + public int usesRemaining; + + public override string Name { get @@ -121,7 +126,23 @@ namespace Revitalize.Objects this.spellCostModifierInt = Convert.ToInt32(array[6]); int meh = Convert.ToInt32(array[7]); this.spellCostModifierPercent = meh / 100; - this.description = array[8]; + this.vanillaDescription = array[8]; + try + { + this.usesRemaining = Convert.ToInt32(array[9]); + } + catch(Exception err) + { + this.usesRemaining = -1; + } + if (usesRemaining == -1) + { + this.description = vanillaDescription; + } + else + { + this.description = this.vanillaDescription += "\nUses Remaining: " + usesRemaining; + } } catch(Exception e) { diff --git a/Revitalize/Revitalize/Revitalize/Revitalize.csproj b/Revitalize/Revitalize/Revitalize/Revitalize.csproj index 9a8aa81f..13f96af5 100644 --- a/Revitalize/Revitalize/Revitalize/Revitalize.csproj +++ b/Revitalize/Revitalize/Revitalize/Revitalize.csproj @@ -50,6 +50,8 @@ + + @@ -98,6 +100,7 @@ + diff --git a/Revitalize/Revitalize/Revitalize/bin/Debug/Revitalize.dll b/Revitalize/Revitalize/Revitalize/bin/Debug/Revitalize.dll index 0963e395..db740f6c 100644 Binary files a/Revitalize/Revitalize/Revitalize/bin/Debug/Revitalize.dll and b/Revitalize/Revitalize/Revitalize/bin/Debug/Revitalize.dll differ diff --git a/Revitalize/Revitalize/Revitalize/obj/Debug/Revitalize.dll b/Revitalize/Revitalize/Revitalize/obj/Debug/Revitalize.dll index 0963e395..db740f6c 100644 Binary files a/Revitalize/Revitalize/Revitalize/obj/Debug/Revitalize.dll and b/Revitalize/Revitalize/Revitalize/obj/Debug/Revitalize.dll differ diff --git a/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/blankPixel.xnb b/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/blankPixel.xnb new file mode 100644 index 00000000..21b7bed9 Binary files /dev/null and b/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/blankPixel.xnb differ diff --git a/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/gridline.xnb b/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/gridline.xnb new file mode 100644 index 00000000..9dcb10c3 Binary files /dev/null and b/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/gridline.xnb differ diff --git a/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/whitePixel.xnb b/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/whitePixel.xnb new file mode 100644 index 00000000..c8687016 Binary files /dev/null and b/Revitalize/RevitalizeProjectCompiled/Revitalize/Paint/ModAssets/whitePixel.xnb differ diff --git a/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/blankPixel.png b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/blankPixel.png new file mode 100644 index 00000000..13b38d57 Binary files /dev/null and b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/blankPixel.png differ diff --git a/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/blankPixel.yaml b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/blankPixel.yaml new file mode 100644 index 00000000..48279c70 --- /dev/null +++ b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/blankPixel.yaml @@ -0,0 +1,21 @@ + +xnbData: + target: "w" + compressed: true + hiDef: true + readerData: + - + type: "Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553" + version: 0 + + + numSharedResources: 0 + +content: #!Texture2D + format: 0 + +extractedImages: + - + path: "" + + diff --git a/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/gridline.png b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/gridline.png new file mode 100644 index 00000000..bde9af7f Binary files /dev/null and b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/gridline.png differ diff --git a/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/gridline.yaml b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/gridline.yaml new file mode 100644 index 00000000..48279c70 --- /dev/null +++ b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/gridline.yaml @@ -0,0 +1,21 @@ + +xnbData: + target: "w" + compressed: true + hiDef: true + readerData: + - + type: "Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553" + version: 0 + + + numSharedResources: 0 + +content: #!Texture2D + format: 0 + +extractedImages: + - + path: "" + + diff --git a/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/whitePixel.png b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/whitePixel.png new file mode 100644 index 00000000..f569c5fa Binary files /dev/null and b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/whitePixel.png differ diff --git a/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/whitePixel.yaml b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/whitePixel.yaml new file mode 100644 index 00000000..48279c70 --- /dev/null +++ b/Revitalize/RevitalizeProjectDecompiled/Revitalize/Paint/ModAssets/whitePixel.yaml @@ -0,0 +1,21 @@ + +xnbData: + target: "w" + compressed: true + hiDef: true + readerData: + - + type: "Microsoft.Xna.Framework.Content.Texture2DReader, Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553" + version: 0 + + + numSharedResources: 0 + +content: #!Texture2D + format: 0 + +extractedImages: + - + path: "" + +