示例#1
0
        static public void Refresh(string appDir)
        {
            DebugLogger.Log("Hardcoded", "Refreshing hardcoded data");
            string       dataDir  = Path.Combine(appDir, "data") + Path.DirectorySeparatorChar;
            string       dataFile = dataDir + "hardcoded.json";
            string       fileText = File.ReadAllText(dataFile);
            Measurements m        = JsonConvert.DeserializeObject <Measurements>(fileText);

            if (UpgradeHPTextColour != null)
            {
                DebugLogger.Log("Hardcoded", "Disposing previously loaded data");
                UsedCarListMeasurements.TextFont.Dispose();
                GarageCarListMeasurements.TextFont.Dispose();
                UpgradeHPTextColour.Dispose();
                DealershipPriceColour.Dispose();
                StandardFontColour.Dispose();
                PartFontColour.Dispose();
                EquippedPartFontColour.Dispose();
                StandardFont.Dispose();
                BigFont.Dispose();
                PartFont.Dispose();
                SmallLicenseGraphic.Dispose();
                LargeLicenseGraphic.Dispose();
                CarPicture.Dispose();
                CarLogo.Dispose();
                LicenseTrophyGraphic.Dispose();
                DrivetrainGraphic.Dispose();
                IconImages.Dispose();
            }
            UsedCarListMeasurements       = m.usedCarList;
            GarageCarListMeasurements     = m.garageCarList;
            EquippedPartsListMeasurements = m.installedCarPartsList;
            UpgradeHPTextColour           = new SolidBrush(m.upgradeHPColour);
            DealershipPriceColour         = new SolidBrush(m.dealershipPriceColour);
            StandardFontColour            = new SolidBrush(m.standardFontColour);
            PartFontColour         = new SolidBrush(m.partFontColour);
            EquippedPartFontColour = new SolidBrush(m.installedCarPartsList.TextColour);
            ColourSwatchSize       = m.colourSwatchSize;
            StandardFont           = m.standardFont;
            BigFont  = m.bigFont;
            PartFont = m.partNameFont;
            DumpFontInfo("Standard Font", StandardFont);
            DumpFontInfo("Big Font", BigFont);
            DumpFontInfo("Part Font", PartFont);
            DumpFontInfo("Installed Part Font", m.installedCarPartsList.TextFont);
            SmallLicenseGraphic  = new Bitmap(dataDir + "smalllicense.png");
            LargeLicenseGraphic  = new Bitmap(dataDir + "biglicense.png");
            CarPicture           = new Bitmap(dataDir + "carpicture.png");
            CarLogo              = MakeBlackTransparentAndDispose(new Bitmap(dataDir + "carlogo.png"));
            LicenseTrophyGraphic = MakeBlackTransparentAndDispose(new Bitmap(dataDir + "licensetrophy.png"));
            DrivetrainGraphic    = MakeBlackTransparentAndDispose(new Bitmap(dataDir + "drivetrain.png"));
            IconImages.Refresh(m.iconImageData, Globals.App.GT2Version, dataDir);
        }
示例#2
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
                );
        }