Exemplo n.º 1
0
        public void Draw(SpriteBatch spriteBatch, float alpha, Vector2 viewPosition, float scaleSize, float layerDepth, ShowcaseDrawMode drawMode)
        {
            var depthProvider = new DepthProvider(layerDepth);

            DrawFurniture(spriteBatch, viewPosition, alpha, scaleSize, Config.Sprite, Color.White, drawMode, depthProvider);

            var tintColor = Config.AutoTint? GetAutoTintColor() : Color;

            if (Config.Tint != null && tintColor != Color.Black)
            {
                DrawFurniture(spriteBatch, viewPosition, alpha, scaleSize, Config.Tint, tintColor, drawMode, depthProvider);
            }
            if (drawMode != ShowcaseDrawMode.WithoutItems)
            {
                DrawItems(spriteBatch, alpha, viewPosition, scaleSize, drawMode, depthProvider);
            }
            if (Config.SecondSprite != null)
            {
                DrawFurniture(spriteBatch, viewPosition, alpha, scaleSize, Config.SecondSprite, Color.White, drawMode, depthProvider);
            }
            if (Config.SecondTint != null && tintColor != Color.Black)
            {
                DrawFurniture(spriteBatch, viewPosition, alpha, scaleSize, Config.SecondTint, tintColor, drawMode, depthProvider);
            }
        }
Exemplo n.º 2
0
        private void UpdateItemGlow(Item item, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            var color = GetItemGlowColor(item);

            if (color == null)
            {
                return;
            }

            var isDarkItem = (color == Color.Black);

            if (GlowConfig.ShowGlows)
            {
                var colorAlpha = isDarkItem ? 0.8f : 0.6f;
                spriteBatch.Draw(
                    GlowTexture,
                    viewPosition + TileSize / 2 * (scaleSize * Config.Layout.Scale / Game1.pixelZoom),
                    GlowTexture.Bounds,
                    color.Value * colorAlpha * alpha,
                    0,
                    GlowTexture.Bounds.Center.ToVector(),
                    4f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom),
                    SpriteEffects.None,
                    depthProvider.GetDepth());
            }

            if (isDarkItem || !GlowConfig.ShowLights)
            {
                return;
            }

            if (!LightSources.TryGetValue(item, out var light))
            {
                light = new LightSource(LightSource.lantern, Vector2.Zero, 32f / Game1.options.lightingQuality);
                LightSources.Add(item, light);
            }
            light.position = viewPosition + new Vector2(Game1.viewport.X, Game1.viewport.Y) + TileSize / 2;
        }
Exemplo n.º 3
0
        private void DrawItem(Tool tool, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            bool IsWeapon() => (tool is MeleeWeapon) || (tool is Slingshot);

            var textureInfo    = IsWeapon()? TextureInfo.Weapons : TextureInfo.Tools;
            var rotation       = GetItemRotation(tool) * MathHelper.PiOver4;
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            spriteBatch.Draw(
                textureInfo.Texture,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * GetRotationScale(rotation)),
                textureInfo.GetSourceRect(tool.indexOfMenuItemView),
                Color.White * alpha,
                rotation,
                new Vector2(spriteSheetTileSize, spriteSheetTileSize) / 2f,
                scaleSize * Config.Layout.Scale / GetRotationScale(rotation),
                SpriteEffects.None,
                depthProvider.GetDepth());
        }
Exemplo n.º 4
0
        private void DrawItem(Furniture furniture, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            spriteBatch.Draw(
                furnitureTexture,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * furniture.defaultSourceRect.Height / spriteSheetTileSize),
                furniture.defaultSourceRect,
                Color.White * alpha,
                0,
                new Vector2(spriteSheetTileSize, furniture.defaultSourceRect.Height) / 2f,
                scaleSize * Config.Layout.Scale,
                SpriteEffects.None,
                depthProvider.GetDepth());
        }
