From b8906e42e849901807b0825fc77d8c213bc94a68 Mon Sep 17 00:00:00 2001 From: Ginsakura Date: Wed, 14 Aug 2024 21:51:33 +0800 Subject: [PATCH] =?UTF-8?q?1.2.7rc2=20=20=E7=8B=AC=E7=AB=8B=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=87=BD=E6=95=B0=20=20Release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dist.yml | 16 +++++----- How_to_use.zh.md | 8 ++--- Launcher.py | 51 +++++++++++++++++++++++++++++++ MainWindowOldStyle.py | 61 ++++++++++++++++++++------------------ MusyncSavDecode.py | 13 ++++++-- MusyncSavDecodeGUI.py | 38 ++++++------------------ Push.ps1 | 8 ++--- README.md | 9 ++++++ changelog.txt | 9 ++++++ 9 files changed, 136 insertions(+), 77 deletions(-) create mode 100644 Launcher.py diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index b678e61..7faa123 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -80,23 +80,23 @@ jobs: - name: Dist NoConsole ${{ env.Version }} Compress Version # if: ${{ env.NotSkip == 'true'}} run: | - pyinstaller --distpath ./NoCLI/ -D -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py -w --clean - Compress-Archive -LiteralPath ./NoCLI/MusyncSavDecodeGUI/ -DestinationPath ("./MusyncSavDecodeGUI_NoConsole_${{ env.Version }}.zip") + pyinstaller --distpath ./NoCLI/ -D -i ./musync_data/Musync.ico ./Launcher.py -w --clean + Compress-Archive -LiteralPath ./NoCLI/Launcher/ -DestinationPath ("./MusyncSavDecodeGUI_NoConsole_${{ env.Version }}.zip") - name: Dist NoConsole ${{ env.Version }} AllInOne Version # if: ${{ env.NotSkip == 'true'}} run: | - pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py -w - Rename-Item -Path ./MusyncSavDecodeGUI.exe -NewName ("MusyncSavDecodeGUI_NoConsole_${{ env.Version }}_AllInOne.exe") + pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./Launcher.py -w + Rename-Item -Path ./Launcher.exe -NewName ("MusyncSavDecodeGUI_NoConsole_${{ env.Version }}_AllInOne.exe") - name: Dist WithConsole ${{ env.Version }} Compress Version # if: ${{ env.NotSkip == 'true'}} run: | - pyinstaller --distpath ./WithCLI/ -D -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py - Compress-Archive -LiteralPath ./WithCLI/MusyncSavDecodeGUI/ -DestinationPath ("./MusyncSavDecodeGUI_WithConsole_${{ env.Version }}.zip") + pyinstaller --distpath ./WithCLI/ -D -i ./musync_data/Musync.ico ./Launcher.py + Compress-Archive -LiteralPath ./WithCLI/Launcher/ -DestinationPath ("./MusyncSavDecodeGUI_WithConsole_${{ env.Version }}.zip") - name: Dist WithConsole ${{ env.Version }} AllInOne Version # if: ${{ env.NotSkip == 'true'}} run: | - pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py - Rename-Item -Path ./MusyncSavDecodeGUI.exe -NewName ("MusyncSavDecodeGUI_WithConsole_${{ env.Version }}_AllInOne.exe") + pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./Launcher.py + Rename-Item -Path ./Launcher.exe -NewName ("MusyncSavDecodeGUI_WithConsole_${{ env.Version }}_AllInOne.exe") - name: Commit Release # if: ${{ env.NotSkip == 'true'}} diff --git a/How_to_use.zh.md b/How_to_use.zh.md index 5142e41..533599c 100644 --- a/How_to_use.zh.md +++ b/How_to_use.zh.md @@ -40,19 +40,19 @@ - 无命令行的散包: ```cmd - pyinstaller --distpath ./NoCLI/ -D -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py -w + pyinstaller --distpath ./NoCLI/ -D -i ./musync_data/Musync.ico ./Launcher.py -w ``` - 无命令行的单exe文件: ```cmd - pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py -w + pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./Launcher.py -w ``` - 带命令行的散包: ```cmd - pyinstaller --distpath ./WithCLI/ -D -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py + pyinstaller --distpath ./WithCLI/ -D -i ./musync_data/Musync.ico ./Launcher.py ``` - 带命令行的单exe文件: ```cmd - pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./MusyncSavDecodeGUI.py + pyinstaller --distpath ./ -F -i ./musync_data/Musync.ico ./Launcher.py ``` ## 功能介绍 diff --git a/Launcher.py b/Launcher.py new file mode 100644 index 0000000..7458602 --- /dev/null +++ b/Launcher.py @@ -0,0 +1,51 @@ +import ctypes +import json +import os +import sys +# import requests + +# from tkinter import * +from tkinter import Tk,font + +import Functions +import MainWindowOldStyle as OldStyle +import MusyncSavDecodeGUI as NewStyle + +version = '1.2.7rc2' +isPreRelease = True +preVersion = "1.2.7pre2" +# isPreRelease = False + +def launcher(): + root = Tk() + ctypes.windll.shcore.SetProcessDpiAwareness(1) + fonts = list(font.families()) + Functions.CheckFileBeforeStarting(fonts) + # del fonts + Functions.CheckConfig() + with open('./musync_data/ExtraFunction.cfg','r',encoding='utf8') as cfg: + cfg = json.load(cfg) + if cfg['ChangeConsoleStyle']: + Functions.ChangeConsoleStyle() + root.tk.call('tk', 'scaling', 1.25) + root.resizable(False, True) #允许改变窗口高度,不允许改变窗口宽度 + # 强制仅旧版UI + window = OldStyle.MusyncSavDecodeGUI(root=root,version=version,preVersion=preVersion,isPreRelease=isPreRelease) + # if cfg['EnableFramelessWindow']: + # root.overrideredirect(1) + # window = NewStyle.MusyncSavDecodeGUI(root=root) + # else: + # window = OldStyle.MusyncSavDecodeGUI(root=root,version=version,preVersion=preVersion,isPreRelease=isPreRelease) + root.update() + root.mainloop() + + +if __name__ == '__main__': + if sys.argv[-1] == "debug": + launcher() + else: + try: + launcher() + except Exception as e: + print(repr(e)) + os.system("pause") diff --git a/MainWindowOldStyle.py b/MainWindowOldStyle.py index 06d8a65..7b856bf 100644 --- a/MainWindowOldStyle.py +++ b/MainWindowOldStyle.py @@ -84,6 +84,7 @@ def fixed_map(option): self.isDLC = 0 self.wh = [0,0] self.checkGameStartEvent = threading.Event() + self.CheckGameIsStartThread = None root.protocol("WM_DELETE_WINDOW", self.on_closing) @@ -172,30 +173,33 @@ def fixed_map(option): self.TreeviewColumnUpdate() def CheckGameIsStart(event): - while True: - if event.is_set(): - print("Stop Thread: CheckGameIsStart.") - break - startTime = time.perf_counter_ns() - # print("Checking Game Is Start?") - for ids in psutil.pids(): - try: - if psutil.Process(pid=ids).name() == "MUSYNX.exe": - # self.config["MainExecPath"] - self.isGameRunning["text"] = "游戏已启动" - self.isGameRunning["bg"] = "#98E22B" - break - except Exception as e: - print(repr(e)) - - else: - self.isGameRunning["text"] = "游戏未启动" - self.isGameRunning["bg"] = "#FF8080" - endTime = time.perf_counter_ns() - print("CheckGameIsStart Run Time: %f ms"%((endTime - startTime)/1000000)) - time.sleep(5) + count = 0 + while event.is_set(): + if count%10 == 0: + startTime = time.perf_counter_ns() + # print("Checking Game Is Start?") + for ids in psutil.pids(): + try: + if psutil.Process(pid=ids).name() == "MUSYNX.exe": + # self.config["MainExecPath"] + self.isGameRunning["text"] = "游戏已启动" + self.isGameRunning["bg"] = "#98E22B" + break + except Exception as e: + print(repr(e)) + else: + self.isGameRunning["text"] = "游戏未启动" + self.isGameRunning["bg"] = "#FF8080" + endTime = time.perf_counter_ns() + print("CheckGameIsStart Run Time: %f ms"%((endTime - startTime)/1000000)) + count = 0 + time.sleep(0.5) + count += 1 + print("Stop Thread: CheckGameIsStart.") - threading.Thread(target=CheckGameIsStart, args=(self.checkGameStartEvent, )).start() + self.checkGameStartEvent.set() + self.CheckGameIsStartThread = threading.Thread(target=CheckGameIsStart, args=(self.checkGameStartEvent, )) + self.CheckGameIsStartThread.start() threading.Thread(target=self.CheckJsonUpdate).start() if self.config['DisableCheckUpdate']: @@ -227,13 +231,12 @@ def CheckGameIsStart(event): elif os.path.isfile('./musync_data/SavDecode.decode'): self.InitLabel('解码存档中......') MusyncSavDecode.MUSYNCSavProcess(decodeFile='./musync_data/SavDecode.decode').Main('decode') - self.DataLoad() - else: - self.DataLoad() + self.DataLoad() # TK事件重载 def on_closing(self): - self.checkGameStartEvent.set() + self.checkGameStartEvent.clear() + self.CheckGameIsStartThread.join() self.root.destroy() # json文件检查 @@ -643,9 +646,9 @@ def UpdateWindow(self): if __name__ == '__main__': - version = '1.2.6rc3' + version = '0.0.0rc0' isPreRelease = True - preVersion = "1.2.6pre7" + preVersion = "9.9.9pre9" root = Tk() ctypes.windll.shcore.SetProcessDpiAwareness(1) diff --git a/MusyncSavDecode.py b/MusyncSavDecode.py index 5063db0..415632d 100644 --- a/MusyncSavDecode.py +++ b/MusyncSavDecode.py @@ -52,15 +52,22 @@ def SaveFileAnalyze(self): print("SaveFileAnalyze Start.") self.savBinFile = open(f'./musync_data/SavDecode.decode','rb+') self.savAnalyzeFile = open(f'./musync_data/SavAnalyze.analyze','w+') - self.SaveBinFileRead(887) self.SaveBinFileRead(22) + self.SaveBinFileRead(92) + self.SaveBinFileRead(518) + self.SaveBinFileRead(41) + self.SaveBinFileRead(121) + binTemp = self.savBinFile.read(1) + while (binTemp != b'\x55'): # UIB_PlayingScene + binTemp = self.savBinFile.read(1) + self.SaveBinFileRead(21) while True: binTemp = self.savBinFile.read(1) if binTemp == b'\x06': self.SaveAnalyzeFileWrite(f'上次游玩曲目: {"".join(self.lastPlaySong)}') break else: - self.lastPlaySong.append(binTemp.decode()) + self.lastPlaySong.append(binTemp.decode('ascii')) self.SaveBinFileRead(475) while True: if self.savBinFile.read(1) == b'\x02': @@ -91,7 +98,6 @@ def SaveFileAnalyze(self): self.SaveAnalyzeFileWrite(self.saveData[136:162].decode()) #'k__BackingField' self.SaveAnalyzeFileWrite(self.saveData[163:185].decode()) #'k__BackingField' self.SaveBinFileRead(37) - self.SaveAnalyzeFileWrite('| SongID | Unknown0 | SpeedStall | Unknown1 | SyncNumber | UploadScore | PlayCount | statu |') self.Analyze2Json() self.savBinFile.close() self.savAnalyzeFile.close() @@ -103,6 +109,7 @@ def SaveFileAnalyze(self): def Analyze2Json(self): startTime = time.perf_counter_ns() print("Analyze2Json Start.") + self.SaveAnalyzeFileWrite('| SongID | Unknown0 | SpeedStall | Unknown1 | SyncNumber | UploadScore | PlayCount | statu |') saveDataAnalyze = open(f'./musync_data/SavAnalyze.json','w+',encoding='utf8') # FavSong = open(f'./musync_data/FavSong.tmp','w',encoding='utf8') saveDataAnalyzeJson = dict() diff --git a/MusyncSavDecodeGUI.py b/MusyncSavDecodeGUI.py index 4018889..3122216 100644 --- a/MusyncSavDecodeGUI.py +++ b/MusyncSavDecodeGUI.py @@ -22,11 +22,6 @@ from HitDelay import HitDelayCheck,HitDelayText import MusyncSavDecode -version = '1.2.7rc1' -isPreRelease = True -preVersion = "1.2.7pre1" -isPreRelease = False - class MusyncSavDecodeGUI(object): """docstring for MusyncSavDecodeGUI""" def __init__(self, root=None, isTKroot=True): @@ -718,6 +713,10 @@ def input(self,char:str,length:int=10): self.canvas.itemconfig(self.tex,text=self.info+'|') if __name__ == '__main__': + version = '1.2.7rc1' + isPreRelease = True + preVersion = "1.2.7pre2" + try: root = Tk() ctypes.windll.shcore.SetProcessDpiAwareness(1) @@ -731,32 +730,13 @@ def input(self,char:str,length:int=10): Functions.ChangeConsoleStyle() root.tk.call('tk', 'scaling', 1.25) root.resizable(False, True) #允许改变窗口高度,不允许改变窗口宽度 - if cfg['EnableFramelessWindow']: - root.overrideredirect(1) - window = MusyncSavDecodeGUI(root=root) - else: - window = OldStyle.MusyncSavDecodeGUI(root=root,version=version,preVersion=preVersion,isPreRelease=isPreRelease) + # if cfg['EnableFramelessWindow']: + # root.overrideredirect(1) + # window = MusyncSavDecodeGUI(root=root) + # else: + # window = OldStyle.MusyncSavDecodeGUI(root=root,version=version,preVersion=preVersion,isPreRelease=isPreRelease) root.update() root.mainloop() except Exception as e: print(repr(e)) os.system("pause") - # root = Tk() - # ctypes.windll.shcore.SetProcessDpiAwareness(1) - # fonts = list(font.families()) - # Functions.CheckFileBeforeStarting(fonts) - # # del fonts - # Functions.CheckConfig() - # with open('./musync_data/ExtraFunction.cfg','r',encoding='utf8') as cfg: - # cfg = json.load(cfg) - # if cfg['ChangeConsoleStyle']: - # Functions.ChangeConsoleStyle() - # root.tk.call('tk', 'scaling', 1.25) - # root.resizable(False, True) #允许改变窗口高度,不允许改变窗口宽度 - # if cfg['EnableFramelessWindow']: - # root.overrideredirect(1) - # window = MusyncSavDecodeGUI(root=root) - # else: - # window = OldStyle.MusyncSavDecodeGUI(root=root,version=version,preVersion=preVersion,isPreRelease=isPreRelease) - # root.update() - # root.mainloop() diff --git a/Push.ps1 b/Push.ps1 index 2f0628c..7f36d44 100644 --- a/Push.ps1 +++ b/Push.ps1 @@ -5,13 +5,13 @@ echo =========== echo $message[-1] echo =========== if ($message[-1] -eq 'rc'){ - $version = (py -c "import MusyncSavDecodeGUI;print(MusyncSavDecodeGUI.version)") + $version = (py -c "import Launcher;print(Launcher.version)") $release = 'Release' }elseif($message[-1] -eq 'pre'){ - $version = (py -c "import MusyncSavDecodeGUI;print(MusyncSavDecodeGUI.preVersion)") + $version = (py -c "import Launcher;print(Launcher.preVersion)") $release = 'PreRelease' }else{ - $version = (py -c "import MusyncSavDecodeGUI;print(MusyncSavDecodeGUI.preVersion)") + $version = (py -c "import Launcher;print(Launcher.preVersion)") $release = '[no ci]' } if ($message[0] -eq ""){ @@ -20,9 +20,9 @@ if ($message[0] -eq ""){ $str = $version+' '+$message[0]+' '+$release echo $str +git pull git add . git commit -m $str git push # git tag -a $version -m $message[0] -git pull Read-Host -Prompt "Press Enter to exit" \ No newline at end of file diff --git a/README.md b/README.md index 45cc9ee..98945d6 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,15 @@ HitDelay模块用法:启用DLL注入后,在本次游戏进行首次谱面游玩 --> ### Version 1.2.7 #### PreRelease +#### Release 2 +1. 更新 + 1. 将启动函数单独拆分到`Launcher.py` +2. 修复 + 1. 修复关闭窗口时子线程未被停止的bug + 2. (尝试)修复读取村当时字符串无法被解码导致的崩溃 + 3. 修复控制台输出表格头顺序错误的bug +3. 优化 + 1. (尝试)优化存档读取兼容性 #### Release 1 1. 更新 1. 通过threading.event事件在关闭窗口时结束子线程以避免在关闭时出现孤儿进程的情况 diff --git a/changelog.txt b/changelog.txt index 78870f9..ebd86d0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -13,6 +13,15 @@ ### Version 1.2.7 #### PreRelease +#### Release 2 +1. 更新 + 1. 将启动函数单独拆分到`Launcher.py` +2. 修复 + 1. 修复关闭窗口时子线程未被停止的bug + 2. (尝试)修复读取村当时字符串无法被解码导致的崩溃 + 3. 修复控制台输出表格头顺序错误的bug +3. 优化 + 1. (尝试)优化存档读取兼容性 #### Release 1 1. 更新 1. 通过threading.event事件在关闭窗口时结束子线程以避免在关闭时出现孤儿进程的情况