示例#1
0
        public CarListRenderer(GMFile.BoxItem item, IBoxContentRenderer probeRender)
        {
            probeRenderer = probeRender;
            if (item == GMFile.BoxItem.UsedCarList)
            {
                renderMeasurements = Hardcoded.UsedCarListMeasurements;
                includePrice       = true;
            }
            else
            {
                renderMeasurements = Hardcoded.GarageCarListMeasurements;
                includePrice       = false;
            }
            textColour = new SolidBrush(renderMeasurements.TextColour);
            borderPen  = new Pen(renderMeasurements.BorderColour);
            int numItems = renderMeasurements.ItemsToRender;

            itemRects = new Rectangle[numItems];
            Point topLeft   = renderMeasurements.TopLeftRenderPoint;
            int   boxHeight = renderMeasurements.ItemMargin + renderMeasurements.ItemPadding;
            Size  itemSize  = renderMeasurements.ItemBoxSize;
            // the item box is rendered middle aligned (vertically)
            // boxHeight - the total height from the top of one box space to another
            // itemSize - the size of the actual box content
            int yOffset = (boxHeight - itemSize.Height) / 2;

            for (int i = 0; i < numItems; ++i)
            {
                int yPos = topLeft.Y + yOffset;
                itemRects[i] = new Rectangle(topLeft.X, yPos, itemSize.Width, itemSize.Height);
                topLeft.Offset(0, boxHeight);
            }
            typeFormat     = StringFormat.GenericTypographic;
            swatchGradient = new LinearGradientBrush(
                new Rectangle(Point.Empty, renderMeasurements.SwatchSize),
                Color.White,
                Color.Blue,
                LinearGradientMode.ForwardDiagonal
                );
        }
