From 8722d4fd83e9272797dacb7a6b958268862906e2 Mon Sep 17 00:00:00 2001 From: EillesWan Date: Tue, 31 Jan 2023 20:39:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- magicDemo.py | 28 +++++++++++++++++----------- msctPkgver/__init__.py | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/magicDemo.py b/magicDemo.py index 1177c50..ef08062 100644 --- a/magicDemo.py +++ b/magicDemo.py @@ -34,9 +34,11 @@ languages = { ":": ":", ",": ",", ".": "。", - "ChooseFileFormat": "请输入输出格式[BDX(1)或MCPACK(0)]", - "ChoosePlayer": "请选择播放方式[计分板(1) 或 延迟(0)]", "ChoosePath": "请输入MIDI路径或所在文件夹", + "ChooseFileFormat": "请输入输出格式[BDX(1)或MCPACK(0)]", + "EnterMethod": "请输入转换算法", + "MethodRangeErr": "输入的转换算法应为 [{},{}](首位皆含)之间的一个整数。", + "ChoosePlayer": "请选择播放方式[计分板(1) 或 延迟(0)]", "WhetherArgEntering": "是否为文件夹内文件的转换统一参数[是(1) 或 否(0)]", "EnterArgs": "请输入转换参数", "noteofArgs": "注:文件夹内的全部midi将统一以此参数转换", @@ -204,6 +206,15 @@ out_path = format_ipt( f"{_('FileNotFound')}{_(',')}{_('Re-Enter')}{_('.')}", )[0].lower() +def isMethodOK(sth: str): + if int(sth) in range(1,len(conversion.methods)+1): + return int(sth) + else: + raise ValueError + +convert_method = format_ipt(f"{_('EnterMethod')}{_(':')}",isMethodOK,f"{_('MethodRangeErr')}")[1] + + # 选择输出格式 while True: fileFormat = ipt(f"{_('ChooseFileFormat')}{_(':')}").lower() @@ -308,23 +319,18 @@ for singleMidi in midis: json.dump(conversion.toDICT(), f) f.write(5 * "\n") conversion_result = ( - conversion.to_mcpack(2, *prompts) + conversion.to_mcpack(convert_method, *prompts) if fileFormat == 0 else ( - conversion.to_BDX_file(2, *prompts) + conversion.to_BDX_file(convert_method, *prompts) if playerFormat == 1 - else conversion.to_BDX_file_with_delay(2, *prompts) + else conversion.to_BDX_file_with_delay(convert_method, *prompts) ) ) if conversion_result[0]: - c3 = conversion_result[3] - c4 = conversion_result[4] - fF = fileFormat prt( - f" {_('CmdLength')}{_(':')}{conversion_result[1]}{_(',')}{_('MaxDelay')}{_(':')}" - f"{conversion_result[2]}" - f"{f'''{_(',')}{_('PlaceSize')}{_(':')}{c3}{_(',')}{_('LastPos')}{_(':')}{c4}''' if fF == 1 else ''}" + f" {_('CmdLength')}{_(':')}{conversion_result[1]}{_(',')}{_('MaxDelay')}{_(':')}{conversion_result[2]}{f'''{_(',')}{_('PlaceSize')}{_(':')}{conversion_result[3]}{_(',')}{_('LastPos')}{_(':')}{conversion_result[4]}''' if fileFormat == 1 else ''}" ) else: prt(f"{_('Failed')}") diff --git a/msctPkgver/__init__.py b/msctPkgver/__init__.py index 2f52aa1..43dce68 100644 --- a/msctPkgver/__init__.py +++ b/msctPkgver/__init__.py @@ -18,7 +18,7 @@ Terms & Conditions: ../License.md from .main import * -__version__ = "0.2.2.1" +__version__ = "0.2.2.2" __all__ = [] __author__ = (("金羿", "Eilles Wan"), ("诸葛亮与八卦阵", "bgArray"), ("鸣凤鸽子", "MingFengPigeon"))