Beispiel #1
0
 public override void draw(SpriteBatch b)
 {
     if (this.drawBG)
     {
         b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.5f);
     }
     if (Game1.delayedActions.Count() > 0 || this.freeze)
     {
         return;
     }
     if (!this.onFarm)
     {
         base.draw(b);
         IClickableMenu.drawTextureBox(b, this.xPositionOnScreen - 96, this.yPositionOnScreen - 16, this.maxWidthOfBuildingViewer + 64, this.maxHeightOfBuildingViewer + 64, this.magicalConstruction ? Color.RoyalBlue : Color.White);
         this.currentBuilding.drawInMenu(b, this.xPositionOnScreen + this.maxWidthOfBuildingViewer / 2 - (int)((NetFieldBase <int, NetInt>) this.currentBuilding.tilesWide) * 64 / 2 - 64, this.yPositionOnScreen + this.maxHeightOfBuildingViewer / 2 - this.currentBuilding.getSourceRectForMenu().Height * 4 / 2);
         if (this.CurrentBlueprint.isUpgrade())
         {
             this.upgradeIcon.draw(b);
         }
         string str = " Deluxe  Barn   ";
         SpriteText.drawStringWithScrollBackground(b, this.buildingName, this.xPositionOnScreen + this.maxWidthOfBuildingViewer - IClickableMenu.spaceToClearSideBorder - 16 + 64 + ((this.width - (this.maxWidthOfBuildingViewer + 128)) / 2 - SpriteText.getWidthOfString(str) / 2), this.yPositionOnScreen, str, 1f, -1);
         IClickableMenu.drawTextureBox(b, this.xPositionOnScreen + this.maxWidthOfBuildingViewer - 16, this.yPositionOnScreen + 80, this.maxWidthOfDescription + 64, this.maxWidthOfDescription + 96, this.magicalConstruction ? Color.RoyalBlue : Color.White);
         if (this.magicalConstruction)
         {
             Utility.drawTextWithShadow(b, Game1.parseText(this.buildingDescription, Game1.dialogueFont, this.maxWidthOfDescription + 32), Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + this.maxWidthOfDescription + 64 - 4), (float)(this.yPositionOnScreen + 80 + 16 + 4)), Game1.textColor * 0.25f, 1f, -1f, -1, -1, 0.0f, 3);
             Utility.drawTextWithShadow(b, Game1.parseText(this.buildingDescription, Game1.dialogueFont, this.maxWidthOfDescription + 32), Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + this.maxWidthOfDescription + 64 - 1), (float)(this.yPositionOnScreen + 80 + 16 + 4)), Game1.textColor * 0.25f, 1f, -1f, -1, -1, 0.0f, 3);
         }
         Utility.drawTextWithShadow(b, Game1.parseText(this.buildingDescription, Game1.dialogueFont, this.maxWidthOfDescription + 32), Game1.dialogueFont, new Vector2((float)(this.xPositionOnScreen + this.maxWidthOfDescription + 64), (float)(this.yPositionOnScreen + 80 + 16)), this.magicalConstruction ? Color.PaleGoldenrod : Game1.textColor, 1f, -1f, -1, -1, this.magicalConstruction ? 0.0f : 0.25f, 3);
         Vector2 location = new Vector2((float)(this.xPositionOnScreen + this.maxWidthOfDescription + 16 + 64), (float)(this.yPositionOnScreen + 256 + 32));
         SpriteText.drawString(b, "$", (int)location.X, (int)location.Y, 999999, -1, 999999, 1f, 0.88f, false, -1, "", -1);
         if (this.magicalConstruction)
         {
             Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.price), Game1.dialogueFont, new Vector2(location.X + 64f, location.Y + 8f), Game1.textColor * 0.5f, 1f, -1f, -1, -1, this.magicalConstruction ? 0.0f : 0.25f, 3);
             Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.price), Game1.dialogueFont, new Vector2((float)((double)location.X + 64.0 + 4.0 - 1.0), location.Y + 8f), Game1.textColor * 0.25f, 1f, -1f, -1, -1, this.magicalConstruction ? 0.0f : 0.25f, 3);
         }
         Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", (object)this.price), Game1.dialogueFont, new Vector2((float)((double)location.X + 64.0 + 4.0), location.Y + 4f), Game1.player.money >= this.price ? (this.magicalConstruction ? Color.PaleGoldenrod : Game1.textColor) : Color.Red, 1f, -1f, -1, -1, this.magicalConstruction ? 0.0f : 0.25f, 3);
         location.X -= 16f;
         location.Y -= 21f;
         foreach (Item ingredient in this.ingredients)
         {
             location.Y += 68f;
             ingredient.drawInMenu(b, location, 1f);
             bool flag = !(ingredient is StardewValley.Object) || Game1.player.hasItemInInventory((int)((NetFieldBase <int, NetInt>)(ingredient as StardewValley.Object).parentSheetIndex), ingredient.Stack, 0);
             if (this.magicalConstruction)
             {
                 Utility.drawTextWithShadow(b, ingredient.DisplayName, Game1.dialogueFont, new Vector2((float)((double)location.X + 64.0 + 12.0), location.Y + 24f), Game1.textColor * 0.25f, 1f, -1f, -1, -1, this.magicalConstruction ? 0.0f : 0.25f, 3);
                 Utility.drawTextWithShadow(b, ingredient.DisplayName, Game1.dialogueFont, new Vector2((float)((double)location.X + 64.0 + 16.0 - 1.0), location.Y + 24f), Game1.textColor * 0.25f, 1f, -1f, -1, -1, this.magicalConstruction ? 0.0f : 0.25f, 3);
             }
             Utility.drawTextWithShadow(b, ingredient.DisplayName, Game1.dialogueFont, new Vector2((float)((double)location.X + 64.0 + 16.0), location.Y + 20f), flag ? (this.magicalConstruction ? Color.PaleGoldenrod : Game1.textColor) : Color.Red, 1f, -1f, -1, -1, this.magicalConstruction ? 0.0f : 0.25f, 3);
         }
         this.backButton.draw(b);
         this.forwardButton.draw(b);
         this.okButton.draw(b, this.blueprints[this.currentBlueprintIndex].doesFarmerHaveEnoughResourcesToBuild() ? Color.White : Color.Gray * 0.8f, 0.88f);
         this.demolishButton.draw(b);
         this.moveButton.draw(b);
     }
     else
     {
         string s = this.upgrading ? Game1.content.LoadString("Strings\\UI:Carpenter_SelectBuilding_Upgrade", (object)new BluePrint(this.CurrentBlueprint.nameOfBuildingToUpgrade).displayName) : (this.demolishing ? Game1.content.LoadString("Strings\\UI:Carpenter_SelectBuilding_Demolish") : Game1.content.LoadString("Strings\\UI:Carpenter_ChooseLocation"));
         SpriteText.drawStringWithScrollBackground(b, s, Game1.viewport.Width / 2 - SpriteText.getWidthOfString(s) / 2, 16, "", 1f, -1);
         if (!this.upgrading && !this.demolishing && !this.moving)
         {
             Vector2 vector2 = new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / 64), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / 64));
             for (int y = 0; y < this.CurrentBlueprint.tilesHeight; ++y)
             {
                 for (int x = 0; x < this.CurrentBlueprint.tilesWidth; ++x)
                 {
                     int     structurePlacementTile = this.CurrentBlueprint.getTileSheetIndexForStructurePlacementTile(x, y);
                     Vector2 tileLocation           = new Vector2(vector2.X + (float)x, vector2.Y + (float)y);
                     if (!(Game1.currentLocation as BuildableGameLocation).isBuildable(tileLocation))
                     {
                         ++structurePlacementTile;
                     }
                     b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, tileLocation * 64f), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(194 + structurePlacementTile * 16, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.999f);
                 }
             }
         }
         else if (this.moving && this.buildingToMove != null)
         {
             Vector2 vector2_1 = new Vector2((float)((Game1.viewport.X + Game1.getOldMouseX()) / 64), (float)((Game1.viewport.Y + Game1.getOldMouseY()) / 64));
             BuildableGameLocation currentLocation = Game1.currentLocation as BuildableGameLocation;
             for (int y = 0; y < (int)((NetFieldBase <int, NetInt>) this.buildingToMove.tilesHigh); ++y)
             {
                 for (int x = 0; x < (int)((NetFieldBase <int, NetInt>) this.buildingToMove.tilesWide); ++x)
                 {
                     int     structurePlacementTile = this.buildingToMove.getTileSheetIndexForStructurePlacementTile(x, y);
                     Vector2 vector2_2 = new Vector2(vector2_1.X + (float)x, vector2_1.Y + (float)y);
                     bool    flag      = currentLocation.buildings.Contains(this.buildingToMove) && this.buildingToMove.occupiesTile(vector2_2);
                     if (!currentLocation.isBuildable(vector2_2) && !flag)
                     {
                         ++structurePlacementTile;
                     }
                     b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, vector2_2 * 64f), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(194 + structurePlacementTile * 16, 388, 16, 16)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 0.999f);
                 }
             }
         }
     }
     this.cancelButton.draw(b);
     this.drawMouse(b);
     if (this.hoverText.Length <= 0)
     {
         return;
     }
     IClickableMenu.drawHoverText(b, this.hoverText, Game1.dialogueFont, 0, 0, -1, (string)null, -1, (string[])null, (Item)null, 0, -1, -1, -1, -1, 1f, (CraftingRecipe)null);
 }