Exemplo n.º 5
0
        private void DrawItem(Object item, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            var rotation       = GetItemRotation(item) * MathHelper.PiOver4;
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            void DrawObjectSprite(int spriteIndex, Color color) => spriteBatch.Draw(
                Game1.objectSpriteSheet,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * GetRotationScale(rotation)),
                TextureInfo.Objects.GetSourceRect(spriteIndex),
                color * alpha,
                rotation,
                new Vector2(spriteSheetTileSize, spriteSheetTileSize) / 2f,
                scaleSize * Config.Layout.Scale / GetRotationScale(rotation),
                SpriteEffects.None,
                depthProvider.GetDepth());

            DrawObjectSprite(item.ParentSheetIndex, Color.White);
            if (!(item is ColoredObject coloredObject))
            {
                return;
            }
            DrawObjectSprite(item.ParentSheetIndex + 1, coloredObject.color);
        }
Exemplo n.º 6
0
        private void DrawItemShadow(Item item, SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, DepthProvider depthProvider)
        {
            if (!(item is Object) || (item is Furniture))
            {
                return;
            }
            var tileScaledSize = Game1.tileSize / 2f * (scaleSize * Config.Layout.Scale / Game1.pixelZoom);

            spriteBatch.Draw(
                Game1.shadowTexture,
                viewPosition + new Vector2(tileScaledSize, tileScaledSize * 1.5f),
                Game1.shadowTexture.Bounds,
                Color.White * 0.4f * alpha,
                0,
                Game1.shadowTexture.Bounds.Center.ToVector(),
                scaleSize * Config.Layout.Scale * 0.9f,
                SpriteEffects.None,
                depthProvider.GetDepth());
        }
Exemplo n.º 7
0
        private void DrawItems(SpriteBatch spriteBatch, float alpha, Vector2 viewPosition, float scaleSize, ShowcaseDrawMode drawMode, DepthProvider depthProvider)
        {
            if (ItemProvider.All(i => i == null))
            {
                return;
            }
            ItemProvider.UpdateCurrentRotation(currentRotation);

            var itemProvider     = (drawMode != ShowcaseDrawMode.Icon)? ItemProvider : ItemProvider.Clone(newRotation: 0);
            var actualSourceRect = (drawMode != ShowcaseDrawMode.Icon)? sourceRect : defaultSourceRect;
            var layout           = GetLayout(scaleSize, actualSourceRect, itemProvider);

            if (drawMode != ShowcaseDrawMode.Icon)
            {
                ForEachDrawItem(itemProvider, layout, (item, relativeItemPosition)
                                => DrawItemShadow(item, spriteBatch, viewPosition + relativeItemPosition, alpha, scaleSize, depthProvider));
                ForEachDrawItem(itemProvider, layout, (item, relativeItemPosition)
                                => UpdateItemGlow(item, spriteBatch, viewPosition + relativeItemPosition, alpha, scaleSize, depthProvider));
            }

            ForEachDrawItem(itemProvider, layout, (item, relativeItemPosition)
                            => DrawItem((dynamic)item, spriteBatch, viewPosition + relativeItemPosition, alpha, scaleSize, depthProvider));
        }
Exemplo n.º 8
0
        private void DrawFurniture(SpriteBatch spriteBatch, Vector2 viewPosition, float alpha, float scaleSize, SpriteInfo sprite, Color color, ShowcaseDrawMode drawMode, DepthProvider depthProvider)
        {
            var currentSourceRect = GetDefaultSourceRect(sprite, defaultSourceRect.Width, defaultSourceRect.Height);

            if (drawMode != ShowcaseDrawMode.Icon)
            {
                currentSourceRect.X     += (sourceRect.X - defaultSourceRect.X);
                currentSourceRect.Y     += (sourceRect.Y - defaultSourceRect.Y);
                currentSourceRect.Height = sourceRect.Height;
                currentSourceRect.Width  = sourceRect.Width;
            }

            spriteBatch.Draw(
                GetTexture(sprite),
                viewPosition,
                currentSourceRect,
                color * alpha,
                0,
                Vector2.Zero,
                scaleSize,
                (flipped && drawMode != ShowcaseDrawMode.Icon) ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
                depthProvider.GetDepth());
        }