コード例 #1
0
        public DSInjector()
        {
            BasePath    = null;
            ShortName   = null;
            LongName    = null;
            InPath      = null;
            RomPath     = null;
            IconPath    = null;
            BootTvPath  = null;
            BootDrcPath = null;
            OutPath     = null;
            Encrypt     = true;

            _base      = GetLoadedBase();
            Rom        = null;
            BootTvImg  = new BootImage();
            BootDrcImg = new BootImage();
            IconImg    = new IconImage();
        }
コード例 #2
0
        private bool CreateImage(string[] args)
        {
            BootImage bootImg   = new BootImage();
            string    framePath = null;
            string    titlePath = null;
            string    released  = null;
            string    outPath   = null;

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "create-image":
                    break;

                case "-frame":
                    if (i + 1 < args.Length && framePath == null)
                    {
                        framePath = args[++i];
                        break;
                    }
                    else
                    {
                        Cll.Log.WriteLine("Error in the \"-frame\" option.");
                        return(false);
                    }

                case "-title":
                    if (i + 1 < args.Length && titlePath == null)
                    {
                        titlePath = args[++i];
                        break;
                    }
                    else
                    {
                        Cll.Log.WriteLine("Error in the \"-title\" option.");
                        return(false);
                    }

                case "-name":
                    if (i + 1 < args.Length && bootImg.NameLine1 == null)
                    {
                        bootImg.NameLine1 = args[++i];
                        bootImg.NameLine2 = "";
                        bootImg.Longname  = false;
                        break;
                    }
                    else
                    {
                        Cll.Log.WriteLine("Error in the \"-name\" option.");
                        return(false);
                    }

                case "-longname":
                    if (i + 2 < args.Length && bootImg.NameLine1 == null)
                    {
                        bootImg.NameLine1 = args[++i];
                        bootImg.NameLine2 = args[++i];
                        bootImg.Longname  = true;
                        break;
                    }
                    else
                    {
                        Cll.Log.WriteLine("Error in the \"-longname\" option.");
                        return(false);
                    }

                case "-r":
                    if (i + 1 < args.Length && released == null)
                    {
                        released = args[++i];
                        break;
                    }
                    else
                    {
                        Cll.Log.WriteLine("Error in the \"-r\" option.");
                        return(false);
                    }

                case "-out":
                    if (i + 1 < args.Length && outPath == null)
                    {
                        outPath = args[++i];
                        break;
                    }
                    else
                    {
                        Cll.Log.WriteLine("Error in the \"-out\" option.");
                        return(false);
                    }

                default:
                    Cll.Log.WriteLine("Invalid option \"" + args[i] + "\".");
                    return(false);
                }
            }

            if (framePath != null && !File.Exists(framePath))
            {
                Cll.Log.WriteLine("The frame image \"" + framePath + "\" not exists.");
                return(false);
            }
            if (titlePath != null && !File.Exists(titlePath))
            {
                Cll.Log.WriteLine("The title screen \"" + titlePath + "\" not exists.");
                return(false);
            }
            if (released != null)
            {
                try
                {
                    bootImg.Released = Convert.ToInt32(released);
                    if (bootImg.Released < 2004)
                    {
                        Cll.Log.WriteLine("The year of release is less than 2004.");
                        return(false);
                    }
                }
                catch
                {
                    Cll.Log.WriteLine("The year of release is not an integer.");
                    return(false);
                }
            }
            if (outPath != null)
            {
                if (!Directory.Exists(outPath))
                {
                    Cll.Log.WriteLine("The \"" + outPath + "\" folder not exist.");
                    return(false);
                }
            }
            else
            {
                outPath = Environment.CurrentDirectory;
            }

            outPath += "\\image.png";
            Cll.Log.WriteLine("Creating image ----------------------------------------------------------------");
            if (titlePath != null)
            {
                Cll.Log.WriteLine("title: " + titlePath);
            }
            if (framePath != null)
            {
                Cll.Log.WriteLine("frame: " + framePath);
            }
            if (bootImg.NameLine1 != "")
            {
                if (bootImg.NameLine2 == "")
                {
                    Cll.Log.WriteLine("name: " + bootImg.NameLine1);
                }
                else
                {
                    Cll.Log.WriteLine("longname:\n" + bootImg.NameLine1 + "\n" + bootImg.NameLine2);
                }
            }
            if (released != null)
            {
                Cll.Log.WriteLine("released: " + released);
            }
            if (outPath != null)
            {
                Cll.Log.WriteLine("out: " + outPath);
            }

            System.Drawing.Bitmap image = null;
            try
            {
                if (framePath != null)
                {
                    bootImg.Frame = new System.Drawing.Bitmap(framePath);
                }
                if (titlePath != null)
                {
                    bootImg.TitleScreen = new System.Drawing.Bitmap(titlePath);
                }
                image = bootImg.Create();
                image.Save(outPath, System.Drawing.Imaging.ImageFormat.Png);
                image.Dispose();
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                bootImg.Dispose();
                if (image != null)
                {
                    image.Dispose();
                }
            }
        }