mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2024-11-11 01:27:35 +08:00
新增一些可读性优化文本
This commit is contained in:
parent
60c85c663e
commit
ae2c9de9df
94
Cmd_Msct.py
94
Cmd_Msct.py
@ -12,8 +12,6 @@
|
|||||||
# 代码写的并非十分的漂亮,还请大佬多多包涵;本软件源代码依照Apache软件协议公开
|
# 代码写的并非十分的漂亮,还请大佬多多包涵;本软件源代码依照Apache软件协议公开
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -28,16 +26,9 @@ __version__ = version.version[1]+version.version[0]
|
|||||||
__author__ = 'W-YI (金羿)'
|
__author__ = 'W-YI (金羿)'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log("系统工作————————加载变量及函数")
|
log("系统工作————————加载变量及函数")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print("更新执行位置...")
|
print("更新执行位置...")
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
@ -45,22 +36,18 @@ if sys.platform == 'win32':
|
|||||||
log("更新执行位置,当前文件位置"+__file__)
|
log("更新执行位置,当前文件位置"+__file__)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.chdir(__file__[:len(__file__)-__file__[len(__file__)::-1].index('/')])
|
os.chdir(__file__[:len(__file__) -
|
||||||
|
__file__[len(__file__)::-1].index('/')])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
log("其他平台:"+sys.platform+"更新执行位置,当前文件位置"+__file__)
|
log("其他平台:"+sys.platform+"更新执行位置,当前文件位置"+__file__)
|
||||||
print('完成!')
|
print('完成!')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __main__():
|
def __main__():
|
||||||
|
|
||||||
print('建立变量,存入内存,载入字典常量函数')
|
print('建立变量,存入内存,载入字典常量函数')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 主体部分
|
# 主体部分
|
||||||
|
|
||||||
# 支持多文件同时操作
|
# 支持多文件同时操作
|
||||||
@ -126,7 +113,6 @@ def __main__():
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
global is_new_file
|
global is_new_file
|
||||||
global is_save
|
global is_save
|
||||||
global ProjectName
|
global ProjectName
|
||||||
@ -137,8 +123,6 @@ def __main__():
|
|||||||
ProjectName = ''
|
ProjectName = ''
|
||||||
NowMusic = 0
|
NowMusic = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def DMM(): # 反回字典用于编辑
|
def DMM(): # 反回字典用于编辑
|
||||||
datasetmodelpart = {
|
datasetmodelpart = {
|
||||||
'set': {
|
'set': {
|
||||||
@ -151,17 +135,14 @@ def __main__():
|
|||||||
}
|
}
|
||||||
return datasetmodelpart
|
return datasetmodelpart
|
||||||
|
|
||||||
|
|
||||||
print("完成")
|
print("完成")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 菜单命令
|
# 菜单命令
|
||||||
print('加载菜单命令...');
|
print('加载菜单命令...')
|
||||||
|
|
||||||
def exitapp(cmd):
|
def exitapp(cmd):
|
||||||
|
|
||||||
log("程序正常退出",False)
|
log("程序正常退出", False)
|
||||||
global is_save
|
global is_save
|
||||||
if is_save == False:
|
if is_save == False:
|
||||||
if '/s' in cmd:
|
if '/s' in cmd:
|
||||||
@ -170,15 +151,13 @@ def __main__():
|
|||||||
print("您尚未保存,请使用 /s 开关保存并退出")
|
print("您尚未保存,请使用 /s 开关保存并退出")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
global dataset
|
global dataset
|
||||||
del dataset
|
del dataset
|
||||||
except:
|
except:
|
||||||
pass;
|
pass
|
||||||
|
|
||||||
|
if '/c' in cmd:
|
||||||
if '/c' in cmd :
|
|
||||||
print("清除log(此句不载入日志)")
|
print("清除log(此句不载入日志)")
|
||||||
try:
|
try:
|
||||||
if os.path.exists("./log/"):
|
if os.path.exists("./log/"):
|
||||||
@ -190,45 +169,35 @@ def __main__():
|
|||||||
except:
|
except:
|
||||||
print("无法清除日志及临时文件")
|
print("无法清除日志及临时文件")
|
||||||
|
|
||||||
|
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
print('退出函数加载完成!')
|
print('退出函数加载完成!')
|
||||||
|
|
||||||
|
|
||||||
print("载入文件读取函数")
|
print("载入文件读取函数")
|
||||||
|
|
||||||
def ReadFile(fn:str) -> list:
|
def ReadFile(fn: str) -> list:
|
||||||
from nmcsup.nmcreader import ReadFile as fileRead
|
from nmcsup.nmcreader import ReadFile as fileRead
|
||||||
k = fileRead(fn)
|
k = fileRead(fn)
|
||||||
if k == False :
|
if k == False:
|
||||||
log("找不到"+fn)
|
log("找不到"+fn)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
return k
|
return k
|
||||||
|
|
||||||
|
def ReadMidi(midfile: str) -> str:
|
||||||
def ReadMidi(midfile:str) -> str:
|
|
||||||
from nmcsup.nmcreader import ReadMidi as midiRead
|
from nmcsup.nmcreader import ReadMidi as midiRead
|
||||||
k = midiRead(midfile)
|
k = midiRead(midfile)
|
||||||
if k == False :
|
if k == False:
|
||||||
log("找不到"+midfile)
|
log("找不到"+midfile)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
return k
|
return k
|
||||||
|
|
||||||
|
|
||||||
print('完成!')
|
print('完成!')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print("载入命令函数")
|
print("载入命令函数")
|
||||||
|
|
||||||
|
def saveProject(cmd: list):
|
||||||
def saveProject(cmd:list):
|
|
||||||
global is_new_file
|
global is_new_file
|
||||||
if '/a' in cmd:
|
if '/a' in cmd:
|
||||||
log("另存项目")
|
log("另存项目")
|
||||||
@ -245,17 +214,13 @@ def __main__():
|
|||||||
global is_save
|
global is_save
|
||||||
is_save = True
|
is_save = True
|
||||||
|
|
||||||
|
|
||||||
print('保存项目函数加载完成!')
|
print('保存项目函数加载完成!')
|
||||||
|
|
||||||
|
def loadMusic(cmd: list):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def loadMusic(cmd:list):
|
|
||||||
if '/mid' in cmd:
|
if '/mid' in cmd:
|
||||||
th = NewThread(ReadMidi, (cmd[cmd.index('/mid')+1],))
|
th = NewThread(ReadMidi, (cmd[cmd.index('/mid')+1],))
|
||||||
th.start()
|
th.start()
|
||||||
|
|
||||||
def midiSPT(th):
|
def midiSPT(th):
|
||||||
for i in th.getResult():
|
for i in th.getResult():
|
||||||
datas = DMM()
|
datas = DMM()
|
||||||
@ -269,6 +234,7 @@ def __main__():
|
|||||||
elif '/txt' in cmd:
|
elif '/txt' in cmd:
|
||||||
th = NewThread(ReadFile, (cmd[cmd.index('/txt')+1],))
|
th = NewThread(ReadFile, (cmd[cmd.index('/txt')+1],))
|
||||||
th.start()
|
th.start()
|
||||||
|
|
||||||
def midiSPT(th):
|
def midiSPT(th):
|
||||||
for i in th.getResult():
|
for i in th.getResult():
|
||||||
datas = DMM()
|
datas = DMM()
|
||||||
@ -290,10 +256,9 @@ def __main__():
|
|||||||
global is_save
|
global is_save
|
||||||
is_save = False
|
is_save = False
|
||||||
|
|
||||||
|
|
||||||
print('音轨载入函数加载完成!')
|
print('音轨载入函数加载完成!')
|
||||||
|
|
||||||
def funBuild(cmd:list):
|
def funBuild(cmd: list):
|
||||||
if '/file' in cmd:
|
if '/file' in cmd:
|
||||||
from msctspt.funcOpera import makeFuncFiles
|
from msctspt.funcOpera import makeFuncFiles
|
||||||
makepath = cmd[cmd.index('/file')+1]
|
makepath = cmd[cmd.index('/file')+1]
|
||||||
@ -316,17 +281,18 @@ def __main__():
|
|||||||
if not os.path.exists('./temp/'):
|
if not os.path.exists('./temp/'):
|
||||||
os.makedirs('./temp/')
|
os.makedirs('./temp/')
|
||||||
makeFunDir(dataset[0], './temp/')
|
makeFunDir(dataset[0], './temp/')
|
||||||
shutil.move('./temp/'+dataset[0]['mainset']['PackName'] +"Pack/behavior_packs/"+dataset[0]['mainset']['PackName']+"/functions",'./')
|
shutil.move('./temp/'+dataset[0]['mainset']['PackName'] +
|
||||||
shutil.move('./temp/'+dataset[0]['mainset']['PackName'] +"Pack/behavior_packs/"+dataset[0]['mainset']['PackName']+"/manifest.json",'./')
|
"Pack/behavior_packs/"+dataset[0]['mainset']['PackName']+"/functions", './')
|
||||||
|
shutil.move('./temp/'+dataset[0]['mainset']['PackName'] + "Pack/behavior_packs/" +
|
||||||
|
dataset[0]['mainset']['PackName']+"/manifest.json", './')
|
||||||
with zipfile.ZipFile(makepath+dataset[0]['mainset']['PackName']+'.mcpack', "w") as zipobj:
|
with zipfile.ZipFile(makepath+dataset[0]['mainset']['PackName']+'.mcpack', "w") as zipobj:
|
||||||
for i in os.listdir('./functions/'):
|
for i in os.listdir('./functions/'):
|
||||||
zipobj.write('./functions/'+i)
|
zipobj.write('./functions/'+i)
|
||||||
zipobj.write('./manifest.json')
|
zipobj.write('./manifest.json')
|
||||||
shutil.move('./functions','./temp/')
|
shutil.move('./functions', './temp/')
|
||||||
shutil.move('./manifest.json','./temp/')
|
shutil.move('./manifest.json', './temp/')
|
||||||
shutil.rmtree("./temp/")
|
shutil.rmtree("./temp/")
|
||||||
|
|
||||||
|
|
||||||
print("函数建立函数加载完成")
|
print("函数建立函数加载完成")
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
@ -334,13 +300,10 @@ def __main__():
|
|||||||
else:
|
else:
|
||||||
os.system("clear")
|
os.system("clear")
|
||||||
|
|
||||||
|
if sys.platform in ('win32', 'linux'):
|
||||||
if sys.platform in ('win32','linux'):
|
|
||||||
print("您当前的运行环境为标准桌面,您可以打开 Musicreater.py 运行窗口模式的 音·创")
|
print("您当前的运行环境为标准桌面,您可以打开 Musicreater.py 运行窗口模式的 音·创")
|
||||||
print("您也可以输入 win 指令在不退出命令行模式的同时打开窗口模式\n")
|
print("您也可以输入 win 指令在不退出命令行模式的同时打开窗口模式\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(__author__+" 音·创 —— 当前核心版本 "+__version__+'\n')
|
print(__author__+" 音·创 —— 当前核心版本 "+__version__+'\n')
|
||||||
|
|
||||||
nowWorkPath = os.path.split(os.path.realpath(__file__))[0]
|
nowWorkPath = os.path.split(os.path.realpath(__file__))[0]
|
||||||
@ -360,9 +323,11 @@ def __main__():
|
|||||||
def run(cmd):
|
def run(cmd):
|
||||||
os.system(cmd)
|
os.system(cmd)
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
NewThread(run,("python "+os.path.split(os.path.realpath(__file__))[0]+"/Musicreater.py",)).start()
|
NewThread(run, ("python "+os.path.split(os.path.realpath(__file__))
|
||||||
|
[0]+"/Musicreater.py",)).start()
|
||||||
else:
|
else:
|
||||||
NewThread(run,("python3 "+os.path.split(os.path.realpath(__file__))[0]+"/Musicreater.py",)).start()
|
NewThread(run, ("python3 "+os.path.split(os.path.realpath(__file__))
|
||||||
|
[0]+"/Musicreater.py",)).start()
|
||||||
elif cmd[0] == 'chdir':
|
elif cmd[0] == 'chdir':
|
||||||
nowWorkPath = os.path.realpath(cmd[1])
|
nowWorkPath = os.path.realpath(cmd[1])
|
||||||
os.chdir(nowWorkPath)
|
os.chdir(nowWorkPath)
|
||||||
@ -372,12 +337,5 @@ def __main__():
|
|||||||
os.system(strcmd)
|
os.system(strcmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
__main__()
|
__main__()
|
@ -30,6 +30,14 @@ Copyright © W-YI 2021
|
|||||||
|
|
||||||
|
|
||||||
新更新日志
|
新更新日志
|
||||||
|
Beta 0.0.4.3
|
||||||
|
2021 11 3~2021 12 26
|
||||||
|
1.不断改进包以及代码可读性
|
||||||
|
2.修正部分源码错误
|
||||||
|
3.修正部分格式错误
|
||||||
|
4.加强对Linux系统的支持
|
||||||
|
5.新增命令行模式
|
||||||
|
6.代码中新增大量注释
|
||||||
|
|
||||||
|
|
||||||
Beta 0.0.4 ~ Beta 0.0.4.2
|
Beta 0.0.4 ~ Beta 0.0.4.2
|
||||||
|
22
命令行操作.md
22
命令行操作.md
@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
## 命令列表
|
## 命令列表
|
||||||
|
|
||||||
### exit
|
### exit \[/s\] \[/c\]
|
||||||
|
|
||||||
- ```/s``` 保存并退出
|
- ```/s``` 保存并退出
|
||||||
- ```/c``` 清除日志
|
- ```/c``` 清除日志
|
||||||
|
|
||||||
### save
|
### save \[/a \<fileName\>\]
|
||||||
|
|
||||||
- ```/a <文件名>``` 指定文件名
|
- ```/a <文件名>``` 指定文件名保存
|
||||||
|
|
||||||
### load
|
### load \[/\<loadMethod: input|txt|mid\> \<text|fileName\>\]
|
||||||
|
|
||||||
- ```/input <文本>``` 输入音符
|
- ```/input <文本>``` 输入音符
|
||||||
- ```/txt <文件名>``` 从文本载入音符
|
- ```/txt <文件名>``` 从文本载入音符
|
||||||
@ -21,14 +21,14 @@
|
|||||||
|
|
||||||
### win
|
### win
|
||||||
|
|
||||||
开启窗口(仅支持的系统下有效)
|
- 开启窗口模式的 音·创(仅支持的系统下有效)
|
||||||
|
|
||||||
### chdir <位置>
|
### chdir \<direction\>
|
||||||
|
|
||||||
切换当前工作目录
|
- 切换当前工作目录
|
||||||
|
|
||||||
### build
|
### build \[/\<buildMethod: file|directory|mcpack\> \<direction\>\]
|
||||||
|
|
||||||
- ```/file``` 在当前目录生成函数文件(散装)
|
- ```/file <目录位置>``` 在指定目录生成函数文件(散装)
|
||||||
- ```/directory <文件名>``` 在当前目录生成一个附加包目录
|
- ```/directory <目录位置>``` 在指定目录生成一个附加包目录
|
||||||
- ```/mcpack <文件名>``` 在当前目录生成一个.mcpack附加包
|
- ```/mcpack <目录位置>``` 在指定目录生成一个.mcpack附加包
|
Loading…
Reference in New Issue
Block a user