Ejemplo n.º 1
0
Archivo: Sky.cs Proyecto: yyc12345/bpm
        public static (bool status, string desc) Deploy(string gamePath, string currentPath, string parameter)
        {
            try {
                var _gamePath    = new FilePathBuilder(gamePath, Information.OS);
                var _currentPath = new FilePathBuilder(currentPath);

                var cache_file = _currentPath.Enter("deploy.cfg").Path;
                _currentPath.Backtracking();
                var local_file_folder = _currentPath.Path;
                var target_folder     = _gamePath.Enter("Textures").Enter("Sky").Path;

                //restore old
                var deploy_cache = ScriptCommon.ReadDeploy(cache_file);
                if (deploy_cache != "")
                {
                    var target_old_file = new FilePathBuilder(target_folder).Enter($"Sky_{deploy_cache}").Path;
                    ScriptCommon.RemoveWithRestore(target_old_file + "_Back.BMP");
                    ScriptCommon.RemoveWithRestore(target_old_file + "_Down.BMP");
                    ScriptCommon.RemoveWithRestore(target_old_file + "_Front.BMP");
                    ScriptCommon.RemoveWithRestore(target_old_file + "_Left.BMP");
                    ScriptCommon.RemoveWithRestore(target_old_file + "_Right.BMP");
                }
                ScriptCommon.RecordDeploy(cache_file, "");

                //deploy new
                _gamePath    = new FilePathBuilder(gamePath);
                _currentPath = new FilePathBuilder(currentPath);

                if (parameter == "")
                {
                    return(true, "");
                }
                var sky      = "A";
                var sp_param = parameter.Split('_');
                if (sp_param[0] == "level")
                {
                    var level = int.Parse(sp_param[1]);
                    if (!(level >= 1 && level <= 15))
                    {
                        return(false, "Illegal parameter range");
                    }
                    sky = level_dict[level];
                }
                else if (sp_param[0] == "sky")
                {
                    sky = sp_param[1].ToUpper();
                }
                else
                {
                    return(false, "Illegal formation");
                }

                if (!legal_character_dict.Contains(sky))
                {
                    return(false, "Illegal formation");
                }


                var target_file = new FilePathBuilder(target_folder).Enter($"Sky_{sky}").Path;
                ScriptCommon.CopyWithBackups(target_file + "_Back.BMP", new FilePathBuilder(local_file_folder).Enter("back.bmp").Path);
                ScriptCommon.CopyWithBackups(target_file + "_Down.BMP", new FilePathBuilder(local_file_folder).Enter("down.bmp").Path);
                ScriptCommon.CopyWithBackups(target_file + "_Front.BMP", new FilePathBuilder(local_file_folder).Enter("front.bmp").Path);
                ScriptCommon.CopyWithBackups(target_file + "_Left.BMP", new FilePathBuilder(local_file_folder).Enter("left.bmp").Path);
                ScriptCommon.CopyWithBackups(target_file + "_Right.BMP", new FilePathBuilder(local_file_folder).Enter("right.bmp").Path);

                ScriptCommon.RecordDeploy(cache_file, sky);
            } catch (Exception e) {
                return(false, "Runtime error:" + Environment.NewLine + e.Message);
            }
            return(true, "");
        }
Ejemplo n.º 2
0
Archivo: BGM.cs Proyecto: yyc12345/bpm
        public static (bool status, string desc) Deploy(string gamePath, string currentPath, string parameter)
        {
            try {
                var _gamePath    = new FilePathBuilder(gamePath, Information.OS);
                var _currentPath = new FilePathBuilder(currentPath);

                var cache_file = _currentPath.Enter("deploy.cfg").Path;
                _currentPath.Backtracking();
                var local_file_folder = _currentPath.Path;
                var target_folder     = _gamePath.Enter("Sounds").Path;

                //restore old
                var deploy_cache = ScriptCommon.ReadDeploy(cache_file);
                if (deploy_cache != "")
                {
                    var target_old_file = new FilePathBuilder(target_folder).Enter($"Music_Theme_{deploy_cache}").Path;
                    ScriptCommon.RemoveWithRestore(target_old_file + "_1.wav");
                    ScriptCommon.RemoveWithRestore(target_old_file + "_2.wav");
                    ScriptCommon.RemoveWithRestore(target_old_file + "_3.wav");
                }
                ScriptCommon.RecordDeploy(cache_file, "");

                //deploy new
                _gamePath    = new FilePathBuilder(gamePath);
                _currentPath = new FilePathBuilder(currentPath);

                if (parameter == "")
                {
                    return(true, "");
                }
                var theme    = "1";
                var sp_param = parameter.Split('_');
                if (sp_param[0] == "level")
                {
                    var level = int.Parse(sp_param[1]);
                    if (!(level >= 1 && level <= 15))
                    {
                        return(false, "Illegal parameter range");
                    }
                    theme = level_dict[level];
                }
                else if (sp_param[0] == "theme")
                {
                    theme = sp_param[1];
                }
                else
                {
                    return(false, "Illegal formation");
                }

                if (!legal_character_dict.Contains(theme))
                {
                    return(false, "Illegal formation");
                }


                var target_file = new FilePathBuilder(target_folder).Enter($"Music_Theme_{theme}").Path;
                ScriptCommon.CopyWithBackups(target_file + "_1.wav", new FilePathBuilder(local_file_folder).Enter("1.wav").Path);
                ScriptCommon.CopyWithBackups(target_file + "_2.wav", new FilePathBuilder(local_file_folder).Enter("2.wav").Path);
                ScriptCommon.CopyWithBackups(target_file + "_3.wav", new FilePathBuilder(local_file_folder).Enter("3.wav").Path);

                ScriptCommon.RecordDeploy(cache_file, theme);
            } catch (Exception e) {
                return(false, "Runtime error:" + Environment.NewLine + e.Message);
            }
            return(true, "");
        }