新增整个音乐生成单个BDX,同时需要合并一下诸葛亮的分支

This commit is contained in:
EillesWan 2022-01-31 23:01:11 +08:00
parent 2fcfdca0a0
commit a83052bd5d
11 changed files with 193 additions and 47 deletions

View File

@ -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)

View File

@ -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",

View File

@ -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: "",

View File

@ -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

View File

@ -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__()

View File

@ -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)

View File

@ -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")

View File

@ -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使用对于每个玩家的独立播放器

View File

@ -36,8 +36,8 @@
有些枪必须开,有些可以不开 ——长津湖
夕阳西下,余辉将尽,夜幕降临,寒风凛冽 ——原神
愿风擦拭你的双眼,让你看清真相 ——原神
心愿之结晶而何能之宝贵
心愿之结晶 而何能之宝贵
神明,正倾诉着他辉煌的过去……
一切过程与结果都不重要重要的是热爱与真情
一切过程与结果都不重要 重要的是热爱与真情
给大家带来笑容 这就是我存在的使命
不忘本源 牢记故地

View File

@ -1,2 +1,2 @@
from msctspt.bugReporter import version
version.installLibraries(version)
print(version().__call__())