Ejemplo n.º 1
0
        public AnimalQueryMenuExtended(FarmAnimal farmAnimal) : base(farmAnimal)
        {
            _farmAnimal = farmAnimal;
            if (Context.IsMainPlayer && !DataLoader.ModConfig.DisablePregnancy)
            {
                if (PregnancyController.IsAnimalPregnant(this._farmAnimal.myID.Value))
                {
                    this.allowReproductionButton = null;
                    pregnantStatus = new ClickableTextureComponent(
                        new Microsoft.Xna.Framework.Rectangle(
                            this.xPositionOnScreen + AnimalQueryMenu.width + Game1.pixelZoom * 3,
                            this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 2 - IClickableMenu.borderWidth + Game1.pixelZoom,
                            Game1.pixelZoom * 11, Game1.pixelZoom * 11), DataLoader.LooseSprites,
                        new Microsoft.Xna.Framework.Rectangle(34, 29, 11, 11), 4f, false);
                }
            }

            if (Context.IsMainPlayer && !DataLoader.ModConfig.DisableTreats && TreatsController.CanReceiveTreat(farmAnimal))
            {
                if (TreatsController.IsReadyForTreat(farmAnimal))
                {
                    treatStatus = new ClickableTextureComponent(
                        new Microsoft.Xna.Framework.Rectangle(
                            this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4,
                            this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 2 - IClickableMenu.borderWidth,
                            Game1.tileSize, Game1.tileSize), DataLoader.ToolsSprites,
                        new Microsoft.Xna.Framework.Rectangle(240, 0, 16, 16), 4f, false);
                }
                else
                {
                    treatStatus = new ClickableTextureComponent(
                        new Microsoft.Xna.Framework.Rectangle(
                            this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4,
                            this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 2 - IClickableMenu.borderWidth,
                            Game1.tileSize, Game1.tileSize), DataLoader.LooseSprites,
                        new Microsoft.Xna.Framework.Rectangle(16, 28, 16, 16), 4f, false);
                }
            }

            if (AnimalContestController.IsParticipant(farmAnimal))
            {
                animalContestIndicator = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 4 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), DataLoader.ToolsSprites, new Microsoft.Xna.Framework.Rectangle(256, 0, 16, 16), 4f, false);
            }

            if (!DataLoader.ModConfig.DisableMeat && MeatController.CanGetMeatFrom(farmAnimal))
            {
                if (!this._farmAnimal.isBaby())
                {
                    meatButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), DataLoader.LooseSprites, new Microsoft.Xna.Framework.Rectangle(0, 28, 16, 16), 4f, false);
                }
            }

            _parentName     = DataLoader.Helper.Reflection.GetField <String>(this, "parentName").GetValue();
            _textBox        = DataLoader.Helper.Reflection.GetField <TextBox>(this, "textBox").GetValue();
            _movingAnimal   = DataLoader.Helper.Reflection.GetField <bool>(this, "movingAnimal");
            _confirmingSell = DataLoader.Helper.Reflection.GetField <bool>(this, "confirmingSell");
            _lovelLevel     = DataLoader.Helper.Reflection.GetField <double>(this, "loveLevel");
            _hoverText      = DataLoader.Helper.Reflection.GetField <string>(this, "hoverText");
        }
