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>

File diff suppressed because it is too large Load Diff

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>