Пример #1
0
		public void DrawToggler( SpriteBatch sb ) {
			Vector2 pos, size;
			Color bodyColor = HonorBoundUI.ButtonBodyColor;
			Color edgeColor = HonorBoundUI.ButtonEdgeColor;

			if( this.IsTogglerLit ) { bodyColor = HonorBoundUI.ButtonBodyLitColor; }
			this.GetTogglerDimensions( out pos, out size );
			
			DrawHelpers.DrawBorderedRect( sb, bodyColor, edgeColor, pos, size, 2 );
		}
        private Rectangle[] DrawPageTicks(SpriteBatch sb)
        {
            Player plr = Main.LocalPlayer;

            if (plr == null || !plr.active)
            {
                return(new Rectangle[0]);                   //?
            }

            var mymod    = ExtensibleInventoryMod.Instance;
            var myplayer = TmlHelpers.SafelyGetModPlayer <ExtensibleInventoryPlayer>(plr);

            var pos      = new Vector2(mymod.Config.PageTicksPositionXCoord, mymod.Config.PageTicksPositionYCoord);
            int pages    = myplayer.Library.CurrentBook.CountPages();
            int maxPages = pages > 29 ? 28 : pages;
            var rects    = new Rectangle[pages];

            var unsharedColor = new Color(192, 192, 192);
            var sharedColor   = new Color(128, 255, 32);

            for (int i = 0; i < maxPages; i++)
            {
                bool isCurrPage = i == myplayer.Library.CurrentBook.CurrentPageIdx;
                bool isShared   = myplayer.Library.CurrentBook.IsPageSharing(i);

                var  rect       = new Rectangle((int)(pos.X + (i * 16)), (int)pos.Y, 13, 4);
                bool isHovering = rect.Contains(Main.mouseX, Main.mouseY);

                Color fillColor = new Color(128, 128, 256) * myplayer.Library.CurrentBook.GaugePageFullness(i);
                Color bordColor = (isShared ? sharedColor : unsharedColor) * (isHovering ? 1f : 0.65f);
                int   thickness = isCurrPage ? 2 : 1;

                DrawHelpers.DrawBorderedRect(sb, fillColor, bordColor, rect, thickness);

                rects[i] = rect;
            }

            if (pages != maxPages)
            {
                sb.DrawString(Main.fontMouseText, "...", new Vector2(pos.X + (28 * 16), pos.Y - 12f), Color.White);
            }

            return(rects);
        }