From e0a69e5f7a728159232f840aa68019a62937dd7e Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 30 Jan 2017 22:51:50 -0800 Subject: [PATCH] Yay --- Revitalize/Revitalize/Revitalize/Class1.cs | 3 +- .../Revitalize/Revitalize/CoreObject.cs | 2 +- .../Revitalize/Objects/ExtraSeeds.cs | 1029 +++++++++++++++++ .../Resources/DataNodes/SeedDataNode.cs | 22 + .../Revitalize/Resources/Dictionaries.cs | 15 +- .../Revitalize/Revitalize/Revitalize.csproj | 5 + Revitalize/Revitalize/Revitalize/Serialize.cs | 111 +- Revitalize/Revitalize/Revitalize/Util.cs | 25 + RuneFactoryRevive/Zip27Zip/Zip27Zip.sln | 22 + .../Zip27Zip/Zip27Zip/App.config | 6 + .../Zip27Zip/Zip27Zip/ExampleText.txt | 1 + .../Zip27Zip/Zip27Zip/Program.cs | 117 ++ .../Zip27Zip/Properties/AssemblyInfo.cs | 36 + .../Zip27Zip/Zip27Zip/Zip27Zip.csproj | 62 + 14 files changed, 1444 insertions(+), 12 deletions(-) create mode 100644 Revitalize/Revitalize/Revitalize/Objects/ExtraSeeds.cs create mode 100644 Revitalize/Revitalize/Revitalize/Resources/DataNodes/SeedDataNode.cs create mode 100644 RuneFactoryRevive/Zip27Zip/Zip27Zip.sln create mode 100644 RuneFactoryRevive/Zip27Zip/Zip27Zip/App.config create mode 100644 RuneFactoryRevive/Zip27Zip/Zip27Zip/ExampleText.txt create mode 100644 RuneFactoryRevive/Zip27Zip/Zip27Zip/Program.cs create mode 100644 RuneFactoryRevive/Zip27Zip/Zip27Zip/Properties/AssemblyInfo.cs create mode 100644 RuneFactoryRevive/Zip27Zip/Zip27Zip/Zip27Zip.csproj diff --git a/Revitalize/Revitalize/Revitalize/Class1.cs b/Revitalize/Revitalize/Revitalize/Class1.cs index 11af5bcd..f2717f54 100644 --- a/Revitalize/Revitalize/Revitalize/Class1.cs +++ b/Revitalize/Revitalize/Revitalize/Class1.cs @@ -107,7 +107,7 @@ namespace Revitalize mouseAction = true; string s = Game1.player.ActiveObject.getCategoryName(); - + // Log.AsyncC(s); if (Dictionaries.interactionTypes.ContainsKey(s)) { Dictionaries.interactFunction f; @@ -262,6 +262,7 @@ namespace Revitalize objShopList.Add(new GiftPackage(1120, Vector2.Zero,newInventory)); // my_shop_list.Add((new Decoration(1120, Vector2.Zero))); + objShopList.Add(new ExtraSeeds(1, Vector2.Zero)); Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(objShopList, 0, null); if (Game1.player == null) return; diff --git a/Revitalize/Revitalize/Revitalize/CoreObject.cs b/Revitalize/Revitalize/Revitalize/CoreObject.cs index 8f3d04ed..2fff5bf4 100644 --- a/Revitalize/Revitalize/Revitalize/CoreObject.cs +++ b/Revitalize/Revitalize/Revitalize/CoreObject.cs @@ -1356,7 +1356,7 @@ public override bool isPlaceable() 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), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize, SpriteEffects.None, layerDepth); + spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height)), 1f * this.getScaleSize() * scaleSize *.5f, SpriteEffects.None, layerDepth); } public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) diff --git a/Revitalize/Revitalize/Revitalize/Objects/ExtraSeeds.cs b/Revitalize/Revitalize/Revitalize/Objects/ExtraSeeds.cs new file mode 100644 index 00000000..1b31c3dd --- /dev/null +++ b/Revitalize/Revitalize/Revitalize/Objects/ExtraSeeds.cs @@ -0,0 +1,1029 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Revitalize.Resources; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Locations; +using StardewValley.Menus; +using System; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace Revitalize.Objects +{ + ///Make xtra crops data sheet + ///edit crops png, crops xnb, and objectInformation.XNB and springObjects.png. + + + /// + /// Stardew ExtraSeeds Class. VERY Broken. Only extend from this class. + /// + /// + public class ExtraSeeds : Revitalize.CoreObject + { + + public new Texture2D TextureSheet; + + public override string Name + { + get + { + return this.name; + } + set + { + this.name = value; + } + } + + public override void InitializeBasics(int InvMaxSize, Vector2 tile) + { + this.inventory = new List(); + this.inventoryMaxSize = InvMaxSize; + this.tileLocation = tile; + lightsOn = false; + lightColor = Color.Black; + thisType = this.GetType(); + } + + public ExtraSeeds() + { + this.updateDrawPosition(); + } + + public ExtraSeeds(bool f) + { + //does nothng + } + + public ExtraSeeds(int which, Vector2 Tile, int InventoryMaxSize = 0, bool isRemovable = true) + { + InitializeBasics(InventoryMaxSize, Tile); + removable = isRemovable; + this.lightColor = Color.Black; + if (TextureSheet == null) + { + TextureSheet = Game1.content.Load("Revitalize\\CropsNSeeds\\Graphics\\seeds"); + texturePath = "Revitalize\\CropsNSeeds\\Graphics\\seeds"; + } + Dictionary dictionary = Game1.content.Load>("Revitalize\\CropsNSeeds\\Data\\seeds"); + string[] array = dictionary[which].Split(new char[] + { + '/' + }); + this.name = array[0]; + this.Decoration_type = this.getTypeNumberFromName(array[1]); + this.description = "Some seeds. Maybe you should plant them."; + 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) + { + return this.RightClicked(who); + + // Game1.showRedMessage("YOOO"); + //do some stuff when the right button is down + // rotate(); + if (this.heldObject != null) + { + // Game1.player.addItemByMenuIfNecessary(this.heldObject); + // this.heldObject = null; + } + else + { + // this.heldObject = Game1.player.ActiveObject; + // Game1.player.removeItemFromInventory(heldObject); + } + //this.minutesUntilReady = 30; + } + else + { + //Game1.showRedMessage("CRY"); + } + + if (justCheckingForActivity) + { + return true; + } + return this.clicked(who); + } + + //DONT USE THIS BASE IT IS TERRIBLE + public override bool clicked(Farmer who) + { + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + + + if (removable == false) return false; + + + 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 ExtraSeeds))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + // this.flaggedForPickUp = true; + thisLocation = null; + return true; + } + else + { + // return true; + // this.heldObject = new ExtraSeeds(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + thisLocation = null; + return true; + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + Util.addItemToInventoryElseDrop(this); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + removeLights(this.thisLocation); + this.lightsOn = false; + thisLocation = null; + return true; + } + + + + return false; + } + + public virtual bool RightClicked(Farmer who) + { + + + // Game1.showRedMessage("THIS IS CLICKED!!!"); + //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + /* + + 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 ExtraSeeds))) + { + if (Game1.player.currentLocation is FarmHouse) + { + // + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + // this.flaggedForPickUp = true; + return true; + } + else + { + // return true; + // this.heldObject = new ExtraSeeds(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); + Game1.player.addItemByMenuIfNecessary(this); + removeLights(this.thisLocation); + this.lightsOn = false; + Game1.playSound("coin"); + return true; + + } + } + if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) + { + // Game1.showRedMessage("Why3?"); + // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); + Util.addItemToInventoryElseDrop(this); + this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); + this.heldObject = null; + Game1.playSound("coin"); + removeLights(this.thisLocation); + this.lightsOn = false; + 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(thisLocation, lightColor); + this.addLights(thisLocation, lightColor); + } + + public override bool performObjectDropInAction(StardewValley.Object dropIn, bool probe, Farmer who) + { + Game1.showRedMessage("HEY!"); + if ((this.Decoration_type == 11 || this.Decoration_type == 5) && this.heldObject == null && !dropIn.bigCraftable && (!(dropIn is ExtraSeeds) || ((dropIn as ExtraSeeds).getTilesWide() == 1 && (dropIn as ExtraSeeds).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 ExtraSeeds).Decoration_type)); + this.heldObject.performDropDownAction(who); + if (!probe) + { + Game1.playSound("woodyStep"); + // Log.AsyncC("HUH?"); + if (who != null) + { + who.reduceActiveItemByOne(); + } + } + return true; + } + return false; + } + + + public override bool minutesElapsed(int minutes, GameLocation environment) + { + // Log.Info("minutes passed in"+minutes); + // Log.Info("minues remaining" + this.minutesUntilReady); + // Log.Info(this.lightColor); + this.minutesUntilReady = (this.minutesUntilReady - minutes); + if (Game1.isDarkOut()) + { + // this.addLights(thisLocation, lightColor); + this.addLights(thisLocation, lightColor); + } + else + { + this.removeLights(environment); + } + + if (minutesUntilReady == 0) + { + // Log.AsyncC(this.name + "Is ready!"); + // Log.AsyncC(Game1.player.getStandingPosition()); + // Vector2 v2 = new Vector2(this.tileLocation.X * Game1.tileSize, this.tileLocation.Y * Game1.tileSize); + //Game1.createItemDebris((Item)this.heldObject, v2, Game1.player.getDirection()); + // minutesUntilReady = 30; + } + + 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; + } + this.spillInventoryEverywhere(); + base.performRemoveAction(tileLocation, environment); + } + + public override 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 override 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) + { + + return false; + 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("ExtraSeeds")) + { + ExtraSeeds current = (ExtraSeeds)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 (ExtraSeeds current in (l as FarmHouse).ExtraSeeds) + { + 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 Util.canBePlacedHere(this, l, tile); + } + } + + public virtual void updateDrawPosition() + { + this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height))); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) + { + + } + + public override int getTilesWide() + { + return this.boundingBox.Width / Game1.tileSize; + } + + public override int getTilesHigh() + { + return this.boundingBox.Height / Game1.tileSize; + } + + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + + // Game1.showRedMessage("BALLS"); + return true; + + 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 * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); + foreach (KeyValuePair c in location.objects) + { + StardewValley.Object ehh = c.Value; + if (((ehh.GetType()).ToString()).Contains("Spawner")) + { + Decoration current2 = (Decoration)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(); + // Log.AsyncO(this.boundingBox); + // Log.AsyncO(x); + // Log.AsyncY(y); + for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++) + { + Util.placementAction(this, location, x + 1, y, who); + } + for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++) + { + Util.placementAction(this, location, x + 1, y, 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 * Game1.tileSize, y / Game1.tileSize * 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; + // Log.AsyncC(x); + // Log.AsyncY(y); + // Log.AsyncY(this.drawPosition); + 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 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), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize, SpriteEffects.None, layerDepth); + spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize *1.5f, 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), Color.White * 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), Color.White * 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 ExtraSeeds) + { + (this.heldObject as ExtraSeeds).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as ExtraSeeds).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), Color.White * 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)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f); + } + } + + public override void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) + { + spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); + } + + public override Item getOne() + { + ExtraSeeds ExtraSeeds = new ExtraSeeds(this.parentSheetIndex, this.tileLocation, this.inventoryMaxSize); + /* + drawPosition = this.drawPosition; + defaultBoundingBox = this.defaultBoundingBox; + boundingBox = this.boundingBox; + currentRotation = this.currentRotation - 1; + rotations = this.rotations; + rotate(); + */ + return ExtraSeeds; + } + + public override string getCategoryName() + { + return "Seeds"; + // return base.getCategoryName(); + } + + public override Color getCategoryColor() + { + return Util.invertColor(LightColors.Turquoise); + } + + + public override int maximumStackSize() + { + return base.maximumStackSize(); + } + + } +} diff --git a/Revitalize/Revitalize/Revitalize/Resources/DataNodes/SeedDataNode.cs b/Revitalize/Revitalize/Revitalize/Resources/DataNodes/SeedDataNode.cs new file mode 100644 index 00000000..6ad8f6f4 --- /dev/null +++ b/Revitalize/Revitalize/Revitalize/Resources/DataNodes/SeedDataNode.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Resources.DataNodes +{ + class SeedDataNode + { + public int parentIndex; + public int cropIndex; + + public SeedDataNode(int parentInt, int cropInt) + { + parentIndex = parentInt; + cropIndex = cropInt; + + } + + } +} diff --git a/Revitalize/Revitalize/Revitalize/Resources/Dictionaries.cs b/Revitalize/Revitalize/Revitalize/Resources/Dictionaries.cs index 27298755..73d5db8e 100644 --- a/Revitalize/Revitalize/Revitalize/Resources/Dictionaries.cs +++ b/Revitalize/Revitalize/Revitalize/Resources/Dictionaries.cs @@ -19,7 +19,7 @@ namespace Revitalize.Resources public static Dictionary acceptedTypes; public static Dictionary interactionTypes; public static Dictionary quarryList; - + public static Dictionary seedList; public static void initializeDictionaries() @@ -27,6 +27,7 @@ namespace Revitalize.Resources acceptedTypes = new Dictionary(); quarryList = new Dictionary(); interactionTypes = new Dictionary(); + seedList = new Dictionary(); fillAllDictionaries(); } @@ -35,6 +36,7 @@ namespace Revitalize.Resources addAllAcceptedTypes(); addAllInteractionTypes(); fillQuaryList(); + fillSeedList(); } @@ -46,12 +48,15 @@ namespace Revitalize.Resources acceptedTypes.Add("Revitalize.Objects.Machines.Quarry", new SerializerDataNode(new ser(Serialize.serializeQuarry), new par(Serialize.parseQuarry))); acceptedTypes.Add("Revitalize.Objects.Machines.Spawner", new SerializerDataNode(new ser(Serialize.serializeSpawner), new par(Serialize.parseSpawner))); acceptedTypes.Add("Revitalize.Objects.GiftPackage", new SerializerDataNode(new ser(Serialize.serializeGiftPackage), new par(Serialize.parseGiftPackage))); + acceptedTypes.Add("Revitalize.Objects.ExtraSeeds", new SerializerDataNode(new ser(Serialize.serializeExtraSeeds), new par(Serialize.parseExtraSeeds))); } public static void addAllInteractionTypes() { - interactionTypes.Add("Seed", Util.plantCropHere); + interactionTypes.Add("Seed", Util.plantCropHere); //for generic stardew seeds + interactionTypes.Add("Seeds", Util.plantExtraCropHere); //for modded stardew seeds interactionTypes.Add("Gift Package", Util.getGiftPackageContents); + } @@ -68,7 +73,13 @@ namespace Revitalize.Resources } + public static void fillSeedList() + { + //crop row number is actually counts row 0 on upper left and row right on upper right. + //parentsheetindex,actualCropNumber + seedList.Add("Pink Turnip Seeds", new SeedDataNode(1,1)); //new potato seeds. Need to make actual thing. + } } diff --git a/Revitalize/Revitalize/Revitalize/Revitalize.csproj b/Revitalize/Revitalize/Revitalize/Revitalize.csproj index d65483b7..18d66882 100644 --- a/Revitalize/Revitalize/Revitalize/Revitalize.csproj +++ b/Revitalize/Revitalize/Revitalize/Revitalize.csproj @@ -55,6 +55,7 @@ + @@ -63,6 +64,7 @@ + @@ -73,6 +75,9 @@ + + + diff --git a/Revitalize/Revitalize/Revitalize/Serialize.cs b/Revitalize/Revitalize/Revitalize/Serialize.cs index b8ee7415..fc94cf2b 100644 --- a/Revitalize/Revitalize/Revitalize/Serialize.cs +++ b/Revitalize/Revitalize/Revitalize/Serialize.cs @@ -36,7 +36,7 @@ namespace Revitalize InvPath = Path.Combine(PlayerDataPath, "Inventory"); - Log.AsyncC(TrackedTerrainDataPath); + // Log.AsyncC(TrackedTerrainDataPath); if (!Directory.Exists(DataDirectoryPath)) { @@ -131,7 +131,7 @@ namespace Revitalize string[] ehh = File.ReadAllLines(path); string data = ehh[0]; - Log.AsyncC(data); + // Log.AsyncC(data); dynamic obj = JObject.Parse(data); @@ -330,7 +330,7 @@ namespace Revitalize } catch(Exception e) { - Log.AsyncM(e); + // Log.AsyncM(e); return null; } @@ -426,7 +426,7 @@ namespace Revitalize } catch (Exception e) { - Log.AsyncM(e); + // Log.AsyncM(e); return null; } @@ -522,7 +522,7 @@ namespace Revitalize } catch (Exception e) { - Log.AsyncM(e); + // Log.AsyncM(e); return null; } @@ -535,6 +535,101 @@ namespace Revitalize Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (GiftPackage)d); } + public static ExtraSeeds parseExtraSeeds(string data) + { + + dynamic obj = JObject.Parse(data); + + + // Log.AsyncC(obj.thisType); + + + ExtraSeeds d = new ExtraSeeds(false); + + d.price = obj.price; + d.Decoration_type = obj.Decoration_type; + d.rotations = obj.rotations; + d.currentRotation = obj.currentRotation; + string s1 = Convert.ToString(obj.sourceRect); + d.sourceRect = Util.parseRectFromJson(s1); + string s2 = Convert.ToString(obj.defaultSourceRect); + d.defaultSourceRect = Util.parseRectFromJson(s2); + string s3 = Convert.ToString(obj.defaultBoundingBox); + d.defaultBoundingBox = Util.parseRectFromJson(s3); + d.description = obj.description; + d.flipped = obj.flipped; + d.flaggedForPickUp = obj.flaggedForPickUp; + d.tileLocation = obj.tileLocation; + d.parentSheetIndex = obj.parentSheetIndex; + d.owner = obj.owner; + d.name = obj.name; + d.type = obj.type; + d.canBeSetDown = obj.canBeSetDown; + d.canBeGrabbed = obj.canBeGrabbed; + d.isHoedirt = obj.isHoedirt; + d.isSpawnedObject = obj.isSpawnedObject; + d.questItem = obj.questItem; + d.isOn = obj.isOn; + d.fragility = obj.fragility; + d.edibility = obj.edibility; + d.stack = obj.stack; + d.quality = obj.quality; + d.bigCraftable = obj.bigCraftable; + d.setOutdoors = obj.setOutdoors; + d.setIndoors = obj.setIndoors; + d.readyForHarvest = obj.readyForHarvest; + d.showNextIndex = obj.showNextIndex; + d.hasBeenPickedUpByFarmer = obj.hasBeenPickedUpByFarmer; + d.isRecipe = obj.isRecipe; + d.isLamp = obj.isLamp; + d.heldObject = obj.heldObject; + d.minutesUntilReady = obj.minutesUntilReady; + string s4 = Convert.ToString(obj.boundingBox); + d.boundingBox = Util.parseRectFromJson(s4); + d.scale = obj.scale; + d.lightSource = obj.lightSource; + d.shakeTimer = obj.shakeTimer; + d.internalSound = obj.internalSound; + d.specialVariable = obj.specialVariable; + d.category = obj.category; + d.specialItem = obj.specialItem; + d.hasBeenInInventory = obj.hasBeenInInventory; + string t = obj.texturePath; + d.TextureSheet = Game1.content.Load(t); + d.texturePath = t; + + + JArray array = obj.inventory; + d.inventory = array.ToObject>(); + + + d.inventoryMaxSize = obj.inventoryMaxSize; + d.itemReadyForHarvest = obj.itemReadyForHarvest; + d.lightsOn = obj.lightsOn; + d.thisLocation = obj.thisLocation; + d.lightColor = obj.lightColor; + d.thisType = obj.thisType; + d.removable = obj.removable; + + try + { + return d; + } + catch (Exception e) + { + // Log.AsyncM(e); + return null; + } + + + + + } + public static void serializeExtraSeeds(Item d) + { + Serialize.WriteToJsonFile(Path.Combine(InvPath, d.Name + ".json"), (ExtraSeeds)d); + } + public static Light parseLight(string data) @@ -714,7 +809,7 @@ namespace Revitalize } catch (Exception e) { - Log.AsyncM(e); + // Log.AsyncM(e); return null; } @@ -810,7 +905,7 @@ namespace Revitalize } catch (Exception e) { - Log.AsyncM(e); + //Log.AsyncM(e); return null; } @@ -838,7 +933,7 @@ namespace Revitalize if (t == null) { - Log.AsyncC("BOOOOO"); + // Log.AsyncC("BOOOOO"); } Lists.trackedTerrainFeatures.Add(new TrackedTerrainDataNode(location, (HoeDirt)t, position)); diff --git a/Revitalize/Revitalize/Revitalize/Util.cs b/Revitalize/Revitalize/Revitalize/Util.cs index 36fd0d01..fa592f08 100644 --- a/Revitalize/Revitalize/Revitalize/Util.cs +++ b/Revitalize/Revitalize/Revitalize/Util.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Revitalize.Objects; using Revitalize.Resources; +using Revitalize.Resources.DataNodes; using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; @@ -690,6 +691,30 @@ namespace Revitalize } } + + public static void plantExtraCropHere() + { + //Log.AsyncC("HELLO"); + HoeDirt t; + TerrainFeature r; + bool plant = Game1.player.currentLocation.terrainFeatures.TryGetValue(Game1.currentCursorTile, out r); + t = (r as HoeDirt); + if (t is HoeDirt) + { + if ((t as HoeDirt).crop == null) + { + // Log.AsyncG("BOOP"); + SeedDataNode f; + bool g =Dictionaries.seedList.TryGetValue(((ExtraSeeds)Game1.player.ActiveObject).name, out f); + + (t as HoeDirt).crop = new Crop(f.cropIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y); + Game1.player.reduceActiveItemByOne(); + Game1.playSound("dirtyHit"); + Revitalize.Resources.Lists.trackedTerrainFeatures.Add(new Resources.DataNodes.TrackedTerrainDataNode(Game1.player.currentLocation, t, new Vector2((int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y))); + } + } + } + /// /// Static wrapper; /// diff --git a/RuneFactoryRevive/Zip27Zip/Zip27Zip.sln b/RuneFactoryRevive/Zip27Zip/Zip27Zip.sln new file mode 100644 index 00000000..3f0a61a3 --- /dev/null +++ b/RuneFactoryRevive/Zip27Zip/Zip27Zip.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 14 for Windows Desktop +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zip27Zip", "Zip27Zip\Zip27Zip.csproj", "{84B87D16-1B5B-41C7-BE30-168AA1F182A7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {84B87D16-1B5B-41C7-BE30-168AA1F182A7}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {84B87D16-1B5B-41C7-BE30-168AA1F182A7}.Debug|Any CPU.Build.0 = Release|Any CPU + {84B87D16-1B5B-41C7-BE30-168AA1F182A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84B87D16-1B5B-41C7-BE30-168AA1F182A7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RuneFactoryRevive/Zip27Zip/Zip27Zip/App.config b/RuneFactoryRevive/Zip27Zip/Zip27Zip/App.config new file mode 100644 index 00000000..8e156463 --- /dev/null +++ b/RuneFactoryRevive/Zip27Zip/Zip27Zip/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/RuneFactoryRevive/Zip27Zip/Zip27Zip/ExampleText.txt b/RuneFactoryRevive/Zip27Zip/Zip27Zip/ExampleText.txt new file mode 100644 index 00000000..05a682bd --- /dev/null +++ b/RuneFactoryRevive/Zip27Zip/Zip27Zip/ExampleText.txt @@ -0,0 +1 @@ +Hello! \ No newline at end of file diff --git a/RuneFactoryRevive/Zip27Zip/Zip27Zip/Program.cs b/RuneFactoryRevive/Zip27Zip/Zip27Zip/Program.cs new file mode 100644 index 00000000..b6bc745e --- /dev/null +++ b/RuneFactoryRevive/Zip27Zip/Zip27Zip/Program.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Diagnostics; +using System.IO; + +class Program +{ + static void Main() + { + + string sourceName; + string targetName; + /* + // 1 + // Initialize process information. + // + ProcessStartInfo p = new ProcessStartInfo(); + p.FileName = "7za.exe"; + + // 2 + // Use 7-zip + // specify a=archive and -tgzip=gzip + // and then target file in quotes followed by source file in quotes + // + p.Arguments = "a \"" + targetName + "\" \"" + + sourceName + "\" "; + p.WindowStyle = ProcessWindowStyle.Maximized; + + + // 3. + // Start process and wait for it to exit + // + Process x = Process.Start(p); + x.WaitForExit(); + + + ProcessStartInfo P = new ProcessStartInfo(); + + P.FileName = "7za.exe"; + + P.Arguments = "e Example.7z -oc:\\Users\\owner\\Downloads -y"; + P.WindowStyle = ProcessWindowStyle.Maximized; + Process X = Process.Start(P); + + X.WaitForExit(); + */ + + string[] fileContents = File.ReadAllLines("SearchDirectories.txt"); + + List directoryList = new List(); + List allZipFiles = new List(); + + foreach(var v in fileContents) + { + + directoryList.Add(v); + } + + foreach (var v in directoryList) + { + Console.WriteLine("Searching " + v + " for .zip files"); + string Path = v; + string[] zipsInDirectory = Directory.GetFiles(Path, "*.zip", SearchOption.AllDirectories); + int count2 = zipsInDirectory.Length; + int count3 = 1; + foreach(var q in zipsInDirectory) + { + Console.WriteLine("Adding in zip number " + count3 + " of " + count2 + " to the archival list."); + Console.WriteLine("Adding in zip " + q + " to the archival list."); + allZipFiles.Add(q); + count3++; + } + + } + + int maxCount = allZipFiles.Count; + int count = 1; + List removalList = new List(); + + foreach(var v in allZipFiles) + { + Console.WriteLine("Compressing File "+ count +" of "+ maxCount); + // Console.WriteLine(v.ToString()); + // FileInfo fInfo = new FileInfo(v); + // Console.WriteLine( fInfo.FullName); + /* + string s = v.Remove(v.Length - 4, 4); + Console.WriteLine("Compressing " +s); + sourceName = v.ToString(); + targetName = s + ".7z"; + ProcessStartInfo process = new ProcessStartInfo(); + process.FileName = "7za.exe"; + process.Arguments = "a \"" + targetName + "\" \"" + + sourceName + "\" -y"; + process.WindowStyle = ProcessWindowStyle.Minimized; + Process processRun = Process.Start(process); + count++; + processRun.WaitForExit(); + Console.WriteLine("Sucessfully compressed "+ s +" to .7zip format."); + + */ + removalList.Add(v); + } + + System.Threading.Thread.Sleep(1000); + foreach (var v in removalList) + { + Console.WriteLine("Deleting " + v); + File.Delete(v); + + } + + System.Threading.Thread.Sleep(1000); + } +} \ No newline at end of file diff --git a/RuneFactoryRevive/Zip27Zip/Zip27Zip/Properties/AssemblyInfo.cs b/RuneFactoryRevive/Zip27Zip/Zip27Zip/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..dbc73978 --- /dev/null +++ b/RuneFactoryRevive/Zip27Zip/Zip27Zip/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Zip27Zip")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Zip27Zip")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("84b87d16-1b5b-41c7-be30-168aa1f182a7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RuneFactoryRevive/Zip27Zip/Zip27Zip/Zip27Zip.csproj b/RuneFactoryRevive/Zip27Zip/Zip27Zip/Zip27Zip.csproj new file mode 100644 index 00000000..d1afa811 --- /dev/null +++ b/RuneFactoryRevive/Zip27Zip/Zip27Zip/Zip27Zip.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {84B87D16-1B5B-41C7-BE30-168AA1F182A7} + Exe + Properties + Zip27Zip + Zip27Zip + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file