Ejemplo n.º 2
0
 public override void performHoverAction(int x, int y)
 {
     base.performHoverAction(x, y);
     if (_movingAnimal.GetValue())
     {
         Vector2  tile             = new Vector2((float)((x + Game1.viewport.X) / Game1.tileSize), (float)((y + Game1.viewport.Y) / Game1.tileSize));
         Farm     locationFromName = Game1.getLocationFromName("Farm") as Farm;
         Building buildingAt       = locationFromName.getBuildingAt(tile);
         if (buildingAt != null)
         {
             if (buildingAt.color.Equals(Color.LightGreen * 0.8f) &&
                 PregnancyController.IsAnimalPregnant(this._farmAnimal.myID.Value) &&
                 PregnancyController.CheckBuildingLimit((buildingAt.indoors.Value as AnimalHouse)))
             {
                 buildingAt.color.Value = Color.Red * 0.8f;
             }
         }
     }
     else
     {
         if (this.meatButton != null)
         {
             if (this.meatButton.containsPoint(x, y))
             {
                 this.meatButton.scale = Math.Min(4.1f, this.meatButton.scale + 0.05f);
                 _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ExchangeAnimalForMeat"));
             }
             else
             {
                 this.meatButton.scale = Math.Max(4f, this.sellButton.scale - 0.05f);
             }
         }
         if (this.pregnantStatus != null)
         {
             if (this.pregnantStatus.containsPoint(x, y))
             {
                 int daysUtilBirth = PregnancyController.GetPregnancyItem(this._farmAnimal.myID.Value).DaysUntilBirth;
                 if (daysUtilBirth > 1)
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.DaysUntilBirth", new { numberOfDays = daysUtilBirth }));
                 }
                 else
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ReadyForBirth"));
                 }
             }
         }
         if (this.treatStatus != null)
         {
             if (this.treatStatus.containsPoint(x, y))
             {
                 int daysUntilNextTreat = TreatsController.DaysUntilNextTreat(this._farmAnimal);
                 if (daysUntilNextTreat > 1)
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.WantsTreatInDays", new { numberOfDays = daysUntilNextTreat }));
                 }
                 else if (daysUntilNextTreat == 1)
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.WantsTreatTomorrow"));
                 }
                 else
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.WantsTreat"));
                 }
             }
         }
         if (this.animalContestIndicator != null)
         {
             if (this.animalContestIndicator.containsPoint(x, y))
             {
                 if (AnimalContestController.CanChangeParticipant(this._farmAnimal))
                 {
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ChangeParticipant"));
                 }
                 else if (AnimalContestController.HasParticipated(this._farmAnimal) && AnimalContestController.HasWon(this._farmAnimal))
                 {
                     SDate date = AnimalContestController.GetParticipantDate(this._farmAnimal);
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.Winner", new { contestDate = Utility.getDateStringFor(date.Day, Utility.getSeasonNumber(date.Season), date.Year) }));
                 }
                 else
                 {
                     SDate date = AnimalContestController.GetParticipantDate(this._farmAnimal);
                     _hoverText.SetValue(DataLoader.i18n.Get("Menu.AnimalQueryMenu.ContestParticipant", new { contestDate = Utility.getDateStringFor(date.Day, Utility.getSeasonNumber(date.Season), date.Year) }));
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        public AnimalQueryMenuExtended(FarmAnimal farmAnimal) : base(farmAnimal)
        {
            _farmAnimal = farmAnimal;
            if (!DataLoader.ModConfig.DisablePregnancy)
            {
                if (PregnancyController.IsAnimalPregnant(this._farmAnimal))
                {
                    pregnantStatus = new ClickableTextureComponent(
                        new Microsoft.Xna.Framework.Rectangle(
                            this.xPositionOnScreen + AnimalQueryMenu.width + Game1.pixelZoom * 3,
                            this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 2 - IClickableMenu.borderWidth + Game1.pixelZoom,
                            Game1.pixelZoom * 11, Game1.pixelZoom * 11), DataLoader.LooseSprites,
                        new Microsoft.Xna.Framework.Rectangle(34, 29, 11, 11), 4f, false)
                    {
                        myID            = region_allowReproductionButton,
                        downNeighborID  = region_okButton,
                        upNeighborID    = region_sellButton,
                        rightNeighborID = region_treatStatus
                    };
                    this.okButton.upNeighborID     = region_allowReproductionButton;
                    this.sellButton.downNeighborID = region_allowReproductionButton;
                    if (Game1.options.SnappyMenus)
                    {
                        this.allClickableComponents.Remove(this.allowReproductionButton);
                        this.allClickableComponents.Add(pregnantStatus);
                    }
                    this.allowReproductionButton = null;
                }
            }

            if (!DataLoader.ModConfig.DisableTreats && TreatsController.CanReceiveTreat(farmAnimal))
            {
                if (TreatsController.IsReadyForTreat(farmAnimal))
                {
                    treatStatus = new ClickableTextureComponent(
                        new Microsoft.Xna.Framework.Rectangle(
                            this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4,
                            this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 2 - IClickableMenu.borderWidth,
                            Game1.tileSize, Game1.tileSize), DataLoader.ToolsSprites,
                        new Microsoft.Xna.Framework.Rectangle(240, 0, 16, 16), 4f, false)
                    {
                        myID           = region_treatStatus,
                        leftNeighborID = region_allowReproductionButton
                    };
                }
                else
                {
                    treatStatus = new ClickableTextureComponent(
                        new Microsoft.Xna.Framework.Rectangle(
                            this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4,
                            this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 2 - IClickableMenu.borderWidth,
                            Game1.tileSize, Game1.tileSize), DataLoader.LooseSprites,
                        new Microsoft.Xna.Framework.Rectangle(16, 28, 16, 16), 4f, false)
                    {
                        myID           = region_treatStatus,
                        leftNeighborID = region_allowReproductionButton
                    };
                }
                if (this.allowReproductionButton != null)
                {
                    this.allowReproductionButton.rightNeighborID = region_treatStatus;
                }
                if (Game1.options.SnappyMenus)
                {
                    this.allClickableComponents.Add(treatStatus);
                }
            }

            if (AnimalContestController.HasWon(farmAnimal))
            {
                animalContestIndicator = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 4 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), DataLoader.LooseSprites, new Microsoft.Xna.Framework.Rectangle(AnimalContestController.HasFertilityBonus(this._farmAnimal) ? 48 : 64, 29, 16, 15), 4f, false)
                {
                    myID           = region_animalConstestIndicator,
                    leftNeighborID = region_moveHomeButton
                };
                this.moveHomeButton.rightNeighborID = region_animalConstestIndicator;
                if (Game1.options.SnappyMenus)
                {
                    this.allClickableComponents.Add(animalContestIndicator);
                }
            }
            else if (farmAnimal.GetDayParticipatedContest() != null)
            {
                animalContestIndicator = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 4 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), DataLoader.ToolsSprites, new Microsoft.Xna.Framework.Rectangle(256, 0, 16, 16), 4f, false)
                {
                    myID           = region_animalConstestIndicator,
                    leftNeighborID = region_moveHomeButton
                };
                this.moveHomeButton.rightNeighborID = region_animalConstestIndicator;
                if (Game1.options.SnappyMenus)
                {
                    this.allClickableComponents.Add(animalContestIndicator);
                }
            }

            if (!DataLoader.ModConfig.DisableMeat && MeatController.CanGetMeatFrom(farmAnimal))
            {
                if (!this._farmAnimal.isBaby())
                {
                    meatButton = new ClickableTextureComponent(new Microsoft.Xna.Framework.Rectangle(this.xPositionOnScreen + AnimalQueryMenu.width + Game1.tileSize + 4, this.yPositionOnScreen + AnimalQueryMenu.height - Game1.tileSize * 3 - IClickableMenu.borderWidth, Game1.tileSize, Game1.tileSize), DataLoader.LooseSprites, new Microsoft.Xna.Framework.Rectangle(0, 28, 16, 16), 4f, false)
                    {
                        myID           = region_meatButton,
                        leftNeighborID = region_sellButton
                    };
                }
                this.sellButton.rightNeighborID = region_meatButton;
                if (Game1.options.SnappyMenus)
                {
                    this.allClickableComponents.Add(meatButton);
                }
            }

            if (this.animalContestIndicator != null)
            {
                this.moveHomeButton.rightNeighborID = region_animalConstestIndicator;
                if (this.meatButton != null)
                {
                    this.meatButton.upNeighborID = region_animalConstestIndicator;
                    this.animalContestIndicator.downNeighborID = region_meatButton;
                }
                else if (this.treatStatus != null)
                {
                    this.treatStatus.upNeighborID = region_animalConstestIndicator;
                    this.animalContestIndicator.downNeighborID = region_treatStatus;
                }
            }

            if (this.meatButton != null)
            {
                this.sellButton.rightNeighborID = region_meatButton;
                if (this.treatStatus != null)
                {
                    this.treatStatus.upNeighborID  = region_meatButton;
                    this.meatButton.downNeighborID = region_treatStatus;
                }
            }

            if (this.treatStatus != null)
            {
                if (this.pregnantStatus == null && this.allowReproductionButton == null)
                {
                    this.treatStatus.downNeighborID = region_okButton;
                    if (this.meatButton == null && this.animalContestIndicator == null)
                    {
                        this.treatStatus.upNeighborID  = region_sellButton;
                        this.okButton.upNeighborID     = region_treatStatus;
                        this.sellButton.downNeighborID = region_treatStatus;
                    }
                }
            }

            _parentName     = DataLoader.Helper.Reflection.GetField <String>(this, "parentName").GetValue();
            _textBox        = DataLoader.Helper.Reflection.GetField <TextBox>(this, "textBox").GetValue();
            _movingAnimal   = DataLoader.Helper.Reflection.GetField <bool>(this, "movingAnimal");
            _confirmingSell = DataLoader.Helper.Reflection.GetField <bool>(this, "confirmingSell");
            _lovelLevel     = DataLoader.Helper.Reflection.GetField <double>(this, "loveLevel");
            _hoverText      = DataLoader.Helper.Reflection.GetField <string>(this, "hoverText");
        }