Skip to content

Commit

Permalink
1.2.7rc2 独立启动函数 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginsakura committed Aug 14, 2024
1 parent 8c81ded commit b8906e4
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 77 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}
Expand Down
8 changes: 4 additions & 4 deletions How_to_use.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

## 功能介绍
Expand Down
51 changes: 51 additions & 0 deletions Launcher.py
Original file line number Diff line number Diff line change
@@ -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")
61 changes: 32 additions & 29 deletions MainWindowOldStyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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']:
Expand Down Expand Up @@ -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文件检查
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 10 additions & 3 deletions MusyncSavDecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -91,7 +98,6 @@ def SaveFileAnalyze(self):
self.SaveAnalyzeFileWrite(self.saveData[136:162].decode()) #'<PlayCount>k__BackingField'
self.SaveAnalyzeFileWrite(self.saveData[163:185].decode()) #'<Isfav>k__BackingField'
self.SaveBinFileRead(37)
self.SaveAnalyzeFileWrite('| SongID | Unknown0 | SpeedStall | Unknown1 | SyncNumber | UploadScore | PlayCount | statu |')
self.Analyze2Json()
self.savBinFile.close()
self.savAnalyzeFile.close()
Expand All @@ -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()
Expand Down
38 changes: 9 additions & 29 deletions MusyncSavDecodeGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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()
8 changes: 4 additions & 4 deletions Push.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""){
Expand All @@ -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"
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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事件在关闭窗口时结束子线程以避免在关闭时出现孤儿进程的情况
Expand Down
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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事件在关闭窗口时结束子线程以避免在关闭时出现孤儿进程的情况
Expand Down

0 comments on commit b8906e4

Please sign in to comment.