mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2024-11-11 01:27:35 +08:00
新年第一次更新
This commit is contained in:
parent
81272a1166
commit
9f8694ef14
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
12
.idea/Musicreater.iml
Normal file
12
.idea/Musicreater.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
46
.idea/inspectionProfiles/Project_Default.xml
Normal file
46
.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="LongLine" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyArgumentEqualDefaultInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyAugmentAssignmentInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyCompatibilityInspection" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="ourVersions">
|
||||
<value>
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="3.10" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyMandatoryEncodingInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyMissingTypeHintsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="E501" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="ignoredErrors">
|
||||
<list>
|
||||
<option value="N802" />
|
||||
<option value="N803" />
|
||||
<option value="N806" />
|
||||
<option value="N813" />
|
||||
<option value="N801" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredIdentifiers">
|
||||
<list>
|
||||
<option value="list.__getitem__" />
|
||||
<option value="list.split" />
|
||||
</list>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Musicreater.iml" filepath="$PROJECT_DIR$/.idea/Musicreater.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
392
Musicreater.py
392
Musicreater.py
@ -101,7 +101,7 @@ dataset = [
|
||||
'FileName': 'Music'
|
||||
},
|
||||
'notes': [
|
||||
|
||||
|
||||
]
|
||||
},
|
||||
],
|
||||
@ -216,6 +216,7 @@ def __main__():
|
||||
else:
|
||||
return k
|
||||
|
||||
# 老的列表读取
|
||||
def ReadMidi(midfile: str): # -> str
|
||||
from nmcsup.nmcreader import ReadMidi as midiRead
|
||||
k = midiRead(midfile)
|
||||
@ -225,17 +226,19 @@ def __main__():
|
||||
else:
|
||||
return k
|
||||
|
||||
# 音色读取
|
||||
def LoadMidi(midfile: str): # -> str
|
||||
from nmcsup.nmcreader import midi_conversion
|
||||
k = midi_conversion(midfile)
|
||||
from bgArrayLib.reader import midiNewReader
|
||||
k = midiNewReader(midfile)
|
||||
if k is False:
|
||||
tk.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[105].format(midfile))
|
||||
return
|
||||
else:
|
||||
return k
|
||||
|
||||
# 新的类读取
|
||||
def MidiAnalysisClass(midfile: str):
|
||||
from nmcsup.nmcreader import midiClassReader
|
||||
from bgArrayLib.reader import midiClassReader
|
||||
k = midiClassReader(midfile)
|
||||
if k is False:
|
||||
tk.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[105].format(midfile))
|
||||
@ -502,99 +505,6 @@ def __main__():
|
||||
RefreshMain()
|
||||
RefreshMusic(NowMusic)
|
||||
|
||||
# def openNewProject():
|
||||
# global is_save
|
||||
# if is_save is not True:
|
||||
# result = tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106])
|
||||
# if result:
|
||||
# SaveProject()
|
||||
# fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[7], initialdir=r'./',
|
||||
# filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[112], '*')],
|
||||
# multiple=True)
|
||||
# if fn is None or fn == '':
|
||||
# return
|
||||
# else:
|
||||
# # print(fn)
|
||||
# fn = fn[0]
|
||||
# # print(fn)
|
||||
# log("尝试打开:" + fn)
|
||||
# try:
|
||||
# try:
|
||||
# with open(fn, 'rb') as C:
|
||||
# global dataset
|
||||
# # print(pickle.load(C))
|
||||
# read = pickle.load(C) # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # print(read)
|
||||
# dataset = read[0]
|
||||
# pkl1 = read[1]
|
||||
# log("读取新文件成功")
|
||||
# with open("1.pkl", 'wb') as w:
|
||||
# pickle.dump(pkl1, w)
|
||||
# except KeyError:
|
||||
# with open(fn, 'rb') as C:
|
||||
# dataset[0] = pickle.load(C)
|
||||
# log("读取新文件成功")
|
||||
# except pickle.UnpicklingError: # 程序规范修改:根据新的语法标准:except后面不能没有错误类型,测试后改为:
|
||||
# # pickle.UnpicklingError
|
||||
# print(READABLETEXT[8].format(fn))
|
||||
# log('无法打开{}'.format(fn))
|
||||
# return
|
||||
# global is_new_file
|
||||
# global ProjectName
|
||||
# is_new_file = False
|
||||
# ProjectName = fn
|
||||
# del fn
|
||||
# global NowMusic
|
||||
# RefreshMain()
|
||||
# RefreshMusic(NowMusic)
|
||||
|
||||
# def openClassProject():
|
||||
# global is_save
|
||||
# if is_save is not True:
|
||||
# result = tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106])
|
||||
# if result:
|
||||
# SaveProject()
|
||||
# fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[7], initialdir=r'./',
|
||||
# filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[112], '*')],
|
||||
# multiple=True)
|
||||
# if fn is None or fn == '':
|
||||
# return
|
||||
# else:
|
||||
# # print(fn)
|
||||
# fn = fn[0]
|
||||
# # print(fn)
|
||||
# log("尝试打开:" + fn)
|
||||
# try:
|
||||
# try:
|
||||
# with open(fn, 'rb') as C:
|
||||
# global dataset
|
||||
# # print(pickle.load(C))
|
||||
# read = pickle.load(C) # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # print(read)
|
||||
# dataset = read
|
||||
# log("读取新文件成功")
|
||||
# except KeyError:
|
||||
# with open(fn, 'rb') as C:
|
||||
# dataset[0] = pickle.load(C)
|
||||
# log("读取新文件成功")
|
||||
# except pickle.UnpicklingError: # 程序规范修改:根据新的语法标准:except后面不能没有错误类型,测试后改为:
|
||||
# # pickle.UnpicklingError
|
||||
# print(READABLETEXT[8].format(fn))
|
||||
# log('无法打开{}'.format(fn))
|
||||
# return
|
||||
# global is_new_file
|
||||
# global ProjectName
|
||||
# is_new_file = False
|
||||
# ProjectName = fn
|
||||
# del fn
|
||||
# global NowMusic
|
||||
# RefreshMain()
|
||||
# RefreshMusic(NowMusic)
|
||||
|
||||
print('打开项目命令加载完成!')
|
||||
|
||||
def appabout():
|
||||
@ -698,7 +608,7 @@ def __main__():
|
||||
|
||||
print('读MP3加载完成')
|
||||
|
||||
def FromMidi():
|
||||
def FromListMidi():
|
||||
log('从midi导入音乐')
|
||||
midfile = tkinter.filedialog.askopenfilename(title=READABLETEXT[21], initialdir=r'./',
|
||||
filetypes=[(READABLETEXT[114], '.mid .midi'),
|
||||
@ -727,7 +637,7 @@ def __main__():
|
||||
threading.Thread(target=midiSPT, args=(th,)).start()
|
||||
del th
|
||||
|
||||
def NewFromMidi():
|
||||
def FromNewMidi():
|
||||
try:
|
||||
tkinter.messagebox.showinfo("开发提示", "因为一些原因这个功能暂时取消")
|
||||
except tkinter.TclError:
|
||||
@ -760,7 +670,7 @@ def __main__():
|
||||
del th
|
||||
dataset[0]['mainset']['ReadMethod'] = "new"
|
||||
|
||||
def FromMidiClass():
|
||||
def FromClassMidi():
|
||||
log('从midi导入音乐并采用类读取方式')
|
||||
midfile = tkinter.filedialog.askopenfilename(title=READABLETEXT[21], initialdir=r'./',
|
||||
filetypes=[(READABLETEXT[114], '.mid .midi'),
|
||||
@ -842,6 +752,7 @@ def __main__():
|
||||
RefreshMusic(NowMusic)
|
||||
|
||||
print('写入命令加载完成!')
|
||||
print('开始加载列表生成函数函数。')
|
||||
|
||||
def ShowCMD():
|
||||
log('展示指令')
|
||||
@ -861,16 +772,6 @@ def __main__():
|
||||
else:
|
||||
makeFuncFiles(dataset[0], file + '/')
|
||||
|
||||
def MakeNewCMD():
|
||||
log('生成新文件')
|
||||
from msctspt.funcOpera import makeNewFuncFiles
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[25], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
log('取消')
|
||||
return
|
||||
else:
|
||||
makeNewFuncFiles(dataset[0], file + '/')
|
||||
|
||||
def MakeCMDdir():
|
||||
log('生成函数包')
|
||||
from msctspt.funcOpera import makeFunDir
|
||||
@ -881,16 +782,6 @@ def __main__():
|
||||
else:
|
||||
makeFunDir(dataset[0], file + '/')
|
||||
|
||||
def MakeNewCMDdir():
|
||||
log('生成新函数包与材质包')
|
||||
from msctspt.funcOpera import makeNewFunDir
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[26], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
log('取消')
|
||||
return
|
||||
else:
|
||||
makeNewFunDir(dataset[0], file + '/')
|
||||
|
||||
def MakePackFile():
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[27], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
@ -918,6 +809,29 @@ def __main__():
|
||||
shutil.move('./manifest.json', './temp/')
|
||||
shutil.rmtree('./temp/')
|
||||
|
||||
print('完成加载列表生成函数函数。')
|
||||
print('开始加载乐器类生成函数函数。')
|
||||
|
||||
def MakeNewCMD():
|
||||
log('生成新文件')
|
||||
from msctspt.funcOpera import makeNewFuncFiles
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[25], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
log('取消')
|
||||
return
|
||||
else:
|
||||
makeNewFuncFiles(dataset[0], file + '/')
|
||||
|
||||
def MakeNewCMDdir():
|
||||
log('生成新函数包与材质包')
|
||||
from msctspt.funcOpera import makeNewFunDir
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[26], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
log('取消')
|
||||
return
|
||||
else:
|
||||
makeNewFunDir(dataset[0], file + '/')
|
||||
|
||||
def MakeNewFunctionPackFile():
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[27], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
@ -983,6 +897,9 @@ def __main__():
|
||||
shutil.move('./manifest.json', './temp/')
|
||||
shutil.rmtree('./temp/')
|
||||
|
||||
print('完成加载乐器类生成函数函数。')
|
||||
print('开始加载乐器音色资源绑定函数。')
|
||||
|
||||
def changeResourcesPath():
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[27], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
@ -999,6 +916,58 @@ def __main__():
|
||||
else:
|
||||
tkinter.messagebox.showinfo(title=READABLETEXT[1], message=READABLETEXT[159])
|
||||
|
||||
print('开始加载类生成函数函数。')
|
||||
|
||||
def MakeClassCMD():
|
||||
log('生成类文件')
|
||||
from msctspt.funcOpera import makeClassFuncFiles
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[25], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
log('取消')
|
||||
return
|
||||
else:
|
||||
makeClassFuncFiles(dataset[0], file + '/')
|
||||
|
||||
def MakeClassCMDdir():
|
||||
log('生成类函数包与材质包')
|
||||
from msctspt.funcOpera import makeClassFunDir
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[26], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
log('取消')
|
||||
return
|
||||
else:
|
||||
makeClassFunDir(dataset[0], file + '/')
|
||||
|
||||
def MakeClassFunctionPackFile():
|
||||
file = tkinter.filedialog.askdirectory(title=READABLETEXT[27], initialdir=r'./')
|
||||
if file is None or file == '':
|
||||
log('取消')
|
||||
return
|
||||
import zipfile
|
||||
|
||||
from msctspt.funcOpera import makeClassFunDir
|
||||
log('生成附加包文件')
|
||||
if not os.path.exists('./temp/'):
|
||||
os.makedirs('./temp/')
|
||||
makeClassFunDir(dataset[0], './temp/')
|
||||
|
||||
shutil.move('./temp/{}Pack/behavior_packs/{}/functions'.format(dataset[0]['mainset']['PackName'],
|
||||
dataset[0]['mainset']['PackName']), './')
|
||||
|
||||
shutil.move('./temp/{}Pack/behavior_packs/{}/manifest.json'.format(dataset[0]['mainset']['PackName'],
|
||||
dataset[0]['mainset']['PackName']), './')
|
||||
|
||||
with zipfile.ZipFile('{}/{}.mcpack'.format(file, dataset[0]['mainset']['PackName']), 'w') as zipobj:
|
||||
for i in os.listdir('./functions/'):
|
||||
zipobj.write('./functions/{}'.format(i))
|
||||
zipobj.write('./manifest.json')
|
||||
shutil.move('./functions', './temp/')
|
||||
shutil.move('./manifest.json', './temp/')
|
||||
shutil.rmtree('./temp/')
|
||||
|
||||
print('完成加载类生成函数函数。')
|
||||
print('开始加载地图函数。')
|
||||
|
||||
# 转为空方块世界
|
||||
def ToBlockWorldEpt():
|
||||
import zipfile
|
||||
@ -1290,8 +1259,6 @@ 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
|
||||
@ -1313,8 +1280,9 @@ def __main__():
|
||||
(READABLETEXT[112], '*')],
|
||||
defaultextension=dataset[0]['mainset']['PackName'] + '.bdx',
|
||||
initialfile=dataset[0]['mainset']['PackName'] + '.bdx')
|
||||
|
||||
|
||||
maxHeight = 200
|
||||
print(maxHeight) # 使用变量
|
||||
|
||||
while True:
|
||||
maxHeight = tkinter.simpledialog.askinteger(title=READABLETEXT[28],
|
||||
@ -1322,31 +1290,23 @@ def __main__():
|
||||
initialvalue='200')
|
||||
if maxHeight >= 5:
|
||||
break
|
||||
elif maxHeight == None:
|
||||
elif maxHeight is 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],)
|
||||
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,18 +1626,6 @@ def __main__():
|
||||
filemenu.add_command(label=READABLETEXT[55], command=SaveProject)
|
||||
filemenu.add_command(label=READABLETEXT[56], command=SaveAsProject)
|
||||
|
||||
# filemenu.add_separator()
|
||||
#
|
||||
# filemenu.add_command(label=READABLETEXT[149], command=openNewProject)
|
||||
# filemenu.add_command(label=READABLETEXT[150], command=SaveNewProject)
|
||||
# filemenu.add_command(label=READABLETEXT[151], command=SaveAsNewProject)
|
||||
|
||||
# filemenu.add_separator()
|
||||
#
|
||||
# filemenu.add_command(label=READABLETEXT[161], command=openClassProject)
|
||||
# filemenu.add_command(label=READABLETEXT[162], command=SaveClassProject)
|
||||
# filemenu.add_command(label=READABLETEXT[163], command=SaveAsClassProject)
|
||||
|
||||
filemenu.add_separator() # 分隔符
|
||||
|
||||
filemenu.add_command(label=READABLETEXT[57], command=exitapp)
|
||||
@ -1688,12 +1636,12 @@ def __main__():
|
||||
# 创建编辑菜单
|
||||
editmenu = tk.Menu(main_menu_bar, tearoff=0)
|
||||
editmenu.add_command(label=READABLETEXT[59], command=FromMP3)
|
||||
editmenu.add_command(label=READABLETEXT[60], command=FromMidi)
|
||||
editmenu.add_command(label=READABLETEXT[60], command=FromListMidi)
|
||||
editmenu.add_command(label=READABLETEXT[61], command=FromForm)
|
||||
editmenu.add_command(label=READABLETEXT[62], command=FromText)
|
||||
editmenu.add_separator()
|
||||
editmenu.add_command(label=READABLETEXT[160], command=FromMidiClass)
|
||||
editmenu.add_command(label=READABLETEXT[148], command=NewFromMidi)
|
||||
editmenu.add_command(label=READABLETEXT[160], command=FromClassMidi)
|
||||
editmenu.add_command(label=READABLETEXT[148], command=FromNewMidi)
|
||||
# 将子菜单加入到菜单条中
|
||||
main_menu_bar.add_cascade(label=READABLETEXT[63], menu=editmenu)
|
||||
|
||||
@ -1707,6 +1655,10 @@ def __main__():
|
||||
funcmenu.add_command(label=READABLETEXT[153], command=MakeNewCMDdir)
|
||||
funcmenu.add_command(label=READABLETEXT[154], command=MakeNewFunctionPackFile)
|
||||
funcmenu.add_command(label=READABLETEXT[155], command=MakeNewFunctionPack_ResourcesPacks_File)
|
||||
funcmenu.add_separator()
|
||||
funcmenu.add_command(label=READABLETEXT[164], command=MakeClassCMD)
|
||||
funcmenu.add_command(label=READABLETEXT[165], command=MakeClassCMDdir)
|
||||
funcmenu.add_command(label=READABLETEXT[166], command=MakeClassFunctionPackFile)
|
||||
|
||||
# 将子菜单加入到菜单条中
|
||||
main_menu_bar.add_cascade(label=READABLETEXT[67], menu=funcmenu)
|
||||
@ -1724,8 +1676,6 @@ def __main__():
|
||||
# 将子菜单加入到菜单条中
|
||||
main_menu_bar.add_cascade(label=READABLETEXT[74], menu=worldmenu)
|
||||
|
||||
|
||||
|
||||
# 创建结构功能菜单
|
||||
structureMenu = tk.Menu(main_menu_bar, tearoff=0)
|
||||
structureMenu.add_command(label=READABLETEXT[92], command=toBDXfile)
|
||||
@ -1736,8 +1686,6 @@ def __main__():
|
||||
|
||||
main_menu_bar.add_cascade(label=READABLETEXT[95], menu=structureMenu)
|
||||
|
||||
|
||||
|
||||
# 创建辅助功能菜单
|
||||
otherMenu = tk.Menu(main_menu_bar, tearoff=0)
|
||||
otherMenu.add_command(label=READABLETEXT[75], command=MakeFuncPlayer)
|
||||
@ -1747,7 +1695,6 @@ def __main__():
|
||||
|
||||
main_menu_bar.add_cascade(label=READABLETEXT[81], menu=otherMenu)
|
||||
|
||||
|
||||
# 创建实验功能菜单
|
||||
trymenu = tk.Menu(main_menu_bar, tearoff=0)
|
||||
trymenu.add_command(label=READABLETEXT[82], command=ShowCMD)
|
||||
@ -1780,10 +1727,15 @@ def __main__():
|
||||
# 大标题
|
||||
tk.Label(UpLeftFrame, text=READABLETEXT[91], font=('', 20)).pack()
|
||||
# 按钮式文本
|
||||
LabelPackName = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[46].format(str(dataset[0]['mainset']['PackName'])), font=('', 15))
|
||||
LabelMusicTitle = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[47].format(str(dataset[0]['mainset']['MusicTitle'])), font=('', 15))
|
||||
LabelIsRepeat = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[48].format(str(dataset[0]['mainset']['IsRepeat'])), font=('', 15))
|
||||
LabelPlayerSelect = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[49].format(str(dataset[0]['mainset']['PlayerSelect'])), font=('', 15))
|
||||
LabelPackName = tk.Label(UpLeftFrame, bg='white',
|
||||
text=READABLETEXT[46].format(str(dataset[0]['mainset']['PackName'])), font=('', 15))
|
||||
LabelMusicTitle = tk.Label(UpLeftFrame, bg='white',
|
||||
text=READABLETEXT[47].format(str(dataset[0]['mainset']['MusicTitle'])), font=('', 15))
|
||||
LabelIsRepeat = tk.Label(UpLeftFrame, bg='white',
|
||||
text=READABLETEXT[48].format(str(dataset[0]['mainset']['IsRepeat'])), font=('', 15))
|
||||
LabelPlayerSelect = tk.Label(UpLeftFrame, bg='white',
|
||||
text=READABLETEXT[49].format(str(dataset[0]['mainset']['PlayerSelect'])),
|
||||
font=('', 15))
|
||||
# 绑定按钮
|
||||
LabelPackName.bind('<Button-1>', changePackName)
|
||||
LabelMusicTitle.bind('<Button-1>', changeMusicTitle)
|
||||
@ -1816,10 +1768,17 @@ def __main__():
|
||||
# 大标题
|
||||
tk.Label(UpRightFrame, text=READABLETEXT[97], font=('', 20)).pack()
|
||||
# 按钮式文本
|
||||
LabelEntityName = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[42].format(dataset[0]['musics'][NowMusic]['set']['EntityName']), font=('', 15))
|
||||
LabelScoreboardName = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[43].format(dataset[0]['musics'][NowMusic]['set']['ScoreboardName']), font=('', 15))
|
||||
LabelInstrument = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[44].format(dataset[0]['musics'][NowMusic]['set']['Instrument']), font=('', 15))
|
||||
LabelFileName = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[45].format(dataset[0]['musics'][NowMusic]['set']['FileName']), font=('', 15))
|
||||
LabelEntityName = tk.Label(UpRightFrame, bg='white',
|
||||
text=READABLETEXT[42].format(dataset[0]['musics'][NowMusic]['set']['EntityName']),
|
||||
font=('', 15))
|
||||
LabelScoreboardName = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[43].format(
|
||||
dataset[0]['musics'][NowMusic]['set']['ScoreboardName']), font=('', 15))
|
||||
LabelInstrument = tk.Label(UpRightFrame, bg='white',
|
||||
text=READABLETEXT[44].format(dataset[0]['musics'][NowMusic]['set']['Instrument']),
|
||||
font=('', 15))
|
||||
LabelFileName = tk.Label(UpRightFrame, bg='white',
|
||||
text=READABLETEXT[45].format(dataset[0]['musics'][NowMusic]['set']['FileName']),
|
||||
font=('', 15))
|
||||
# 绑定按钮
|
||||
LabelEntityName.bind('<Button-1>', changeEntityName)
|
||||
LabelScoreboardName.bind('<Button-1>', changeScoreboardName)
|
||||
@ -1909,3 +1868,112 @@ def __main__():
|
||||
|
||||
if __name__ == '__main__':
|
||||
__main__()
|
||||
|
||||
##################
|
||||
|
||||
# def openNewProject():
|
||||
# global is_save
|
||||
# if is_save is not True:
|
||||
# result = tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106])
|
||||
# if result:
|
||||
# SaveProject()
|
||||
# fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[7], initialdir=r'./',
|
||||
# filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[112], '*')],
|
||||
# multiple=True)
|
||||
# if fn is None or fn == '':
|
||||
# return
|
||||
# else:
|
||||
# # print(fn)
|
||||
# fn = fn[0]
|
||||
# # print(fn)
|
||||
# log("尝试打开:" + fn)
|
||||
# try:
|
||||
# try:
|
||||
# with open(fn, 'rb') as C:
|
||||
# global dataset
|
||||
# # print(pickle.load(C))
|
||||
# read = pickle.load(C) # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # print(read)
|
||||
# dataset = read[0]
|
||||
# pkl1 = read[1]
|
||||
# log("读取新文件成功")
|
||||
# with open("1.pkl", 'wb') as w:
|
||||
# pickle.dump(pkl1, w)
|
||||
# except KeyError:
|
||||
# with open(fn, 'rb') as C:
|
||||
# dataset[0] = pickle.load(C)
|
||||
# log("读取新文件成功")
|
||||
# except pickle.UnpicklingError: # 程序规范修改:根据新的语法标准:except后面不能没有错误类型,测试后改为:
|
||||
# # pickle.UnpicklingError
|
||||
# print(READABLETEXT[8].format(fn))
|
||||
# log('无法打开{}'.format(fn))
|
||||
# return
|
||||
# global is_new_file
|
||||
# global ProjectName
|
||||
# is_new_file = False
|
||||
# ProjectName = fn
|
||||
# del fn
|
||||
# global NowMusic
|
||||
# RefreshMain()
|
||||
# RefreshMusic(NowMusic)
|
||||
|
||||
# def openClassProject():
|
||||
# global is_save
|
||||
# if is_save is not True:
|
||||
# result = tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106])
|
||||
# if result:
|
||||
# SaveProject()
|
||||
# fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[7], initialdir=r'./',
|
||||
# filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[112], '*')],
|
||||
# multiple=True)
|
||||
# if fn is None or fn == '':
|
||||
# return
|
||||
# else:
|
||||
# # print(fn)
|
||||
# fn = fn[0]
|
||||
# # print(fn)
|
||||
# log("尝试打开:" + fn)
|
||||
# try:
|
||||
# try:
|
||||
# with open(fn, 'rb') as C:
|
||||
# global dataset
|
||||
# # print(pickle.load(C))
|
||||
# read = pickle.load(C) # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # 重要的事情说三遍!!!pickle.load只能load一次,所以多load几次就有bug,要一次读完!
|
||||
# # print(read)
|
||||
# dataset = read
|
||||
# log("读取新文件成功")
|
||||
# except KeyError:
|
||||
# with open(fn, 'rb') as C:
|
||||
# dataset[0] = pickle.load(C)
|
||||
# log("读取新文件成功")
|
||||
# except pickle.UnpicklingError: # 程序规范修改:根据新的语法标准:except后面不能没有错误类型,测试后改为:
|
||||
# # pickle.UnpicklingError
|
||||
# print(READABLETEXT[8].format(fn))
|
||||
# log('无法打开{}'.format(fn))
|
||||
# return
|
||||
# global is_new_file
|
||||
# global ProjectName
|
||||
# is_new_file = False
|
||||
# ProjectName = fn
|
||||
# del fn
|
||||
# global NowMusic
|
||||
# RefreshMain()
|
||||
# RefreshMusic(NowMusic)
|
||||
|
||||
|
||||
# ------------------
|
||||
# filemenu.add_separator()
|
||||
#
|
||||
# filemenu.add_command(label=READABLETEXT[149], command=openNewProject)
|
||||
# filemenu.add_command(label=READABLETEXT[150], command=SaveNewProject)
|
||||
# filemenu.add_command(label=READABLETEXT[151], command=SaveAsNewProject)
|
||||
|
||||
# filemenu.add_separator()
|
||||
#
|
||||
# filemenu.add_command(label=READABLETEXT[161], command=openClassProject)
|
||||
# filemenu.add_command(label=READABLETEXT[162], command=SaveClassProject)
|
||||
# filemenu.add_command(label=READABLETEXT[163], command=SaveAsClassProject)
|
||||
|
@ -1,16 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
|
||||
|
||||
from nmcsup.log import log
|
||||
import pickle
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Note:
|
||||
def __init__(self, channel, pitch, velocity, time, time_position, instrument):
|
||||
self.channel = channel
|
||||
@ -28,7 +22,7 @@ class Note:
|
||||
self.CD = "d"
|
||||
|
||||
|
||||
def midi_conversion(midfile: str):
|
||||
def midiNewReader(midfile: str):
|
||||
import mido
|
||||
# from msctspt.threadOpera import NewThread
|
||||
from bgArrayLib.bpm import get
|
||||
@ -129,6 +123,7 @@ def midiClassReader(midfile: str):
|
||||
|
||||
def Time(mt, tpb_a, bpm_a):
|
||||
return round(mt / tpb_a / bpm_a * 60 * 20)
|
||||
|
||||
Notes = []
|
||||
tracks = []
|
||||
try:
|
||||
@ -150,13 +145,3 @@ def midiClassReader(midfile: str):
|
||||
Notes.append(tracks)
|
||||
print(Notes.__len__())
|
||||
return Notes
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -120,7 +120,7 @@ READABLETEXT = {
|
||||
105: "找不到或无法读取文件😢:{}",
|
||||
106: "您当前的项目已修改但未存储,是否先保存当前项目?",
|
||||
107: "项目已经存储至:{}",
|
||||
108: ("音·创0.0.X工程文件","音·创0.1+工程文件","音·创0.1+TEST工程文件"),
|
||||
108: ("音·创0.0.X工程文件", "音·创0.1+工程文件", "音·创0.1+TEST工程文件"),
|
||||
109: "任意类型",
|
||||
110: "函数音创工程文件",
|
||||
111: "MMFM0.0.6版本工程文件",
|
||||
@ -160,22 +160,25 @@ READABLETEXT = {
|
||||
145: "您输入的乐器并非游戏内置乐器,是否继续用您输入的字符作为乐器?",
|
||||
146: "修改本音轨生成的文件名",
|
||||
# -----2022.1.25更新
|
||||
147: "生成新文件至...",
|
||||
147: "生成乐器文件至...",
|
||||
148: "从midi导入音轨且用新方法解析",
|
||||
149: "打开 新: 音·创项目...",
|
||||
150: "保存为新项目",
|
||||
151: "另存为新项...",
|
||||
# 149: "打开 新: 音·创项目...",
|
||||
# 150: "保存为新项目",
|
||||
# 151: "另存为新项...",
|
||||
152: "(开发调试)关闭本次日志记录",
|
||||
153: "生成新函数包至...",
|
||||
154: "生成新函数附加包文件至...",
|
||||
155: "生成新函数附加包文件,并将神羽资源包以散包形式放置至...",
|
||||
153: "生成乐器函数包至...",
|
||||
154: "生成乐器函数附加包文件至...",
|
||||
155: "生成乐器函数附加包文件,并将神羽资源包以散包形式放置至...",
|
||||
156: "[神羽资源包位置选择]:选择文件夹...",
|
||||
157: "没有路径文件(.rpposi文件),请仔细阅读Readme或先试用:帮助与疑问->[神羽资源包位置选择]:选择文件夹... 方法添加路径文件吧!",
|
||||
158: "有路径文件(.rpposi文件),但路径指示错误,请仔细阅读Readme或先用:帮助与疑问->[神羽资源包位置选择]:选择文件夹... 更改路径!",
|
||||
159: "更改路径文件(.rpposi文件)成功!!",
|
||||
160: "从midi导入音轨且用类方法解析",
|
||||
161: "打开 类方法: 音·创项目...",
|
||||
162: "保存为类方法项目",
|
||||
163: "另存为类方法项...",
|
||||
# 161: "打开 类方法: 音·创项目...",
|
||||
# 162: "保存为类方法项目",
|
||||
# 163: "另存为类方法项...",
|
||||
164: "生成新文件至...",
|
||||
165: "生成新函数包至...",
|
||||
166: "生成新函数附加包文件至...",
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -92,15 +92,6 @@ def funSplit(bigFile, maxCmdLen: int = 10000):
|
||||
return parts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 注意!播放器应该为个人独立播放器,此处bug需要修改
|
||||
def makeFuncFiles(musicset, path='./'):
|
||||
"""在指定目录下生成函数文件"""
|
||||
@ -148,18 +139,48 @@ def makeFuncFiles(musicset, path='./'):
|
||||
log("完成============================")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def makeFunDir(musicset, path='./'):
|
||||
"""在指定目录下生成函数包文件夹"""
|
||||
import os
|
||||
import uuid
|
||||
log("=============================生成函数包文件夹")
|
||||
# note,packname="Ryoun",FileName="Music",EntityName_='music_support',ScoreboardName_='music_support',
|
||||
# MusicTitle_='Noname',PlayerSelect_='',Repeat_=False,Instrument_='harp'
|
||||
try:
|
||||
os.makedirs(path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset'][
|
||||
'PackName'] + "/functions")
|
||||
log("已创建目录" + path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset'][
|
||||
'PackName'] + "/functions")
|
||||
except FileExistsError:
|
||||
log("目录已有无需创建")
|
||||
pass
|
||||
# 判断文件皆存在
|
||||
if not (os.path.exists(
|
||||
path + musicset['mainset']['PackName'] + "Pack/world_behavior_packs.json") and os.path.exists(
|
||||
path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset'][
|
||||
'PackName'] + "/manifest.json")):
|
||||
log("创建manifest.json以及world_behavior_packs.json")
|
||||
behaviorUuid = uuid.uuid4()
|
||||
with open(path + musicset['mainset']['PackName'] + "Pack/world_behavior_packs.json", "w") as f:
|
||||
f.write("[\n {\"pack_id\": \"" + str(behaviorUuid) + "\",\n \"version\": [ 0, 0, 1 ]}\n]")
|
||||
p = path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset']['PackName'] + \
|
||||
"/manifest.json"
|
||||
with open(p, "w") as f:
|
||||
f.write("{\n \"format_version\": 1,\n \"header\": {\n \"description\": \"" + musicset['mainset'][
|
||||
'PackName'] + " Pack : behavior pack\",\n \"version\": [ 0, 0, 1 ],\n \"name\": \"" +
|
||||
musicset['mainset']['PackName'] + "Pack\",\n \"uuid\": \"" + str(
|
||||
behaviorUuid) + "\"\n },\n \"modules\": [\n {\n \"description\": \"" + musicset['mainset'][
|
||||
'PackName'] + " Pack : behavior pack\",\n \"type\": \"data\",\n \"version\":"
|
||||
" [ 0, 0, 1 ],\n \"uuid\": \"" + str(
|
||||
uuid.uuid4()) + "\"\n }\n ]\n}")
|
||||
makeFuncFiles(musicset, path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset'][
|
||||
'PackName'] + "/functions/")
|
||||
log("完成============================")
|
||||
|
||||
|
||||
def makeNewFuncFiles(musicset, path='./'):
|
||||
"""在指定目录下生成函数文件"""
|
||||
from msctspt.transfer import classList_conversion
|
||||
from msctspt.transfer import newList_conversion_SinglePlayer
|
||||
commands = []
|
||||
starts = []
|
||||
starts.__len__()
|
||||
@ -175,17 +196,19 @@ def makeNewFuncFiles(musicset, path='./'):
|
||||
for i in range(len(musicset['musics'])):
|
||||
log('写入第' + str(i) + '个数据')
|
||||
# commands.append("execute @e[name=\"" + musicset['musics'][i]['set']['EntityName'] + "\",scores={" +
|
||||
# musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset'][
|
||||
# musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset']
|
||||
# [
|
||||
# 'PlayerSelect'] + " title " + musicset['mainset']['MusicTitle'] + "\n")
|
||||
# commands.append("execute @e[name=\"" + musicset['musics'][i]['set']['EntityName'] + "\",scores={" +
|
||||
# musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset'][
|
||||
# musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset']
|
||||
# [
|
||||
# 'PlayerSelect'] + " subtitle 本函数乐曲由§b§l凌云§r§3函数音乐创建§r生成\n")
|
||||
if len(musicset['musics'][i]['notes']) > maxlen:
|
||||
maxlen = len(musicset['musics'][i]['notes'])
|
||||
with open(path + musicset['mainset']['MusicTitle'] + '_Part' + str(i) + '.mcfunction', 'w',
|
||||
encoding='UTF-8') as f:
|
||||
f.writelines(classList_conversion(musicset['musics'][i]['notes'],
|
||||
musicset['musics'][i]['set']['ScoreboardName']))
|
||||
f.writelines(newList_conversion_SinglePlayer(musicset['musics'][i]['notes'],
|
||||
musicset['musics'][i]['set']['ScoreboardName']))
|
||||
if musicset['mainset']['IsRepeat']:
|
||||
log("增加重复语句")
|
||||
for i in range(len(musicset['musics'])):
|
||||
@ -245,7 +268,61 @@ def makeNewFunDir(musicset, path='./'):
|
||||
log("完成============================")
|
||||
|
||||
|
||||
def makeFunDir(musicset, path='./'):
|
||||
def makeClassFuncFiles(musicset, path='./'):
|
||||
"""在指定目录下生成函数文件"""
|
||||
from msctspt.transfer import classList_conversion_SinglePlayer
|
||||
commands = []
|
||||
starts = []
|
||||
starts.__len__()
|
||||
starts.append("scoreboard objectives add " + musicset['musics'][0]['set']['ScoreboardName'] + " dummy\n")
|
||||
starts.append("summon armor_stand " + musicset['musics'][0]['set']['EntityName'] + '\n')
|
||||
starts.append("scoreboard objectives setdisplay sidebar " + musicset['musics'][0]['set']['ScoreboardName'] + '\n')
|
||||
starts.append("scoreboard players set @e[type=armor_stand, name=\"" + musicset['musics'][0]['set']['EntityName'] +
|
||||
"\"] " + musicset['musics'][0]['set']['ScoreboardName'] + " 0" + '\n')
|
||||
log("=========================正在在此处生成文件:" + path)
|
||||
commands.append("scoreboard players add @e[name=\"" + musicset['musics'][0]['set']['EntityName'] + "\"] " +
|
||||
musicset['musics'][0]['set']['ScoreboardName'] + " 1\n")
|
||||
maxlen = -1
|
||||
for i in range(len(musicset['musics'])):
|
||||
log('写入第' + str(i) + '个数据')
|
||||
# commands.append("execute @e[name=\"" + musicset['musics'][i]['set']['EntityName'] + "\",scores={" +
|
||||
# musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset']
|
||||
# [
|
||||
# 'PlayerSelect'] + " title " + musicset['mainset']['MusicTitle'] + "\n")
|
||||
# commands.append("execute @e[name=\"" + musicset['musics'][i]['set']['EntityName'] + "\",scores={" +
|
||||
# musicset['musics'][i]['set']['ScoreboardName'] + "=1..10}] ~~~ title @a" + musicset['mainset']
|
||||
# [
|
||||
# 'PlayerSelect'] + " subtitle 本函数乐曲由§b§l凌云§r§3函数音乐创建§r生成\n")
|
||||
if len(musicset['musics'][i]['notes']) > maxlen:
|
||||
maxlen = len(musicset['musics'][i]['notes'])
|
||||
with open(path + musicset['mainset']['MusicTitle'] + '_Part' + str(i) + '.mcfunction', 'w',
|
||||
encoding='UTF-8') as f:
|
||||
f.writelines(classList_conversion_SinglePlayer(musicset['musics'][i]['notes'],
|
||||
musicset['musics'][i]['set']['ScoreboardName'],
|
||||
musicset['musics'][i]['set']['Instrument'],
|
||||
musicset['mainset']['PlayerSelect'],
|
||||
True))
|
||||
if musicset['mainset']['IsRepeat']:
|
||||
log("增加重复语句")
|
||||
for i in range(len(musicset['musics'])):
|
||||
commands.append("execute @e[name=\"" + musicset['musics'][i]['set']['EntityName'] + "\",scores={" +
|
||||
musicset['musics'][i]['set']['ScoreboardName'] + "=" + str(
|
||||
(maxlen + 2) * 10) + "}] ~~~ scoreboard players set @e[name=\"" + musicset['musics'][i]['set'][
|
||||
'EntityName'] + "\"] " + musicset['musics'][i]['set']['ScoreboardName'] + " -1\n")
|
||||
log("增加版权语句")
|
||||
commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿),bgArray(诸葛亮与八卦阵)\n")
|
||||
starts.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿),bgArray(诸葛亮与八卦阵)\n")
|
||||
log("写入支持文件")
|
||||
with open(path + musicset['mainset']['MusicTitle'] + '_Support.mcfunction', 'w', encoding='UTF-8') as f:
|
||||
f.writelines(commands)
|
||||
log("写入开始文件")
|
||||
with open(path + 'Start_' + musicset['mainset']['MusicTitle'] + '.mcfunction', 'w', encoding='UTF-8') as f:
|
||||
f.writelines(starts)
|
||||
del commands, starts, maxlen
|
||||
log("完成============================")
|
||||
|
||||
|
||||
def makeClassFunDir(musicset, path='./'):
|
||||
"""在指定目录下生成函数包文件夹"""
|
||||
import os
|
||||
import uuid
|
||||
@ -265,7 +342,6 @@ def makeFunDir(musicset, path='./'):
|
||||
path + musicset['mainset']['PackName'] + "Pack/world_behavior_packs.json") and os.path.exists(
|
||||
path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset'][
|
||||
'PackName'] + "/manifest.json")):
|
||||
|
||||
log("创建manifest.json以及world_behavior_packs.json")
|
||||
behaviorUuid = uuid.uuid4()
|
||||
with open(path + musicset['mainset']['PackName'] + "Pack/world_behavior_packs.json", "w") as f:
|
||||
@ -280,7 +356,7 @@ def makeFunDir(musicset, path='./'):
|
||||
'PackName'] + " Pack : behavior pack\",\n \"type\": \"data\",\n \"version\":"
|
||||
" [ 0, 0, 1 ],\n \"uuid\": \"" + str(
|
||||
uuid.uuid4()) + "\"\n }\n ]\n}")
|
||||
makeFuncFiles(musicset, path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset'][
|
||||
makeClassFuncFiles(musicset, path + musicset['mainset']['PackName'] + "Pack/behavior_packs/" + musicset['mainset'][
|
||||
'PackName'] + "/functions/")
|
||||
log("完成============================")
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
"""音·创 的转换工具库"""
|
||||
|
||||
|
||||
# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日
|
||||
# 统计:致命(三级)错误:0个;警告(二级)错误:4个--未解决1个;语法(一级)错误:302个
|
||||
|
||||
@ -26,15 +25,8 @@ def hans2pinyin(hans, style=3):
|
||||
return final
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def classList_conversion_SinglePlayer(List: list, ScoreboardName: str, playerSelection: str = '',
|
||||
isProsess: bool = False) -> list:
|
||||
def classList_conversion_SinglePlayer(List: list, ScoreboardName: str, Instrument: str, playerSelection: str = '',
|
||||
isProsess: bool = False) -> list:
|
||||
from bgArrayLib.compute import round_up
|
||||
commands = []
|
||||
length = len(List)
|
||||
@ -48,11 +40,17 @@ 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} @s ~ ~ ~ 1000 1.0 1000\n")
|
||||
commands.append(
|
||||
f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}="
|
||||
f"{str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~{127 - i.velocity} "
|
||||
f"~ playsound {Instrument} @s ~ ~ ~ 1000 {i.pitch} 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")
|
||||
commands.append(
|
||||
f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}="
|
||||
f"{str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~ ~ "
|
||||
f"title @s actionbar §e▶ 播放中: §a{j}/{length} || {int(j / length * 1000) / 10}\n")
|
||||
j += 1
|
||||
except :
|
||||
except:
|
||||
pass
|
||||
# a += List[i][1]
|
||||
# commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n")
|
||||
@ -60,13 +58,37 @@ def classList_conversion_SinglePlayer(List: list, ScoreboardName: str, playerSel
|
||||
return commands
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def newList_conversion_SinglePlayer(List: list, ScoreboardName: str, playerSelection: str = '',
|
||||
isProsess: bool = False) -> list:
|
||||
from bgArrayLib.compute import round_up
|
||||
commands = []
|
||||
length = len(List)
|
||||
j = 1
|
||||
print(List)
|
||||
for k in range(len(List)):
|
||||
i = List[k][0]
|
||||
print(i)
|
||||
print(type(i))
|
||||
try:
|
||||
if i.instrument > 119:
|
||||
pass
|
||||
else:
|
||||
commands.append(
|
||||
f"execute @a{playerSelection} ~ ~ ~ execute @s[scores={{{ScoreboardName}="
|
||||
f"{str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~{127 - i.velocity} "
|
||||
f"~ 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}="
|
||||
f"{str(round_up(i.time_position)).replace('.0', '')}}}] ~ ~ ~ "
|
||||
f"title @s actionbar §e▶ 播放中: §a{j}/{length} || {int(j / length * 1000) / 10}\n")
|
||||
j += 1
|
||||
except:
|
||||
pass
|
||||
# a += List[i][1]
|
||||
# commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n")
|
||||
print(commands)
|
||||
return commands
|
||||
|
||||
|
||||
def classList_conversion(List: list, ScoreboardName: str, isProsess: bool = False) -> list:
|
||||
@ -104,25 +126,6 @@ def classList_conversion(List: list, ScoreboardName: str, isProsess: bool = Fals
|
||||
print(commands)
|
||||
return commands
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def formCmdBlock(direction: Iterable, command: str, particularValue: int, impluse: int = 0, condition: bool = False,
|
||||
needRedstone: bool = True, tickDelay: int = 0, customName: str = '', lastOutput: str = '',
|
||||
@ -172,7 +175,7 @@ def formCmdBlock(direction: Iterable, command: str, particularValue: int, implus
|
||||
是否输出
|
||||
|
||||
:return: 指令方块字典结构,如下
|
||||
'''
|
||||
"""
|
||||
'''
|
||||
:param block: {
|
||||
"direction": [x: int, y: int, z: int] #方块位置
|
||||
@ -188,7 +191,7 @@ def formCmdBlock(direction: Iterable, command: str, particularValue: int, implus
|
||||
"conditional": int, #是否有条件 1 bytes
|
||||
"needRedstone": int #是否需要红石 1 bytes
|
||||
}
|
||||
"""
|
||||
'''
|
||||
return {"direction": direction,
|
||||
"block_name": "command_block",
|
||||
"particular_value": particularValue,
|
||||
@ -205,7 +208,7 @@ def formCmdBlock(direction: Iterable, command: str, particularValue: int, implus
|
||||
|
||||
|
||||
def note2bdx(filePath: str, dire: list, Notes: list, ScoreboardName: str, Instrument: str,
|
||||
PlayerSelect: str = '', isProsess: bool = False, height: int = 200):
|
||||
PlayerSelect: str = '', isProsess: bool = False, height: int = 200):
|
||||
"""使用方法同Note2Cmd
|
||||
:param 参数说明:
|
||||
filePath: 生成.bdx文件的位置
|
||||
@ -257,24 +260,8 @@ def note2bdx(filePath: str, dire: list, Notes: list, ScoreboardName: str, Instru
|
||||
return BdxConverter(filePath, 'Build by RyounMusicreater', blocks)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool = False, height: int = 200, isSquare: bool = False):
|
||||
def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool = False, height: int = 200,
|
||||
isSquare: bool = False):
|
||||
"""使用方法同Note2Cmd
|
||||
:param 参数说明:
|
||||
filePath: 生成.bdx文件的位置
|
||||
@ -293,14 +280,18 @@ def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool =
|
||||
direction = list(direction)
|
||||
|
||||
for track in music['musics']:
|
||||
cmdList = 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))
|
||||
# 开头的指令方块
|
||||
blocks.append(formCmdBlock(dire,
|
||||
f"scoreboard players add @a{music['mainset']['PlayerSelect']} "
|
||||
f"{track['set']['ScoreboardName']} 1",
|
||||
1, 1))
|
||||
dire[1] += 1
|
||||
blocks.append(formCmdBlock(dire, cmdList.pop(0), 2,needRedstone=False))
|
||||
blocks.append(formCmdBlock(dire, cmdList.pop(0), 2, needRedstone=False))
|
||||
dire[1] += 1
|
||||
# :0 下 无条件
|
||||
# :1 上 无条件
|
||||
@ -309,36 +300,24 @@ def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool =
|
||||
# :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))
|
||||
|
||||
blocks.append(formCmdBlock(dire, cmd, 5 if (down is 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
|
||||
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):
|
||||
if dire[1] < height + direction[1]:
|
||||
dire[1] += 1
|
||||
|
||||
if (down is 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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def note2webs(Notes: list, Instrument: str, speed: float = 5.0, PlayerSelect: str = '', isProsess: bool = False):
|
||||
"""传入音符,在oaclhost:8080上建立websocket服务器以供我的世界connect/wssever指令连接
|
||||
:param 参数说明:
|
||||
@ -369,17 +348,13 @@ def note2webs(Notes: list, Instrument: str, speed: float = 5.0, PlayerSelect: st
|
||||
await fcwslib.send_command(websocket,
|
||||
'execute @a' + PlayerSelect + ' ~ ~ ~ title @s actionbar §e▶ 播放中: §a' +
|
||||
str(
|
||||
j) + '/' + str(length) + ' || ' + str(int(j / length * 1000) / 10))
|
||||
j) + '/' + str(length) + ' || ' + str(int(j / length * 1000) / 10))
|
||||
j += 1
|
||||
time.sleep(Notes[i][1] / speed)
|
||||
|
||||
fcwslib.run_server(run_server)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def note2RSworld(world: str, startpos: list, notes: list, instrument: str, speed: float = 2.5,
|
||||
posadder: Iterable = (1, 0, 0), baseblock: str = 'stone'): # -> bool
|
||||
"""传入音符,生成以音符盒存储的红石音乐
|
||||
@ -407,7 +382,7 @@ def note2RSworld(world: str, startpos: list, notes: list, instrument: str, speed
|
||||
powered = 'true'
|
||||
else:
|
||||
powered = 'false'
|
||||
return Block('universal_minecraft', 'noteblock',
|
||||
return Block('universal_minecraft', 'notebooks',
|
||||
{"instrument": ts(instrument1.replace("note.", '')), 'note': ts(str(note)),
|
||||
'powered': ts(powered)})
|
||||
|
||||
@ -487,11 +462,6 @@ def note2RSworld(world: str, startpos: list, notes: list, instrument: str, speed
|
||||
level.close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ryStruct:
|
||||
|
||||
def __init__(self, world: str) -> None:
|
||||
@ -556,9 +526,6 @@ class ryStruct:
|
||||
return self.RyStruct
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
RyStruct = {
|
||||
(0,0,0) = {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -5,7 +5,6 @@
|
||||
|
||||
from nmcsup.log import log
|
||||
|
||||
|
||||
import amulet
|
||||
import amulet_nbt
|
||||
from amulet.api.block import Block
|
||||
@ -83,9 +82,6 @@ def Mp32Mid(mp3File, midFile):
|
||||
PianoTranscription(device="cpu").transcribe(audio, midFile)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 传入一个音符列表转为指令列表
|
||||
def Note2Cmd(Notes: list, ScoreboardName: str, Instrument: str, PlayerSelect: str = '',
|
||||
isProsess: bool = False) -> list:
|
||||
@ -105,27 +101,11 @@ def Note2Cmd(Notes: list, ScoreboardName: str, Instrument: str, PlayerSelect: st
|
||||
j += 1
|
||||
commands.append("\n\n# 凌云我的世界开发团队 x 凌云软件开发团队 : W-YI(金羿)\n")
|
||||
return commands
|
||||
|
||||
|
||||
# def newDataStructureCounterChange():
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 简单载入方块
|
||||
# level.set_version_block(posx,posy,posz,"minecraft:overworld",("bedrock", (1, 16, 20)),Block(namespace, name))
|
||||
|
||||
@ -264,10 +244,3 @@ def Notes2Player(Note, dire: list, CmdData: dict):
|
||||
def Datas2BlkWorld(NoteData, world: str, dire: list):
|
||||
for i in range(len(NoteData)):
|
||||
Blocks2World(world, [dire[0], dire[1], dire[2] + i], NoteData[i])
|
||||
|
||||
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user