示例#1
0
        public static string GetFairFullPath(string path)
        {
            using (WorkingDir wd = new WorkingDir())
            {
                string argsFile = wd.MakePath();
                string outFile  = wd.MakePath();
                string molp     = SecurityTools.MakePassword_9();

                string[] args =
                {
                    "//O",
                    outFile,
                    "//MOLP",
                    molp,
                    "//-E",
                    "//$",
                    JString.AsLine(path),
                };

                File.WriteAllLines(argsFile, args, StringTools.ENCODING_SJIS);

                ProcessTools.Start(@"C:\Factory\Bodewig\DenebolaToolkit\FairFullPath.exe", "//R \"" + argsFile + "\"").WaitForExit();

                string[] outLines = File.ReadAllLines(outFile, StringTools.ENCODING_SJIS)
                                    .Where(v => v.StartsWith(molp))
                                    .Select(v => v.Substring(molp.Length)).ToArray();

                if (outLines.Length != 1)
                {
                    throw new Exception("不正なパス文字列です。");
                }

                return(outLines[0]);
            }
        }
示例#2
0
        private DDHashedData MakeThumbnail()
        {
            DDMain.KeepMainScreen();

            using (DDSubScreen screen = new DDSubScreen(THUMB_W, THUMB_H))
                using (screen.Section())
                {
                    DDDraw.DrawRect(DDGround.KeptMainScreen.ToPicture(), 0, 0, THUMB_W, THUMB_H);

                    using (WorkingDir wd = new WorkingDir())
                    {
                        string bmpFile = wd.MakePath();
                        string pngFile = wd.MakePath();

                        DX.SaveDrawScreenToBMP(0, 0, THUMB_W, THUMB_H, bmpFile);

                        using (
                            Bitmap                       // KeepComment:@^_ConfuserElsa // NoRename:@^_ConfuserElsa
                            bmp =
                                (Bitmap)Bitmap.FromFile( // KeepComment:@^_ConfuserElsa // NoRename:@^_ConfuserElsa
                                    bmpFile
                                    ))
                        {
                            bmp
                            .Save(                             // KeepComment:@^_ConfuserElsa // NoRename:@^_ConfuserElsa
                                pngFile,
                                ImageFormat.Png                // KeepComment:@^_ConfuserElsa // NoRename:@^_ConfuserElsa
                                );
                        }
                        return(new DDHashedData(File.ReadAllBytes(pngFile)));
                    }
                }
        }
示例#3
0
        private static byte[] LoadFile(ResInfo resInfo)
        {
            byte[] fileData;

            if (resInfo.CachedFile == null)
            {
                fileData = LoadFile(resInfo.ResFile, resInfo.Offset, resInfo.Size);

#if true
                {
                    Func <string> a_makeLocalName = () => "$" + SCommon.CRandom.GetRange(1, 3);
                    string        dir             = Path.Combine(WD.GetPath(a_makeLocalName()), a_makeLocalName(), a_makeLocalName(), a_makeLocalName());
                    SCommon.CreateDir(dir);
                    resInfo.CachedFile = Path.Combine(dir, "$" + CachedFileCounter++);
                }
#else // シンプル
                resInfo.CachedFile = WD.MakePath();
#endif

                File.WriteAllBytes(resInfo.CachedFile, fileData);
            }
            else
            {
                fileData = File.ReadAllBytes(resInfo.CachedFile);
            }
            return(fileData);
        }
示例#4
0
        private void CheckJacketFile(WorkingDir wd)
        {
            if (StringTools.EqualsIgnoreCase(Path.GetExtension(this.JacketFile), Consts.JPEG_2000_EXT))             // ? Jpeg-2000
            {
                string oldFile = wd.MakePath() + Consts.JPEG_2000_EXT;
                string fileNew = wd.MakePath() + ".bmp";

                File.Copy(this.JacketFile, oldFile);

                this.Batch(
                    Ground.I.JP2ToBmpFile + " " + oldFile + " " + fileNew,
                    ProcMain.SelfDir
                    );

                if (File.Exists(fileNew) == false)
                {
                    throw new Exception("JPEG-2000 ファイルの処理に失敗しました。");
                }

                this.JacketFile = fileNew;

                try
                {
                    new Canvas2(this.JacketFile);                     // 読み込みテスト
                }
                catch
                {
                    throw new Exception("JPEG-2000 ファイルの処理に失敗しました。(読み込みテスト)");
                }
            }
            else             // ? Jpeg-2000 以外
            {
                try
                {
                    new Canvas2(this.JacketFile);                     // 読み込みテスト
                }
                catch
                {
                    throw new Exception("ジャケット画像ファイルの読み込みに失敗しました。");
                }
            }

            GC.Collect();
        }
