mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-11 05:30:17 +00:00
impr: TabTools_StepCalculator
ui
This commit is contained in:
parent
5aedf91c09
commit
e0d92b7784
@ -165,7 +165,7 @@
|
||||
<widget class="QRadioButton" name="legacyPlayPlus_x125fragRadioButton">
|
||||
<property name="text">
|
||||
<string notr="true">x1.25
|
||||
125</string>
|
||||
250</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -361,6 +361,13 @@
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>calculate.toStep.playResultLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="calculate_toStep_playResultSpinBox">
|
||||
<property name="sizePolicy">
|
||||
@ -380,10 +387,10 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="calculate_toStep_calculatePlayResultFromScoreButton">
|
||||
<property name="text">
|
||||
<string>calculate.toStep.playResultLabel</string>
|
||||
<string>calculate.toStep.calculatePlayResultFromScoreButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -401,24 +408,36 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="calculate_toStep_resultLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="calculate_toStep_calculatePlayResultFromScoreButton">
|
||||
<property name="text">
|
||||
<string>calculate.toStep.calculatePlayResultFromScoreButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="calculate_toStep_resultLabel">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="calculate_toStep_detailedResultLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel { color: gray; }</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -463,17 +482,36 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="calculate_fromStep_resultLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QLabel" name="calculate_fromStep_resultLabel">
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="calculate_fromStep_detailedResultLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel { color: gray; }</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">...</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -137,7 +137,7 @@ class Ui_TabTools_StepCalculator(object):
|
||||
self.legacyPlayPlus_x125fragRadioButton = QRadioButton(self.legacyPlayPlus_useFragmentsGroupBox)
|
||||
self.legacyPlayPlus_x125fragRadioButton.setObjectName(u"legacyPlayPlus_x125fragRadioButton")
|
||||
self.legacyPlayPlus_x125fragRadioButton.setText(u"x1.25\n"
|
||||
"125")
|
||||
"250")
|
||||
|
||||
self.horizontalLayout_3.addWidget(self.legacyPlayPlus_x125fragRadioButton)
|
||||
|
||||
@ -288,6 +288,11 @@ class Ui_TabTools_StepCalculator(object):
|
||||
self.formLayout_2 = QFormLayout(self.groupBox)
|
||||
self.formLayout_2.setObjectName(u"formLayout_2")
|
||||
self.formLayout_2.setLabelAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
|
||||
self.label_2 = QLabel(self.groupBox)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
|
||||
self.formLayout_2.setWidget(0, QFormLayout.LabelRole, self.label_2)
|
||||
|
||||
self.calculate_toStep_playResultSpinBox = QDoubleSpinBox(self.groupBox)
|
||||
self.calculate_toStep_playResultSpinBox.setObjectName(u"calculate_toStep_playResultSpinBox")
|
||||
sizePolicy2.setHeightForWidth(self.calculate_toStep_playResultSpinBox.sizePolicy().hasHeightForWidth())
|
||||
@ -298,10 +303,10 @@ class Ui_TabTools_StepCalculator(object):
|
||||
|
||||
self.formLayout_2.setWidget(0, QFormLayout.FieldRole, self.calculate_toStep_playResultSpinBox)
|
||||
|
||||
self.label_2 = QLabel(self.groupBox)
|
||||
self.label_2.setObjectName(u"label_2")
|
||||
self.calculate_toStep_calculatePlayResultFromScoreButton = QPushButton(self.groupBox)
|
||||
self.calculate_toStep_calculatePlayResultFromScoreButton.setObjectName(u"calculate_toStep_calculatePlayResultFromScoreButton")
|
||||
|
||||
self.formLayout_2.setWidget(0, QFormLayout.LabelRole, self.label_2)
|
||||
self.formLayout_2.setWidget(1, QFormLayout.FieldRole, self.calculate_toStep_calculatePlayResultFromScoreButton)
|
||||
|
||||
self.label_7 = QLabel(self.groupBox)
|
||||
self.label_7.setObjectName(u"label_7")
|
||||
@ -310,18 +315,28 @@ class Ui_TabTools_StepCalculator(object):
|
||||
|
||||
self.formLayout_2.setWidget(2, QFormLayout.LabelRole, self.label_7)
|
||||
|
||||
self.verticalLayout_9 = QVBoxLayout()
|
||||
self.verticalLayout_9.setObjectName(u"verticalLayout_9")
|
||||
self.calculate_toStep_resultLabel = QLabel(self.groupBox)
|
||||
self.calculate_toStep_resultLabel.setObjectName(u"calculate_toStep_resultLabel")
|
||||
sizePolicy4.setHeightForWidth(self.calculate_toStep_resultLabel.sizePolicy().hasHeightForWidth())
|
||||
self.calculate_toStep_resultLabel.setSizePolicy(sizePolicy4)
|
||||
self.calculate_toStep_resultLabel.setText(u"...")
|
||||
self.calculate_toStep_resultLabel.setAlignment(Qt.AlignBottom|Qt.AlignLeading|Qt.AlignLeft)
|
||||
|
||||
self.formLayout_2.setWidget(2, QFormLayout.FieldRole, self.calculate_toStep_resultLabel)
|
||||
self.verticalLayout_9.addWidget(self.calculate_toStep_resultLabel)
|
||||
|
||||
self.calculate_toStep_calculatePlayResultFromScoreButton = QPushButton(self.groupBox)
|
||||
self.calculate_toStep_calculatePlayResultFromScoreButton.setObjectName(u"calculate_toStep_calculatePlayResultFromScoreButton")
|
||||
self.calculate_toStep_detailedResultLabel = QLabel(self.groupBox)
|
||||
self.calculate_toStep_detailedResultLabel.setObjectName(u"calculate_toStep_detailedResultLabel")
|
||||
font = QFont()
|
||||
font.setPointSize(8)
|
||||
self.calculate_toStep_detailedResultLabel.setFont(font)
|
||||
self.calculate_toStep_detailedResultLabel.setStyleSheet(u"QLabel { color: gray; }")
|
||||
self.calculate_toStep_detailedResultLabel.setText(u"...")
|
||||
self.calculate_toStep_detailedResultLabel.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
|
||||
|
||||
self.formLayout_2.setWidget(1, QFormLayout.FieldRole, self.calculate_toStep_calculatePlayResultFromScoreButton)
|
||||
self.verticalLayout_9.addWidget(self.calculate_toStep_detailedResultLabel)
|
||||
|
||||
|
||||
self.formLayout_2.setLayout(2, QFormLayout.FieldRole, self.verticalLayout_9)
|
||||
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.groupBox)
|
||||
@ -350,13 +365,26 @@ class Ui_TabTools_StepCalculator(object):
|
||||
|
||||
self.formLayout_3.setWidget(1, QFormLayout.LabelRole, self.label_9)
|
||||
|
||||
self.verticalLayout_10 = QVBoxLayout()
|
||||
self.verticalLayout_10.setObjectName(u"verticalLayout_10")
|
||||
self.calculate_fromStep_resultLabel = QLabel(self.groupBox_2)
|
||||
self.calculate_fromStep_resultLabel.setObjectName(u"calculate_fromStep_resultLabel")
|
||||
sizePolicy4.setHeightForWidth(self.calculate_fromStep_resultLabel.sizePolicy().hasHeightForWidth())
|
||||
self.calculate_fromStep_resultLabel.setSizePolicy(sizePolicy4)
|
||||
self.calculate_fromStep_resultLabel.setText(u"...")
|
||||
self.calculate_fromStep_resultLabel.setAlignment(Qt.AlignBottom|Qt.AlignLeading|Qt.AlignLeft)
|
||||
|
||||
self.formLayout_3.setWidget(1, QFormLayout.FieldRole, self.calculate_fromStep_resultLabel)
|
||||
self.verticalLayout_10.addWidget(self.calculate_fromStep_resultLabel)
|
||||
|
||||
self.calculate_fromStep_detailedResultLabel = QLabel(self.groupBox_2)
|
||||
self.calculate_fromStep_detailedResultLabel.setObjectName(u"calculate_fromStep_detailedResultLabel")
|
||||
self.calculate_fromStep_detailedResultLabel.setFont(font)
|
||||
self.calculate_fromStep_detailedResultLabel.setStyleSheet(u"QLabel { color: gray; }")
|
||||
self.calculate_fromStep_detailedResultLabel.setText(u"...")
|
||||
self.calculate_fromStep_detailedResultLabel.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
|
||||
|
||||
self.verticalLayout_10.addWidget(self.calculate_fromStep_detailedResultLabel)
|
||||
|
||||
|
||||
self.formLayout_3.setLayout(1, QFormLayout.FieldRole, self.verticalLayout_10)
|
||||
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.groupBox_2)
|
||||
@ -394,8 +422,8 @@ class Ui_TabTools_StepCalculator(object):
|
||||
self.partnerSkillPresetButton_maya.setText(QCoreApplication.translate("TabTools_StepCalculator", u"partner.skill.presets.maya", None))
|
||||
self.groupBox.setTitle(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.toStep", None))
|
||||
self.label_2.setText(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.toStep.playResultLabel", None))
|
||||
self.label_7.setText(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.toStep.resultLabel", None))
|
||||
self.calculate_toStep_calculatePlayResultFromScoreButton.setText(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.toStep.calculatePlayResultFromScoreButton", None))
|
||||
self.label_7.setText(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.toStep.resultLabel", None))
|
||||
self.groupBox_2.setTitle(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.fromStep", None))
|
||||
self.label_4.setText(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.fromStep.targetStepLabel", None))
|
||||
self.label_9.setText(QCoreApplication.translate("TabTools_StepCalculator", u"calculate.fromStep.resultLabel", None))
|
||||
|
@ -1,6 +1,5 @@
|
||||
import logging
|
||||
|
||||
from arcaea_offline.calculate import calculate_play_rating
|
||||
from arcaea_offline.calculate.world_step import (
|
||||
AmaneBelowExPartnerBonus,
|
||||
AwakenedEtoPartnerBonus,
|
||||
@ -15,14 +14,22 @@ from arcaea_offline.calculate.world_step import (
|
||||
calculate_step,
|
||||
calculate_step_original,
|
||||
)
|
||||
from arcaea_offline.models import Chart, Score
|
||||
from PySide6.QtCore import QEasingCurve, QObject, QSize, Qt, QTimeLine
|
||||
from PySide6.QtGui import QIcon, QPainter, QPaintEvent, QPixmap
|
||||
from PySide6.QtCore import (
|
||||
QCoreApplication,
|
||||
QEasingCurve,
|
||||
QObject,
|
||||
QSize,
|
||||
QTimeLine,
|
||||
Signal,
|
||||
)
|
||||
from PySide6.QtGui import QIcon, QPixmap
|
||||
from PySide6.QtWidgets import (
|
||||
QAbstractButton,
|
||||
QButtonGroup,
|
||||
QDialog,
|
||||
QGraphicsColorizeEffect,
|
||||
QLabel,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
@ -30,26 +37,13 @@ from ui.designer.tabs.tabTools.tabTools_StepCalculator_ui import (
|
||||
Ui_TabTools_StepCalculator,
|
||||
)
|
||||
from ui.extends.shared.language import LanguageChangeEventFilter
|
||||
from ui.implements.components.chartAndScoreInput import ChartAndScoreInput
|
||||
from ui.implements.components.chartSelector import ChartSelector
|
||||
from ui.implements.components.playRatingCalculator import PlayRatingCalculator
|
||||
from ui.implements.components.songIdSelector import SongIdSelectorMode
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MapTypeListWidgetWidget(QLabel):
|
||||
def paintEvent(self, e: QPaintEvent) -> None:
|
||||
size = self.size()
|
||||
painter = QPainter(self)
|
||||
scaledPixmap = self.pixmap().scaled(
|
||||
size,
|
||||
Qt.AspectRatioMode.KeepAspectRatio,
|
||||
Qt.TransformationMode.SmoothTransformation,
|
||||
)
|
||||
x = (size.width() - scaledPixmap.width()) / 2
|
||||
y = (size.height() - scaledPixmap.height()) / 2
|
||||
painter.drawPixmap(x, y, scaledPixmap)
|
||||
|
||||
|
||||
class ButtonGrayscaleEffectApplier(QObject):
|
||||
def __init__(self, parent: QAbstractButton):
|
||||
super().__init__(parent)
|
||||
@ -79,11 +73,56 @@ class ButtonGrayscaleEffectApplier(QObject):
|
||||
target.setGraphicsEffect(effect)
|
||||
|
||||
|
||||
class ChartAndScoreInputDialog(ChartAndScoreInput):
|
||||
class PlayRatingCalculatorDialog(QDialog):
|
||||
accepted = Signal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setWindowFlag(Qt.WindowType.Dialog, True)
|
||||
self.setSongIdSelectorMode(SongIdSelectorMode.Chart)
|
||||
|
||||
self.verticalLayout = QVBoxLayout(self)
|
||||
|
||||
self.chartSelector = ChartSelector(self)
|
||||
self.chartSelector.setSongIdSelectorMode(SongIdSelectorMode.Chart)
|
||||
self.verticalLayout.addWidget(self.chartSelector)
|
||||
|
||||
self.playRatingCalculator = PlayRatingCalculator(self)
|
||||
self.verticalLayout.addWidget(self.playRatingCalculator)
|
||||
|
||||
self.acceptButton = QPushButton(self)
|
||||
self.acceptButton.setText(
|
||||
# fmt: off
|
||||
QCoreApplication.translate("StepCalculator", "playRatingCalculatorDialog.acceptButton")
|
||||
# fmt: on
|
||||
)
|
||||
self.acceptButton.setEnabled(False)
|
||||
self.verticalLayout.addWidget(self.acceptButton)
|
||||
|
||||
self.chartSelector.valueChanged.connect(self.updatePlayRatingCalculator)
|
||||
self.playRatingCalculator.arcaeaScoreLineEdit.textChanged.connect(
|
||||
self.updateAcceptButton
|
||||
)
|
||||
self.acceptButton.clicked.connect(self.accepted)
|
||||
|
||||
def updatePlayRatingCalculator(self):
|
||||
chart = self.chartSelector.value()
|
||||
if chart is None:
|
||||
self.playRatingCalculator.setConstant(None)
|
||||
else:
|
||||
self.playRatingCalculator.setConstant(chart.constant)
|
||||
self.updateAcceptButton()
|
||||
|
||||
def updateAcceptButton(self):
|
||||
if self.playRatingCalculator.result is None:
|
||||
self.acceptButton.setEnabled(False)
|
||||
else:
|
||||
self.acceptButton.setEnabled(True)
|
||||
|
||||
def reset(self):
|
||||
self.chartSelector.resetButton.click()
|
||||
self.playRatingCalculator.arcaeaScoreLineEdit.clear()
|
||||
|
||||
def value(self):
|
||||
return self.playRatingCalculator.result
|
||||
|
||||
|
||||
class TabTools_StepCalculator(Ui_TabTools_StepCalculator, QWidget):
|
||||
@ -203,23 +242,18 @@ class TabTools_StepCalculator(Ui_TabTools_StepCalculator, QWidget):
|
||||
)
|
||||
self.partnerSkillPresetButton_maya.clicked.connect(self.applyPartnerPreset)
|
||||
|
||||
def openChartAndScoreInputDialog(self):
|
||||
dialog = ChartAndScoreInputDialog(self)
|
||||
dialog.scoreCommited.connect(
|
||||
lambda: self.setPlayResultFromChartAndScoreInput(dialog)
|
||||
)
|
||||
dialog.show()
|
||||
self.playRatingCalculatorDialog = PlayRatingCalculatorDialog(self)
|
||||
self.playRatingCalculatorDialog.accepted.connect(self.set_toStep_PlayRating)
|
||||
|
||||
def setPlayResultFromChartAndScoreInput(self, dialog: ChartAndScoreInputDialog):
|
||||
if score := dialog.score():
|
||||
chart = dialog.chart()
|
||||
self.calculate_toStep_playResultSpinBox.setValue(
|
||||
float(calculate_play_rating(chart.constant, score.score))
|
||||
)
|
||||
dialog.close()
|
||||
dialog.deleteLater()
|
||||
else:
|
||||
return
|
||||
def openChartAndScoreInputDialog(self):
|
||||
self.playRatingCalculatorDialog.reset()
|
||||
self.playRatingCalculatorDialog.show()
|
||||
|
||||
def set_toStep_PlayRating(self):
|
||||
result = self.playRatingCalculatorDialog.value()
|
||||
if result is not None:
|
||||
self.calculate_toStep_playResultSpinBox.setValue(result)
|
||||
self.playRatingCalculatorDialog.close()
|
||||
|
||||
def applyPartnerPreset(self):
|
||||
if not self.sender():
|
||||
@ -307,7 +341,8 @@ class TabTools_StepCalculator(Ui_TabTools_StepCalculator, QWidget):
|
||||
step = calculate_step(
|
||||
playResult, partner_bonus=partnerBonus, step_booster=stepBooster
|
||||
)
|
||||
self.calculate_toStep_resultLabel.setText(f"{step}<br>({stepOriginal})")
|
||||
self.calculate_toStep_resultLabel.setText(str(step))
|
||||
self.calculate_toStep_detailedResultLabel.setText(str(stepOriginal))
|
||||
except Exception:
|
||||
if self.detailedLogOutputCheckBox.isChecked():
|
||||
logger.exception("Cannot calculate toStep")
|
||||
@ -315,16 +350,14 @@ class TabTools_StepCalculator(Ui_TabTools_StepCalculator, QWidget):
|
||||
|
||||
# fromStep
|
||||
try:
|
||||
self.calculate_fromStep_resultLabel.setText(
|
||||
str(
|
||||
calculate_play_rating_from_step(
|
||||
self.calculate_fromStep_targetStepSpinBox.value(),
|
||||
self.partnerStepValueSpinBox.value(),
|
||||
partner_bonus=partnerBonus,
|
||||
step_booster=stepBooster,
|
||||
)
|
||||
)
|
||||
fromStepResult = calculate_play_rating_from_step(
|
||||
self.calculate_fromStep_targetStepSpinBox.value(),
|
||||
self.partnerStepValueSpinBox.value(),
|
||||
partner_bonus=partnerBonus,
|
||||
step_booster=stepBooster,
|
||||
)
|
||||
self.calculate_fromStep_resultLabel.setText(str(round(fromStepResult, 2)))
|
||||
self.calculate_fromStep_detailedResultLabel.setText(str(fromStepResult))
|
||||
except Exception:
|
||||
if self.detailedLogOutputCheckBox.isChecked():
|
||||
logger.exception("Cannot calculate fromStep")
|
||||
|
Loading…
x
Reference in New Issue
Block a user