Beispiel #2
0
 /// <summary>Get whether a tile is buildable.</summary>
 /// <param name="location">The current location.</param>
 /// <param name="tile">The tile to check.</param>
 /// <remarks>Derived from <see cref="BuildableGameLocation.buildStructure(Building, Vector2, Farmer, bool)"/>.</remarks>
 private bool IsBuildable(BuildableGameLocation location, Vector2 tile)
 {
     return(location.isBuildable(tile));
 }
Beispiel #3
0
        public override void draw(SpriteBatch b)
        {
            if (drawBG)
            {
                b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.5f);
            }
            if (Game1.globalFade || freeze)
            {
                return;
            }
            if (!onFarm)
            {
                base.draw(b);
                IClickableMenu.drawTextureBox(b, xPositionOnScreen - 96, yPositionOnScreen - 16, maxWidthOfBuildingViewer + 64, maxHeightOfBuildingViewer + 64, magicalConstruction ? Color.RoyalBlue : Color.White);
                currentBuilding.drawInMenu(b, xPositionOnScreen + maxWidthOfBuildingViewer / 2 - (int)currentBuilding.tilesWide * 64 / 2 - 64, yPositionOnScreen + maxHeightOfBuildingViewer / 2 - currentBuilding.getSourceRectForMenu().Height * 4 / 2);
                if (CurrentBlueprint.isUpgrade())
                {
                    upgradeIcon.draw(b);
                }
                string placeholder = " Deluxe  Barn   ";
                if (SpriteText.getWidthOfString(buildingName) >= SpriteText.getWidthOfString(placeholder))
                {
                    placeholder = buildingName + " ";
                }
                SpriteText.drawStringWithScrollCenteredAt(b, buildingName, xPositionOnScreen + maxWidthOfBuildingViewer - IClickableMenu.spaceToClearSideBorder - 16 + 64 + (width - (maxWidthOfBuildingViewer + 128)) / 2, yPositionOnScreen, SpriteText.getWidthOfString(placeholder));
                int descriptionWidth;
                switch (LocalizedContentManager.CurrentLanguageCode)
                {
                case LocalizedContentManager.LanguageCode.es:
                    descriptionWidth = maxWidthOfDescription + 64 + ((CurrentBlueprint?.name == "Deluxe Barn") ? 96 : 0);
                    break;

                case LocalizedContentManager.LanguageCode.it:
                    descriptionWidth = maxWidthOfDescription + 96;
                    break;

                case LocalizedContentManager.LanguageCode.fr:
                    descriptionWidth = maxWidthOfDescription + 96 + ((CurrentBlueprint?.name == "Slime Hutch" || CurrentBlueprint?.name == "Deluxe Coop" || CurrentBlueprint?.name == "Deluxe Barn") ? 72 : 0);
                    break;

                case LocalizedContentManager.LanguageCode.ko:
                    descriptionWidth = maxWidthOfDescription + 96 + ((CurrentBlueprint?.name == "Slime Hutch") ? 64 : ((CurrentBlueprint?.name == "Deluxe Coop") ? 96 : ((CurrentBlueprint?.name == "Deluxe Barn") ? 112 : ((CurrentBlueprint?.name == "Big Barn") ? 64 : 0))));
                    break;

                default:
                    descriptionWidth = maxWidthOfDescription + 64;
                    break;
                }
                IClickableMenu.drawTextureBox(b, xPositionOnScreen + maxWidthOfBuildingViewer - 16, yPositionOnScreen + 80, descriptionWidth, maxHeightOfBuildingViewer - 32, magicalConstruction ? Color.RoyalBlue : Color.White);
                if (magicalConstruction)
                {
                    Utility.drawTextWithShadow(b, Game1.parseText(buildingDescription, Game1.dialogueFont, descriptionWidth - 32), Game1.dialogueFont, new Vector2(xPositionOnScreen + maxWidthOfBuildingViewer - 4, yPositionOnScreen + 80 + 16 + 4), Game1.textColor * 0.25f, 1f, -1f, -1, -1, 0f);
                    Utility.drawTextWithShadow(b, Game1.parseText(buildingDescription, Game1.dialogueFont, descriptionWidth - 32), Game1.dialogueFont, new Vector2(xPositionOnScreen + maxWidthOfBuildingViewer - 1, yPositionOnScreen + 80 + 16 + 4), Game1.textColor * 0.25f, 1f, -1f, -1, -1, 0f);
                }
                Utility.drawTextWithShadow(b, Game1.parseText(buildingDescription, Game1.dialogueFont, descriptionWidth - 32), Game1.dialogueFont, new Vector2(xPositionOnScreen + maxWidthOfBuildingViewer, yPositionOnScreen + 80 + 16), magicalConstruction ? Color.PaleGoldenrod : Game1.textColor, 1f, -1f, -1, -1, magicalConstruction ? 0f : 0.75f);
                Vector2 ingredientsPosition = new Vector2(xPositionOnScreen + maxWidthOfBuildingViewer + 16, yPositionOnScreen + 256 + 32);
                if (ingredients.Count < 3 && (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.fr || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ko || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.pt))
                {
                    ingredientsPosition.Y += 64f;
                }
                SpriteText.drawString(b, "$", (int)ingredientsPosition.X, (int)ingredientsPosition.Y);
                if (magicalConstruction)
                {
                    Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", price), Game1.dialogueFont, new Vector2(ingredientsPosition.X + 64f, ingredientsPosition.Y + 8f), Game1.textColor * 0.5f, 1f, -1f, -1, -1, magicalConstruction ? 0f : 0.25f);
                    Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", price), Game1.dialogueFont, new Vector2(ingredientsPosition.X + 64f + 4f - 1f, ingredientsPosition.Y + 8f), Game1.textColor * 0.25f, 1f, -1f, -1, -1, magicalConstruction ? 0f : 0.25f);
                }
                Utility.drawTextWithShadow(b, Game1.content.LoadString("Strings\\StringsFromCSFiles:LoadGameMenu.cs.11020", price), Game1.dialogueFont, new Vector2(ingredientsPosition.X + 64f + 4f, ingredientsPosition.Y + 4f), (Game1.player.Money < price) ? Color.Red : (magicalConstruction ? Color.PaleGoldenrod : Game1.textColor), 1f, -1f, -1, -1, magicalConstruction ? 0f : 0.25f);
                ingredientsPosition.X -= 16f;
                ingredientsPosition.Y -= 21f;
                foreach (Item i in ingredients)
                {
                    ingredientsPosition.Y += 68f;
                    i.drawInMenu(b, ingredientsPosition, 1f);
                    bool hasItem = (!(i is Object) || Game1.player.hasItemInInventory((i as Object).parentSheetIndex, i.Stack)) ? true : false;
                    if (magicalConstruction)
                    {
                        Utility.drawTextWithShadow(b, i.DisplayName, Game1.dialogueFont, new Vector2(ingredientsPosition.X + 64f + 12f, ingredientsPosition.Y + 24f), Game1.textColor * 0.25f, 1f, -1f, -1, -1, magicalConstruction ? 0f : 0.25f);
                        Utility.drawTextWithShadow(b, i.DisplayName, Game1.dialogueFont, new Vector2(ingredientsPosition.X + 64f + 16f - 1f, ingredientsPosition.Y + 24f), Game1.textColor * 0.25f, 1f, -1f, -1, -1, magicalConstruction ? 0f : 0.25f);
                    }
                    Utility.drawTextWithShadow(b, i.DisplayName, Game1.dialogueFont, new Vector2(ingredientsPosition.X + 64f + 16f, ingredientsPosition.Y + 20f), hasItem ? (magicalConstruction ? Color.PaleGoldenrod : Game1.textColor) : Color.Red, 1f, -1f, -1, -1, magicalConstruction ? 0f : 0.25f);
                }
                backButton.draw(b);
                forwardButton.draw(b);
                okButton.draw(b, blueprints[currentBlueprintIndex].doesFarmerHaveEnoughResourcesToBuild() ? Color.White : (Color.Gray * 0.8f), 0.88f);
                demolishButton.draw(b);
                moveButton.draw(b);
            }
            else
            {
                string message = upgrading ? Game1.content.LoadString("Strings\\UI:Carpenter_SelectBuilding_Upgrade", new BluePrint(CurrentBlueprint.nameOfBuildingToUpgrade).displayName) : (demolishing ? Game1.content.LoadString("Strings\\UI:Carpenter_SelectBuilding_Demolish") : Game1.content.LoadString("Strings\\UI:Carpenter_ChooseLocation"));
                SpriteText.drawStringWithScrollBackground(b, message, Game1.viewport.Width / 2 - SpriteText.getWidthOfString(message) / 2, 16);
                if (!upgrading && !demolishing && !moving)
                {
                    Vector2 mousePositionTile2 = new Vector2((Game1.viewport.X + Game1.getOldMouseX()) / 64, (Game1.viewport.Y + Game1.getOldMouseY()) / 64);
                    for (int y2 = 0; y2 < CurrentBlueprint.tilesHeight; y2++)
                    {
                        for (int x2 = 0; x2 < CurrentBlueprint.tilesWidth; x2++)
                        {
                            int     sheetIndex2 = CurrentBlueprint.getTileSheetIndexForStructurePlacementTile(x2, y2);
                            Vector2 currentGlobalTilePosition2 = new Vector2(mousePositionTile2.X + (float)x2, mousePositionTile2.Y + (float)y2);
                            if (!(Game1.currentLocation as BuildableGameLocation).isBuildable(currentGlobalTilePosition2))
                            {
                                sheetIndex2++;
                            }
                            b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, currentGlobalTilePosition2 * 64f), new Microsoft.Xna.Framework.Rectangle(194 + sheetIndex2 * 16, 388, 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.999f);
                        }
                    }
                }
                else if (moving && buildingToMove != null)
                {
                    Vector2 mousePositionTile = new Vector2((Game1.viewport.X + Game1.getOldMouseX()) / 64, (Game1.viewport.Y + Game1.getOldMouseY()) / 64);
                    BuildableGameLocation bl  = Game1.currentLocation as BuildableGameLocation;
                    for (int y = 0; y < (int)buildingToMove.tilesHigh; y++)
                    {
                        for (int x = 0; x < (int)buildingToMove.tilesWide; x++)
                        {
                            int     sheetIndex = buildingToMove.getTileSheetIndexForStructurePlacementTile(x, y);
                            Vector2 currentGlobalTilePosition = new Vector2(mousePositionTile.X + (float)x, mousePositionTile.Y + (float)y);
                            bool    occupiedByBuilding        = bl.buildings.Contains(buildingToMove) && buildingToMove.occupiesTile(currentGlobalTilePosition);
                            if (!bl.isBuildable(currentGlobalTilePosition) && !occupiedByBuilding)
                            {
                                sheetIndex++;
                            }
                            b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, currentGlobalTilePosition * 64f), new Microsoft.Xna.Framework.Rectangle(194 + sheetIndex * 16, 388, 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.999f);
                        }
                    }
                }
            }
            cancelButton.draw(b);
            drawMouse(b);
            if (hoverText.Length > 0)
            {
                IClickableMenu.drawHoverText(b, hoverText, Game1.dialogueFont);
            }
        }