v1.0.1
This commit is contained in:
parent
0cdbc6fd41
commit
185efc1f96
@ -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)
|
Binary file not shown.
Binary file not shown.
42
src/main.py
42
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("<font color=red>最新版本:连接到纯世蜉生失败,原因:{}</font>".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()
|
||||
|
@ -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)
|
||||
|
@ -241,6 +241,9 @@
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -372,6 +375,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_updatelog">
|
||||
<property name="text">
|
||||
<string>更新日志:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_updatelog">
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_release">
|
||||
<property name="text">
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user