コード例 #1
0
ファイル: BundleDesign.cs プロジェクト: MyNameIsDark01/FModel
        private static void drawHeader(Bitmap myBitmap, JToken myBundle)
        {
            bool   isSXBanner        = false;
            string bundleDisplayName = BundleInfos.getBundleDisplayName(myItem);
            string lastFolder        = BundleInfos.getLastFolder(BundlePath);

            JToken displayStyle = myBundle["DisplayStyle"];

            if (displayStyle != null)
            {
                if (Settings.Default.isChallengesTheme)
                {
                    string[] colorParts = Settings.Default.challengesColors.Split(',');
                    headerColor = Color.FromArgb(255, Int32.Parse(colorParts[0]), Int32.Parse(colorParts[1]), Int32.Parse(colorParts[2]));
                }
                else
                {
                    headerColor = BundleInfos.getSecondaryColor(myBundle);
                }

                JToken customBackground = displayStyle["CustomBackground"];
                JToken displayImage     = displayStyle["DisplayImage"];
                if (customBackground != null)
                {
                    JToken assetPathName = customBackground["asset_path_name"];
                    if (assetPathName != null)
                    {
                        if (assetPathName.Value <string>().Contains("/Game/Athena/UI/Challenges/Art/MissionTileImages/") && !ThePak.CurrentUsedItem.Equals("QuestBundle_S10_SeasonX"))
                        {
                            isSXBanner = true;
                            string textureFile   = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                            Image  challengeIcon = Resources.unknown512;
                            string textureAsset  = JohnWick.AssetToTexture2D(textureFile);;
                            if (!string.IsNullOrEmpty(textureAsset))
                            {
                                using (var bmpTemp = new Bitmap(textureAsset))
                                {
                                    challengeIcon = new Bitmap(bmpTemp);
                                }
                            }

                            toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                            if (Settings.Default.isChallengesTheme && File.Exists(Settings.Default.challengesBannerFileName))
                            {
                                Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                            }
                            else
                            {
                                var opacityImage = ImageUtilities.SetImageOpacity(challengeIcon, (float)0.3);
                                toDrawOn.DrawImage(opacityImage, new Point(0, 0));
                            }
                        }
                    }
                }
                if (!isSXBanner)
                {
                    if (displayImage != null)
                    {
                        JToken assetPathName = displayImage["asset_path_name"];
                        if (assetPathName != null)
                        {
                            string textureFile   = Path.GetFileName(assetPathName.Value <string>()).Substring(0, Path.GetFileName(assetPathName.Value <string>()).LastIndexOf('.'));
                            Image  challengeIcon = Resources.unknown512;
                            string textureAsset  = JohnWick.AssetToTexture2D(textureFile);
                            if (!string.IsNullOrEmpty(textureAsset))
                            {
                                using (var bmpTemp = new Bitmap(textureAsset))
                                {
                                    challengeIcon = new Bitmap(bmpTemp);
                                }
                            }

                            toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                            if (Settings.Default.isChallengesTheme)
                            {
                                if (File.Exists(Settings.Default.challengesBannerFileName))
                                {
                                    Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                    var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                    toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                                }
                            }

                            toDrawOn.DrawImage(ImageUtilities.ResizeImage(challengeIcon, 256, 256), new Point(0, 0));
                        }
                    }
                    else
                    {
                        toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                        if (Settings.Default.isChallengesTheme)
                        {
                            if (File.Exists(Settings.Default.challengesBannerFileName))
                            {
                                Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                                var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                                toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                            }
                        }
                    }
                }
            }
            else
            {
                if (Settings.Default.isChallengesTheme)
                {
                    string[] colorParts = Settings.Default.challengesColors.Split(',');
                    headerColor = Color.FromArgb(255, Int32.Parse(colorParts[0]), Int32.Parse(colorParts[1]), Int32.Parse(colorParts[2]));
                }
                else
                {
                    headerColor = getRandomColor();
                }

                toDrawOn.FillRectangle(new SolidBrush(headerColor), new Rectangle(-1, -1, myBitmap.Width + 1, 257));
                if (Settings.Default.isChallengesTheme)
                {
                    if (File.Exists(Settings.Default.challengesBannerFileName))
                    {
                        Image banner       = Image.FromFile(Settings.Default.challengesBannerFileName);
                        var   opacityImage = ImageUtilities.SetImageOpacity(banner, (float)Settings.Default.challengesOpacity / 1000);
                        toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 1024, 256), 0, 0);
                    }
                }
            }

            GraphicsPath gp = new GraphicsPath();

            gp.StartFigure();
            gp.AddLine(0, 256, myBitmap.Width, 256);
            gp.AddLine(myBitmap.Width, 256, myBitmap.Width, 241);
            gp.AddLine(myBitmap.Width, 241, myBitmap.Width / 2 + 25, 236);
            gp.AddLine(myBitmap.Width / 2 + 25, 236, myBitmap.Width / 2 + 35, 249);
            gp.AddLine(myBitmap.Width / 2 + 35, 249, 0, 241);
            gp.CloseFigure();
            toDrawOn.FillPath(new SolidBrush(ControlPaint.Light(headerColor)), gp);

            GraphicsPath p     = new GraphicsPath();
            Pen          myPen = new Pen(ControlPaint.Light(headerColor, (float)0.2), 3);

            myPen.LineJoin = LineJoin.Round; //needed to avoid spikes
            p.AddString(
                lastFolder,
                Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1],
                (int)FontStyle.Regular, 30,
                new Point(isSXBanner || displayStyle == null ? 30 : 265, 70),
                FontUtilities.leftString
                );
            toDrawOn.DrawPath(myPen, p);
            toDrawOn.FillPath(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.05)), p);

            toDrawOn.DrawString(bundleDisplayName, new Font(Settings.Default.IconLanguage == "Japanese" ? FontUtilities.pfc.Families[2] : FontUtilities.pfc.Families[1], 40), new SolidBrush(Color.White), new Point(isSXBanner || displayStyle == null ? 25 : 260, 105));

            toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(headerColor, (float)0.1)), new Rectangle(-1, 255, myBitmap.Width + 1, myBitmap.Height));
        }