示例#2
0
        public static IBoxContentRenderer Create(
            GMFile.BoxItem item,
            GMFile.InfoBoxAttributes infoAttrs,
            GMFile.QueryAttributes queryAttrs,
            Color drawColour
            )
        {
            InitTexts();
            IBoxContentRenderer renderer = null;
            string renderText;

            if (!textsToRender.TryGetValue((int)item, out renderText))
            {
                renderText = "TextMissing";
            }
            string            itemName      = Enum.GetName(typeof(GMFile.BoxItem), item);
            bool              bigText       = (infoAttrs & GMFile.InfoBoxAttributes.UseBigFont) != 0;
            Font              usedFont      = bigText ? Hardcoded.BigFont : Hardcoded.StandardFont;
            ProbeDataRenderer probeRenderer = new ProbeDataRenderer(infoAttrs, queryAttrs, usedFont);

            switch (item)
            {
            case GMFile.BoxItem.DealershipNewCarBox:
            {
                if ((infoAttrs & GMFile.InfoBoxAttributes.DontRenderDealerPrice) != 0)
                {
                    renderer = new BlankRenderer("Blank - " + itemName, probeRenderer, drawColour);
                }
                else
                {
                    renderer = new DealershipCarPriceRenderer(renderText, probeRenderer, usedFont, bigText);
                }
            }
            break;

            case GMFile.BoxItem.CarColourName:
            case GMFile.BoxItem.CreditsBalance:
            case GMFile.BoxItem.Price:
            case GMFile.BoxItem.DayCount:
            case GMFile.BoxItem.ChampionshipBonusPrize:
            case GMFile.BoxItem.CarSaleValue:
            {
                AlignToRect bottom = bigText ? new AlignToRect(AlignYBottomBig) : new AlignToRect(AlignYBottom);
                AlignToRect right  = new AlignToRect(AlignXRight);
                renderer = new AlignedTextRenderer(renderText, probeRenderer, right, bottom, usedFont);
            }
            break;

            case GMFile.BoxItem.CurrentCarHP:
            case GMFile.BoxItem.UpgradeCarHP:
            {
                AlignToRect bottom = bigText ? new AlignToRect(AlignYBottomBig) : new AlignToRect(AlignYBottom);
                AlignToRect right  = new AlignToRect(AlignXRight);
                renderer = new AlignedTextRenderer(renderText, probeRenderer, right, bottom, usedFont, Hardcoded.UpgradeHPTextColour);
            }
            break;

            case GMFile.BoxItem.CurrentCarShortName:
            case GMFile.BoxItem.CarHP:
            case GMFile.BoxItem.CarWeight:
            case GMFile.BoxItem.CarYear:
            {
                AlignToRect bottom = bigText ? new AlignToRect(AlignYBottomBig) : new AlignToRect(AlignYBottom);
                AlignToRect left   = new AlignToRect(AlignXLeft);
                renderer = new AlignedTextRenderer(renderText, probeRenderer, left, bottom, usedFont);
            }
            break;

            case GMFile.BoxItem.UpgradeName:
            {
                AlignToRect bottom = bigText ? new AlignToRect(AlignYBottomBig) : new AlignToRect(AlignYBottom);
                AlignToRect centre = new AlignToRect(AlignXCentre);
                renderer = new AlignedTextRenderer(renderText, probeRenderer, centre, bottom, Hardcoded.PartFont, Hardcoded.PartFontColour);
            }
            break;

            case GMFile.BoxItem.CarColourSwatches:
            {
                renderer = new SwatchRenderer(probeRenderer);
            }
            break;

            case GMFile.BoxItem.UsedCarList:
            case GMFile.BoxItem.GarageCarList:
            {
                renderer = new CarListRenderer(item, probeRenderer);
            }
            break;

            case GMFile.BoxItem.CarDisplay:
            {
                renderer = new CarDisplayRenderer(probeRenderer);
            }
            break;

            case GMFile.BoxItem.CarLogo:
            case GMFile.BoxItem.CarDrivetrainGraphic:
            {
                renderer = new CentralImageRenderer(
                    probeRenderer,
                    (item == GMFile.BoxItem.CarLogo) ? Hardcoded.CarLogo : Hardcoded.DrivetrainGraphic
                    );
            }
            break;

            case GMFile.BoxItem.StatusHighestGainedLicense:
            {
                renderer = new CentralImageRenderer(
                    probeRenderer,
                    Hardcoded.LargeLicenseGraphic
                    );
            }
            break;

            case GMFile.BoxItem.CarEquippedPartsList:
            {
                renderer = new EquippedCarPartsRenderer(probeRenderer);
            }
            break;

            default:
                if ((item >= GMFile.BoxItem.InfoScreenCarLength) && (item <= GMFile.BoxItem.InfoScreenCarMaxTorque))
                {
                    AlignToRect bottom = bigText ? new AlignToRect(AlignYBottomBig) : new AlignToRect(AlignYBottom);
                    AlignToRect left   = new AlignToRect(AlignXLeft);
                    renderer = new AlignedTextRenderer(renderText, probeRenderer, left, bottom, usedFont);
                }
                else if ((item >= GMFile.BoxItem.StatusPercentageCompletion) && (item <= GMFile.BoxItem.StatusNumberOfLicenseKidsTrophies))
                {
                    AlignToRect bottom = bigText ? new AlignToRect(AlignYBottomBig) : new AlignToRect(AlignYBottom);
                    AlignToRect right  = new AlignToRect(AlignXRight);
                    renderer = new AlignedTextRenderer(renderText, probeRenderer, right, bottom, usedFont);
                }
                else if ((item >= GMFile.BoxItem.IC1LicenseResult) && (item <= GMFile.BoxItem.S10LicenseResult))
                {
                    renderer = new CentralImageRenderer(probeRenderer, Hardcoded.LicenseTrophyGraphic);
                }
                else
                {
                    renderer = new BlankRenderer("Blank - " + itemName, probeRenderer, drawColour);
                }
                break;
            }
            return(renderer);
        }