Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
[0.2.1] 修复了日志自动删除始终生效的问题
Browse files Browse the repository at this point in the history
删除了图表显示
  • Loading branch information
AuroraZiling committed Jun 30, 2023
1 parent 35a0957 commit 55e2fcb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/asta.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

def startUp():
assetsCheck()
if cfg.customizeAutoDeleteLog and utils.get_log_file_amount() > 3:
if cfg.customizeAutoDeleteLog.value and utils.get_log_file_amount() > 3:
utils.delete_directory(utils.log_dir)


Expand Down
35 changes: 0 additions & 35 deletions src/modules/Core/GachaReport/Analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,38 +133,3 @@ def get_guarantee(self, data_type):
elif not nearest_5_star:
guarantee_text = "暂无数据"
return guarantee_text

def get_pie_chart(self):

if not self.total_amount:
return empty_chart()

self.chartSeries.append('5星', 0)
self.chartSeries.append('4星', 0)
self.chartSeries.append('3星', 0)

self.chart5Star = self.chartSeries.slices()[0]
self.chart5Star.setBrush(QColor(COLOR_MAPPING["5"]))
self.chart5Star.setLabelFont(QFont("Microsoft YaHei", 10))
self.chart5Star.setValue(self.star_5_amount)

self.chart4Star = self.chartSeries.slices()[1]
self.chart4Star.setBrush(QColor(COLOR_MAPPING["4"]))
self.chart4Star.setLabelFont(QFont("Microsoft YaHei", 10))
self.chart4Star.setValue(self.star_4_amount)

self.chart3Star = self.chartSeries.slices()[2]
self.chart3Star.setBrush(QColor(COLOR_MAPPING["3"]))
self.chart3Star.setLabelFont(QFont("Microsoft YaHei", 10))
self.chart3Star.setValue(self.star_3_amount)

self.chart.addSeries(self.chartSeries)
self.chart.setBackgroundVisible(False)
self.chart.createDefaultAxes()

self.chart.legend().setVisible(True)
self.chart.legend().setGeometry(QRectF(0, 0, 200, 200))
self.chart.legend().setAlignment(Qt.AlignmentFlag.AlignLeft)
self.chart.legend().setLabelColor(QColor(255, 255, 255) if isDarkTheme() else QColor(0, 0, 0))

return self.chart
9 changes: 5 additions & 4 deletions src/modules/Core/GachaReport/gacha_report_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from PySide6.QtCore import QThread, Signal

from ...constant import SRGF_VERSION, SRGF_DATA_MODEL, GACHATYPE, SRGF_GACHATYPE
from ...constant import SRGF_VERSION, SRGF_DATA_MODEL, GACHATYPE
from ..SRGF.converter import originalToSRGFListUnit
from .gacha_report_utils import updateAPI
from ...Scripts.Utils.tools import Tools
Expand All @@ -19,16 +19,17 @@

class GachaReportThread(QThread):
trigger = Signal(tuple)
isAdditional = False

def __init__(self, gachaUrl, parent=None, isAdd=False):
super(GachaReportThread, self).__init__(parent)
self.uid = ""
self.region_time_zone = ""
self.gachaUrl = gachaUrl
self.isAdd = isAdd
self.isAdditional = isAdd

def run(self):
if not self.isAdd:
if not self.isAdditional:
SRGFExportJsonData = SRGF_DATA_MODEL
gachaList = []
for key in GACHATYPE.keys():
Expand Down Expand Up @@ -66,7 +67,7 @@ def run(self):
pickle.dump(SRGFExportJsonData, f)
self.trigger.emit((1, "跃迁记录更新完毕", self.uid))
else:
dataPath = f"{utils.working_dir}/data/{self.isAdd}/{self.isAdd}_data.pickle"
dataPath = f"{utils.working_dir}/data/{self.isAdditional}/{self.isAdditional}_data.pickle"
if not os.path.exists(dataPath):
self.trigger.emit((-1, f"增量更新失败",
"请检查是否对当前UID进行过全量更新"))
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Core/GachaReport/gacha_report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def getDefaultGameDataPath():
match = re.search(r'Loading player data from (.*)StarRail_Data.*', logFile)
game_path = match.group(1) if match else None
logging.info(f"[GachaReport.utils] Game Path get: {game_path}")
return game_path
return game_path if game_path else "未找到游戏路径"


def extractAPI(url):
Expand Down
21 changes: 6 additions & 15 deletions src/modules/Views/gacha_report_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from PySide6 import QtGui
from PySide6.QtCharts import QChartView
from PySide6.QtCore import Qt, QModelIndex
from PySide6.QtGui import QColor, QPalette, QPainter
from PySide6.QtGui import QColor, QPalette
from PySide6.QtWidgets import QFrame, QLabel, QHBoxLayout, QVBoxLayout, QAbstractItemView, QHeaderView, \
QTableWidgetItem, QStyleOptionViewItem

Expand Down Expand Up @@ -114,8 +114,6 @@ def __init__(self, parent=None):

self.bottomRightAnalysisLabel = QLabel("保底情况")
self.bottomRightAnalysisGuaranteeLabel = QLabel("未知")
self.bottomRightGraphLabel = QLabel("图像", self)
self.bottomRightGraphView = QChartView(self)
self.bottomRightVBox.addWidget(self.bottomRightBasicLabel)
self.bottomRightVBox.addWidget(self.bottomRightBasicTotalLabel)
self.bottomRightVBox.addLayout(self.bottomRightBasicLevelHBox)
Expand All @@ -124,8 +122,6 @@ def __init__(self, parent=None):
self.bottomRightVBox.addWidget(self.bottomRightBasicListTextEdit)
self.bottomRightVBox.addWidget(self.bottomRightAnalysisLabel)
self.bottomRightVBox.addWidget(self.bottomRightAnalysisGuaranteeLabel)
self.bottomRightVBox.addWidget(self.bottomRightGraphLabel)
self.bottomRightVBox.addWidget(self.bottomRightGraphView)

