public CataloguePage(int x, int y, int width, int height, GameMenu parent) : base(x, y, width, height, false) { this.parent = parent; this.buildingPlacementTiles = Game1.content.Load <Texture2D>("LooseSprites\\buildingPlacementTiles"); CataloguePage.widthToMoveActiveTab = Game1.tileSize / 8; CataloguePage.blueprintButtonMargin = Game1.tileSize / 2; this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4, false, (List <Item>)null, (InventoryMenu.highlightThisItem)null, -1, 3, 0, 0, true); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4 + CataloguePage.widthToMoveActiveTab, this.yPositionOnScreen + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), "", "Buildings", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 4, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 3, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10138"), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 5, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 4, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10139"), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 8, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 5, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10140"), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 6, -1, -1), 1f, false)); for (int index = 0; index < 4; ++index) { this.blueprintButtons.Add(new Dictionary <ClickableComponent, BluePrint>()); } int num = Game1.tileSize * 8; int[] numArray = new int[4]; for (int index = 0; index < Game1.player.blueprints.Count; ++index) { BluePrint structureToPlace = new BluePrint(Game1.player.blueprints[index]); if (CataloguePage.canPlaceThisBuildingOnTheCurrentMap(structureToPlace, Game1.currentLocation)) { structureToPlace.canBuildOnCurrentMap = true; } int tabNumberFromName = this.getTabNumberFromName(structureToPlace.blueprintType); if (structureToPlace.blueprintType != null) { int width1 = (int)((double)Math.Max(structureToPlace.tilesWidth, 4) / 4.0 * (double)Game1.tileSize) + CataloguePage.blueprintButtonMargin; if (numArray[tabNumberFromName] % (num - IClickableMenu.borderWidth * 2) + width1 > num - IClickableMenu.borderWidth * 2) { numArray[tabNumberFromName] += num - IClickableMenu.borderWidth * 2 - numArray[tabNumberFromName] % (num - IClickableMenu.borderWidth * 2); } this.blueprintButtons[Math.Min(3, tabNumberFromName)].Add(new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(x + IClickableMenu.borderWidth + numArray[tabNumberFromName] % (num - IClickableMenu.borderWidth * 2), y + IClickableMenu.borderWidth + numArray[tabNumberFromName] / (num - IClickableMenu.borderWidth * 2) * Game1.tileSize * 2 + Game1.tileSize, width1, Game1.tileSize * 2), structureToPlace.name), structureToPlace); numArray[tabNumberFromName] += width1; } } }
// Token: 0x06000DB7 RID: 3511 RVA: 0x00116AF0 File Offset: 0x00114CF0 public CataloguePage(int x, int y, int width, int height, GameMenu parent) : base(x, y, width, height, false) { this.parent = parent; this.buildingPlacementTiles = Game1.content.Load <Texture2D>("LooseSprites\\buildingPlacementTiles"); CataloguePage.widthToMoveActiveTab = Game1.tileSize / 8; CataloguePage.blueprintButtonMargin = Game1.tileSize / 2; this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4, false, null, null, -1, 3, 0, 0, true); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4 + CataloguePage.widthToMoveActiveTab, this.yPositionOnScreen + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), "", "Buildings", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 4, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 3, Game1.tileSize, Game1.tileSize), "", "Building Upgrades", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 5, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 4, Game1.tileSize, Game1.tileSize), "", "Animals", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 8, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 5, Game1.tileSize, Game1.tileSize), "", "Demolish Buildings", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 6, -1, -1), 1f, false)); for (int i = 0; i < 4; i++) { this.blueprintButtons.Add(new Dictionary <ClickableComponent, BluePrint>()); } int widthOfBlueprintSpace = Game1.tileSize * 8; int[] rowWidthTally = new int[4]; for (int j = 0; j < Game1.player.blueprints.Count; j++) { BluePrint print = new BluePrint(Game1.player.blueprints[j]); if (CataloguePage.canPlaceThisBuildingOnTheCurrentMap(print, Game1.currentLocation)) { print.canBuildOnCurrentMap = true; } int tabNumber = this.getTabNumberFromName(print.blueprintType); if (print.blueprintType != null) { int printWidth = (int)((float)Math.Max(print.tilesWidth, 4) / 4f * (float)Game1.tileSize) + CataloguePage.blueprintButtonMargin; if (rowWidthTally[tabNumber] % (widthOfBlueprintSpace - IClickableMenu.borderWidth * 2) + printWidth > widthOfBlueprintSpace - IClickableMenu.borderWidth * 2) { rowWidthTally[tabNumber] += widthOfBlueprintSpace - IClickableMenu.borderWidth * 2 - rowWidthTally[tabNumber] % (widthOfBlueprintSpace - IClickableMenu.borderWidth * 2); } this.blueprintButtons[Math.Min(3, tabNumber)].Add(new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(x + IClickableMenu.borderWidth + rowWidthTally[tabNumber] % (widthOfBlueprintSpace - IClickableMenu.borderWidth * 2), y + IClickableMenu.borderWidth + rowWidthTally[tabNumber] / (widthOfBlueprintSpace - IClickableMenu.borderWidth * 2) * Game1.tileSize * 2 + Game1.tileSize, printWidth, Game1.tileSize * 2), print.name), print); rowWidthTally[tabNumber] += printWidth; } } }
public CataloguePage(int x, int y, int width, int height, GameMenu parent) : base(x, y, width, height, false) { this.parent = parent; this.buildingPlacementTiles = Game1.content.Load <Texture2D>("LooseSprites\\buildingPlacementTiles"); CataloguePage.widthToMoveActiveTab = Game1.tileSize / 8; CataloguePage.blueprintButtonMargin = Game1.tileSize / 2; this.inventory = new InventoryMenu(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + IClickableMenu.borderWidth, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth + Game1.tileSize * 5 - Game1.tileSize / 4, false, null, null, -1, 3, 0, 0, true); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4 + CataloguePage.widthToMoveActiveTab, this.yPositionOnScreen + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), "", "Buildings", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 4, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 3, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10138", new object[0]), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 5, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 4, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10139", new object[0]), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 8, -1, -1), 1f, false)); this.sideTabs.Add(new ClickableTextureComponent("", new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 5, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10140", new object[0]), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 6, -1, -1), 1f, false)); for (int i = 0; i < 4; i++) { this.blueprintButtons.Add(new Dictionary <ClickableComponent, BluePrint>()); } int num = Game1.tileSize * 8; int[] array = new int[4]; for (int j = 0; j < Game1.player.blueprints.Count; j++) { BluePrint bluePrint = new BluePrint(Game1.player.blueprints[j]); if (CataloguePage.canPlaceThisBuildingOnTheCurrentMap(bluePrint, Game1.currentLocation)) { bluePrint.canBuildOnCurrentMap = true; } int tabNumberFromName = this.getTabNumberFromName(bluePrint.blueprintType); if (bluePrint.blueprintType != null) { int num2 = (int)((float)Math.Max(bluePrint.tilesWidth, 4) / 4f * (float)Game1.tileSize) + CataloguePage.blueprintButtonMargin; if (array[tabNumberFromName] % (num - IClickableMenu.borderWidth * 2) + num2 > num - IClickableMenu.borderWidth * 2) { array[tabNumberFromName] += num - IClickableMenu.borderWidth * 2 - array[tabNumberFromName] % (num - IClickableMenu.borderWidth * 2); } this.blueprintButtons[Math.Min(3, tabNumberFromName)].Add(new ClickableComponent(new Microsoft.Xna.Framework.Rectangle(x + IClickableMenu.borderWidth + array[tabNumberFromName] % (num - IClickableMenu.borderWidth * 2), y + IClickableMenu.borderWidth + array[tabNumberFromName] / (num - IClickableMenu.borderWidth * 2) * Game1.tileSize * 2 + Game1.tileSize, num2, Game1.tileSize * 2), bluePrint.name), bluePrint); array[tabNumberFromName] += num2; } } }
public override void receiveLeftClick(int x, int y, bool playSound = true) { if (!this.placingStructure) { this.heldItem = this.inventory.leftClick(x, y, this.heldItem, true); for (int index = 0; index < this.sideTabs.Count; ++index) { if (this.sideTabs[index].containsPoint(x, y) && this.currentTab != index) { Game1.playSound("smallSelect"); if (index == 3) { this.placingStructure = true; this.demolishing = true; this.parent.invisible = true; } else { this.sideTabs[this.currentTab].bounds.X -= CataloguePage.widthToMoveActiveTab; this.currentTab = index; this.sideTabs[index].bounds.X += CataloguePage.widthToMoveActiveTab; } } } foreach (ClickableComponent key in this.blueprintButtons[this.currentTab].Keys) { if (key.containsPoint(x, y)) { if (this.blueprintButtons[this.currentTab][key].doesFarmerHaveEnoughResourcesToBuild()) { this.structureForPlacement = this.blueprintButtons[this.currentTab][key]; this.placingStructure = true; this.parent.invisible = true; if (this.currentTab == 1) { this.upgrading = true; } Game1.playSound("smallSelect"); break; } Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10002"), Color.Red, 3500f)); break; } } } else if (this.demolishing) { if (!(Game1.currentLocation is Farm)) { return; } if (Game1.IsClient) { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10148"), Color.Red, 3500f)); } else { Vector2 vector2 = new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)); Building buildingAt = ((BuildableGameLocation)Game1.currentLocation).getBuildingAt(vector2); if (Game1.IsMultiplayer && buildingAt != null && buildingAt.indoors.farmers.Count > 0) { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10149"), Color.Red, 3500f)); } else if (buildingAt != null && ((BuildableGameLocation)Game1.currentLocation).destroyStructure(buildingAt)) { int num = buildingAt.tileY + buildingAt.tilesHigh; for (int index = 0; index < buildingAt.texture.Bounds.Height / Game1.tileSize; ++index) { GameLocation currentLocation = Game1.currentLocation; Texture2D texture = buildingAt.texture; Microsoft.Xna.Framework.Rectangle bounds = buildingAt.texture.Bounds; int x1 = bounds.Center.X; bounds = buildingAt.texture.Bounds; int y1 = bounds.Center.Y; int width = Game1.tileSize / 16; int height = Game1.tileSize / 16; Microsoft.Xna.Framework.Rectangle sourcerectangle = new Microsoft.Xna.Framework.Rectangle(x1, y1, width, height); int xTile = buildingAt.tileX + Game1.random.Next(buildingAt.tilesWide); int yTile = buildingAt.tileY + buildingAt.tilesHigh - index; int numberOfChunks = Game1.random.Next(20, 45); int groundLevelTile = num; Game1.createRadialDebris(currentLocation, texture, sourcerectangle, xTile, yTile, numberOfChunks, groundLevelTile); } Game1.playSound("explosion"); Utility.spreadAnimalsAround(buildingAt, (Farm)Game1.currentLocation); if (!Game1.IsServer) { return; } MultiplayerUtility.broadcastBuildingChange((byte)1, vector2, "", Game1.currentLocation.name, Game1.player.uniqueMultiplayerID); } else { this.parent.invisible = false; this.placingStructure = false; this.demolishing = false; } } } else if (this.upgrading && Game1.currentLocation.GetType() == typeof(Farm)) { (Game1.currentLocation as Farm).tryToUpgrade(((BuildableGameLocation)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize))), this.structureForPlacement); } else if (!CataloguePage.canPlaceThisBuildingOnTheCurrentMap(this.structureForPlacement, Game1.currentLocation)) { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:CataloguePage.cs.10152"), Color.Red, 3500f)); } else if (!this.structureForPlacement.doesFarmerHaveEnoughResourcesToBuild()) { Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10002"), Color.Red, 3500f)); } else if (this.tryToBuild()) { this.structureForPlacement.consumeResources(); if (this.structureForPlacement.blueprintType.Equals("Animals")) { return; } Game1.playSound("axe"); } else { if (Game1.IsClient) { return; } Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:BlueprintsMenu.cs.10016"), Color.Red, 3500f)); } }
// Token: 0x06000DB9 RID: 3513 RVA: 0x00116F10 File Offset: 0x00115110 public override void receiveLeftClick(int x, int y, bool playSound = true) { if (!this.placingStructure) { this.heldItem = this.inventory.leftClick(x, y, this.heldItem, true); for (int i = 0; i < this.sideTabs.Count; i++) { if (this.sideTabs[i].containsPoint(x, y) && this.currentTab != i) { Game1.playSound("smallSelect"); if (i == 3) { this.placingStructure = true; this.demolishing = true; this.parent.invisible = true; } else { ClickableTextureComponent expr_8F_cp_0_cp_0 = this.sideTabs[this.currentTab]; expr_8F_cp_0_cp_0.bounds.X = expr_8F_cp_0_cp_0.bounds.X - CataloguePage.widthToMoveActiveTab; this.currentTab = i; ClickableTextureComponent expr_B5_cp_0_cp_0 = this.sideTabs[i]; expr_B5_cp_0_cp_0.bounds.X = expr_B5_cp_0_cp_0.bounds.X + CataloguePage.widthToMoveActiveTab; } } } using (Dictionary <ClickableComponent, BluePrint> .KeyCollection.Enumerator enumerator = this.blueprintButtons[this.currentTab].Keys.GetEnumerator()) { while (enumerator.MoveNext()) { ClickableComponent c = enumerator.Current; if (c.containsPoint(x, y)) { if (this.blueprintButtons[this.currentTab][c].doesFarmerHaveEnoughResourcesToBuild()) { this.structureForPlacement = this.blueprintButtons[this.currentTab][c]; this.placingStructure = true; this.parent.invisible = true; if (this.currentTab == 1) { this.upgrading = true; } Game1.playSound("smallSelect"); break; } Game1.addHUDMessage(new HUDMessage("Not Enough Resources", Color.Red, 3500f)); break; } } return; } } if (this.demolishing) { if (!(Game1.currentLocation is Farm)) { return; } if (Game1.IsClient) { Game1.addHUDMessage(new HUDMessage("Only the farm owner can demolish.", Color.Red, 3500f)); return; } Vector2 tileLocation = new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize)); Building destroyed = ((Farm)Game1.currentLocation).getBuildingAt(tileLocation); if (Game1.IsMultiplayer && destroyed != null && destroyed.indoors.farmers.Count > 0) { Game1.addHUDMessage(new HUDMessage("Someone's in there!", Color.Red, 3500f)); return; } if (destroyed == null || !((Farm)Game1.currentLocation).destroyStructure(destroyed)) { this.parent.invisible = false; this.placingStructure = false; this.demolishing = false; return; } int groundYTile = destroyed.tileY + destroyed.tilesHigh; for (int j = 0; j < destroyed.texture.Bounds.Height / Game1.tileSize; j++) { Game1.createRadialDebris(Game1.currentLocation, destroyed.texture, new Microsoft.Xna.Framework.Rectangle(destroyed.texture.Bounds.Center.X, destroyed.texture.Bounds.Center.Y, Game1.tileSize / 16, Game1.tileSize / 16), destroyed.tileX + Game1.random.Next(destroyed.tilesWide), destroyed.tileY + destroyed.tilesHigh - j, Game1.random.Next(20, 45), groundYTile); } Game1.playSound("explosion"); Utility.spreadAnimalsAround(destroyed, (Farm)Game1.currentLocation); if (Game1.IsServer) { MultiplayerUtility.broadcastBuildingChange(1, tileLocation, "", Game1.currentLocation.name, Game1.player.uniqueMultiplayerID); return; } } else { if (this.upgrading && Game1.currentLocation.GetType() == typeof(Farm)) { (Game1.currentLocation as Farm).tryToUpgrade(((Farm)Game1.getLocationFromName("Farm")).getBuildingAt(new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / Game1.tileSize), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / Game1.tileSize))), this.structureForPlacement); return; } if (!CataloguePage.canPlaceThisBuildingOnTheCurrentMap(this.structureForPlacement, Game1.currentLocation)) { Game1.addHUDMessage(new HUDMessage("You can't build that in this location.", Color.Red, 3500f)); return; } if (!this.structureForPlacement.doesFarmerHaveEnoughResourcesToBuild()) { Game1.addHUDMessage(new HUDMessage("Not Enough Resources", Color.Red, 3500f)); return; } if (this.tryToBuild()) { this.structureForPlacement.consumeResources(); if (!this.structureForPlacement.blueprintType.Equals("Animals")) { Game1.playSound("axe"); return; } } else if (!Game1.IsClient) { Game1.addHUDMessage(new HUDMessage("Can't Build There", Color.Red, 3500f)); } } }