Ejemplo n.º 1
0
        private void PrintRoleIconAndName(OrderCard orderCard, CardImage cardImage)
        {
            var graphics        = cardImage.Graphics;
            var usableRectangle = cardImage.UsableRectangle;

            var cardNameFont    = new Font(headerFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var suit            = orderCard.CardSuit;
            var roleName        = suit.RoleName();
            var iconImageWidth  = RoleIconWidth(cardImage);
            var iconImageHeight = (int)(iconImageWidth * 190f / 140f);

            GraphicsUtilities.PrintScaledPng(
                graphics,
                $@"RoleIcons\{roleName}",
                usableRectangle.X,
                usableRectangle.Y,
                iconImageWidth,
                iconImageHeight);

            var text  = new string(roleName.ToUpper().ToCharArray().SelectMany(character => character == 'M' ? new[] { character } : new[] { character, (char)0x2009 }).ToArray());
            var brush = BrushesByCardSuit[suit];
            var singleCharacterMeasurement = graphics.MeasureString("M", cardNameFont, new SizeF(usableRectangle.Width, usableRectangle.Height), GraphicsUtilities.HorizontalNearAlignment);
            var textBoxWidth    = (int)singleCharacterMeasurement.Width;
            var xOffset         = (int)(iconImageWidth / 2.0f - textBoxWidth / 2);
            var yOffset         = iconImageHeight;
            var rectangle       = new Rectangle(usableRectangle.X + xOffset, usableRectangle.Y + yOffset, textBoxWidth, usableRectangle.Height);
            var textMeasurement = graphics.MeasureString(text, cardNameFont, new SizeF(rectangle.Width, rectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);

            graphics.FillRectangle(new SolidBrush(Color.FromArgb(200, Color.White)), new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, (int)textMeasurement.Height));
            GraphicsUtilities.DrawString(graphics, text, cardNameFont, brush, rectangle);
        }
Ejemplo n.º 2
0
        public CardImage CreateOrderCardBack()
        {
            var name            = "OrderCardBack";
            var cardImage       = new CardImage(name, ImageOrientation.Portrait);
            var graphics        = cardImage.Graphics;
            var usableRectangle = cardImage.UsableRectangle;

            cardImage.PrintCardBorderAndBackground(Color.Black, Color.Black);
            GraphicsUtilities.PrintScaledPng(
                graphics,
                $@"Misc\GloryToRome",
                usableRectangle.X + (int)(usableRectangle.Width * .07f),
                usableRectangle.Y + (int)(usableRectangle.Height * .15f),
                (int)(usableRectangle.Width * (1 - (.07f * 2))),
                (int)(usableRectangle.Height * .3f));
            GraphicsUtilities.PrintScaledPng(
                graphics,
                $@"Misc\GloryToRome",
                usableRectangle.X + (int)(usableRectangle.Width * .07f),
                usableRectangle.Bottom - (int)(usableRectangle.Height * (.15f + .3f)),
                (int)(usableRectangle.Width * (1 - (.07f * 2))),
                (int)(usableRectangle.Height * .3f),
                RotateFlipType.Rotate180FlipNone);
            GraphicsUtilities.PrintScaledPng(
                graphics,
                $@"Misc\OrderBackSeparator",
                usableRectangle.X + (usableRectangle.Width / 2 - (int)((usableRectangle.Width * .4f) / 2)),
                usableRectangle.Y + (usableRectangle.Height / 2 - (int)((usableRectangle.Height * .05f) / 2)),
                (int)(usableRectangle.Width * .4f),
                (int)(usableRectangle.Height * .05f));
            return(cardImage);
        }
Ejemplo n.º 3
0
        private void PrintInfluence(OrderCard orderCard, CardImage cardImage)
        {
            var graphics           = cardImage.Graphics;
            var usableRectangle    = cardImage.UsableRectangle;
            var influenceImageSide = InfluenceImageSide(cardImage);

            var suit = orderCard.CardSuit;

            for (var i = 0; i < suit.Influence(); i++)
            {
                GraphicsUtilities.PrintScaledPng(
                    graphics,
                    $@"Influence\{suit.ColorText()}Influence",
                    usableRectangle.X + influenceImageSide * i,
                    usableRectangle.Bottom - influenceImageSide,
                    influenceImageSide,
                    influenceImageSide);
            }
        }
Ejemplo n.º 4
0
        private void PrintSetIndicator(OrderCard orderCard, CardImage cardImage)
        {
            var graphics        = Graphics.FromImage(cardImage.Bitmap);
            var usableRectangle = cardImage.UsableRectangle;

            var setIndicatorCircleWidth = (int)(usableRectangle.Width * SetIndicatorPercentage);
            var setIndicatorImageSide   = (int)(setIndicatorCircleWidth * .7f);
            var suit      = orderCard.CardSuit;
            var brush     = new SolidBrush(suit.Color());
            var haloBrush = new SolidBrush(Color.FromArgb(200, Color.White));
            var set       = orderCard.CardSet;

            for (var i = 0; i < suit.Points(); i++)
            {
                var circleRectangle = new Rectangle(
                    usableRectangle.Right - setIndicatorCircleWidth,
                    usableRectangle.Y + (i * setIndicatorCircleWidth) + (i > 0 ? i * (int)(setIndicatorCircleWidth * .2f) : 0),
                    setIndicatorCircleWidth,
                    setIndicatorCircleWidth);
                var haloSize      = (int)(circleRectangle.Width * 1.2f);
                var haloRectangle = new Rectangle(
                    circleRectangle.X - (haloSize - circleRectangle.Width) / 2,
                    circleRectangle.Y - (haloSize - circleRectangle.Width) / 2,
                    haloSize,
                    haloSize);

                graphics.FillEllipse(haloBrush, haloRectangle);
                graphics.FillEllipse(brush, circleRectangle);
                if (set.HasSetImage())
                {
                    GraphicsUtilities.PrintScaledPng(
                        graphics,
                        "Misc",
                        set.SetText(),
                        circleRectangle.X + (int)(circleRectangle.Width * ((1 - .7f) / 2)),
                        circleRectangle.Y + (int)(circleRectangle.Height * ((1 - .7f) / 2)),
                        setIndicatorImageSide,
                        setIndicatorImageSide);
                }
            }
        }
Ejemplo n.º 5
0
        private void PrintRoleIconAndName(OrderCard orderCard, CardImage cardImage)
        {
            var graphics        = Graphics.FromImage(cardImage.Bitmap);
            var usableRectangle = cardImage.UsableRectangle;

            var cardNameFont    = new Font(boldFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var suit            = orderCard.CardSuit;
            var roleName        = suit.RoleName();
            var iconImageWidth  = RoleIconWidth(cardImage);
            var iconImageHeight = (int)(iconImageWidth * 190f / 140f);

            GraphicsUtilities.PrintScaledPng(
                graphics,
                "RoleIcons",
                roleName,
                usableRectangle.X,
                usableRectangle.Y,
                iconImageWidth,
                iconImageHeight);

            var text    = roleName.ToUpper();
            var brush   = BrushesByCardSuit[suit];
            var letters = text.ToList().Select(letter => letter.ToString()).ToList();;
            var singleCharacterMeasurement = letters.Max(letter => graphics.MeasureString(letter, cardNameFont, new SizeF(usableRectangle.Width, usableRectangle.Height), GraphicsUtilities.HorizontalNearAlignment).Width);
            var textBoxWidth = (int)singleCharacterMeasurement;
            var xOffset      = (int)(iconImageWidth / 2.0f - textBoxWidth / 2);
            var yOffset      = iconImageHeight;
            var rectangle    = new Rectangle(usableRectangle.X + xOffset, usableRectangle.Y + yOffset, textBoxWidth, usableRectangle.Height);
            var fragments    = letters
                               .Select(character => new TextFragment
            {
                Brush         = brush,
                Font          = cardNameFont,
                ForcesNewline = true,
                Text          = character
            })
                               .ToList();

            GraphicsUtilities.DrawFragmentsCentered(graphics, fragments, rectangle, 200, false, false);
        }
Ejemplo n.º 6
0
        public CardImage CreateSiteFront(CardSuit suit)
        {
            var name            = $"{suit.ResourceName()}_Site";
            var cardImage       = new CardImage(name, ImageOrientation.Portrait);
            var graphics        = cardImage.Graphics;
            var fullRectangle   = cardImage.FullRectangle;
            var usableRectangle = cardImage.UsableRectangle;

            cardImage.PrintCardBorderAndBackground(Color.White, Color.White);

            DrawSiteCost(cardImage, suit);

            var costRegionHeight             = (int)(fullRectangle.Height * SiteCostRegionHeightPercentage);
            var costImagePaddingHeight       = (int)(fullRectangle.Height * SiteResourceSectionPaddingPercentage);
            var costImageTopPaddingHeight    = costImagePaddingHeight / 2;
            var costImageBottomPaddingHeight = costImagePaddingHeight / 2;
            var costImageSectionHeight       = (int)(fullRectangle.Height * SiteResourceHeightPercentage);
            var costImageHeight    = costImageSectionHeight - costImagePaddingHeight;
            var costImageRectangle = new Rectangle(
                usableRectangle.X,
                fullRectangle.Y + (fullRectangle.Bottom - (costRegionHeight + costImageBottomPaddingHeight + costImageHeight)),
                usableRectangle.Width,
                costImageHeight);

            //graphics.FillRectangle(new SolidBrush(Color.Blue), costImageRectangle);
            GraphicsUtilities.PrintScaledAndCenteredPng(
                graphics,
                $@"Resources\{suit.ResourceName()}",
                costImageRectangle.X,
                costImageRectangle.Y,
                costImageRectangle.Width,
                costImageRectangle.Height);

            var cardNameFont     = new Font(headerFontFamily, orderCardHeaderFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
            var text             = AddHairSpaces(suit.ResourceName().ToUpper());
            var maxTextBoxWidth  = usableRectangle.Width;
            var initialRectangle = new Rectangle(usableRectangle.X, usableRectangle.Y, maxTextBoxWidth, usableRectangle.Height);
            var textMeasurement  = graphics.MeasureString(text, cardNameFont, new SizeF(initialRectangle.Width, initialRectangle.Height), GraphicsUtilities.HorizontalCenterAlignment);
            var textHeight       = (int)Math.Ceiling(textMeasurement.Height);
            var yOffset          = fullRectangle.Bottom - (costRegionHeight + costImageSectionHeight + textHeight);
            var textRectangle    = new Rectangle(usableRectangle.X, usableRectangle.Y + yOffset, maxTextBoxWidth, textHeight);

            graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.White)), textRectangle);
            //graphics.FillRectangle(new SolidBrush(Color.Blue), textRectangle);
            GraphicsUtilities.DrawString(graphics, text, cardNameFont, GraphicsUtilities.BlackBrush, textRectangle, GraphicsUtilities.HorizontalCenterAlignment);

            var centerPoint = usableRectangle.X + usableRectangle.Width / 2;

            var coinOffsetCount = 0f;

            switch (suit.Cost())
            {
            case 1:
                coinOffsetCount = -.5f;
                break;

            case 2:
                coinOffsetCount = -1;
                break;

            case 3:
                coinOffsetCount = -1.5f;
                break;
            }
            var siteCoinPadding = SiteCoinPadding(cardImage);
            var siteCoinWidth   = SiteCoinWidth(cardImage);
            var xOffset         = (int)(coinOffsetCount * siteCoinWidth + (coinOffsetCount + .5f) * siteCoinPadding);

            for (var i = 0; i < suit.Cost(); i++)
            {
                GraphicsUtilities.PrintScaledPng(
                    graphics,
                    $@"Misc\Coin",
                    centerPoint + xOffset + (i * (siteCoinWidth + siteCoinPadding)),
                    usableRectangle.Y,
                    siteCoinWidth,
                    siteCoinWidth);
            }

            return(cardImage);
        }
