/*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="modConfig">The mod configuration.</param>
        /// <param name="onEdited">The callback invoked when the sprinkler settings are changed.</param>
        public SprinklerShapeEditMenu(SprinklerModConfig modConfig, Action onEdited)
        {
            this.Config   = modConfig;
            this.OnEdited = onEdited;

            int menuWidth  = this.MaxArraySize * this.DefaultTileSize + this.MinLeftMargin * 2;
            int menuHeight = this.MaxArraySize * this.DefaultTileSize + this.MinTopMargin * 2;
            int menuX      = Game1.viewport.Width / 2 - menuWidth / 2;
            int menuY      = Game1.viewport.Height / 2 - menuHeight / 2;

            this.initialize(menuX, menuY, menuWidth, menuHeight, true);

            this.Tabs = new List <ClickableComponent>();
            int tabWidth  = this.TabItemWidth + this.TabLeftMargin + this.TabRightMargin;
            int tabHeight = this.TabItemHeight + this.TabVerticalMargins * 2;

            this.Tabs.Add(new ClickableComponent(new Rectangle(menuX - this.TabDistanceFromMenu - tabWidth, menuY + tabHeight * 0 + this.TabDistanceVerticalBetweenTabs, tabWidth, tabHeight), new Object(Vector2.Zero, 599)));
            this.Tabs.Add(new ClickableComponent(new Rectangle(menuX - this.TabDistanceFromMenu - tabWidth, this.Tabs[0].bounds.Y + tabHeight + this.TabDistanceVerticalBetweenTabs, tabWidth, tabHeight), new Object(Vector2.Zero, 621)));
            this.Tabs.Add(new ClickableComponent(new Rectangle(menuX - this.TabDistanceFromMenu - tabWidth, this.Tabs[1].bounds.Y + tabHeight + this.TabDistanceVerticalBetweenTabs, tabWidth, tabHeight), new Object(Vector2.Zero, 645)));

            this.OkButton = new ClickableTextureComponent("save-changes", new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2, this.yPositionOnScreen + this.height - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), "", "Save Changes", Game1.mouseCursors, new Rectangle(128, 256, 64, 64), 1f);

            this.WhitePixel = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
            this.WhitePixel.SetData(new[] { Color.White });

            this.SetActiveSprinklerSheetIndex(599);
        }
Esempio n. 2
0
        public static bool extraInfoActive; //deliberately public, so other mods can read it.


        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            SprinklerMod.Helper = helper;
            ModConfig           = helper.ReadConfig <SprinklerModConfig>();
            oldCraftingRecipes  = null;
            oldObjectInfo       = null;
            extraInfoActive     = false;

            TimeEvents.DayOfMonthChanged       += Event_ChangedDayOfMonth;
            GameEvents.LoadContent             += Event_LoadContent;
            GameEvents.UpdateTick              += Event_UpdateTick;
            GraphicsEvents.OnPreRenderHudEvent += Event_PreRenderHud;

            scarecrowGrid = new int[19, 19];
            int     scarecrowCenterValue = 19 / 2;
            Vector2 scarecrowCenter      = new Vector2(scarecrowCenterValue, scarecrowCenterValue);
            int     x         = 0;
            int     y         = 0;
            float   maxX      = 19f;
            float   maxY      = 19f;
            Vector2 vIterator = new Vector2(0, 0);

            while (vIterator.X < maxX)
            {
                vIterator.Y = 0;
                y           = 0;
                while (vIterator.Y < maxY)
                {
                    if (Vector2.Distance(vIterator, scarecrowCenter) < 9f)
                    {
                        scarecrowGrid[x, y] = 1;
                    }
                    else
                    {
                        scarecrowGrid[x, y] = 0;
                    }

                    ++vIterator.Y;
                    ++y;
                }
                ++vIterator.X;
                ++x;
            }
        }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="config">The mod configuration.</param>
 /// <param name="maxGridSize">The maximum sprinkler coverage supported by this mod (in tiles wide or high).</param>
 internal BetterSprinklersApi(SprinklerModConfig config, int maxGridSize)
 {
     this.Config      = config;
     this.MaxGridSize = maxGridSize;
 }