示例#5
0
        private static string[] Perform_Interlude(string arguments, Func <bool> interlude)
        {
            using (WorkingDir wd = new WorkingDir())
            {
                string outFile = wd.MakePath();

                Perform_OutFile_Interlude(arguments, outFile, interlude);

                return(File.ReadAllLines(outFile, Encoding.ASCII));
            }
        }
示例#6
0
        public string Echo(string message)
        {
            using (WorkingDir wd = new WorkingDir())
            {
                string file = wd.MakePath();

                File.WriteAllText(file, message, Encoding.UTF8);

                message = File.ReadAllText(file, Encoding.UTF8);
            }
            return(message);
        }
示例#7
0
        public int GetHandle(int handleIndex)
        {
            if (this.Handles == null)
            {
                this.Handles = new int[this.HandleCount];

                {
                    byte[] fileData = this.Func_GetFileData();
                    int    handle   = -1;

#if false // SetLoop*SamplePosSoundMem が正常に動作しない。@ 2021.4.30
                    using (WorkingDir wd = new WorkingDir())
                    {
                        string file = wd.MakePath();
                        File.WriteAllBytes(file, fileData);
                        handle = DX.LoadSoundMem(file);
                    }
#else
                    DDSystem.PinOn(fileData, p => handle = DX.LoadSoundMemByMemImage(p, fileData.Length));                     // DxLibDotNet3_22c で正常に動作しない。@ 2021.4.18
#endif

                    if (handle == -1)                     // ? 失敗
                    {
                        throw new DDError("Sound File SHA-512: " + SCommon.Hex.ToString(SCommon.GetSHA512(fileData)));
                    }

                    this.Handles[0] = handle;
                }

                for (int index = 1; index < this.HandleCount; index++)
                {
                    int handle = DX.DuplicateSoundMem(this.Handles[0]);

                    if (handle == -1)                     // ? 失敗
                    {
                        throw new DDError();
                    }

                    this.Handles[index] = handle;
                }

                this.PostLoaded();

                foreach (Action routine in this.PostLoaded2)
                {
                    routine();
                }
            }
            return(this.Handles[handleIndex]);
        }
示例#8
0
        public static void Add(byte[] fileData, string localFile)
        {
            string dir  = WD.MakePath();
            string file = Path.Combine(dir, localFile);

            FileTools.CreateDir(dir);
            File.WriteAllBytes(file, fileData);

            if (DDWin32.AddFontResourceEx(file, DDWin32.FR_PRIVATE, IntPtr.Zero) == 0)             // ? 失敗
            {
                throw new DDError();
            }

            FontFiles.Add(file);
        }
示例#9
0
        public World(string startMapName)
        {
            using (WorkingDir wd = new WorkingDir())
            {
                string file = wd.MakePath();

                File.WriteAllBytes(file, DDResource.Load(@"res\World\World.csv"));

                using (CsvFileReader reader = new CsvFileReader(file))
                {
                    this.MapNameTableRows = reader.ReadToEnd();
                }
            }
            this.CurrPoint = this.GetPoint(startMapName);
        }
示例#10
0
        public World(string worldName, string startMapName)
        {
            string worldFile = GameCommon.GetWorldFile(worldName);

            using (WorkingDir wd = new WorkingDir())
            {
                string file = wd.MakePath();

                File.WriteAllBytes(file, DDResource.Load(worldFile));

                using (CsvFileReader reader = new CsvFileReader(file))
                {
                    this.MapNameTableRows = reader.ReadToEnd();
                }
            }
            this.CurrPoint = this.GetPoint(startMapName);
            this.WorldName = worldName;
        }
示例#11
0
        public int GetHandle(int handleIndex)
        {
            if (this.Handles == null)
            {
                this.Handles = new int[1];

                {
                    byte[] fileData = this.Func_GetFileData();
                    int    handle   = -1;

#if false // SetLoop*SamplePosSoundMem が正常に動作しない。@ 2021.4.30
                    using (WorkingDir wd = new WorkingDir())
                    {
                        string file = wd.MakePath();
                        File.WriteAllBytes(file, fileData);
                        handle = DX.LoadSoundMem(file);
                    }
#else
                    DDSystem.PinOn(fileData, p => handle = DX.LoadSoundMemByMemImage(p, fileData.Length));                     // DxLibDotNet3_22c で正常に動作しない。@ 2021.4.18
#endif

                    if (handle == -1)                     // ? 失敗
                    {
                        throw new DDError();
                    }

                    this.Handles[0] = handle;
                }

                foreach (Action <int> routine in this.PostLoadeds)
                {
                    routine(this.Handles[0]);
                }
            }
            return(this.Handles[handleIndex]);
        }