コード例 #2
0
ファイル: BundleDesign.cs プロジェクト: OujiaBoard/FModel
        /// <summary>
        /// draw the pretty header if DisplayStyle exist, else the pretty header but with random colors
        /// </summary>
        /// <param name="myBitmap"></param>
        /// <param name="myBundle"></param>
        public static void drawBackground(Bitmap myBitmap, ChallengeBundleIdParser myBundle)
        {
            if (Settings.Default.createIconForChallenges && myBundle.DisplayStyle != null)
            {
                //main header
                toDrawOn.FillRectangle(new SolidBrush(BundleInfos.getSecondaryColor(myBundle)), new Rectangle(0, 0, myBitmap.Width, 281));

                //gradient at left and right main header
                LinearGradientBrush linGrBrush_left = new LinearGradientBrush(new Point(0, 282 / 2), new Point(282, 282 / 2),
                                                                              ControlPaint.Light(BundleInfos.getSecondaryColor(myBundle), (float)0.3), BundleInfos.getSecondaryColor(myBundle));
                toDrawOn.FillRectangle(linGrBrush_left, new Rectangle(0, 0, 282, 282));
                LinearGradientBrush linGrBrush_right = new LinearGradientBrush(new Point(2500, 282 / 2), new Point(1500, 282 / 2),
                                                                               ControlPaint.Light(BundleInfos.getSecondaryColor(myBundle), (float)0.3), BundleInfos.getSecondaryColor(myBundle));
                toDrawOn.FillRectangle(linGrBrush_right, new Rectangle(1500, 0, 1000, 282));

                //last folder with border
                GraphicsPath p     = new GraphicsPath();
                Pen          myPen = new Pen(ControlPaint.Light(BundleInfos.getSecondaryColor(myBundle), (float)0.2), 3);
                myPen.LineJoin = LineJoin.Round; //needed to avoid spikes
                p.AddString(BundleInfos.getLastFolder(BundlePath), FontUtilities.pfc.Families[1], (int)FontStyle.Regular, 55, new Point(342, 40), FontUtilities.leftString);
                toDrawOn.DrawPath(myPen, p);
                toDrawOn.FillPath(new SolidBrush(ControlPaint.Dark(BundleInfos.getSecondaryColor(myBundle), (float)0.05)), p);

                //name
                toDrawOn.DrawString(BundleInfos.getBundleDisplayName(myItem), new Font(FontUtilities.pfc.Families[1], 115), new SolidBrush(Color.White), new Point(325, 70));

                //image
                string textureFile = Path.GetFileName(myBundle.DisplayStyle.DisplayImage.AssetPathName).Substring(0, Path.GetFileName(myBundle.DisplayStyle.DisplayImage.AssetPathName).LastIndexOf('.'));
                Image  challengeIcon;
                using (var bmpTemp = new Bitmap(JohnWick.AssetToTexture2D(textureFile)))
                {
                    challengeIcon = new Bitmap(bmpTemp);
                }
                toDrawOn.DrawImage(ImageUtilities.ResizeImage(challengeIcon, 282, 282), new Point(40, 0));

                //fill the rest
                toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(BundleInfos.getSecondaryColor(myBundle), (float)0.1)), new Rectangle(0, 271, myBitmap.Width, myBitmap.Height));
            }
            else
            {
                Color myBaseColor = getRandomColor();

                //main header
                toDrawOn.FillRectangle(new SolidBrush(myBaseColor), new Rectangle(0, 0, myBitmap.Width, 281));

                //gradient at left and right main header
                LinearGradientBrush linGrBrush_left = new LinearGradientBrush(new Point(0, 282 / 2), new Point(282, 282 / 2),
                                                                              ControlPaint.Light(myBaseColor, (float)0.3), myBaseColor);
                toDrawOn.FillRectangle(linGrBrush_left, new Rectangle(0, 0, 282, 282));
                LinearGradientBrush linGrBrush_right = new LinearGradientBrush(new Point(2500, 282 / 2), new Point(1500, 282 / 2),
                                                                               ControlPaint.Light(myBaseColor, (float)0.3), myBaseColor);
                toDrawOn.FillRectangle(linGrBrush_right, new Rectangle(1500, 0, 1000, 282));

                //fill the rest
                toDrawOn.FillRectangle(new SolidBrush(ControlPaint.Dark(myBaseColor, (float)0.1)), new Rectangle(0, 271, myBitmap.Width, myBitmap.Height));

                //last folder
                toDrawOn.DrawString(BundleInfos.getLastFolder(BundlePath), new Font(FontUtilities.pfc.Families[1], 42), new SolidBrush(ControlPaint.Dark(myBaseColor, (float)0.05)), new Point(40, 40));

                //name
                toDrawOn.DrawString(BundleInfos.getBundleDisplayName(myItem), new Font(FontUtilities.pfc.Families[1], 115), new SolidBrush(Color.White), new Point(25, 70));
            }
        }