diff --git a/src/AutoProcess.py b/src/AutoProcess.py
index 37a359f..3d7ea82 100644
--- a/src/AutoProcess.py
+++ b/src/AutoProcess.py
@@ -5,7 +5,6 @@
@Contact : Hatanezumi@chunshengserver.cn
'''
import os
-import json
import requests
def get_mods(base_path:str) -> tuple[bool,str|list[str]]:
@@ -43,7 +42,7 @@ def get_cloud(path:str, target, arg):
if req.status_code != 200:
target(arg,False,"返回值为:{}".format(req.status_code))
return
- res = json.loads(req.content)
+ res = req.content
target(arg,True,res)
except Exception as err:
target(arg,False,err)
\ No newline at end of file
diff --git a/src/__pycache__/AutoProcess.cpython-310.pyc b/src/__pycache__/AutoProcess.cpython-310.pyc
index 118e38a..82e1e83 100644
Binary files a/src/__pycache__/AutoProcess.cpython-310.pyc and b/src/__pycache__/AutoProcess.cpython-310.pyc differ
diff --git a/src/__pycache__/main.cpython-310.pyc b/src/__pycache__/main.cpython-310.pyc
index 2697115..3e1a49f 100644
Binary files a/src/__pycache__/main.cpython-310.pyc and b/src/__pycache__/main.cpython-310.pyc differ
diff --git a/src/main.py b/src/main.py
index 9cc5869..a2d516f 100644
--- a/src/main.py
+++ b/src/main.py
@@ -6,6 +6,7 @@
'''
import os
import sys
+import json
import py7zr
import requests
import webbrowser
@@ -14,6 +15,7 @@ from PySide6.QtCore import Qt, QStringListModel, Signal, QObject
from PySide6.QtGui import QColor,QIcon, QTextCursor
from ui.MainWindow import Ui_MainWindow
from threading import Thread
+import ctypes.wintypes
from src import AutoProcess
#常量
@@ -22,6 +24,7 @@ REFRESH = 101
GETMODS = 200
GETMODINFO = 201
GETNEWVERSION = 202
+GETUPDATELOG = 203
GETOTHER = 210
INFO = 300
WARNING = 301
@@ -37,6 +40,7 @@ class CustomizeSingals(QObject):
download_err = Signal(Exception)
set_new_version = Signal(str)
get_new_version_err = Signal(str)
+ set_plainTextEdit_updatelog = Signal(str)
class Process():
@staticmethod
def set_comboBox(comboBox:QComboBox, texts:list):
@@ -56,12 +60,15 @@ class Process():
singals.set_Status_Tip.connect(window.set_Status_Tip)
singals.set_new_version.connect(window.set_new_version)
singals.get_new_version_err.connect(window.get_new_version_err)
+ singals.set_plainTextEdit_updatelog.connect(window.set_plainTextEdit_updatelog)
if not state:
if mode == INIT:
if source == GETMODS:
singals.set_Status_Tip.emit('获取云AR信息失败:{}'.format(res))
elif source == GETNEWVERSION:
singals.get_new_version_err.emit(res)
+ elif source == GETUPDATELOG:
+ singals.set_plainTextEdit_updatelog.emit('获取更新日志失败:{}'.format(res))
return
elif mode == REFRESH:
if source == GETMODS:
@@ -69,11 +76,13 @@ class Process():
elif source == GETMODINFO:
singals.message_box.emit(WARNING,'出现错误',"获取mod信息失败:{}".format(res),QMessageBox.Ok,QMessageBox.Ok)
if source == GETMODS:
- singals.set_listView_Network.emit(res)
+ singals.set_listView_Network.emit(json.loads(res))
elif source == GETMODINFO:
- singals.set_network_page.emit(res)
+ singals.set_network_page.emit(json.loads(res))
elif source == GETNEWVERSION:
- singals.set_new_version.emit(res['version'])
+ singals.set_new_version.emit(json.loads(res)['version'])
+ elif source == GETUPDATELOG:
+ singals.set_plainTextEdit_updatelog.emit(res.decode())
except Exception as err:
singals.message_box.emit((WARNING,'出现错误',"获取信息失败:{}".format(err),QMessageBox.Ok,QMessageBox.Ok))
@staticmethod
@@ -130,7 +139,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.listView_local_qsl = QStringListModel()
self.listView_Network_qsl = QStringListModel()
self.fileDialog = QFileDialog(self)
- self.base_mod_path = os.path.join(os.path.splitdrive(os.environ['systemroot'])[0],os.environ['homepath'],'Documents','Red Alert 3','Mods')
+ try:
+ buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH)
+ ctypes.windll.shell32.SHGetFolderPathW(None, 5, None, 0, buf)
+ if buf == '':
+ raise Exception('目录获取失败')
+ self.documents_path = buf.value
+ except:
+ self.base_mod_path = os.path.join(os.path.splitdrive(os.environ['systemroot'])[0],os.environ['homepath'],'Documents','Red Alert 3','Mods')
+ else:
+ self.base_mod_path = os.path.join(self.documents_path,'Red Alert 3','Mods')
self.cloud_mods = {}
self.cloud_mod_source = (None,{})
self.isdownloading = False
@@ -154,18 +172,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
#获取更新信息
t = Thread(target=AutoProcess.get_cloud,args=('https://www.chunshengserver.cn/files/RA3mods/RA3_affiliated_mod_downloader.json',Process.get_cloud_data,(self,INIT,GETNEWVERSION)),daemon=True)
t.start()
+ #获取更新日志
+ t = Thread(target=AutoProcess.get_cloud,args=('https://www.chunshengserver.cn/files/RA3mods/更新日志.txt',Process.get_cloud_data,(self,INIT,GETUPDATELOG)),daemon=True)
+ t.start()
def __comboBox_mods_changed(self):
if self.mods[0] is False:
return
- # currentText = self.comboBox_mods.currentText()#为了保证数据安全采用字符串匹配的方式
- # find = False
- # for mod_path in self.mods[1]:
- # if os.path.split(mod_path)[1].removesuffix('.skudef') == currentText:
- # self.select_mod = mod_path
- # find = True
- # break
- # if find is False:
- # return
#显示本地列表内容
currentIndex = self.comboBox_mods.currentIndex()#因为有重复的名称,所以采用索引匹配
mod_path = self.mods[1][currentIndex]
@@ -313,7 +325,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.progressBar_Download.setValue(value)
def download_finished(self,path:str):
self.isdownloading = False
- self.progressBar_Download.value(0)
+ self.progressBar_Download.setValue(0)
select = QMessageBox.information(self,'下载成功','下载成功,是否自动解压?',QMessageBox.Ok|QMessageBox.Cancel,QMessageBox.Cancel)
if select == QMessageBox.Ok:
try:
@@ -337,6 +349,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.label_about_newverison.setText("最新版本:连接到纯世蜉生失败,原因:{}".format(err))
def __on_pushButton_release_clicked(self):
webbrowser.open('https://cloud.armorrush.com/Hatanezumi/RA3_affiliated_mod_downloader/releases')
+ def set_plainTextEdit_updatelog(self,text:str):
+ self.plainTextEdit_updatelog.setPlainText(text)
def init():
app = QApplication(sys.argv)
main_window = MainWindow()
diff --git a/ui/MainWindow.py b/ui/MainWindow.py
index 7271d81..a13eadb 100644
--- a/ui/MainWindow.py
+++ b/ui/MainWindow.py
@@ -200,6 +200,7 @@ class Ui_MainWindow(object):
self.plainTextEdit_introduce = QPlainTextEdit(self.tab_Network)
self.plainTextEdit_introduce.setObjectName(u"plainTextEdit_introduce")
self.plainTextEdit_introduce.setLineWrapMode(QPlainTextEdit.NoWrap)
+ self.plainTextEdit_introduce.setReadOnly(True)
self.horizontalLayout_3.addWidget(self.plainTextEdit_introduce)
@@ -312,6 +313,18 @@ class Ui_MainWindow(object):
self.verticalLayout_10.addWidget(self.label_about_newverison)
+ self.label_updatelog = QLabel(self.tab_about)
+ self.label_updatelog.setObjectName(u"label_updatelog")
+
+ self.verticalLayout_10.addWidget(self.label_updatelog)
+
+ self.plainTextEdit_updatelog = QPlainTextEdit(self.tab_about)
+ self.plainTextEdit_updatelog.setObjectName(u"plainTextEdit_updatelog")
+ self.plainTextEdit_updatelog.setLineWrapMode(QPlainTextEdit.NoWrap)
+ self.plainTextEdit_updatelog.setReadOnly(True)
+
+ self.verticalLayout_10.addWidget(self.plainTextEdit_updatelog)
+
self.pushButton_release = QPushButton(self.tab_about)
self.pushButton_release.setObjectName(u"pushButton_release")
@@ -368,6 +381,7 @@ class Ui_MainWindow(object):
self.label_about_contact.setText(QCoreApplication.translate("MainWindow", u"\u8054\u7cfb:Hatanezumi@chunshengserver.cn", None))
self.label_about_verison.setText(QCoreApplication.translate("MainWindow", u"\u5f53\u524d\u7248\u672c:", None))
self.label_about_newverison.setText(QCoreApplication.translate("MainWindow", u"\u6700\u65b0\u7248\u672c:", None))
+ self.label_updatelog.setText(QCoreApplication.translate("MainWindow", u"\u66f4\u65b0\u65e5\u5fd7:", None))
self.pushButton_release.setText(QCoreApplication.translate("MainWindow", u"\u53d1\u5e03\u9875", None))
self.tabWidget_Main.setTabText(self.tabWidget_Main.indexOf(self.tab_about), QCoreApplication.translate("MainWindow", u"\u5173\u4e8e", None))
#if QT_CONFIG(statustip)
diff --git a/ui/MainWindow.ui b/ui/MainWindow.ui
index 4074d97..caab5f8 100644
--- a/ui/MainWindow.ui
+++ b/ui/MainWindow.ui
@@ -241,6 +241,9 @@
QPlainTextEdit::NoWrap
+
+ true
+
@@ -372,6 +375,23 @@
+ -
+
+
+ 更新日志:
+
+
+
+ -
+
+
+ QPlainTextEdit::NoWrap
+
+
+ true
+
+
+
-
diff --git a/ui/__pycache__/MainWindow.cpython-310.pyc b/ui/__pycache__/MainWindow.cpython-310.pyc
index 93af9f9..e79f536 100644
Binary files a/ui/__pycache__/MainWindow.cpython-310.pyc and b/ui/__pycache__/MainWindow.cpython-310.pyc differ