示例#12
0
        private void Conv()
        {
            Ground.I.Logger.Info("Conv.1");

            using (WorkingDir wd = new WorkingDir())
            {
                this.WavFile        = wd.MakePath() + ".wav";
                this.MasterWavFile  = wd.MakePath() + ".wav";
                this.SpectrumFile   = wd.MakePath() + ".csv";
                this.SpectrumFile_L = wd.MakePath() + ".csv";
                this.SpectrumFile_R = wd.MakePath() + ".csv";
                this.VideoBmpDir    = wd.MakePath();
                this.VideoJpgDir    = wd.MakePath();

                this.MakeWavFile();
                this.MasteringWavFile();
                this.MakeSpectrumFile();
                this.MakeVideoBmp();
                this.MakeVideoJpg();
                this.MakeMovieFile();
            }
            Ground.I.Logger.Info("Conv.2");
        }
示例#13
0
        public void Perform(string inputDir, string outputDir, bool outputOverwriteMode, int threadCount)
        {
            try
            {
                Ground.I.CmProgressRate.Clear();
                Ground.I.CmReport.Clear();

                using (WorkingDir wd = new WorkingDir())
                {
                    string        successfulFile = wd.MakePath();
                    double        progressRate   = 0.0;
                    List <string> reportBuff     = new List <string>();

                    WaitDlgTools.Show(
                        Consts.CONV_PROCESSING_TITLE,
                        Consts.CONV_PROCESSING_MESSAGE_NORMAL,
                        () =>
                    {
                        ProcessTools.Batch(new string[]
                        {
                            string.Format(
                                Ground.I.ConvExeFile + " CS-Conv {0} {1} {2} {3} \"{4}\""
                                , StringTools.LiteEncode(inputDir)
                                , StringTools.LiteEncode(outputDir)
                                , outputOverwriteMode ? 1 : 0
                                , threadCount
                                , successfulFile
                                ),
                        },
                                           ProcMain.SelfDir
                                           );
                    },
                        () =>
                    {
                        if (Ground.I.EvCancellable_Y.WaitForMillis(0))
                        {
                            WaitDlg.Cancellable = true;
                        }
                        if (Ground.I.EvCancellable_N.WaitForMillis(0))
                        {
                            WaitDlg.Cancellable = false;
                        }
                        if (Ground.I.EvMessage_Normal.WaitForMillis(0))
                        {
                            WaitDlg.MessagePost.Post(Consts.CONV_PROCESSING_MESSAGE_NORMAL);
                        }
                        if (Ground.I.EvMessage_StartGenVideo.WaitForMillis(0))
                        {
                            WaitDlg.MessagePost.Post(Consts.CONV_PROCESSING_MESSAGE_START_GEN_VIDEO);
                        }
                        if (Ground.I.EvMessage_GenVideoRunning.WaitForMillis(0))
                        {
                            WaitDlg.MessagePost.Post(Consts.CONV_PROCESSING_MESSAGE_GEN_VIDEO_RUNNING);
                        }

                        {
                            byte[] message = Ground.I.CmProgressRate.Recv();

                            if (message != null)
                            {
                                progressRate = double.Parse(Encoding.ASCII.GetString(message));
                            }
                        }

                        {
                            byte[] message = Ground.I.CmReport.Recv();

                            if (message != null)
                            {
                                reportBuff.Add(Encoding.UTF8.GetString(message));

                                while (REPORT_BUFF_MAX < reportBuff.Count)
                                {
                                    reportBuff.RemoveAt(0);
                                }

                                WaitDlg.DetailMessagePost.Post(reportBuff.ToArray());
                            }
                        }

                        return(progressRate);
                    },
                        () =>
                    {
                        Ground.I.EvStop_Conv.Set();
                        Ground.I.EvStop_Master.Set();
                    });

                    if (File.Exists(successfulFile) == false)
                    {
                        throw new Exception("変換プロセスは正常に動作しませんでした。");
                    }

                    bool userCancelled = Ground.I.EvMessage_UserCancelled.WaitForMillis(0);

                    if (WaitDlg.LastCancelled || userCancelled)
                    {
                        MessageDlgTools.Show(MessageDlg.Mode_e.Warning, "変換中止", "変換プロセスを中止しました。(" + (userCancelled ? 1 : 0) + ")");
                    }
                    else
                    {
                        MessageDlgTools.Information("変換完了", "変換プロセスは終了しました。");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error("変換処理エラー", ex);
            }
        }