Ejemplo n.º 7
0
        internal CardImage CreateMerchantBonusImage(CardSuit suit)
        {
            var cardImage = new CardImage($"MerchantBonus_{suit.ResourceName()}", ImageOrientation.Portrait);
            var graphics  = cardImage.Graphics;

            cardImage.PrintCardBorderAndBackground(Color.White, Color.White);
            var fullRectangle   = cardImage.FullRectangle;
            var usableRectangle = cardImage.UsableRectangle;
            var xOffset         = usableRectangle.Width / 5;
            var yOffset         = (int)(usableRectangle.Width * .05f);

            PrintCardName("Merchant Bonus", cardImage, GraphicsUtilities.BlackBrush, false, xOffset, 3 * usableRectangle.Width / 5, yOffset);
            var costImagePaddingHeight       = (int)(fullRectangle.Height * SiteResourceSectionPaddingPercentage);
            var costImageTopPaddingHeight    = costImagePaddingHeight / 2;
            var costImageBottomPaddingHeight = costImagePaddingHeight / 2;
            var costImageSectionHeight       = (int)(fullRectangle.Height * SiteResourceHeightPercentage);
            var costImageHeight    = costImageSectionHeight - costImagePaddingHeight;
            var costImageRectangle = new Rectangle(
                usableRectangle.X,
                fullRectangle.Y + (fullRectangle.Bottom - ((int)(fullRectangle.Height * .30f) + costImageBottomPaddingHeight + costImageHeight)),
                usableRectangle.Width,
                costImageHeight);

            //graphics.FillRectangle(new SolidBrush(Color.Blue), costImageRectangle);
            GraphicsUtilities.PrintScaledAndCenteredPng(
                graphics,
                $@"Resources\{suit.ResourceName()}",
                costImageRectangle.X,
                costImageRectangle.Y,
                costImageRectangle.Width,
                costImageRectangle.Height);
            PrintCardText(
                $"+3 victory points for |the player with the most |{suit.ResourceName().ToUpper()} in his vault at |the end of the game.",
                cardImage,
                fullRectangle.Bottom - ((int)(fullRectangle.Height * .35f)),
                usableRectangle.Width,
                (int)(fullRectangle.Height * .25f),
                0,
                false,
                GraphicsUtilities.BlackBrush);

            var centerPoint = usableRectangle.X + usableRectangle.Width / 2;

            var coinOffsetCount = -1.5f;
            var siteCoinPadding = SiteCoinPadding(cardImage);
            var siteCoinWidth   = SiteCoinWidth(cardImage);
            var coinXOffset     = (int)(coinOffsetCount * siteCoinWidth + (coinOffsetCount + .5f) * siteCoinPadding);

            for (var i = 0; i < 3; i++)
            {
                GraphicsUtilities.PrintScaledPng(
                    graphics,
                    $@"Misc\Coin",
                    centerPoint + coinXOffset + (i * (siteCoinWidth + siteCoinPadding)),
                    usableRectangle.Y + (int)(usableRectangle.Width * .26f),
                    siteCoinWidth,
                    siteCoinWidth);
            }

            return(cardImage);
        }