self.bottomHBox.addLayout(self.bottomLeftVBox)
self.bottomHBox.addLayout(self.bottomRightVBox)
Expand Down Expand Up @@ -198,7 +194,7 @@ def __headerRightAddUpdateDropBtnWebCache(self):
self.gachaReportThread.start()
self.gachaReportThread.trigger.connect(self.gachaReportStatusChanged)
else:
InfoBar.error("失败", "无法从游戏缓存中获取请求", InfoBarPosition.TOP_RIGHT, parent=self)
InfoBar.error("失败", "无法从游戏缓存中获取请求,请检查游戏目录是否正确或是否第一次打开跃迁记录", InfoBarPosition.TOP_RIGHT, parent=self)

def __headerRightFullUpdateDropBtnWebCache(self):
gachaURL = convertAPI(by_web_cache.getURL(cfg.gameDataFolder.value))
Expand All @@ -207,7 +203,7 @@ def __headerRightFullUpdateDropBtnWebCache(self):
if resp.exec():
self.headerRightAddUpdateDropBtn.setEnabled(False)
self.headerRightFullUpdateDropBtn.setEnabled(False)
self.gachaReportThread = GachaReportThread(gachaURL)
self.gachaReportThread = GachaReportThread(gachaURL, isAdd=False)
self.gachaReportThreadStateTooltip = StateToolTip("更新数据中", "数据更新开始",
self)
self.gachaReportThreadStateTooltip.closedSignal.connect(self.__gachaReportThreadStateTooltipClosed)
Expand All @@ -216,7 +212,7 @@ def __headerRightFullUpdateDropBtnWebCache(self):
self.gachaReportThread.start()
self.gachaReportThread.trigger.connect(self.gachaReportStatusChanged)
else:
InfoBar.error("失败", "无法从游戏缓存中获取请求", InfoBarPosition.TOP_RIGHT, parent=self)
InfoBar.error("失败", "无法从游戏缓存中获取请求,请检查游戏目录是否正确或是否第一次打开跃迁记录", InfoBarPosition.TOP_RIGHT, parent=self)

def __headerRightAddUpdateDropBtnURL(self):
w = URLDialog("输入URL", "请在下方输入 MiHoYo API 的URL", self)
Expand Down Expand Up @@ -276,12 +272,10 @@ def setInteractive(self, mode):
self.bottomLeftGachaTable.setEnabled(mode)
self.headerRightGachaTypeCombobox.setEnabled(mode)
self.headerRightUIDSelectCombobox.setEnabled(mode)
self.bottomRightGraphLabel.setEnabled(mode)
self.bottomRightBasicToggleBtn.setEnabled(mode)

def emptyAllStatistics(self):
self.bottomLeftGachaTable.clearContents()
self.bottomRightGraphView.setChart(analysis.empty_chart())

def showEvent(self, a0: QtGui.QShowEvent) -> None:
if not gacha_report_read.getUIDList():
Expand All @@ -293,7 +287,6 @@ def showEvent(self, a0: QtGui.QShowEvent) -> None:
else:
self.initData()
self.setInteractive(True)
self.bottomRightGraphView.setBackgroundBrush(QColor(37, 37, 37) if isDarkTheme() else QColor(255, 255, 255))

def __bottomRightBasicToggleBtnClicked(self):
if self.bottomRightBasicToggleBtn.isChecked():
Expand Down Expand Up @@ -361,7 +354,6 @@ def initFrame(self):
style_sheet.component_style_sheet("gacha_report_push_button_4"))

self.bottomRightBasicListLabel.setFont(utils.get_font(12))
self.bottomRightBasicListTextEdit.setFixedHeight(70)
self.bottomRightBasicToggleBtn.setFixedWidth(160)
self.bottomRightBasicToggleBtn.clicked.connect(self.__bottomRightBasicToggleBtnClicked)

Expand All @@ -371,10 +363,10 @@ def initFrame(self):
self.bottomRightCompleteAnalysisBtn.setStyleSheet(
style_sheet.component_style_sheet("gacha_report_complete_analysis_button"))

self.bottomRightBasicListTextEdit.setReadOnly(True)

self.bottomRightAnalysisLabel.setFont(utils.get_font(14))
self.bottomRightAnalysisGuaranteeLabel.setFont(utils.get_font(10))
self.bottomRightGraphLabel.setFont(utils.get_font(14))
self.bottomRightGraphView.setRenderHint(QPainter.Antialiasing)

def tableUpdateData(self, currentData):
global rowColorMapping
Expand Down Expand Up @@ -403,7 +395,6 @@ def analysisUpdateData(self, currentData):
self.bottomRightBasicListTextEdit.setText(self.analyzer.get_star_5_to_string())
self.bottomRightAnalysisGuaranteeLabel.setText(
self.analyzer.get_guarantee(self.headerRightGachaTypeCombobox.currentText()))
self.bottomRightGraphView.setChart(self.analyzer.get_pie_chart())

def __headerRightGachaTypeComboboxChanged(self):
logging.info(f"[GachaReport] Gacha type selection changed")
Expand Down

0 comments on commit 55e2fcb

Please sign in to comment.