慢慢改bug

This commit is contained in:
2022-02-02 15:09:11 +08:00
parent 073ae827ab
commit 99509be48c
13 changed files with 47 additions and 29 deletions

View File

@ -7,7 +7,7 @@ import brotli
class BdxConverter:
__header = "BD@"
__bin_header = b"BDX"
__generator_author = b"&Charlie_Ping"
__generator_author = b"&Musicreater"
keys = {
# x--, x++, addSmallX(-128~127), addX(-32768~32767), addBigX(-2147483648~2147483647)
@ -50,9 +50,7 @@ class BdxConverter:
@property
def create_and_upload_file(self):
"""
瞎用property 害怕
创建一个bdx文件
要close
:return: 一个文件对象
"""
_dir = os.path.dirname(self.file_path)
@ -73,7 +71,8 @@ class BdxConverter:
with open(self.file_path, "ab+") as f:
f.write(brotli.compress(_bytes))
f.close()
return
return open(self.file_path,'a+')
def upload_blocks(self):
"""
计算差值
@ -83,6 +82,8 @@ class BdxConverter:
:return:
"""
_types = b""
for block in self.blocks:
# print(f"当前方块:{block['block_name']}, 位置: {block['direction']}]")
diff = self.move_pointer(self.direction, block["direction"])
@ -94,6 +95,8 @@ class BdxConverter:
else:
_types += self.obtain_universal_block(block)
self.direction = block["direction"]
return _types
def move_pointer(self, direction: list, new_direction):

View File

@ -10,14 +10,14 @@ class NewThread(threading.Thread):
super(NewThread, self).__init__()
self.func = func
self.args = args
self.result = None
def run(self):
self.result = self.func(*self.args)
def getResult(self):
threading.Thread.join(self) # 等待线程执行完毕
try:
return self.result
except Exception:
return None
return self.result
#
# ————————————————

View File

@ -260,6 +260,10 @@ 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):
"""使用方法同Note2Cmd
@ -272,20 +276,22 @@ def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool =
isSquare: 生成的结构是否需要遵循生成正方形原则
:return 返回一个BdxConverter类同时在指定位置生成.bdx文件"""
from msctspt.bdxOpera_CP import BdxConverter
from msctspt.threadOpera import NewThread
blocks = []
allblocks = []
'''需要放置的方块'''
baseDire = direction
direction = list(direction)
for track in music['musics']:
def trackDealing(direction,track):
blocks = []
cmdList = classList_conversion_SinglePlayer(track['notes'], track['set']['ScoreboardName'],
music['mainset']['PlayerSelect'], isProsess)
if len(cmdList) == 0:
continue
return
elif cmdList is []:
continue
return
dire = direction
down = False
'''当前是否为向下的阶段?'''
@ -306,7 +312,6 @@ def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool =
for cmd in cmdList:
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
@ -317,9 +322,18 @@ def music2BDX(filePath: str, direction: Iterable, music: dict, isProsess: bool =
if (down is False and dire[1] == height + direction[1]) or (down and dire[1] == direction + 1):
down = not down
dire[0] += 1
return blocks
threads = []
for track in music['musics']:
threads.append(NewThread(trackDealing,(direction,track)))
threads[threads.__len__()-1].start()
direction[2] += 2
return BdxConverter(filePath, 'Build by Ryoun Musicreater', blocks)
for th in threads:
allblocks += th.getResult()
return BdxConverter(filePath, 'Build by Ryoun Musicreater', allblocks)
def note2webs(Notes: list, Instrument: str, speed: float = 5.0, PlayerSelect: str = '', isProsess: bool = False):