public static (bool status, string desc) Remove(string gamePath, string currentPath) { try { var _gamePath = new FilePathBuilder(gamePath); var _currentPath = new FilePathBuilder(currentPath); var deploy_cache = ScriptCommon.ReadDeploy(_currentPath.Enter("deploy.cfg").Path); if (deploy_cache == "") { return(true, ""); } var int_level = int.Parse(deploy_cache); var target_file = _gamePath.Enter("3D Entities").Enter("Level").Enter($"Level_{(int_level < 10 ? "0" : "")}{deploy_cache}.NMO").Path; ScriptCommon.RemoveWithRestore(target_file); } catch (Exception e) { return(false, "Runtime error:" + Environment.NewLine + e.Message); } return(true, ""); }
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_map_file = _currentPath.Enter("MapNameInPackage.nmo").Path; var target_map_folder = _gamePath.Enter("3D Entities").Enter("Level").Path; //restore old var deploy_cache = ScriptCommon.ReadDeploy(cache_file); if (deploy_cache != "") { var old_level = int.Parse(deploy_cache); var target_old_file = new FilePathBuilder(target_map_folder).Enter($"Level_{(old_level < 10 ? "0" : "")}{deploy_cache}.NMO").Path; ScriptCommon.RemoveWithRestore(target_old_file); } ScriptCommon.RecordDeploy(cache_file, ""); //deploy new _gamePath = new FilePathBuilder(gamePath); _currentPath = new FilePathBuilder(currentPath); if (parameter == "") { return(true, ""); } var level = int.Parse(parameter); if (!(level >= 1 && level <= 15)) { return(false, "Illegal parameter range"); } var target_file = new FilePathBuilder(target_map_folder).Enter($"Level_{(level < 10 ? "0" : "")}{parameter}.NMO").Path; ScriptCommon.CopyWithBackups(target_file, local_map_file); ScriptCommon.RecordDeploy(cache_file, level.ToString()); } catch (Exception e) { return(false, "Runtime error:" + Environment.NewLine + e.Message); } return(true, ""); }
public static (bool status, string desc) Remove(string gamePath, string currentPath) { try { var _gamePath = new FilePathBuilder(gamePath).Enter("Sounds"); var _currentPath = new FilePathBuilder(currentPath); foreach (var item in file_list) { if (File.Exists(_currentPath.Enter(item).Path)) { ScriptCommon.RemoveWithRestore(_gamePath.Enter(item).Path); _gamePath.Backtracking(); } _currentPath.Backtracking(); } } catch (Exception e) { return(false, "Runtime error:" + Environment.NewLine + e.Message); } return(true, ""); }
public static (bool status, string desc) Remove(string gamePath, string currentPath) { try { var _gamePath = new FilePathBuilder(gamePath); var _currentPath = new FilePathBuilder(currentPath); var deploy_cache = ScriptCommon.ReadDeploy(_currentPath.Enter("deploy.cfg").Path); if (deploy_cache == "") { return(true, ""); } var target_file = _gamePath.Enter("Sounds").Enter($"Music_Theme_{deploy_cache}").Path; ScriptCommon.RemoveWithRestore(target_file + "_1.wav"); ScriptCommon.RemoveWithRestore(target_file + "_2.wav"); ScriptCommon.RemoveWithRestore(target_file + "_3.wav"); } catch (Exception e) { return(false, "Runtime error:" + Environment.NewLine + e.Message); } return(true, ""); }
public static (bool status, string desc) Remove(string gamePath, string currentPath) { try { var _gamePath = new FilePathBuilder(gamePath); var _currentPath = new FilePathBuilder(currentPath); var deploy_cache = ScriptCommon.ReadDeploy(_currentPath.Enter("deploy.cfg").Path); if (deploy_cache == "") { return(true, ""); } var target_file = _gamePath.Enter("Textures").Enter("Sky").Enter($"Sky_{deploy_cache}").Path; ScriptCommon.RemoveWithRestore(target_file + "_Back.BMP"); ScriptCommon.RemoveWithRestore(target_file + "_Down.BMP"); ScriptCommon.RemoveWithRestore(target_file + "_Front.BMP"); ScriptCommon.RemoveWithRestore(target_file + "_Left.BMP"); ScriptCommon.RemoveWithRestore(target_file + "_Right.BMP"); } catch (Exception e) { return(false, "Runtime error:" + Environment.NewLine + e.Message); } return(true, ""); }
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, ""); }
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, ""); }