mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2024-11-14 11:27:42 +08:00
代码正在被重构,请不要更新功能,如果要更新,请推送至OldUI分支
This commit is contained in:
parent
99509be48c
commit
c4dd7b1ce8
69
Musicreater.New.py
Normal file
69
Musicreater.New.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
# W-YI 金羿
|
||||||
|
# QQ 2647547478
|
||||||
|
# 音·创 开发交流群 861684859
|
||||||
|
# Email EillesWan2006@163.com W-YI_DoctorYI@outlook.com EillesWan@outlook.com
|
||||||
|
# 版权所有 Team-Ryoun 金羿
|
||||||
|
# 若需转载或借鉴 请附作者
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Copyright 2022 Eilles Wan (金羿)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the 'License');
|
||||||
|
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
|
||||||
|
distributed under the License is distributed on an 'AS IS' BASIS,
|
||||||
|
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.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 代码写的并非十分的漂亮,还请大佬多多包涵;本软件源代码依照Apache软件协议公开
|
||||||
|
|
||||||
|
|
||||||
|
# 下面为正文
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from msctspt.bugReporter import version
|
||||||
|
|
||||||
|
__ver__ = f'{version.version[1]} {version.version[0]}'
|
||||||
|
__author__ = '金羿Eilles'
|
||||||
|
|
||||||
|
|
||||||
|
import tkinter
|
||||||
|
import tkinter.simpledialog as sdialog
|
||||||
|
import tkinter.filedialog as fdialog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from msctLib.settings import settings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def __main__():
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
__main__()
|
@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# ! python3
|
|
||||||
|
|
||||||
|
|
||||||
# W-YI 金羿
|
# W-YI 金羿
|
||||||
@ -61,7 +60,7 @@ from msctspt.threadOpera import NewThread
|
|||||||
from nmcsup.vers import VER
|
from nmcsup.vers import VER
|
||||||
|
|
||||||
__version__ = VER[1] + VER[0]
|
__version__ = VER[1] + VER[0]
|
||||||
__author__ = 'W-YI (金羿)'
|
__author__ = '金羿Eilles & 诸葛亮与八卦阵bgArray'
|
||||||
dire = ""
|
dire = ""
|
||||||
begp = ""
|
begp = ""
|
||||||
endp = ""
|
endp = ""
|
||||||
|
@ -89,7 +89,7 @@ Musicreater - > function (package) - > the following four new functions
|
|||||||
3. Thank *Charlie_Ping “查理平”* for bdx convert funtion.
|
3. Thank *Charlie_Ping “查理平”* for bdx convert funtion.
|
||||||
4. Thank *CMA_2401PT* for BDXWorkShop as the .bdx structure's operation guide.
|
4. Thank *CMA_2401PT* for BDXWorkShop as the .bdx structure's operation guide.
|
||||||
5. Thank *Miracle Plume “神羽”* \<QQshenyu40403\> for the Miracle Plume Bedrock Edition Audio Resource Pack
|
5. Thank *Miracle Plume “神羽”* \<QQshenyu40403\> for the Miracle Plume Bedrock Edition Audio Resource Pack
|
||||||
6. Thank *Arthur Morgan* for his/her biggest support for Musicreater
|
6. Thank *Arthur Morgan* for his/her biggest support for the debugging of Musicreater
|
||||||
7. Thanks for a lot of groupmates who support me and help me to test the program.
|
7. Thanks for a lot of groupmates who support me and help me to test the program.
|
||||||
8. If you have give me some help but u haven't been in the list, please contact me.
|
8. If you have give me some help but u haven't been in the list, please contact me.
|
||||||
|
|
||||||
|
0
msctLib/__init__.py
Normal file
0
msctLib/__init__.py
Normal file
134
msctLib/data.py
Normal file
134
msctLib/data.py
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
import pickle
|
||||||
|
import json
|
||||||
|
from typing import Any, Iterable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class pickleIO:
|
||||||
|
|
||||||
|
def __init__(self,fileName:str,data: Any = None) -> None:
|
||||||
|
'''简单的pickle操作功能'''
|
||||||
|
self.file = fileName
|
||||||
|
if data:
|
||||||
|
self._data = data
|
||||||
|
else:
|
||||||
|
with open (self.file, 'rb') as f:
|
||||||
|
self._data = pickle.load(f)
|
||||||
|
|
||||||
|
def __call__(self, *args: Any, **kwds: Any) -> Any:
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
def write(self):
|
||||||
|
'''将数据写入pickle'''
|
||||||
|
with open (self.file, 'wb') as f:
|
||||||
|
pickle.dump(self._data, f)
|
||||||
|
|
||||||
|
|
||||||
|
def load(self) -> Any:
|
||||||
|
'''从文件读取数据'''
|
||||||
|
with open (self.file, 'rb') as f:
|
||||||
|
self._data = pickle.load(f)
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def data(self):
|
||||||
|
'''返回数据值'''
|
||||||
|
if self._data is None:
|
||||||
|
raise ValueError('无可用值载入或值为None')
|
||||||
|
else:
|
||||||
|
return self._data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class jsonIO:
|
||||||
|
|
||||||
|
def __init__(self,fileName:str,data: Any = None) -> None:
|
||||||
|
'''简单的json操作功能'''
|
||||||
|
self.file = fileName
|
||||||
|
if data:
|
||||||
|
self._data = data
|
||||||
|
else:
|
||||||
|
with open (self.file, 'r', encoding='utf-8') as f:
|
||||||
|
self._data = json.load(f)
|
||||||
|
|
||||||
|
def __call__(self, *args: Any, **kwds: Any) -> Any:
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
def write(self):
|
||||||
|
'''将数据写入json'''
|
||||||
|
with open (self.file, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(self._data, f)
|
||||||
|
|
||||||
|
|
||||||
|
def load(self) -> Any:
|
||||||
|
'''从文件读取数据'''
|
||||||
|
with open (self.file, 'r', encoding='utf-8') as f:
|
||||||
|
self._data = json.load(f)
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def data(self):
|
||||||
|
'''返回数据值'''
|
||||||
|
return self._data
|
||||||
|
|
||||||
|
|
||||||
|
class uniteIO:
|
||||||
|
|
||||||
|
def __init__(self,fileName:str,fileType,data: Any = None) -> None:
|
||||||
|
'''简单的文件数据IO操作功能'''
|
||||||
|
self.filename = fileName
|
||||||
|
if not fileType is None:
|
||||||
|
self._type = fileType
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
with open (self.filename, 'r', encoding='utf-8') as f:
|
||||||
|
self._type = json
|
||||||
|
except:
|
||||||
|
with open (self.file, 'rb') as f:
|
||||||
|
self._type = pickle
|
||||||
|
|
||||||
|
if self._type == json:
|
||||||
|
with open (self.filename, 'r', encoding='utf-8') as f:
|
||||||
|
self._rfile = f
|
||||||
|
with open (self.filename, 'w', encoding='utf-8') as f:
|
||||||
|
self._wfile = f
|
||||||
|
elif self._type == pickle:
|
||||||
|
with open (self.file, 'rb') as f:
|
||||||
|
self._rfile = f
|
||||||
|
with open (self.file, 'wb') as f:
|
||||||
|
self._wfile = f
|
||||||
|
|
||||||
|
if not data is None:
|
||||||
|
self._data = data
|
||||||
|
else:
|
||||||
|
self._data = self._type.load(self._rfile)
|
||||||
|
|
||||||
|
|
||||||
|
def __call__(self, *args: Any, **kwds: Any) -> Any:
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
def write(self):
|
||||||
|
'''将数据写入文件'''
|
||||||
|
self._type.dump(self._data, self._wfile)
|
||||||
|
|
||||||
|
|
||||||
|
def load(self) -> Any:
|
||||||
|
'''从文件读取数据'''
|
||||||
|
self._data = self._type.load(self._rfile)
|
||||||
|
return self.data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def data(self):
|
||||||
|
'''返回数据值'''
|
||||||
|
return self._data
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
if argv[1]:
|
||||||
|
input(pickle(argv[1]).data)
|
Binary file not shown.
@ -222,23 +222,17 @@ def note2bdx(filePath: str, dire: list, Notes: list, ScoreboardName: str, Instru
|
|||||||
height: 生成结构的最高高度
|
height: 生成结构的最高高度
|
||||||
:return 返回一个BdxConverter类,同时在指定位置生成.bdx文件"""
|
:return 返回一个BdxConverter类,同时在指定位置生成.bdx文件"""
|
||||||
|
|
||||||
# from msctspt.transfer import formCmdBlock
|
|
||||||
from nmcsup.trans import Note2Cmd
|
from nmcsup.trans import Note2Cmd
|
||||||
from msctspt.bdxOpera_CP import BdxConverter
|
from msctspt.bdxOpera_CP import BdxConverter
|
||||||
cmd = Note2Cmd(Notes, ScoreboardName, Instrument, PlayerSelect, isProsess)
|
cmd = Note2Cmd(Notes, ScoreboardName, Instrument, PlayerSelect, isProsess)
|
||||||
cdl = []
|
cdl = []
|
||||||
# 此处是处理一下,防止有注释
|
|
||||||
for i in cmd:
|
for i in cmd:
|
||||||
# e = True
|
if '#' in i:
|
||||||
try:
|
|
||||||
if (i[:i.index('#')].replace(' ', '') != '\n') and (i[:i.index('#')].replace(' ', '') != ''):
|
if (i[:i.index('#')].replace(' ', '') != '\n') and (i[:i.index('#')].replace(' ', '') != ''):
|
||||||
cdl.append(i[:i.index('#')])
|
cdl.append(i[:i.index('#')])
|
||||||
# e = False
|
else:
|
||||||
except: # ValueError
|
|
||||||
cdl.append(i)
|
cdl.append(i)
|
||||||
# finally:
|
|
||||||
# if e is True:
|
|
||||||
# cdl.append(i)
|
|
||||||
i = 0
|
i = 0
|
||||||
down = False
|
down = False
|
||||||
blocks = [formCmdBlock(dire, cdl.pop(0), 1, 1)]
|
blocks = [formCmdBlock(dire, cdl.pop(0), 1, 1)]
|
||||||
@ -261,10 +255,7 @@ def note2bdx(filePath: str, dire: list, Notes: list, ScoreboardName: str, Instru
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def music2cmdBlocks(direction: Iterable, music: dict, isProsess: bool = False, height: int = 200,
|
||||||
|
|
||||||
|
|
||||||
def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool = False, height: int = 200,
|
|
||||||
isSquare: bool = False):
|
isSquare: bool = False):
|
||||||
"""使用方法同Note2Cmd
|
"""使用方法同Note2Cmd
|
||||||
:param 参数说明:
|
:param 参数说明:
|
||||||
@ -274,8 +265,7 @@ def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool =
|
|||||||
isProsess: 是否显示进度条(会很卡)
|
isProsess: 是否显示进度条(会很卡)
|
||||||
height: 生成结构的最高高度
|
height: 生成结构的最高高度
|
||||||
isSquare: 生成的结构是否需要遵循生成正方形原则
|
isSquare: 生成的结构是否需要遵循生成正方形原则
|
||||||
:return 返回一个BdxConverter类,同时在指定位置生成.bdx文件"""
|
:return 返回一个列表,其中包含了音乐生成的所有的指令方块数据"""
|
||||||
from msctspt.bdxOpera_CP import BdxConverter
|
|
||||||
from msctspt.threadOpera import NewThread
|
from msctspt.threadOpera import NewThread
|
||||||
|
|
||||||
allblocks = []
|
allblocks = []
|
||||||
@ -333,7 +323,32 @@ def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool =
|
|||||||
for th in threads:
|
for th in threads:
|
||||||
allblocks += th.getResult()
|
allblocks += th.getResult()
|
||||||
|
|
||||||
return BdxConverter(filePath, 'Build by Ryoun Musicreater', allblocks)
|
return allblocks
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool = False, height: int = 200,
|
||||||
|
isSquare: bool = False):
|
||||||
|
"""使用方法同Note2Cmd
|
||||||
|
:param 参数说明:
|
||||||
|
filePath: 生成.bdx文件的位置
|
||||||
|
dire: 指令方块在地图中生成的起始位置(相对位置)
|
||||||
|
music: 详见 Musicreater.py - dataset[0]
|
||||||
|
isProsess: 是否显示进度条(会很卡)
|
||||||
|
height: 生成结构的最高高度
|
||||||
|
isSquare: 生成的结构是否需要遵循生成正方形原则
|
||||||
|
:return 返回一个BdxConverter类,同时在指定位置生成.bdx文件"""
|
||||||
|
from msctspt.bdxOpera_CP import BdxConverter
|
||||||
|
return BdxConverter(filePath, 'Build by Ryoun Musicreater', music2cmdBlocks(direction,music,isProsess,height,isSquare)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def note2webs(Notes: list, Instrument: str, speed: float = 5.0, PlayerSelect: str = '', isProsess: bool = False):
|
def note2webs(Notes: list, Instrument: str, speed: float = 5.0, PlayerSelect: str = '', isProsess: bool = False):
|
||||||
|
0
options/__init__.py
Normal file
0
options/__init__.py
Normal file
@ -34,7 +34,7 @@
|
|||||||
上了战场就是英雄 ——长津湖
|
上了战场就是英雄 ——长津湖
|
||||||
冰与火 恨与爱 静与情
|
冰与火 恨与爱 静与情
|
||||||
有些枪必须开,有些可以不开 ——长津湖
|
有些枪必须开,有些可以不开 ——长津湖
|
||||||
夕阳西下,余辉将尽,夜幕降临,寒风凛冽 ——原神
|
夕阳西下,余辉将尽\n夜幕降临,寒风凛冽 ——原神
|
||||||
愿风擦拭你的双眼,让你看清真相 ——原神
|
愿风擦拭你的双眼,让你看清真相 ——原神
|
||||||
心愿之结晶 而何能之宝贵
|
心愿之结晶 而何能之宝贵
|
||||||
神明,正倾诉着他辉煌的过去……
|
神明,正倾诉着他辉煌的过去……
|
||||||
|
Loading…
Reference in New Issue
Block a user