feat: TabTools_InfoLookup play rating calculate

This commit is contained in:
283375 2023-09-23 17:44:18 +08:00
parent 4b8d0d0427
commit a9bef5d4d6
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk
5 changed files with 685 additions and 548 deletions

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>665</width>
<height>570</height>
<height>574</height>
</rect>
</property>
<property name="windowTitle">
@ -689,6 +689,66 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>playRatingCalculate</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLineEdit" name="playRatingCalculateScoreLineEdit">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="inputMask">
<string notr="true">B9'999'999;_</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string notr="true">&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="playRatingCalculateResultLabel">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -16,8 +16,8 @@ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QComboBox, QFrame, QGridLayout,
QGroupBox, QHBoxLayout, QLabel, QSizePolicy,
QVBoxLayout, QWidget)
QGroupBox, QHBoxLayout, QLabel, QLineEdit,
QSizePolicy, QSpacerItem, QVBoxLayout, QWidget)
from ui.implements.components.ratingClassSelector import RatingClassSelector
from ui.implements.components.songIdSelector import SongIdSelector
@ -26,7 +26,7 @@ class Ui_TabTools_InfoLookup(object):
def setupUi(self, TabTools_InfoLookup):
if not TabTools_InfoLookup.objectName():
TabTools_InfoLookup.setObjectName(u"TabTools_InfoLookup")
TabTools_InfoLookup.resize(665, 570)
TabTools_InfoLookup.resize(665, 574)
TabTools_InfoLookup.setWindowTitle(u"TabTools_InfoLookup")
self.verticalLayout = QVBoxLayout(TabTools_InfoLookup)
self.verticalLayout.setObjectName(u"verticalLayout")
@ -500,6 +500,40 @@ class Ui_TabTools_InfoLookup(object):
self.verticalLayout.addWidget(self.groupBox_2)
self.groupBox_6 = QGroupBox(TabTools_InfoLookup)
self.groupBox_6.setObjectName(u"groupBox_6")
self.horizontalLayout_5 = QHBoxLayout(self.groupBox_6)
self.horizontalLayout_5.setObjectName(u"horizontalLayout_5")
self.playRatingCalculateScoreLineEdit = QLineEdit(self.groupBox_6)
self.playRatingCalculateScoreLineEdit.setObjectName(u"playRatingCalculateScoreLineEdit")
self.playRatingCalculateScoreLineEdit.setMinimumSize(QSize(100, 0))
self.playRatingCalculateScoreLineEdit.setMaximumSize(QSize(150, 16777215))
self.playRatingCalculateScoreLineEdit.setInputMask(u"B9'999'999;_")
self.horizontalLayout_5.addWidget(self.playRatingCalculateScoreLineEdit)
self.label = QLabel(self.groupBox_6)
self.label.setObjectName(u"label")
self.label.setText(u">")
self.horizontalLayout_5.addWidget(self.label)
self.playRatingCalculateResultLabel = QLabel(self.groupBox_6)
self.playRatingCalculateResultLabel.setObjectName(u"playRatingCalculateResultLabel")
font = QFont()
font.setBold(True)
self.playRatingCalculateResultLabel.setFont(font)
self.playRatingCalculateResultLabel.setText(u"...")
self.horizontalLayout_5.addWidget(self.playRatingCalculateResultLabel)
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(self.horizontalSpacer)
self.verticalLayout.addWidget(self.groupBox_6)
self.retranslateUi(TabTools_InfoLookup)
@ -540,6 +574,7 @@ class Ui_TabTools_InfoLookup(object):
self.label_26.setText(QCoreApplication.translate("TabTools_InfoLookup", u"difficulty.jacketDesigner", None))
self.label_42.setText(QCoreApplication.translate("TabTools_InfoLookup", u"difficulty.jacketNight", None))
self.label_29.setText(QCoreApplication.translate("TabTools_InfoLookup", u"difficulty.title", None))
self.groupBox_6.setTitle(QCoreApplication.translate("TabTools_InfoLookup", u"playRatingCalculate", None))
pass
# retranslateUi

View File

@ -1,5 +1,6 @@
import re
from arcaea_offline.calculate import calculate_play_rating
from arcaea_offline.database import Database
from PySide6.QtCore import QDateTime
from PySide6.QtWidgets import QVBoxLayout, QWidget
@ -26,6 +27,16 @@ class TabTools_InfoLookup(Ui_TabTools_InfoLookup, QWidget):
self.ratingClassSelector.valueChanged.connect(self.updateDifficultyLabels)
self.ratingClassSelector.valueChanged.connect(self.updateChartInfoLabels)
self.songIdSelector.valueChanged.connect(
self.updatePlayRatingCalculateResultLabel
)
self.ratingClassSelector.valueChanged.connect(
self.updatePlayRatingCalculateResultLabel
)
self.playRatingCalculateScoreLineEdit.textChanged.connect(
self.updatePlayRatingCalculateResultLabel
)
self.langSelectComboBox.addItem("En - English [en]", "en")
self.langSelectComboBox.addItem("あ - Japanese [ja]", "ja")
self.langSelectComboBox.addItem("한 - Korean [ko]", "ko")
@ -193,7 +204,38 @@ class TabTools_InfoLookup(Ui_TabTools_InfoLookup, QWidget):
chartInfo = self.db.get_chart_info(songId, ratingClass)
if not chartInfo:
self.resetChartInfoLabels()
return
self.chartConstantLabel.setText(str(chartInfo.constant / 10))
self.chartNotesLabel.setText(
str(chartInfo.notes) if chartInfo.notes is not None else "-"
)
def resetPlayRatingCalculateResultLabel(self):
self.playRatingCalculateResultLabel.setText("...")
def updatePlayRatingCalculateResultLabel(self):
songId = self.songIdSelector.songId()
ratingClass = self.ratingClassSelector.value()
if not songId or ratingClass is None:
self.resetPlayRatingCalculateResultLabel()
return
chartInfo = self.db.get_chart_info(songId, ratingClass)
if not chartInfo or not chartInfo.constant:
self.resetPlayRatingCalculateResultLabel()
return
if scoreText := self.playRatingCalculateScoreLineEdit.text().replace("'", ""):
score = int(scoreText)
self.playRatingCalculateResultLabel.setText(
f"{calculate_play_rating(chartInfo.constant / 10, score):.3f}"
)
else:
self.resetPlayRatingCalculateResultLabel()
return

View File

@ -1040,7 +1040,7 @@ validation</translation>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_InfoLookup.ui" line="695"/>
<source>playRatingCalculate</source>
<translation type="unfinished"></translation>
<translation>Calculate Play Rating</translation>
</message>
</context>
<context>

View File

@ -1039,7 +1039,7 @@
<message>
<location filename="../../designer/tabs/tabTools/tabTools_InfoLookup.ui" line="695"/>
<source>playRatingCalculate</source>
<translation type="unfinished"></translation>
<translation> PTT</translation>
</message>
</context>
<context>