From a83052bd5dd341baf4342d724ef817ba7ef79fae Mon Sep 17 00:00:00 2001 From: EillesWan Date: Mon, 31 Jan 2022 23:01:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B4=E4=B8=AA=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E7=94=9F=E6=88=90=E5=8D=95=E4=B8=AABDX=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E9=9C=80=E8=A6=81=E5=90=88=E5=B9=B6=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=E8=AF=B8=E8=91=9B=E4=BA=AE=E7=9A=84=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Musicreater.py | 77 +++++++++++- languages/enGB.py | 8 +- languages/zhCN.py | 9 +- .../__pycache__/bugReporter.cpython-38.pyc | Bin 4363 -> 4593 bytes msctspt/bugReporter.py | 17 ++- msctspt/funcOpera.py | 2 +- msctspt/transfer.py | 117 ++++++++++++++---- nmcsup/trans.py | 2 +- resources/MSCT Dev Log.txt | 2 +- resources/myWords.txt | 4 +- 补全库.py | 2 +- 11 files changed, 193 insertions(+), 47 deletions(-) diff --git a/Musicreater.py b/Musicreater.py index d5b5e6d..d552b88 100644 --- a/Musicreater.py +++ b/Musicreater.py @@ -1258,6 +1258,7 @@ def __main__(): del cmdlist, behaviorUuid, Outdire, fileName, bigFile, parts, dire, packName, packDire def toScbBDXfile(): + log('单音轨转BDX') from msctspt.transfer import note2bdx global dire while True: @@ -1289,6 +1290,63 @@ def __main__(): log('转换结束!\n' + str(res)) tkinter.messagebox.showinfo(READABLETEXT[33], READABLETEXT[124].format(str(res))) + + + def toBDXfile(): + log('整首歌转BDX') + from msctspt.transfer import music2BDX + global dire + while True: + try: + dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[122], + initialvalue='0 0 0') + if dire is None or dire == '': + return + dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])] + except ValueError: # 测试完为ValueError,故修改语法 + tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117]) + continue + break + + fileName = tkinter.filedialog.asksaveasfilename(title=READABLETEXT[32], initialdir=r'./', + filetypes=[(READABLETEXT[123], '.bdx'), + (READABLETEXT[112], '*')], + defaultextension=dataset[0]['mainset']['PackName'] + '.bdx', + initialfile=dataset[0]['mainset']['PackName'] + '.bdx') + + maxHeight = 200 + + while True: + maxHeight = tkinter.simpledialog.askinteger(title=READABLETEXT[28], + prompt=READABLETEXT[93], + initialvalue='200') + if maxHeight >= 5: + break + elif maxHeight == None: + log('取消') + return + else: + tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[94]) + continue + + if fileName is None or fileName == '': + log('取消') + return + + log('获得文件名:' + fileName) + + res = music2BDX(fileName, dire, dataset[0],) + log('转换结束!\n' + str(res)) + tkinter.messagebox.showinfo(READABLETEXT[33], READABLETEXT[124].format(str(res))) + + + + + + + + + def wsPlay(): from msctspt.transfer import note2webs spd = tkinter.simpledialog.askfloat(READABLETEXT[34], prompt=READABLETEXT[125], initialvalue='5.0') @@ -1666,19 +1724,28 @@ def __main__(): # 将子菜单加入到菜单条中 main_menu_bar.add_cascade(label=READABLETEXT[74], menu=worldmenu) - # 创建其他功能菜单 + # 创建辅助功能菜单 otherMenu = tk.Menu(main_menu_bar, tearoff=0) otherMenu.add_command(label=READABLETEXT[75], command=MakeFuncPlayer) otherMenu.add_separator() - otherMenu.add_command(label=READABLETEXT[76], command=toScbBDXfile) - otherMenu.add_command(label=READABLETEXT[77], command=world2BDX) - otherMenu.add_command(label=READABLETEXT[78], command=world2RyStruct) - otherMenu.add_separator() otherMenu.add_command(label=READABLETEXT[79], command=func2World) otherMenu.add_command(label=READABLETEXT[80], command=bigFunc2World) main_menu_bar.add_cascade(label=READABLETEXT[81], menu=otherMenu) + # 创建结构功能菜单 + structureMenu = tk.Menu(main_menu_bar, tearoff=0) + structureMenu.add_command(label=READABLETEXT[92], command=toBDXfile) + structureMenu.add_command(label=READABLETEXT[76], command=toScbBDXfile) + structureMenu.add_command(label=READABLETEXT[77], command=world2BDX) + structureMenu.add_separator() + structureMenu.add_command(label=READABLETEXT[78], command=world2RyStruct) + + main_menu_bar.add_cascade(label=READABLETEXT[81], menu=structureMenu) + + + + # 创建实验功能菜单 trymenu = tk.Menu(main_menu_bar, tearoff=0) trymenu.add_command(label=READABLETEXT[82], command=ShowCMD) diff --git a/languages/enGB.py b/languages/enGB.py index d51b982..8c8cd34 100644 --- a/languages/enGB.py +++ b/languages/enGB.py @@ -86,7 +86,7 @@ READABLETEXT = { 73: "Save music as notebox into a exist map...", 74: "World", 75: "Generate a function that fits current music...", - 76: "Save selected track as commands in .bdx file...", + 76: "Export selected track as commands in .bdx...", 77: "Export .bdx file from map...", 78: "Export .RyStruct file from map...", 79: "Load functions into a world...", @@ -102,9 +102,9 @@ READABLETEXT = { 89: "Send a bug report", 90: "Q&A", 91: "Main Options", - # 92:"", - # 93:"", - # 94:"", + 92: "Export music as .BDX...", + 93: "请输入指令链生成最高相对高度(≥5)", + 94: "❌You should input a number which is not lower then 4, please reinput again.", # 95:"", 96: "Reset Main Options", 97: "Track Options", diff --git a/languages/zhCN.py b/languages/zhCN.py index c6dae8f..ea6ad7e 100644 --- a/languages/zhCN.py +++ b/languages/zhCN.py @@ -103,9 +103,10 @@ READABLETEXT = { 89: "发送错误日志反馈", 90: "帮助与疑问", 91: "音乐总设置(项目设置)", - # 92:"", - # 93:"", - # 94:"", + # =============================================================此处有新增 + 92: "将音乐导出为BDX", + 93: "请输入指令链生成最高相对高度(≥5)", + 94: "您输入的数据有误❌,相对高度请输入一个不小于4的值,请重新输入。", # 95:"", 96: "重置项目设置", 97: "当前音轨设置(段落设置)", @@ -128,7 +129,7 @@ READABLETEXT = { 114: "Midi文件", 115: "文本文件", 116: "请输入坐标:", - 117: "您输入的格式有误❌,请重新输入!", + 117: "您输入的格式有误❌,请重新输入。", 118: "我的世界指令函数文件", 119: "请输入执行链生成坐标:", # 120: "", diff --git a/msctspt/__pycache__/bugReporter.cpython-38.pyc b/msctspt/__pycache__/bugReporter.cpython-38.pyc index 7dc075db057da07ebc3f176de1ce92ad8078a512..f075cee6e1fab0f114a939f4d7ae8c9b0d6f8ce3 100644 GIT binary patch delta 1182 zcmZuxTTc@~6yDk0mR^?{t|FHT1gHt1AY$|dq7XGoOz>JmNa?PyxNUKEi%QyH6pe@) zb%-yZ0gVqPN@DPV5S2e+jOjB4j1NX%Onma3sZhL3GGEV}Ip^DN&YbB)<+m#3q}S^b zU_71t5lR-kR@y}pWXHvRzy-0<9dxKVjfNtc8D!tZ9VCyHNfA;oKOx;GO+}DLivhZ5 z31C1@$);wUr`yn9icp4-w*mR{$86^$n-3hp`B#oULj26y>Sk@l|67bpQ^>A3WR!uY&f^_(N_pi4bwzL4kC;B9_|an@{b|Istu;OkCk{T z%ebe6YWz(aob~!9U^7`QVU~vGZnF3IWDjGtBBt?R@WQa*AA*%8P zkzV6#DJhQ>C*&D9A+dRH{b)_nW;xWHgsn)pPKc0@W}K=cVVe?EXM#)#kL6kLUOW>$ z0W2J~e*l7sm4%03mnFsNE95FcF_xhV a3cU*nuoo%Hq6G-}hBBx5o0)y_`F{a~s{lv< delta 952 zcmZvaOK;Oa5XZf?<2Z5bq*X^5o77-CW$o}N z2|d7xUa0m9lxrmps24s35*#@A%mHx&3C_%HASn`-_UG|<=0CeT^L=EyY%J+|T7aiA z|I_-`_s+N?l9*M*8t}b%Qj1mFrGe!;Va$Gr<0Q`pC7%@cx24zQ^kK-O1As+31T^JX z4ju0v9Y%i%aRia?ps;^4aYst@f+OC4tF93;%5v%cxuf7%$vD2{dQd#rWN zK?m86Hhp;#lSUBJh;BHy3h3(xV1ZBps6-a~GTc|)=_!(N)}JZsNn3ph`?RH7f|+8= znOEc#`;u80y8sz+%5&GKMO`N}3FUk4R^bIk*pfcFP$dxj_ep@E!nz78`~#a=~xNZ8!Hg)fWT+IqrbtD2Et(2F5AXI^ W%V-r5I9xmqWDPL8;sy4xr}P_8GQ^Dl diff --git a/msctspt/bugReporter.py b/msctspt/bugReporter.py index 119b555..278fa54 100644 --- a/msctspt/bugReporter.py +++ b/msctspt/bugReporter.py @@ -97,7 +97,7 @@ class version: ) """当前所需库,有一些是开发用的,用户不需要安装""" - version = ('0.1.0', 'Delta',) + version = ('0.1.5', 'Delta',) """当前版本""" def __init__(self) -> None: @@ -107,8 +107,9 @@ class version: self.version = version.version """当前版本""" + - def installLibraries(self): + def installLibraries(self,index:str = 'https://pypi.tuna.tsinghua.edu.cn/simple'): """安装全部开发用库""" from sys import platform import os @@ -116,15 +117,21 @@ class version: import shutil try: shutil.rmtree(os.getenv('APPDATA') + '\\Musicreater\\') - except FloatingPointError: + except FileNotFoundError: pass for i in self.libraries: print("安装库:" + i) - os.system("python -m pip install " + i + " -i https://pypi.tuna.tsinghua.edu.cn/simple") + os.system(f"python -m pip install {i} -i {index}") elif platform == 'linux': os.system("sudo apt-get install python3-pip") os.system("sudo apt-get install python3-tk") os.system("sudo apt-get install python3-tkinter") for i in self.libraries: print("安装库:" + i) - os.system("sudo python3 -m pip install " + i + " -i https://pypi.tuna.tsinghua.edu.cn/simple") + os.system(f"sudo python3 -m pip install {i} -i {index}") + + + def __call__(self): + '''直接安装库,顺便返回一下当前版本''' + self.installLibraries() + return self.version diff --git a/msctspt/funcOpera.py b/msctspt/funcOpera.py index 11ccab0..82862db 100644 --- a/msctspt/funcOpera.py +++ b/msctspt/funcOpera.py @@ -159,7 +159,7 @@ def makeFuncFiles(musicset, path='./'): def makeNewFuncFiles(musicset, path='./'): """在指定目录下生成函数文件""" - from nmcsup.trans import classList_conversion + from msctspt.transfer import classList_conversion commands = [] starts = [] starts.__len__() diff --git a/msctspt/transfer.py b/msctspt/transfer.py index 86cf2a6..56167f3 100644 --- a/msctspt/transfer.py +++ b/msctspt/transfer.py @@ -48,14 +48,14 @@ def classList_conversion_SinglePlayer(List: list, ScoreboardName: str, playerSel if i.instrument > 119: pass else: - commands.append(f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}={str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~{127 - i.velocity} ~ playsound {i.instrument}{i.CD}.{i.pitch} @a ~ ~ ~ 1000 1.0 1000\n") + commands.append(f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}={str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~{127 - i.velocity} ~ playsound {i.instrument}{i.CD}.{i.pitch} @s ~ ~ ~ 1000 1.0 1000\n") if isProsess: commands.append(f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}={str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~ ~ title @s actionbar §e▶ 播放中: §a{j}/{length} || {int(j / length * 1000) / 10}\n") j += 1 - except AttributeError: + except : pass # a += List[i][1] - commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n") + # commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n") print(commands) return commands @@ -100,7 +100,7 @@ def classList_conversion(List: list, ScoreboardName: str, isProsess: bool = Fals except AttributeError: pass # a += List[i][1] - commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n") + # commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n") print(commands) return commands @@ -124,26 +124,56 @@ def classList_conversion(List: list, ScoreboardName: str, isProsess: bool = Fals -def formCmdBlock(direction: list, command: str, particularValue: int, impluse: int, condition: bool = False, +def formCmdBlock(direction: Iterable, command: str, particularValue: int, impluse: int = 0, condition: bool = False, needRedstone: bool = True, tickDelay: int = 0, customName: str = '', lastOutput: str = '', executeOnFirstTick: bool = False, trackOutput: bool = True): """ 使用指定项目返回指定的指令方块格式字典 - :param trackOutput: - :param executeOnFirstTick: - :param lastOutput: - :param customName: - :param tickDelay: - :param needRedstone: - :param condition: - :param impluse: + :param direction: `list[x: int, y: int, z: int]` + 方块位置 + :param command: `str` + 指令 :param particularValue: - :param command: - :param direction: + 方块特殊值,即朝向 + :0 下 无条件 + :1 上 无条件 + :2 z轴负方向 无条件 + :3 z轴正方向 无条件 + :4 x轴负方向 无条件 + :5 x轴正方向 无条件 + :6 下 无条件 + :7 下 无条件 - :return: 指令方块字典结构 - """ - """ + :8 下 有条件 + :9 上 有条件 + :10 z轴负方向 有条件 + :11 z轴正方向 有条件 + :12 x轴负方向 有条件 + :13 x轴正方向 有条件 + :14 下 有条件 + :14 下 有条件 + 注意!此处特殊值中的条件会被下面condition参数覆写 + :param impluse: `int 0|1|2` + 方块类型 + 0脉冲 1循环 2连锁 + :param condition: `bool` + 是否有条件 + :param needRedstone: `bool` + 是否需要红石 + :param tickDelay: `int` + 执行延时 + :param customName: `str` + 悬浮字 + :param lastOutput: `str` + 上次输出字符串,注意此处需要留空 + :param executeOnFirstTick: `bool` + 执行第一个已选项(循环指令方块是否激活后立即执行,若为False,则从激活时起延迟后第一次执行) + :param trackOutput: `bool` + 是否输出 + + :return: 指令方块字典结构,如下 + ''' + ''' :param block: { "direction": [x: int, y: int, z: int] #方块位置 "block_name": str, #方块名称(无需指定,默认为command_block) @@ -187,13 +217,14 @@ def note2bdx(filePath: str, dire: list, Notes: list, ScoreboardName: str, Instru PlayerSelect: 执行的玩家选择器 isProsess: 是否显示进度条(会很卡) height: 生成结构的最高高度 - :return 返回一个BdxConverter类(实际上没研究过),同时在指定位置生成.bdx文件""" + :return 返回一个BdxConverter类,同时在指定位置生成.bdx文件""" # from msctspt.transfer import formCmdBlock from nmcsup.trans import Note2Cmd from msctspt.bdxOpera_CP import BdxConverter cmd = Note2Cmd(Notes, ScoreboardName, Instrument, PlayerSelect, isProsess) cdl = [] + # 此处是处理一下,防止有注释 for i in cmd: # e = True try: @@ -243,7 +274,7 @@ def note2bdx(filePath: str, dire: list, Notes: list, ScoreboardName: str, Instru -def music2BDX(filePath: str, dire: list, music: dict, isProsess: bool = False, height: int = 200): +def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool = False, height: int = 200, isSquare: bool = False): """使用方法同Note2Cmd :param 参数说明: filePath: 生成.bdx文件的位置 @@ -251,11 +282,51 @@ def music2BDX(filePath: str, dire: list, music: dict, isProsess: bool = False, h music: 详见 Musicreater.py - dataset[0] isProsess: 是否显示进度条(会很卡) height: 生成结构的最高高度 - :return 返回一个BdxConverter类(实际上没研究过),同时在指定位置生成.bdx文件""" + isSquare: 生成的结构是否需要遵循生成正方形原则 + :return 返回一个BdxConverter类,同时在指定位置生成.bdx文件""" from msctspt.bdxOpera_CP import BdxConverter - cmdLists = [] + + blocks = [] + '''需要放置的方块''' + baseDire = direction + + direction = list(direction) + for track in music['musics']: - classList_conversion_SinglePlayer(track['notes'],track['set']['ScoreboardName'],music['mainset']['PlayerSelect'],isProsess) + cmdList = classList_conversion_SinglePlayer(track['notes'],track['set']['ScoreboardName'],music['mainset']['PlayerSelect'],isProsess) + dire = direction + down = False + '''当前是否为向下的阶段?''' + #开头的指令方块 + blocks.append(formCmdBlock(dire, f"scoreboard players add @a{music['mainset']['PlayerSelect']} {track['set']['ScoreboardName']} 1", 1, 1)) + dire[1] += 1 + blocks.append(formCmdBlock(dire, cmdList.pop(0), 2,needRedstone=False)) + dire[1] += 1 + # :0 下 无条件 + # :1 上 无条件 + # :2 z轴负方向 无条件 + # :3 z轴正方向 无条件 + # :4 x轴负方向 无条件 + # :5 x轴正方向 无条件 + for cmd in cmdList: + blocks.append(formCmdBlock(dire,cmd,5 if (down == False and dire[1] == height+direction[1]) or (down and dire[1] == direction+1) else 0 if down else 1,2,needRedstone=False)) + + if down: + if dire[1] > direction[1]+1: + dire[1]-=1 + else: + if dire[1] < height+direction[1]: + dire[1]+=1 + + if (down == False and dire[1] == height+direction[1]) or (down and dire[1] == direction+1): + down = not down + dire[0] += 1 + direction[2] += 2 + + + + return BdxConverter(filePath, 'Build by Ryoun Musicreater', blocks) + diff --git a/nmcsup/trans.py b/nmcsup/trans.py index 70dcff4..76538d6 100644 --- a/nmcsup/trans.py +++ b/nmcsup/trans.py @@ -270,4 +270,4 @@ if __name__ == '__main__': from nmcreader import midi_conversion path = "L:\\0WorldMusicCreater-MFMS new edition\\框架\\v0.3.2\\Musicreater\\测试用\\同道殊途标准.mid" b = midi_conversion(path) - classList_conversion(b, "n") + # classList_conversion(b, "n") diff --git a/resources/MSCT Dev Log.txt b/resources/MSCT Dev Log.txt index d20bb05..f9d24d3 100644 --- a/resources/MSCT Dev Log.txt +++ b/resources/MSCT Dev Log.txt @@ -34,7 +34,7 @@ Copyright © W-YI 2022 Delta 0.1.1 2022 1 30 1.新增设置调用方案,但未使用 -2.新增多音轨生成单个BDX的功能,但必须用新方法解析 +2.新增整个音乐生成单个BDX的功能,但必须用新方法解析 3.发现陈年旧bug:在msctspt.funcOpera中makeFuncFiles生成的指令格式不对 4.在nmcsup.trans中新增classList_conversion_SinglePlayer使用对于每个玩家的独立播放器 diff --git a/resources/myWords.txt b/resources/myWords.txt index 6f04a61..9eaf79f 100644 --- a/resources/myWords.txt +++ b/resources/myWords.txt @@ -36,8 +36,8 @@ 有些枪必须开,有些可以不开 ——长津湖 夕阳西下,余辉将尽,夜幕降临,寒风凛冽 ——原神 愿风擦拭你的双眼,让你看清真相 ——原神 -心愿之结晶,而何能之宝贵 +心愿之结晶 而何能之宝贵 神明,正倾诉着他辉煌的过去…… -一切过程与结果都不重要,重要的是热爱与真情 +一切过程与结果都不重要 重要的是热爱与真情 给大家带来笑容 这就是我存在的使命 不忘本源 牢记故地 diff --git a/补全库.py b/补全库.py index 136e76c..7c4783e 100644 --- a/补全库.py +++ b/补全库.py @@ -1,2 +1,2 @@ from msctspt.bugReporter import version -version.installLibraries(version) +print(version().__call__())