Musicreater/Musicreater.py

1376 lines
56 KiB
Python
Raw Normal View History

2021-11-21 00:59:15 +08:00
# -*- coding: utf-8 -*-
2022-01-19 10:46:20 +08:00
# ! python3
2021-11-21 00:59:15 +08:00
2022-01-15 00:40:17 +08:00
2021-11-21 00:59:15 +08:00
# W-YI 金羿
# QQ 2647547478
# 音·创 开发交流群 861684859
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
2021-11-21 00:59:15 +08:00
# 版权所有 Team-Ryoun 金羿
# 若需转载或借鉴 请附作者
2022-01-15 00:40:17 +08:00
2022-01-19 10:46:20 +08:00
"""
2022-01-14 22:49:21 +08:00
Copyright 2022 Eilles Wan (金羿)
2022-01-15 00:40:17 +08:00
Licensed under the Apache License, Version 2.0 (the 'License')
2022-01-14 22:49:21 +08:00
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
2022-01-15 00:40:17 +08:00
distributed under the License is distributed on an 'AS IS' BASIS,
2022-01-14 22:49:21 +08:00
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2022-01-19 10:46:20 +08:00
"""
2022-01-15 00:40:17 +08:00
2021-11-21 00:59:39 +08:00
# 代码写的并非十分的漂亮还请大佬多多包涵本软件源代码依照Apache软件协议公开
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# -----------------------------分割线-----------------------------
# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日
# 统计致命三级错误0个警告二级错误15个语法一级错误597个
# 目前我的Pycharm并没有显示任何错误有错误可以向
# bgArray 诸葛亮与八卦阵
# QQ 474037765 或最好加入:音·创 开发交流群 861684859
# ------------------------- split line-----------------------------
# Zhuge Liang and Bagua array help to modify the grammar date: -- January 19, 2022
# Statistics: fatal (Level 3) errors: 0; Warning (Level 2) errors: 15; Syntax (Level 1) error: 597
# At present, my Pycham does not display any errors. If there are errors, you can report them to me
# Bgarray Zhuge Liang and Bagua array
# QQ 474037765 or better join: Musicreater development exchange group 861684859
# ------------------------- split line-----------------------------
# 下面为正文
2022-01-15 00:40:17 +08:00
2021-11-21 00:59:15 +08:00
import json
import os
import shutil
import sys
2021-11-21 00:59:15 +08:00
import threading
import tkinter as tk
import tkinter.filedialog
import tkinter.messagebox
import tkinter.simpledialog
2022-01-15 00:40:17 +08:00
from languages.lang import *
2021-11-21 00:59:15 +08:00
from msctspt.threadOpera import NewThread
from nmcsup.vers import VER
2022-01-19 10:46:20 +08:00
__version__ = VER[1] + VER[0]
2021-11-21 00:59:15 +08:00
__author__ = 'W-YI (金羿)'
2022-01-19 10:46:20 +08:00
dire = ""
begp = ""
endp = ""
2021-11-21 00:59:15 +08:00
2022-01-19 22:25:16 +08:00
2021-11-21 00:59:15 +08:00
print('建立变量,存入内存,载入字典常量函数')
# 主体部分
# 支持多文件同时操作
# dataset[{ 'mainset':{ 'x':'y' }, 'musics': [ { 'set' :{ 'A':'B' } , 'note' : [ [ 'a' , b ], ] }, ] }, ]
# 编辑:
# 修改主设置: dataset[第几个项目]['mainset']['什么设置'] = '设置啥'
# 修改音乐: dataset[第几个项目]['musics'][第几个音轨]['notes'][第几个音符][音符还是时间01] = 改成啥
# 修改音轨设置: dataset[第几个项目]['musics'][第几个音轨]['set']['什么设置'] = '设置啥'
#
# 新增音轨: dataset[第几个项目]['musics'].append(datasetmodelpart)
#
'''
dataset=[
{
'mainset':{
'PackName':'Ryoun',
2021-11-21 00:59:15 +08:00
'MusicTitle':'Noname',
'IsRepeat':False,
'PlayerSelect':''
},
'musics':[
{
'set':{
'EntityName':'music_support',
'ScoreboardName':'music_support',
'Instrument':'harp',
'FileName':'Music'
2021-11-21 00:59:15 +08:00
},
'notes':[
[0.0,1.0],
]
},
],
},
]
'''
dataset = [
{
'mainset': {
'PackName': 'Ryoun',
2021-11-21 00:59:15 +08:00
'MusicTitle': 'Noname',
'IsRepeat': False,
'PlayerSelect': ''
},
'musics': [
{
'set': {
'EntityName': 'MusicSupport',
'ScoreboardName': 'MusicSupport',
'Instrument': 'note.harp',
'FileName': 'Music'
2021-11-21 00:59:15 +08:00
},
'notes': [
[0.0, 1.0],
]
},
],
},
]
is_new_file = True
is_save = True
ProjectName = ''
2022-01-15 00:40:17 +08:00
clearLog = False
2021-11-21 00:59:15 +08:00
NowMusic = 0
root = tk.Tk()
def DMM(): # 反回字典用于编辑
datasetmodelpart = {
'set': {
'EntityName': 'MusicSupport',
'ScoreboardName': 'MusicSupport',
'Instrument': 'note.harp',
'FileName': 'Music'
2021-11-21 00:59:15 +08:00
},
'notes': []
}
return datasetmodelpart
print('完成')
2021-11-21 00:59:15 +08:00
def __main__():
2022-01-19 10:46:20 +08:00
"""音·创 本体\n
2021-11-21 00:59:15 +08:00
W-YI 金羿\n
QQ 2647547478\n
· 开发交流群 861684859\n
Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com\n
版权所有 Team-Ryoun 金羿\n
若需转载或借鉴 请附作者\n
2022-01-19 10:46:20 +08:00
"""
2021-11-21 00:59:15 +08:00
print('音·创 正在启动……')
2021-11-21 00:59:15 +08:00
2021-11-21 11:38:01 +08:00
print('载入日志功能...')
from nmcsup.log import log
2021-11-21 00:59:15 +08:00
print('完成!')
print('更新执行位置...')
2021-11-21 11:38:01 +08:00
if sys.platform == 'win32':
try:
2022-01-19 10:46:20 +08:00
os.chdir(__file__[:len(__file__) - __file__[len(__file__)::-1].index('\\')])
log('更新执行位置,当前文件位置 {}'.format(__file__))
2022-01-19 10:46:20 +08:00
except FileNotFoundError: # 程序规范修改根据新的语法标准except后面不能没有错误类型所以既然是pass就随便填一个错误
pass
2021-11-21 11:38:01 +08:00
else:
try:
2022-01-19 10:46:20 +08:00
os.chdir(__file__[:len(__file__) - __file__[len(__file__)::-1].index('/')])
except FileNotFoundError:
pass
2022-01-19 10:46:20 +08:00
log('其他平台:{} 更新执行位置,当前文件位置 {}'.format(sys.platform, __file__))
2021-11-21 00:59:15 +08:00
print('完成!')
# 读取文件
print('载入文件读取函数')
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
def ReadFile(fn: str): # -> list
2021-11-21 00:59:15 +08:00
from nmcsup.nmcreader import ReadFile as fileRead
k = fileRead(fn)
2022-01-19 10:46:20 +08:00
if k is False:
2022-01-15 00:40:17 +08:00
tk.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[105].format(fn))
2021-11-21 00:59:15 +08:00
return
else:
return k
2022-01-19 10:46:20 +08:00
def ReadMidi(midfile: str): # -> str
2021-11-21 00:59:15 +08:00
from nmcsup.nmcreader import ReadMidi as midiRead
k = midiRead(midfile)
2022-01-19 10:46:20 +08:00
if k is False:
2022-01-15 00:40:17 +08:00
tk.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[105].format(midfile))
2021-11-21 00:59:15 +08:00
return
else:
return k
print('完成!')
# 菜单命令
2022-01-15 00:40:17 +08:00
print('加载菜单命令...')
2021-11-21 00:59:15 +08:00
def exitapp():
global is_save
2022-01-19 10:46:20 +08:00
if is_save is not True:
2022-01-15 00:40:17 +08:00
if tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106]):
2021-11-21 00:59:15 +08:00
SaveProject()
log('程序正常退出')
2021-11-21 19:08:04 +08:00
try:
global dataset
del dataset
2021-11-22 13:13:43 +08:00
global root
root.destroy()
del root
2022-01-19 10:46:20 +08:00
except FileNotFoundError: # 程序规范修改根据新的语法标准except后面不能没有错误类型所以既然是pass就随便填一个错误
2022-01-01 20:19:41 +08:00
pass
2021-11-22 13:13:43 +08:00
2022-01-19 10:46:20 +08:00
if clearLog:
2022-01-03 20:45:25 +08:00
print(READABLETEXT[2])
2022-01-19 18:03:52 +08:00
err = True
2021-11-21 00:59:15 +08:00
try:
if os.path.exists('./log/'):
shutil.rmtree('./log/')
if os.path.exists('./logs/'):
shutil.rmtree('./logs/')
if os.path.exists('./cache/'):
shutil.rmtree('./cache/')
2022-01-19 18:03:52 +08:00
err = False
2022-01-19 10:46:20 +08:00
except ZeroDivisionError: # 程序规范修改根据新的语法标准except后面不能没有错误类型所以既然是pass就随便填一个错误
2022-01-03 20:45:25 +08:00
print(READABLETEXT[3])
2022-01-19 18:03:52 +08:00
finally:
if err is True:
print(READABLETEXT[3])
2022-01-19 10:46:20 +08:00
2021-11-21 00:59:15 +08:00
exit()
print('退出命令加载完成!')
def SaveProject():
if is_new_file:
# 新的项目相等于另存为
SaveAsProject()
return
else:
# 旧项目旧存着吧
log('存储已有文件:{}'.format(ProjectName))
2021-11-21 21:32:46 +08:00
with open(ProjectName, 'w', encoding='utf-8') as f:
2021-11-21 00:59:15 +08:00
json.dump(dataset[0], f)
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showinfo(title=READABLETEXT[4], message=READABLETEXT[107].format(ProjectName))
2021-11-21 00:59:15 +08:00
global is_save
is_save = True
print('保存项目命令加载完成!')
def SaveAsProject():
# 另存为项目
2022-01-19 10:46:20 +08:00
fn = tkinter.filedialog.asksaveasfilename(title=READABLETEXT[5], initialdir=r'./',
filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[109], '*')],
defaultextension='Noname.msct')
if fn is None or fn == '':
2021-11-21 00:59:15 +08:00
return
2022-01-19 10:46:20 +08:00
Project_Name = fn
with open(Project_Name, 'w', encoding='utf-8') as f:
2021-11-21 00:59:15 +08:00
json.dump(dataset[0], f)
2022-01-19 10:46:20 +08:00
tkinter.messagebox.showinfo(title=READABLETEXT[4], message=READABLETEXT[107].format(Project_Name))
2021-11-21 00:59:15 +08:00
global is_save
is_save = True
print('另存项目命令加载完成!')
def openOldProject():
global is_save
2022-01-19 10:46:20 +08:00
if is_save is not True:
2022-01-15 00:40:17 +08:00
result = tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106])
2021-11-21 00:59:15 +08:00
if result:
SaveProject()
2022-01-19 10:46:20 +08:00
fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[6], initialdir=r'./',
filetypes=[(READABLETEXT[110], '.ry.nfc'),
(READABLETEXT[111], '.ry.mfm'), (READABLETEXT[112], '*')],
multiple=True)
if fn is None or fn == '':
2021-11-21 00:59:15 +08:00
return
else:
fn = fn[0]
from nmcsup.nmcreader import ReadOldProject
dataset[0] = ReadOldProject(fn)
def openProject():
global is_save
2022-01-19 10:46:20 +08:00
if is_save is not True:
2022-01-15 00:40:17 +08:00
result = tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[106])
2021-11-21 00:59:15 +08:00
if result:
SaveProject()
2022-01-19 10:46:20 +08:00
fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[7], initialdir=r'./',
filetypes=[(READABLETEXT[108], '.msct'), (READABLETEXT[112], '*')],
multiple=True)
if fn is None or fn == '':
2021-11-21 00:59:15 +08:00
return
else:
fn = fn[0]
try:
2022-01-19 10:46:20 +08:00
with open(fn, 'r', encoding='UTF-8') as C:
dataset[0] = json.load(C)
except json.decoder.JSONDecodeError: # 程序规范修改根据新的语法标准except后面不能没有错误类型测试后改为
# json.decoder.JSONDecodeError
2022-01-03 20:45:25 +08:00
print(READABLETEXT[8].format(fn))
log('无法打开{}'.format(fn))
2021-11-21 00:59:15 +08:00
return
global is_new_file
global ProjectName
is_new_file = False
ProjectName = fn
del fn
global NowMusic
RefreshMain()
RefreshMusic(NowMusic)
print('打开项目命令加载完成!')
def appabout():
aabw = tk.Tk()
2022-01-03 20:45:25 +08:00
aabw.title(READABLETEXT[9])
2022-01-15 00:40:17 +08:00
aabw.geometry('550x600') # 像素
2021-11-21 00:59:15 +08:00
tk.Label(aabw, text='', font=('', 15)).pack()
2022-01-03 20:45:25 +08:00
tk.Label(aabw, text=READABLETEXT[10], font=('', 35)).pack()
2022-01-19 10:46:20 +08:00
tk.Label(aabw, text=READABLETEXT[11].format(VER[1] + VER[0]), font=('', 15)).pack()
2021-11-21 00:59:15 +08:00
# pack 的side可以赋值为LEFT RTGHT TOP BOTTOM
# grid 的row 是列数、column是行排注意这是针对空间控件本身大小来的即是指向当前控件的第几个。
# place的 x、y是(x,y)坐标
2022-01-19 10:46:20 +08:00
# pic = tk.PhotoImage(file='./bin/pics/Ryoun_S.png')
# tk.Label(aabw, image=pic, width=200, height=200).pack()
# del pic
2021-11-21 00:59:15 +08:00
tk.Label(aabw, text='', font=('', 5)).pack()
2022-01-03 20:45:25 +08:00
tk.Label(aabw, text=READABLETEXT[12], font=('', 20)).pack()
2021-11-21 00:59:15 +08:00
tk.Label(aabw, text='', font=('', 15)).pack()
2022-01-15 00:40:17 +08:00
for i in READABLETEXT[15]:
2022-01-19 10:46:20 +08:00
tk.Label(aabw, text=i[0], font=('', 17 if i[1] else 15, 'bold' if i[1] else '')).pack()
2022-01-15 00:40:17 +08:00
tk.Label(aabw, text='', font=('', 5)).pack()
if DEFAULTLANGUAGE != 'zh-CN':
tk.Label(aabw, text=READABLETEXT[16], font=('', 15)).pack()
for i in READABLETEXT['Translator']:
2022-01-19 10:46:20 +08:00
tk.Label(aabw, text=i[0], font=('', 17 if i[1] else 15, 'bold' if i[1] else '')).pack()
2022-01-15 00:40:17 +08:00
def exitAboutWindow():
aabw.destroy()
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
tk.Button(aabw, text=READABLETEXT[13], command=exitAboutWindow).pack()
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
aabw.mainloop()
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
print('关于命令加载完成!')
2021-11-21 00:59:15 +08:00
def apphelp():
ahpw = tk.Tk()
2022-01-03 20:45:25 +08:00
ahpw.title(READABLETEXT[19])
2021-11-21 00:59:15 +08:00
ahpw.geometry('400x600') # 像素
ahpw.mainloop()
print('帮助命令加载完成!')
def FromMP3():
log('从MP3导入音乐')
2022-01-19 10:46:20 +08:00
mp3file = tkinter.filedialog.askopenfilename(title=READABLETEXT[20], initialdir=r'./',
filetypes=[(READABLETEXT[113], '.mp3 .m4a'),
(READABLETEXT[112], '*')], multiple=True)
if mp3file is None or mp3file == '':
log('取消')
2021-11-21 00:59:15 +08:00
return
else:
mp3file = mp3file[0]
from nmcsup.nmcreader import ReadMidi
from nmcsup.trans import Mp32Mid
if not os.path.exists('./Temp/'):
os.makedirs('./Temp/')
2022-01-19 10:46:20 +08:00
Mp32Mid(mp3file, './Temp/Trans.mid')
log('打开midi文件./Temp/Trans.mid')
2021-11-21 00:59:15 +08:00
th = NewThread(ReadMidi, ('./Temp/Trans.mid',))
th.start()
del mp3file
2022-01-19 10:46:20 +08:00
def midiSPT(th_):
for i in th_.getResult():
2021-11-21 00:59:15 +08:00
datas = DMM()
datas['notes'] = i
dataset[0]['musics'].append(datas)
2022-01-19 10:46:20 +08:00
del th_
2021-11-21 00:59:15 +08:00
global is_save
is_save = False
global NowMusic
RefreshMain()
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
2021-11-21 00:59:15 +08:00
threading.Thread(target=midiSPT, args=(th,)).start()
del th
print('读MP3加载完成')
2021-11-21 00:59:15 +08:00
def FromMidi():
log('从midi导入音乐')
2022-01-19 10:46:20 +08:00
midfile = tkinter.filedialog.askopenfilename(title=READABLETEXT[21], initialdir=r'./',
filetypes=[(READABLETEXT[114], '.mid .midi'),
(READABLETEXT[112], '*')], multiple=True)
if midfile is None or midfile == '':
log('取消')
2021-11-21 00:59:15 +08:00
return
else:
midfile = midfile[0]
th = NewThread(ReadMidi, (midfile,))
th.start()
del midfile
2022-01-19 10:46:20 +08:00
def midiSPT(th_):
for i in th_.getResult():
2021-11-21 00:59:15 +08:00
datas = DMM()
datas['notes'] = i
dataset[0]['musics'].append(datas)
2022-01-19 10:46:20 +08:00
del th_
2021-11-21 00:59:15 +08:00
global is_save
is_save = False
global NowMusic
RefreshMain()
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
2021-11-21 00:59:15 +08:00
threading.Thread(target=midiSPT, args=(th,)).start()
del th
print('读midi命令加载完成')
def FromForm():
log('从文本读入音轨')
2022-01-19 10:46:20 +08:00
fn = tkinter.filedialog.askopenfilename(title=READABLETEXT[22], initialdir=r'./',
filetypes=[(READABLETEXT[115], '.txt'), (READABLETEXT[112], '*')],
multiple=True)
if fn is None or fn == '':
log('取消')
2021-11-21 00:59:15 +08:00
return
else:
fn = fn[0]
th = NewThread(ReadFile, (fn,))
th.start()
2022-01-19 10:46:20 +08:00
def midiSPT(th_):
for i in th_.getResult():
2021-11-21 00:59:15 +08:00
datas = DMM()
datas['notes'] = i
dataset[0]['musics'].append(datas)
2022-01-19 10:46:20 +08:00
del th_
2021-11-21 00:59:15 +08:00
global is_save
is_save = False
global NowMusic
RefreshMain()
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
threading.Thread(target=midiSPT, args=(th,)).start()
2021-11-21 00:59:15 +08:00
print('读txt命令加载完成')
def FromText():
log('写入音符至音轨')
2022-01-15 00:40:17 +08:00
dat = tkinter.simpledialog.askstring(title=READABLETEXT[23], prompt=READABLETEXT[14], initialvalue='`1 .2 C')
2022-01-19 10:46:20 +08:00
if dat is None:
2021-11-21 00:59:15 +08:00
return
datas = []
for i in dat.split(' '):
2021-11-21 00:59:15 +08:00
datas.append([str(i), 1.0])
2022-01-03 20:45:25 +08:00
log(READABLETEXT[24].format(str(datas)))
2021-11-21 00:59:15 +08:00
from nmcsup.trans import note2list
datat = DMM()
datat['notes'] = note2list(datas)
dataset[0]['musics'].append(datat)
del datas, datat, dat
global is_save
is_save = False
global NowMusic
RefreshMain()
RefreshMusic(NowMusic)
print('写入命令加载完成!')
def ShowCMD():
log('展示指令')
2021-11-21 00:59:15 +08:00
global NowMusic
from nmcsup.trans import Note2Cmd
2022-01-19 10:46:20 +08:00
RefreshCMDList(
Note2Cmd(dataset[0]['musics'][NowMusic]['notes'], dataset[0]['musics'][NowMusic]['set']['ScoreboardName'],
dataset[0]['musics'][NowMusic]['set']['Instrument'], dataset[0]['mainset']['PlayerSelect']))
2021-11-21 00:59:15 +08:00
def MakeCMD():
log('生成文件')
2021-11-21 00:59:15 +08:00
from msctspt.funcOpera import makeFuncFiles
2022-01-03 20:45:25 +08:00
file = tkinter.filedialog.askdirectory(title=READABLETEXT[25], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if file is None or file == '':
log('取消')
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
makeFuncFiles(dataset[0], file + '/')
2021-11-21 00:59:15 +08:00
def MakeCMDdir():
log('生成函数包')
2021-11-21 00:59:15 +08:00
from msctspt.funcOpera import makeFunDir
2022-01-03 20:45:25 +08:00
file = tkinter.filedialog.askdirectory(title=READABLETEXT[26], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if file is None or file == '':
log('取消')
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
makeFunDir(dataset[0], file + '/')
2021-11-21 00:59:15 +08:00
def MakePackFile():
2022-01-03 20:45:25 +08:00
file = tkinter.filedialog.askdirectory(title=READABLETEXT[27], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if file is None or file == '':
log('取消')
return
2021-11-21 00:59:15 +08:00
import zipfile
from msctspt.funcOpera import makeFunDir
log('生成附加包文件')
2021-11-21 00:59:15 +08:00
if not os.path.exists('./temp/'):
os.makedirs('./temp/')
makeFunDir(dataset[0], './temp/')
2022-01-19 10:46:20 +08:00
shutil.move('./temp/{}Pack/behavior_packs/{}/functions'.format(dataset[0]['mainset']['PackName'],
dataset[0]['mainset']['PackName']), './')
2022-01-19 10:46:20 +08:00
shutil.move('./temp/{}Pack/behavior_packs/{}/manifest.json'.format(dataset[0]['mainset']['PackName'],
dataset[0]['mainset']['PackName']), './')
2022-01-19 10:46:20 +08:00
with zipfile.ZipFile('{}/{}.mcpack'.format(file, dataset[0]['mainset']['PackName']), 'w') as zipobj:
2021-11-21 00:59:15 +08:00
for i in os.listdir('./functions/'):
zipobj.write('./functions/{}'.format(i))
2021-11-21 00:59:15 +08:00
zipobj.write('./manifest.json')
2022-01-19 10:46:20 +08:00
shutil.move('./functions', './temp/')
shutil.move('./manifest.json', './temp/')
shutil.rmtree('./temp/')
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 转为空方块世界
2021-11-21 00:59:15 +08:00
def ToBlockWorldEpt():
import zipfile
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
from nmcsup.trans import Cmd2World, Datas2BlkWorld, Notes2Player
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
return
2021-11-21 00:59:15 +08:00
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-03 20:45:25 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
log('取消')
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire = '{}/{}/'.format(Outdire[0], dataset[0]['mainset']['PackName'])
with zipfile.ZipFile('./nmcsup/EptWorld.zip') as zipobj: # , 'r' (参数等于默认时不写)
2021-11-21 00:59:15 +08:00
zipobj.extractall(Outdire)
NoteData = []
for i in dataset[0]['musics']:
NoteData.append(i['notes'])
2022-01-19 10:46:20 +08:00
Datas2BlkWorld(NoteData, Outdire, dire)
2021-11-21 00:59:15 +08:00
del NoteData
for i in range(len(dataset[0]['musics'])):
2022-01-19 10:46:20 +08:00
Cmd2World(Notes2Player(dataset[0]['musics'][i]['notes'], [dire[0], dire[1], dire[2] + i],
{'Ent': dataset[0]['musics'][i]['set']['EntityName'],
'Pls': dataset[0]['mainset']['PlayerSelect'],
'Ins': dataset[0]['musics'][i]['set']['Instrument']}), Outdire,
[dire[0] - 5 - i, dire[1], dire[2]])
2021-11-21 00:59:15 +08:00
del dire, Outdire
2022-01-19 10:46:20 +08:00
# 转为已存在的方块世界
2021-11-21 00:59:15 +08:00
def ToBlockWorld():
from nmcsup.trans import Cmd2World, Datas2BlkWorld, Notes2Player
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-03 20:45:25 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
log('取消')
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire += '/'
2021-11-21 00:59:15 +08:00
NoteData = []
for i in dataset[0]['musics']:
NoteData.append(i['notes'])
2022-01-19 10:46:20 +08:00
Datas2BlkWorld(NoteData, Outdire, dire)
2021-11-21 00:59:15 +08:00
del NoteData
for i in range(len(dataset[0]['musics'])):
2022-01-19 10:46:20 +08:00
Cmd2World(Notes2Player(dataset[0]['musics'][i]['notes'], [dire[0], dire[1], dire[2] + i],
{'Ent': dataset[0]['musics'][i]['set']['EntityName'],
'Pls': dataset[0]['mainset']['PlayerSelect'],
'Ins': dataset[0]['musics'][i]['set']['Instrument']}), Outdire,
[dire[0] - 5 - i, dire[1], dire[2]])
2021-11-21 00:59:15 +08:00
del dire, Outdire
2022-01-19 10:46:20 +08:00
# 生成函数播放器
2021-11-21 00:59:15 +08:00
def MakeFuncPlayer():
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-15 00:40:17 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[30], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire = '{}/{}/'.format(Outdire, dataset[0]['mainset']['PackName'])
2021-11-21 00:59:15 +08:00
from nmcsup.trans import Notes2Player
for i in range(len(dataset[0]['musics'])):
2022-01-19 10:46:20 +08:00
open(Outdire + dataset[0]['musics'][i]['set']['FileName'] + '_' + str(i) + '.mcfunction', 'w',
encoding='utf-8').writelines(
Notes2Player(dataset[0]['musics'][i]['notes'], [dire[0], dire[1], dire[2] + i],
{'Ent': dataset[0]['musics'][i]['set']['EntityName'],
'Pls': dataset[0]['mainset']['PlayerSelect'],
'Ins': dataset[0]['musics'][i]['set']['Instrument']}))
# 转为空指令世界
2021-11-21 00:59:15 +08:00
def ToCmdWorldEpt():
import zipfile
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
from nmcsup.trans import Cmd2World, Note2Cmd
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
continue
2022-01-19 17:48:47 +08:00
break
2022-01-15 00:40:17 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire += '/' + dataset[0]['mainset']['PackName'] + '/'
with zipfile.ZipFile('./nmcsup/EptWorld.zip') as zipobj: # , 'r' (默认参数不用设置)
2022-01-15 00:40:17 +08:00
zipobj.extractall(Outdire)
2021-11-21 00:59:15 +08:00
for i in range(len(dataset[0]['musics'])):
2022-01-19 10:46:20 +08:00
Cmd2World(Note2Cmd(dataset[0]['musics'][i]['notes'], dataset[0]['musics'][i]['set']['ScoreboardName'],
dataset[0]['musics'][i]['set']['Instrument'], dataset[0]['mainset']['PlayerSelect'],
True), Outdire, [dire[0], dire[1], dire[2] + i])
del dire, Outdire
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 转为已存在的指令世界
2021-11-21 00:59:15 +08:00
def ToCmdWorld():
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
from nmcsup.trans import Cmd2World, Note2Cmd
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-15 00:40:17 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire += '/'
2021-11-21 00:59:15 +08:00
for i in range(len(dataset[0]['musics'])):
2022-01-19 10:46:20 +08:00
Cmd2World(Note2Cmd(dataset[0]['musics'][i]['notes'], dataset[0]['musics'][i]['set']['ScoreboardName'],
dataset[0]['musics'][i]['set']['Instrument'], dataset[0]['mainset']['PlayerSelect'],
True), Outdire, [dire[0], dire[1], dire[2] + i])
del dire, Outdire
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 函数输入指令块
2021-11-21 00:59:15 +08:00
def func2World():
from nmcsup.trans import Cmd2World
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-15 00:40:17 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire += '/'
Cmd2World(open(tkinter.filedialog.askopenfilename(title=READABLETEXT[31], initialdir=r'./',
filetypes=[(READABLETEXT[118], '.mcfunction'),
(READABLETEXT[112], '*')], multiple=True)[0], 'r',
encoding='utf-8').readlines(), Outdire, dire)
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 大函数分割并载入执行链
2021-11-21 00:59:15 +08:00
def bigFunc2World():
log('分割大函数')
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
import uuid
from msctspt.funcOpera import funSplit
from msctspt.transfer import hans2pinyin
from nmcsup.trans import Cmd2World
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[119],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[120])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-15 00:40:17 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
log('取消')
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire += '/'
log('获得地图地址:' + Outdire)
fileName = tkinter.filedialog.askopenfilename(title=READABLETEXT[31], initialdir=r'./',
filetypes=[(READABLETEXT[118], '.mcfunction'),
(READABLETEXT[112], '*')], multiple=True)
if fileName is None or fileName == '':
log('取消')
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
else:
fileName = fileName[0]
2022-01-19 10:46:20 +08:00
log('获得文件名:' + fileName)
bigFile = open(fileName, 'r', encoding='utf-8')
2021-11-21 00:59:15 +08:00
parts = funSplit(bigFile)
if parts == -1:
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[121])
return
log('创建函数文件夹')
2022-01-19 10:46:20 +08:00
packName = fileName[len(fileName) - fileName[::-1].index('/'):fileName.index('.')]
2021-11-21 00:59:15 +08:00
packDire = hans2pinyin(packName)
try:
2022-01-19 10:46:20 +08:00
os.makedirs(Outdire + 'behavior_packs/' + packDire + '/functions/')
except FileExistsError:
log('已存在文件夹')
log('创建manifest.json以及world_behavior_packs.json')
2021-11-21 00:59:15 +08:00
behaviorUuid = uuid.uuid4()
2022-01-19 10:46:20 +08:00
if os.path.exists(Outdire + 'world_behavior_packs.json'):
with open(Outdire + 'world_behavior_packs.json', 'r') as f:
2021-11-21 00:59:15 +08:00
have = json.load(f)
2022-01-19 10:46:20 +08:00
have.append({'pack_id': str(behaviorUuid), 'version': [0, 0, 1]})
with open(Outdire + 'world_behavior_packs.json', 'w', encoding='utf-8') as f:
json.dump(have, f)
2021-11-21 00:59:15 +08:00
del have
else:
2022-01-19 10:46:20 +08:00
with open(Outdire + 'world_behavior_packs.json', 'w', encoding='utf-8') as f:
f.write('[\n {\'pack_id\': \'' + str(behaviorUuid) + '\',\n \'version\': [ 0, 0, 1 ]}\n]')
with open(Outdire + 'behavior_packs/' + packDire + '/manifest.json', 'w') as f:
f.write(
'{\n \'format_version\': 1,\n \'header\': {\n \'description\': \'' + packName +
' Pack : behavior pack\',\n \'version\': [ 0, 0, 1 ],\n \'name\': \'' + packName +
'Pack\',\n \'uuid\': \'' + str(
behaviorUuid) + '\'\n },\n \'modules\': [\n {\n \'description\': \'' + packName +
' Pack : behavior pack\',\n \'type\': '
'\'data\',\n \'version\': [ 0, 0, 1 ],\n \'uuid\': \'' + str(
uuid.uuid4()) + '\'\n }\n ]\n}') # 要求文段不能过长
2021-11-21 00:59:15 +08:00
cmdlist = []
2022-01-19 10:46:20 +08:00
for i in parts:
open(Outdire + 'behavior_packs/' + packDire + '/functions/' + packDire + str(
parts.index(i) + 1) + '.mcfunction', 'w', encoding='utf-8').writelines(i)
cmdlist.append('function ' + packDire + str(parts.index(i) + 1))
Cmd2World(cmdlist, Outdire, dire)
del cmdlist, behaviorUuid, Outdire, fileName, bigFile, parts, dire, packName, packDire
2021-11-21 00:59:15 +08:00
def toScbBDXfile():
from msctspt.transfer import note2bdx
2022-01-19 10:46:20 +08:00
global dire
2021-11-21 00:59:15 +08:00
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[122],
initialvalue='0 0 0')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[120])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-19 10:46:20 +08:00
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')
if fileName is None or fileName == '':
log('取消')
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
log('获得文件名:' + fileName)
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
res = note2bdx(fileName, dire, dataset[0]['musics'][NowMusic]['notes'],
dataset[0]['musics'][NowMusic]['set']['ScoreboardName'],
dataset[0]['musics'][NowMusic]['set']['Instrument'], dataset[0]['mainset']['PlayerSelect'])
2022-01-23 22:33:41 +08:00
2022-01-19 10:46:20 +08:00
log('转换结束!\n' + str(res))
tkinter.messagebox.showinfo(READABLETEXT[33], READABLETEXT[124].format(str(res)))
2021-11-21 00:59:15 +08:00
2022-01-23 22:33:41 +08:00
2021-11-21 00:59:15 +08:00
def wsPlay():
from msctspt.transfer import note2webs
2022-01-19 10:46:20 +08:00
spd = tkinter.simpledialog.askfloat(READABLETEXT[34], prompt=READABLETEXT[125], initialvalue='5.0')
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showinfo(title=READABLETEXT[35], message=READABLETEXT[126])
2022-01-19 10:46:20 +08:00
note2webs(dataset[0]['musics'][NowMusic]['notes'], dataset[0]['musics'][NowMusic]['set']['Instrument'], spd,
dataset[0]['mainset']['PlayerSelect'])
2021-11-21 00:59:15 +08:00
def toRSworldEPT():
import zipfile
2022-01-19 10:46:20 +08:00
global dire
dire = ""
2021-11-21 00:59:15 +08:00
from msctspt.transfer import note2RSworld
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
continue
break
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire += '/' + dataset[0]['mainset']['PackName'] + '/'
with zipfile.ZipFile('./nmcsup/EptWorld.zip') as zipobj: # , 'r'(默认参数不用写)
2022-01-15 00:40:17 +08:00
zipobj.extractall(Outdire)
2021-11-21 00:59:15 +08:00
for i in range(len(dataset[0]['musics'])):
2022-01-19 10:46:20 +08:00
note2RSworld(Outdire, dire, dataset[0]['musics'][i]['notes'], dataset[0]['musics'][i]['set']['Instrument'])
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
del dire, Outdire
2021-11-21 00:59:15 +08:00
def toRSworld():
from msctspt.transfer import note2RSworld
2022-01-19 10:46:20 +08:00
global dire
dire = ""
2021-11-21 00:59:15 +08:00
while True:
try:
2022-01-19 10:46:20 +08:00
dire = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[116],
initialvalue='16 4 16')
if dire is None or dire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
dire = [int(dire.split(' ')[0]), int(dire.split(' ')[1]), int(dire.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 00:59:15 +08:00
continue
break
2022-01-15 00:40:17 +08:00
Outdire = tkinter.filedialog.askdirectory(title=READABLETEXT[29], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if Outdire is None or Outdire == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
Outdire += '/'
2021-11-21 00:59:15 +08:00
for i in range(len(dataset[0]['musics'])):
2022-01-19 10:46:20 +08:00
note2RSworld(Outdire, dire, dataset[0]['musics'][i]['notes'], dataset[0]['musics'][i]['set']['Instrument'])
del dire, Outdire
2021-11-21 00:59:15 +08:00
2021-11-21 17:44:35 +08:00
def world2RyStruct():
2022-01-19 10:46:20 +08:00
global begp
global endp
2022-01-15 00:40:17 +08:00
outdir = tkinter.filedialog.askdirectory(title=READABLETEXT[36], initialdir=r'./')
2022-01-19 10:46:20 +08:00
if outdir is None or outdir == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 17:44:35 +08:00
else:
2022-01-19 10:46:20 +08:00
outdir += '/'
2021-11-21 17:44:35 +08:00
while True:
try:
2022-01-19 10:46:20 +08:00
begp = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[127],
initialvalue='16 4 16')
if begp is None or begp == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 17:44:35 +08:00
begp = [int(begp.split(' ')[0]), int(begp.split(' ')[1]), int(begp.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 17:44:35 +08:00
continue
break
while True:
try:
2022-01-19 10:46:20 +08:00
endp = tkinter.simpledialog.askstring(title=READABLETEXT[28], prompt=READABLETEXT[128],
initialvalue='16 4 16')
if endp is None or endp == '':
2022-01-15 00:40:17 +08:00
return
2021-11-21 17:44:35 +08:00
endp = [int(endp.split(' ')[0]), int(endp.split(' ')[1]), int(endp.split(' ')[2])]
2022-01-19 10:46:20 +08:00
except ValueError: # 测试完为ValueError故修改语法
2022-01-15 00:40:17 +08:00
tkinter.messagebox.showerror(title=READABLETEXT[0], message=READABLETEXT[117])
2021-11-21 17:44:35 +08:00
continue
break
2022-01-19 10:46:20 +08:00
isAir = tkinter.messagebox.askyesno(READABLETEXT[37], READABLETEXT[129])
fileName = tkinter.filedialog.asksaveasfilename(title=READABLETEXT[38], initialdir=r'./',
filetypes=[(READABLETEXT[130], '.RyStruct'),
(READABLETEXT[112], '*')],
defaultextension='*.RyStruct', initialfile='*.RyStruct')
if fileName is None or fileName == '':
log('取消')
return
2021-11-21 17:44:35 +08:00
from msctspt.transfer import ryStruct
2021-11-22 13:13:43 +08:00
rys = ryStruct(outdir)
2022-01-19 10:46:20 +08:00
rys.world2Rys(begp, endp, isAir)
error1 = True
2021-11-21 17:44:35 +08:00
try:
2022-01-19 10:46:20 +08:00
with open(fileName, 'w', encoding='utf-8') as f:
json.dump(rys.RyStruct, f, sort_keys=True, indent=4, separators=(', ', ': '), ensure_ascii=False)
tkinter.messagebox.showinfo(READABLETEXT[33], READABLETEXT[131].format(fileName))
error1 = False
except FileNotFoundError:
tkinter.messagebox.showerror(READABLETEXT[39], READABLETEXT[132].format(fileName, str(rys.RyStruct)))
2021-11-22 13:13:43 +08:00
rys.closeLevel()
2022-01-19 10:46:20 +08:00
finally:
if error1 is True:
tkinter.messagebox.showerror(READABLETEXT[39], READABLETEXT[132].format(fileName, str(rys.RyStruct)))
rys.closeLevel()
2021-11-21 17:44:35 +08:00
def world2BDX():
2022-01-19 10:46:20 +08:00
tkinter.messagebox.showerror(READABLETEXT[0], READABLETEXT[133])
2021-11-21 17:44:35 +08:00
2022-01-19 10:46:20 +08:00
# 使用邮件反馈bug
2021-11-21 00:59:15 +08:00
def sendBugReport():
2021-11-24 12:52:08 +08:00
from msctspt.bugReporter import report
2022-01-19 10:46:20 +08:00
name = tkinter.simpledialog.askstring(title=READABLETEXT[40], prompt=READABLETEXT[134])
contact = tkinter.simpledialog.askstring(title=READABLETEXT[40], prompt=READABLETEXT[135])
describetion = tkinter.simpledialog.askstring(title=READABLETEXT[40], prompt=READABLETEXT[136])
report(name, contact, describetion).emailReport()
del name, contact, describetion
2021-11-21 00:59:15 +08:00
def ClearLog():
2022-01-15 00:40:17 +08:00
global clearLog
clearLog = not clearLog
2021-11-21 00:59:15 +08:00
if clearLog:
2022-01-19 10:46:20 +08:00
tkinter.messagebox.showinfo(READABLETEXT[33], READABLETEXT[137])
2021-11-21 00:59:15 +08:00
else:
2022-01-19 10:46:20 +08:00
tkinter.messagebox.showinfo(READABLETEXT[33], READABLETEXT[138])
2021-11-21 00:59:15 +08:00
2022-01-01 20:19:41 +08:00
print('生成部分及其余命令加载完成!')
2021-11-21 00:59:15 +08:00
2022-01-01 20:19:41 +08:00
print('完成!')
2021-11-21 00:59:15 +08:00
# 窗口部分
2022-01-01 20:19:41 +08:00
print('增加窗口元素...')
2021-11-21 00:59:15 +08:00
global root
2022-01-19 10:46:20 +08:00
root.title(READABLETEXT[41].format(VER[1] + VER[0]))
2022-01-01 20:19:41 +08:00
root.geometry('900x900') # 像素
2021-11-21 00:59:15 +08:00
print('完成!')
print('加载点击与页面更新命令...')
# 音轨菜单被点击
def MusicList_selected(event):
global NowMusic
NowMusic = ListMusicList.get(ListMusicList.curselection())
2022-01-19 10:46:20 +08:00
log('刷新音轨' + str(NowMusic))
2021-11-21 00:59:15 +08:00
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
# 音符菜单被点击
def NoteList_selected(event):
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
pass # 编辑音符操作
def CMDList_selected(event):
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
pass # 命令编辑操作
2022-01-19 10:46:20 +08:00
CMDList_selected("") # 保证函数使用
# !!!!!上面这行在写完这个函数之后记得删!!!!
2021-11-21 00:59:15 +08:00
print('菜单点击命令加载完成!')
# 刷新音轨部分
def RefreshMusic(Music=0):
2022-01-03 20:45:25 +08:00
LabelEntityName['text'] = READABLETEXT[42].format(dataset[0]['musics'][Music]['set']['EntityName'])
2022-01-19 10:46:20 +08:00
LabelScoreboardName['text'] = READABLETEXT[43].format(dataset[0]['musics'][Music]['set']['ScoreboardName'])
2022-01-03 20:45:25 +08:00
LabelInstrument['text'] = READABLETEXT[44].format(dataset[0]['musics'][Music]['set']['Instrument'])
LabelFileName['text'] = READABLETEXT[45].format(dataset[0]['musics'][Music]['set']['FileName'])
2021-11-21 00:59:15 +08:00
NoteList_var.set(()) # 为列表框设置新值
for i in dataset[0]['musics'][Music]['notes']:
ListNoteList.insert(tk.END, str(i))
# 刷新主要部分
def RefreshMain():
2022-01-03 20:45:25 +08:00
LabelPackName['text'] = READABLETEXT[46].format(str(dataset[0]['mainset']['PackName']))
LabelMusicTitle['text'] = READABLETEXT[47].format(str(dataset[0]['mainset']['MusicTitle']))
LabelIsRepeat['text'] = READABLETEXT[48].format(str(dataset[0]['mainset']['IsRepeat']))
LabelPlayerSelect['text'] = READABLETEXT[49].format(str(dataset[0]['mainset']['PlayerSelect']))
2021-11-21 00:59:15 +08:00
MusicList_var.set(()) # 为列表框设置新值
for i in range(len(dataset[0]['musics'])):
ListMusicList.insert(tk.END, i)
global NowMusic
NowMusic = 0
def RefreshCMDList(CMDList):
ListCMDList.delete(tk.END)
for i in CMDList:
ListCMDList.insert(tk.END, str(i))
print('页面刷新函数加载完成!')
def changePackName(event):
2022-01-15 00:40:17 +08:00
a = tkinter.simpledialog.askstring(title=READABLETEXT[50], prompt=READABLETEXT[139], initialvalue='Ryoun')
2022-01-19 10:46:20 +08:00
if a is None:
2021-11-21 21:32:46 +08:00
return
dataset[0]['mainset']['PackName'] = a
2022-01-19 10:46:20 +08:00
del a
2021-11-21 00:59:15 +08:00
RefreshMain()
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
def changeMusicTitle(event):
2022-01-15 00:40:17 +08:00
a = tkinter.simpledialog.askstring(title=READABLETEXT[50], prompt=READABLETEXT[140], initialvalue='Noname')
2022-01-19 10:46:20 +08:00
if a is None:
2021-11-21 21:32:46 +08:00
return
2022-01-19 10:46:20 +08:00
dataset[0]['mainset']['MusicTitle'] = a
2021-11-21 00:59:15 +08:00
RefreshMain()
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
def changeIsRepeat(event):
dataset[0]['mainset']['IsRepeat'] = not dataset[0]['mainset']['IsRepeat']
RefreshMain()
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
def changePlayerSelect(event):
2022-01-19 10:46:20 +08:00
dataset[0]['mainset']['PlayerSelect'] = tkinter.simpledialog.askstring(title=READABLETEXT[50],
prompt=READABLETEXT[141],
initialvalue='')
if dataset[0]['mainset']['PlayerSelect'] is None:
2021-11-21 00:59:15 +08:00
dataset[0]['mainset']['PlayerSelect'] = ''
RefreshMain()
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
def changeEntityName(event):
global NowMusic
2022-01-19 10:46:20 +08:00
a = tkinter.simpledialog.askstring(title=READABLETEXT[51], prompt=READABLETEXT[142],
initialvalue='musicSupport')
if a is None:
2021-11-21 21:32:46 +08:00
return
2022-01-19 10:46:20 +08:00
dataset[0]['musics'][NowMusic]['set']['EntityName'] = a
2021-11-21 00:59:15 +08:00
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
def changeScoreboardName(event):
global NowMusic
2022-01-19 10:46:20 +08:00
a = tkinter.simpledialog.askstring(title=READABLETEXT[51], prompt=READABLETEXT[143],
initialvalue='musicSupport')
if a is None:
2021-11-21 21:32:46 +08:00
return
2022-01-19 10:46:20 +08:00
dataset[0]['musics'][NowMusic]['set']['ScoreboardName'] = a
2021-11-21 00:59:15 +08:00
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
def changeInstrument(event):
from nmcsup.const import Instuments as inst
global NowMusic
2022-01-19 10:46:20 +08:00
while True: # 改正:(True)
instemp = tkinter.simpledialog.askstring(title=READABLETEXT[51], prompt=READABLETEXT[144],
initialvalue='note.harp')
if instemp not in inst.keys(): # 改正not instemp in inst.keys() not in 为固定写法
2022-01-15 00:40:17 +08:00
if tkinter.messagebox.askyesno(title=READABLETEXT[1], message=READABLETEXT[145]):
2021-11-21 00:59:15 +08:00
dataset[0]['musics'][NowMusic]['set']['Instrument'] = instemp
del instemp
break
else:
2022-01-03 20:45:25 +08:00
smsg = READABLETEXT[52]
2021-11-21 00:59:15 +08:00
for i, j in inst.items():
2022-01-19 10:46:20 +08:00
smsg += i + ' : ' + j + '\n'
2022-01-03 20:45:25 +08:00
tkinter.messagebox.showinfo(title=READABLETEXT[1], message=smsg)
2021-11-21 00:59:15 +08:00
del smsg
else:
dataset[0]['musics'][NowMusic]['set']['Instrument'] = instemp
del instemp
break
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
def changeFileName(event):
global NowMusic
2022-01-15 00:40:17 +08:00
a = tkinter.simpledialog.askstring(title=READABLETEXT[51], prompt=READABLETEXT[146], initialvalue='Music')
2022-01-19 10:46:20 +08:00
if a is None:
2021-11-21 21:32:46 +08:00
return
dataset[0]['musics'][NowMusic]['set']['FileName'] = a
2021-11-21 00:59:15 +08:00
RefreshMusic(NowMusic)
2022-01-19 10:46:20 +08:00
print(event) # 保证变量使用虽然我不清楚金羿这为啥不调用要写个event
2021-11-21 00:59:15 +08:00
print('标签点击命令加载完成!')
def ResetSetting():
global dataset
2022-01-19 10:46:20 +08:00
dataset[0]['mainset'] = {'PackName': 'Ryoun', 'MusicTitle': 'Noname', 'IsRepeat': False, 'PlayerSelect': ''}
2021-11-21 00:59:15 +08:00
RefreshMain()
def DelNowMusic():
global NowMusic
del dataset[0]['musics'][NowMusic]
NowMusic -= 1
RefreshMain()
RefreshMusic(NowMusic)
2022-01-01 20:19:41 +08:00
from nmcsup.vers import resetver
2021-11-21 00:59:15 +08:00
print('按钮点击命令加载完成!')
print('完成!')
print('加载菜单与页面...')
# 创建一个菜单
main_menu_bar = tk.Menu(root)
# 创建文件菜单
filemenu = tk.Menu(main_menu_bar, tearoff=0)
2022-01-03 20:45:25 +08:00
filemenu.add_command(label=READABLETEXT[53], command=openProject)
filemenu.add_command(label=READABLETEXT[54], command=openOldProject)
filemenu.add_command(label=READABLETEXT[55], command=SaveProject)
filemenu.add_command(label=READABLETEXT[56], command=SaveAsProject)
2021-11-21 00:59:15 +08:00
filemenu.add_separator() # 分隔符
2022-01-03 20:45:25 +08:00
filemenu.add_command(label=READABLETEXT[57], command=exitapp)
2021-11-21 00:59:15 +08:00
# 将子菜单加入到菜单条中
2022-01-03 20:45:25 +08:00
main_menu_bar.add_cascade(label=READABLETEXT[58], menu=filemenu)
2021-11-21 00:59:15 +08:00
# 创建编辑菜单
editmenu = tk.Menu(main_menu_bar, tearoff=0)
2022-01-03 20:45:25 +08:00
editmenu.add_command(label=READABLETEXT[59], command=FromMP3)
editmenu.add_command(label=READABLETEXT[60], command=FromMidi)
editmenu.add_command(label=READABLETEXT[61], command=FromForm)
editmenu.add_command(label=READABLETEXT[62], command=FromText)
2021-11-21 00:59:15 +08:00
# 将子菜单加入到菜单条中
2022-01-03 20:45:25 +08:00
main_menu_bar.add_cascade(label=READABLETEXT[63], menu=editmenu)
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 创建函数菜单
2021-11-21 00:59:15 +08:00
funcmenu = tk.Menu(main_menu_bar, tearoff=0)
2022-01-03 20:45:25 +08:00
funcmenu.add_command(label=READABLETEXT[64], command=MakeCMD)
funcmenu.add_command(label=READABLETEXT[65], command=MakeCMDdir)
funcmenu.add_command(label=READABLETEXT[66], command=MakePackFile)
2021-11-21 00:59:15 +08:00
# 将子菜单加入到菜单条中
2022-01-03 20:45:25 +08:00
main_menu_bar.add_cascade(label=READABLETEXT[67], menu=funcmenu)
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 创建世界菜单
2022-01-15 00:40:17 +08:00
worldmenu = tk.Menu(main_menu_bar, tearoff=0)
worldmenu.add_command(label=READABLETEXT[68], command=ToBlockWorldEpt)
worldmenu.add_command(label=READABLETEXT[69], command=ToBlockWorld)
2021-11-21 17:44:35 +08:00
worldmenu.add_separator()
2022-01-15 00:40:17 +08:00
worldmenu.add_command(label=READABLETEXT[70], command=ToCmdWorldEpt)
worldmenu.add_command(label=READABLETEXT[71], command=ToCmdWorld)
2021-11-21 17:44:35 +08:00
worldmenu.add_separator()
2022-01-15 00:40:17 +08:00
worldmenu.add_command(label=READABLETEXT[72], command=toRSworldEPT)
worldmenu.add_command(label=READABLETEXT[73], command=toRSworld)
2021-11-21 00:59:15 +08:00
# 将子菜单加入到菜单条中
2022-01-15 00:40:17 +08:00
main_menu_bar.add_cascade(label=READABLETEXT[74], menu=worldmenu)
2021-11-21 00:59:15 +08:00
2021-11-21 17:44:35 +08:00
# 创建其他功能菜单
otherMenu = tk.Menu(main_menu_bar, tearoff=0)
2022-01-03 20:45:25 +08:00
otherMenu.add_command(label=READABLETEXT[75], command=MakeFuncPlayer)
2022-01-15 00:40:17 +08:00
otherMenu.add_separator()
2022-01-03 20:45:25 +08:00
otherMenu.add_command(label=READABLETEXT[76], command=toScbBDXfile)
otherMenu.add_command(label=READABLETEXT[77], command=world2BDX)
otherMenu.add_command(label=READABLETEXT[78], command=world2RyStruct)
2022-01-15 00:40:17 +08:00
otherMenu.add_separator()
otherMenu.add_command(label=READABLETEXT[79], command=func2World)
otherMenu.add_command(label=READABLETEXT[80], command=bigFunc2World)
2021-11-21 00:59:15 +08:00
2022-01-15 00:40:17 +08:00
main_menu_bar.add_cascade(label=READABLETEXT[81], menu=otherMenu)
2021-11-21 17:46:38 +08:00
2021-11-21 17:44:35 +08:00
# 创建实验功能菜单
2021-11-21 00:59:15 +08:00
trymenu = tk.Menu(main_menu_bar, tearoff=0)
2022-01-03 20:45:25 +08:00
trymenu.add_command(label=READABLETEXT[82], command=ShowCMD)
trymenu.add_command(label=READABLETEXT[83], command=wsPlay)
2021-11-21 00:59:15 +08:00
# 将子菜单加入到菜单条中
2022-01-03 20:45:25 +08:00
main_menu_bar.add_cascade(label=READABLETEXT[84], menu=trymenu)
2021-11-21 00:59:15 +08:00
# 创建帮助菜单
helpmenu = tk.Menu(main_menu_bar, tearoff=0)
2022-01-03 20:45:25 +08:00
helpmenu.add_command(label=READABLETEXT[85], command=ClearLog)
helpmenu.add_command(label=READABLETEXT[86], command=resetver)
2021-11-21 00:59:15 +08:00
helpmenu.add_separator() # 分隔符
2022-01-03 20:45:25 +08:00
helpmenu.add_command(label=READABLETEXT[87], command=apphelp)
helpmenu.add_command(label=READABLETEXT[88], command=appabout)
2022-01-19 10:46:20 +08:00
helpmenu.add_command(label=READABLETEXT[89], command=sendBugReport)
2021-11-21 00:59:15 +08:00
# 将子菜单加入到菜单条中
2022-01-03 20:45:25 +08:00
main_menu_bar.add_cascade(label=READABLETEXT[90], menu=helpmenu)
2021-11-21 00:59:15 +08:00
# 窗口内容
2022-01-19 10:46:20 +08:00
# 上半部分框
2021-11-21 00:59:15 +08:00
UpFrame = tk.Frame(root)
2022-01-19 10:46:20 +08:00
# 左边的框(音乐总设置)
2021-11-21 00:59:15 +08:00
UpLeftFrame = tk.Frame(UpFrame, bg='white')
2022-01-01 20:19:41 +08:00
# 大标题
2022-01-03 20:45:25 +08:00
tk.Label(UpLeftFrame, text=READABLETEXT[91], font=('', 20)).pack()
2022-01-01 20:19:41 +08:00
# 按钮式文本
2022-01-15 00:40:17 +08:00
LabelPackName = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[46], font=('', 15))
2022-01-19 10:46:20 +08:00
LabelMusicTitle = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[47], font=('', 15))
2022-01-15 00:40:17 +08:00
LabelIsRepeat = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[48], font=('', 15))
LabelPlayerSelect = tk.Label(UpLeftFrame, bg='white', text=READABLETEXT[49], font=('', 15))
2022-01-01 20:19:41 +08:00
# 绑定按钮
LabelPackName.bind('<Button-1>', changePackName)
LabelMusicTitle.bind('<Button-1>', changeMusicTitle)
LabelIsRepeat.bind('<Button-1>', changeIsRepeat)
LabelPlayerSelect.bind('<Button-1>', changePlayerSelect)
2022-01-01 20:19:41 +08:00
# 装入容器
2021-11-21 00:59:15 +08:00
LabelPackName.pack()
LabelMusicTitle.pack()
LabelIsRepeat.pack()
LabelPlayerSelect.pack()
# 按钮:重置项目设置
2022-01-03 20:45:25 +08:00
tk.Button(UpLeftFrame, text=READABLETEXT[96], command=ResetSetting).pack()
2022-01-19 10:46:20 +08:00
# 装入窗口
2022-01-01 20:19:41 +08:00
UpLeftFrame.pack(side='left')
2021-11-21 00:59:15 +08:00
2022-01-01 20:19:41 +08:00
# 中间的框容器
2021-11-21 00:59:15 +08:00
UpMidleFrame = tk.Frame(UpFrame, bg='blue')
2022-01-01 20:19:41 +08:00
# 列表
2021-11-21 00:59:15 +08:00
MusicList_var = tk.StringVar()
ListMusicList = tk.Listbox(UpMidleFrame, listvariable=MusicList_var)
ListMusicList.bind('<ButtonRelease-1>', MusicList_selected) # 设置选中响应函数
2022-01-01 20:19:41 +08:00
ListMusicList.pack(side='left')
# 滑块
2022-01-19 10:46:20 +08:00
tk.Scrollbar(UpMidleFrame, command=ListMusicList.yview).pack(side='left', fill='y')
# 装入窗口
2022-01-01 20:19:41 +08:00
UpMidleFrame.pack(side='left')
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 右边的框容器
2021-11-21 00:59:15 +08:00
UpRightFrame = tk.Frame(UpFrame, bg='white')
2022-01-01 20:19:41 +08:00
# 大标题
2022-01-03 20:45:25 +08:00
tk.Label(UpRightFrame, text=READABLETEXT[97], font=('', 20)).pack()
2022-01-01 20:19:41 +08:00
# 按钮式文本
2022-01-19 10:46:20 +08:00
LabelEntityName = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[42], font=('', 15))
2022-01-15 00:40:17 +08:00
LabelScoreboardName = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[43], font=('', 15))
2022-01-19 10:46:20 +08:00
LabelInstrument = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[44], font=('', 15))
LabelFileName = tk.Label(UpRightFrame, bg='white', text=READABLETEXT[45], font=('', 15))
2022-01-01 20:19:41 +08:00
# 绑定按钮
LabelEntityName.bind('<Button-1>', changeEntityName)
LabelScoreboardName.bind('<Button-1>', changeScoreboardName)
LabelInstrument.bind('<Button-1>', changeInstrument)
LabelFileName.bind('<Button-1>', changeFileName)
2022-01-01 20:19:41 +08:00
# 装入框容器
2021-11-21 00:59:15 +08:00
LabelEntityName.pack()
LabelScoreboardName.pack()
LabelInstrument.pack()
LabelFileName.pack()
# 按钮:删除选中音轨
2022-01-03 20:45:25 +08:00
tk.Button(UpRightFrame, text=READABLETEXT[102], command=DelNowMusic).pack()
2022-01-19 10:46:20 +08:00
# 装入窗口
2022-01-01 20:19:41 +08:00
UpRightFrame.pack(side='left')
2021-11-21 00:59:15 +08:00
2022-01-19 10:46:20 +08:00
# 上半部分框容器装入窗口
2021-11-21 00:59:15 +08:00
UpFrame.pack()
2022-01-01 20:19:41 +08:00
# 下半部分框容器
2021-11-21 00:59:15 +08:00
DownFrame = tk.Frame(root, bg='blue')
2022-01-19 10:46:20 +08:00
# 经典名言语录
import random
2022-01-19 10:46:20 +08:00
texts = open('./resources/myWords.txt', 'r', encoding='utf-8').readlines()
tk.Label(DownFrame, text=texts[random.randint(0, len(texts) - 1)].replace('\n', '').replace('\\n', '\n'),
fg='white', bg='black', font=('DengXian Light', 20)).pack(fill='x')
del texts
2021-11-21 00:59:15 +08:00
# 音符列表菜单
NoteList_var = tk.StringVar()
ListNoteList = tk.Listbox(DownFrame, listvariable=NoteList_var, width=40, height=30)
ListNoteList.bind('<ButtonRelease-1>', NoteList_selected) # 设置选中响应函数
2022-01-01 20:19:41 +08:00
ListNoteList.pack(side='left')
# 音符列表滑块
2022-01-19 10:46:20 +08:00
tk.Scrollbar(DownFrame, command=ListNoteList.yview).pack(side='left', fill='y')
2021-11-21 00:59:15 +08:00
# 指令列表菜单
2022-01-19 10:46:20 +08:00
ListCMDList = tk.Text(DownFrame, height=37, width=40)
2022-01-01 20:19:41 +08:00
ListCMDList.pack(side='left')
# 指令列表滑块
2022-01-19 10:46:20 +08:00
tk.Scrollbar(DownFrame, command=ListCMDList.yview).pack(fill='y', side='left')
2021-11-21 00:59:15 +08:00
2022-01-01 20:19:41 +08:00
# 下半部分容器载入窗口
2021-11-21 00:59:15 +08:00
DownFrame.pack()
RefreshMain()
# 将菜单添加到主窗口中
root.config(menu=main_menu_bar)
print('完成!')
log('启动root.mainloop窗口')
2021-11-21 00:59:15 +08:00
2021-11-21 19:22:38 +08:00
if len(sys.argv) != 1:
2022-01-19 10:46:20 +08:00
log('初始化打开音·创项目' + sys.argv[1])
2021-11-21 19:22:38 +08:00
global is_save
2022-01-19 10:46:20 +08:00
global dataset
2021-11-21 19:22:38 +08:00
is_save = True
2022-01-19 10:46:20 +08:00
error = True
2021-11-21 19:22:38 +08:00
try:
with open(sys.argv[1], 'r', encoding='UTF-8') as c:
dataset[0] = json.load(c)
2022-01-19 10:46:20 +08:00
error = False
except OSError:
2022-01-03 20:45:25 +08:00
print(READABLETEXT[8].format(sys.argv[1]))
2022-01-19 10:46:20 +08:00
log('无法打开' + sys.argv[1])
2021-11-21 19:22:38 +08:00
return
2022-01-19 10:46:20 +08:00
finally:
if error is True:
print(READABLETEXT[8].format(sys.argv[1]))
log('无法打开' + sys.argv[1])
return
2021-11-21 19:22:38 +08:00
global is_new_file
global ProjectName
is_new_file = False
ProjectName = sys.argv[1]
global NowMusic
RefreshMain()
RefreshMusic(NowMusic)
2021-11-21 00:59:15 +08:00
# 进入窗口消息循环
root.mainloop()
log('退出')
2021-11-24 13:46:45 +08:00
del filemenu, editmenu, helpmenu, otherMenu
2021-11-21 00:59:15 +08:00
exitapp()
if __name__ == '__main__':
2022-01-15 00:40:17 +08:00
__main__()