mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-21 10:10:17 +00:00
feat: insert score when no chart data
This commit is contained in:
parent
716e872f08
commit
4a8bae414b
@ -39,6 +39,9 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -206,6 +209,9 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -287,6 +293,9 @@
|
|||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -336,6 +345,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="12" column="0">
|
||||||
|
<widget class="QCheckBox" name="warnIfIncompleteCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>warnIfIncomplete</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
@ -44,6 +44,7 @@ class Ui_ScoreEditor(object):
|
|||||||
self.pureSpinBox = QSpinBox(ScoreEditor)
|
self.pureSpinBox = QSpinBox(ScoreEditor)
|
||||||
self.pureSpinBox.setObjectName(u"pureSpinBox")
|
self.pureSpinBox.setObjectName(u"pureSpinBox")
|
||||||
self.pureSpinBox.setMinimumSize(QSize(100, 0))
|
self.pureSpinBox.setMinimumSize(QSize(100, 0))
|
||||||
|
self.pureSpinBox.setMinimum(0)
|
||||||
self.pureSpinBox.setMaximum(0)
|
self.pureSpinBox.setMaximum(0)
|
||||||
|
|
||||||
self.gridLayout.addWidget(self.pureSpinBox, 2, 1, 1, 1)
|
self.gridLayout.addWidget(self.pureSpinBox, 2, 1, 1, 1)
|
||||||
@ -148,6 +149,7 @@ class Ui_ScoreEditor(object):
|
|||||||
self.lostSpinBox = QSpinBox(ScoreEditor)
|
self.lostSpinBox = QSpinBox(ScoreEditor)
|
||||||
self.lostSpinBox.setObjectName(u"lostSpinBox")
|
self.lostSpinBox.setObjectName(u"lostSpinBox")
|
||||||
self.lostSpinBox.setMinimumSize(QSize(100, 0))
|
self.lostSpinBox.setMinimumSize(QSize(100, 0))
|
||||||
|
self.lostSpinBox.setMinimum(0)
|
||||||
self.lostSpinBox.setMaximum(0)
|
self.lostSpinBox.setMaximum(0)
|
||||||
|
|
||||||
self.gridLayout.addWidget(self.lostSpinBox, 4, 1, 1, 1)
|
self.gridLayout.addWidget(self.lostSpinBox, 4, 1, 1, 1)
|
||||||
@ -201,6 +203,7 @@ class Ui_ScoreEditor(object):
|
|||||||
self.farSpinBox = QSpinBox(ScoreEditor)
|
self.farSpinBox = QSpinBox(ScoreEditor)
|
||||||
self.farSpinBox.setObjectName(u"farSpinBox")
|
self.farSpinBox.setObjectName(u"farSpinBox")
|
||||||
self.farSpinBox.setMinimumSize(QSize(100, 0))
|
self.farSpinBox.setMinimumSize(QSize(100, 0))
|
||||||
|
self.farSpinBox.setMinimum(0)
|
||||||
self.farSpinBox.setMaximum(0)
|
self.farSpinBox.setMaximum(0)
|
||||||
|
|
||||||
self.gridLayout.addWidget(self.farSpinBox, 3, 1, 1, 1)
|
self.gridLayout.addWidget(self.farSpinBox, 3, 1, 1, 1)
|
||||||
@ -234,6 +237,11 @@ class Ui_ScoreEditor(object):
|
|||||||
|
|
||||||
self.gridLayout.addWidget(self.idLabel, 0, 1, 1, 1)
|
self.gridLayout.addWidget(self.idLabel, 0, 1, 1, 1)
|
||||||
|
|
||||||
|
self.warnIfIncompleteCheckBox = QCheckBox(ScoreEditor)
|
||||||
|
self.warnIfIncompleteCheckBox.setObjectName(u"warnIfIncompleteCheckBox")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.warnIfIncompleteCheckBox, 12, 0, 1, 1)
|
||||||
|
|
||||||
QWidget.setTabOrder(self.scoreLineEdit, self.pureSpinBox)
|
QWidget.setTabOrder(self.scoreLineEdit, self.pureSpinBox)
|
||||||
QWidget.setTabOrder(self.pureSpinBox, self.pureNoneCheckBox)
|
QWidget.setTabOrder(self.pureSpinBox, self.pureNoneCheckBox)
|
||||||
QWidget.setTabOrder(self.pureNoneCheckBox, self.farSpinBox)
|
QWidget.setTabOrder(self.pureNoneCheckBox, self.farSpinBox)
|
||||||
@ -279,6 +287,7 @@ class Ui_ScoreEditor(object):
|
|||||||
self.label.setText(QCoreApplication.translate("ScoreEditor", u"formLabel.score", None))
|
self.label.setText(QCoreApplication.translate("ScoreEditor", u"formLabel.score", None))
|
||||||
self.farNoneCheckBox.setText(QCoreApplication.translate("ScoreEditor", u"setNone", None))
|
self.farNoneCheckBox.setText(QCoreApplication.translate("ScoreEditor", u"setNone", None))
|
||||||
self.idLabel.setText(QCoreApplication.translate("ScoreEditor", u"idAutoInsert", None))
|
self.idLabel.setText(QCoreApplication.translate("ScoreEditor", u"idAutoInsert", None))
|
||||||
|
self.warnIfIncompleteCheckBox.setText(QCoreApplication.translate("ScoreEditor", u"warnIfIncomplete", None))
|
||||||
pass
|
pass
|
||||||
# retranslateUi
|
# retranslateUi
|
||||||
|
|
||||||
|
@ -45,7 +45,14 @@ class ChartSelector(Ui_ChartSelector, QWidget):
|
|||||||
ratingClass = self.ratingClassSelector.value()
|
ratingClass = self.ratingClassSelector.value()
|
||||||
|
|
||||||
if songId and isinstance(ratingClass, int):
|
if songId and isinstance(ratingClass, int):
|
||||||
return self.db.get_chart(songId, ratingClass)
|
result = self.db.get_chart(songId, ratingClass)
|
||||||
|
if result is None and self.songIdSelector.mode == SongIdSelectorMode.SongId:
|
||||||
|
return Chart(
|
||||||
|
song_id=songId,
|
||||||
|
rating_class=ratingClass,
|
||||||
|
set=self.songIdSelector.packId(),
|
||||||
|
)
|
||||||
|
return result
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def updateDatabase(self):
|
def updateDatabase(self):
|
||||||
@ -62,7 +69,9 @@ class ChartSelector(Ui_ChartSelector, QWidget):
|
|||||||
def updateResultLabel(self):
|
def updateResultLabel(self):
|
||||||
chart = self.value()
|
chart = self.value()
|
||||||
if isinstance(chart, Chart):
|
if isinstance(chart, Chart):
|
||||||
|
if chart.constant is not None:
|
||||||
pack = self.db.get_pack(chart.set)
|
pack = self.db.get_pack(chart.set)
|
||||||
|
|
||||||
texts = [
|
texts = [
|
||||||
[
|
[
|
||||||
pack.name,
|
pack.name,
|
||||||
@ -75,6 +84,8 @@ class ChartSelector(Ui_ChartSelector, QWidget):
|
|||||||
]
|
]
|
||||||
texts = [" | ".join(t) for t in texts]
|
texts = [" | ".join(t) for t in texts]
|
||||||
text = f'{texts[0]}<br><font color="gray">{texts[1]}</font>'
|
text = f'{texts[0]}<br><font color="gray">{texts[1]}</font>'
|
||||||
|
else:
|
||||||
|
text = f'No chart data<br><font color="gray">{chart.set} | {chart.song_id} | {chart.rating_class}</font>'
|
||||||
self.resultLabel.setText(text)
|
self.resultLabel.setText(text)
|
||||||
else:
|
else:
|
||||||
self.resultLabel.setText("...")
|
self.resultLabel.setText("...")
|
||||||
|
@ -17,12 +17,13 @@ from PySide6.QtWidgets import (
|
|||||||
from ui.designer.components.scoreEditor_ui import Ui_ScoreEditor
|
from ui.designer.components.scoreEditor_ui import Ui_ScoreEditor
|
||||||
from ui.extends.shared.language import LanguageChangeEventFilter
|
from ui.extends.shared.language import LanguageChangeEventFilter
|
||||||
|
|
||||||
|
# TODO: use bit flags
|
||||||
class ScoreValidateResult(IntEnum):
|
class ScoreValidateResult(IntEnum):
|
||||||
Ok = 0
|
Ok = 0
|
||||||
ScoreMismatch = 1
|
ScoreMismatch = 1
|
||||||
ScoreEmpty = 2
|
ScoreEmpty = 2
|
||||||
ChartInvalid = 50
|
ChartInvalid = 50
|
||||||
|
ChartIncomplete = 51
|
||||||
ScoreIncomplete = 100
|
ScoreIncomplete = 100
|
||||||
|
|
||||||
|
|
||||||
@ -38,6 +39,10 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
self.installEventFilter(self.languageChangeEventFilter)
|
self.installEventFilter(self.languageChangeEventFilter)
|
||||||
|
|
||||||
self.__validateBeforeAccept = True
|
self.__validateBeforeAccept = True
|
||||||
|
self.__warnIfIncomplete = True
|
||||||
|
self.warnIfIncompleteCheckBox.setChecked(self.__warnIfIncomplete)
|
||||||
|
self.warnIfIncompleteCheckBox.toggled.connect(self.setWarnIfIncomplete)
|
||||||
|
|
||||||
self.__chart = None
|
self.__chart = None
|
||||||
self.__score_id = None
|
self.__score_id = None
|
||||||
|
|
||||||
@ -75,13 +80,24 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
|
|
||||||
self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
|
self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
|
||||||
|
|
||||||
|
def validateBeforeAccept(self):
|
||||||
|
return self.__validateBeforeAccept
|
||||||
|
|
||||||
def setValidateBeforeAccept(self, __bool: bool):
|
def setValidateBeforeAccept(self, __bool: bool):
|
||||||
self.__validateBeforeAccept = __bool
|
self.__validateBeforeAccept = __bool
|
||||||
|
|
||||||
|
def warnIfIncomplete(self):
|
||||||
|
return self.__warnIfIncomplete
|
||||||
|
|
||||||
|
def setWarnIfIncomplete(self, __bool: bool):
|
||||||
|
if self.sender() != self.warnIfIncompleteCheckBox:
|
||||||
|
self.warnIfIncompleteCheckBox.setChecked(__bool)
|
||||||
|
self.__warnIfIncomplete = __bool
|
||||||
|
|
||||||
def triggerValidateMessageBox(self):
|
def triggerValidateMessageBox(self):
|
||||||
validate = self.validateScore()
|
validate = self.validateScore()
|
||||||
|
|
||||||
if validate in [ScoreValidateResult.Ok, ScoreValidateResult.ScoreIncomplete]:
|
if validate == ScoreValidateResult.Ok:
|
||||||
return True
|
return True
|
||||||
if validate == ScoreValidateResult.ChartInvalid:
|
if validate == ScoreValidateResult.ChartInvalid:
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
@ -92,6 +108,19 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
if validate == ScoreValidateResult.ChartIncomplete:
|
||||||
|
if not self.__warnIfIncomplete:
|
||||||
|
return True
|
||||||
|
result = QMessageBox.warning(
|
||||||
|
self,
|
||||||
|
# fmt: off
|
||||||
|
QCoreApplication.translate("ScoreEditor", "chartIncompleteDialog.title"),
|
||||||
|
QCoreApplication.translate("ScoreEditor", "chartIncompleteDialog.content"),
|
||||||
|
# fmt: on
|
||||||
|
QMessageBox.StandardButton.Yes,
|
||||||
|
QMessageBox.StandardButton.No,
|
||||||
|
)
|
||||||
|
return result == QMessageBox.StandardButton.Yes
|
||||||
if validate == ScoreValidateResult.ScoreMismatch:
|
if validate == ScoreValidateResult.ScoreMismatch:
|
||||||
result = QMessageBox.warning(
|
result = QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
@ -114,6 +143,19 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
QMessageBox.StandardButton.No,
|
QMessageBox.StandardButton.No,
|
||||||
)
|
)
|
||||||
return result == QMessageBox.StandardButton.Yes
|
return result == QMessageBox.StandardButton.Yes
|
||||||
|
elif validate == ScoreValidateResult.ScoreIncomplete:
|
||||||
|
if not self.__warnIfIncomplete:
|
||||||
|
return True
|
||||||
|
result = QMessageBox.warning(
|
||||||
|
self,
|
||||||
|
# fmt: off
|
||||||
|
QCoreApplication.translate("ScoreEditor", "scoreIncompleteDialog.title"),
|
||||||
|
QCoreApplication.translate("ScoreEditor", "scoreIncompleteDialog.content"),
|
||||||
|
# fmt: on
|
||||||
|
QMessageBox.StandardButton.Yes,
|
||||||
|
QMessageBox.StandardButton.No,
|
||||||
|
)
|
||||||
|
return result == QMessageBox.StandardButton.Yes
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -130,25 +172,20 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
score_text = self.scoreLineEdit.text().replace("'", "")
|
score_text = self.scoreLineEdit.text().replace("'", "")
|
||||||
return int(score_text) if score_text else 0
|
return int(score_text) if score_text else 0
|
||||||
|
|
||||||
def setMinimums(self):
|
def setComboBoxMaximums(self, max: int):
|
||||||
self.pureSpinBox.setMinimum(0)
|
self.pureSpinBox.setMaximum(max)
|
||||||
self.farSpinBox.setMinimum(0)
|
self.farSpinBox.setMaximum(max)
|
||||||
self.lostSpinBox.setMinimum(0)
|
self.lostSpinBox.setMaximum(max)
|
||||||
self.maxRecallSpinBox.setMinimum(-1)
|
self.maxRecallSpinBox.setMaximum(max)
|
||||||
|
|
||||||
def setLimits(self, chart: Chart):
|
def setLimits(self, chart: Chart):
|
||||||
self.setMinimums()
|
if not isinstance(chart, Chart) or chart.notes is None:
|
||||||
self.pureSpinBox.setMaximum(chart.notes)
|
self.setComboBoxMaximums(283375)
|
||||||
self.farSpinBox.setMaximum(chart.notes)
|
else:
|
||||||
self.lostSpinBox.setMaximum(chart.notes)
|
self.setComboBoxMaximums(chart.notes)
|
||||||
self.maxRecallSpinBox.setMaximum(chart.notes)
|
|
||||||
|
|
||||||
def resetLimits(self):
|
def resetLimits(self):
|
||||||
self.setMinimums()
|
self.setComboBoxMaximums(0)
|
||||||
self.pureSpinBox.setMaximum(0)
|
|
||||||
self.farSpinBox.setMaximum(0)
|
|
||||||
self.lostSpinBox.setMaximum(0)
|
|
||||||
self.maxRecallSpinBox.setMaximum(0)
|
|
||||||
|
|
||||||
def setChart(self, chart: Optional[Chart]):
|
def setChart(self, chart: Optional[Chart]):
|
||||||
if isinstance(chart, Chart):
|
if isinstance(chart, Chart):
|
||||||
@ -163,6 +200,9 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
if not isinstance(self.__chart, Chart):
|
if not isinstance(self.__chart, Chart):
|
||||||
return ScoreValidateResult.ChartInvalid
|
return ScoreValidateResult.ChartInvalid
|
||||||
|
|
||||||
|
if self.__chart.notes is None:
|
||||||
|
return ScoreValidateResult.ChartIncomplete
|
||||||
|
|
||||||
score = self.value()
|
score = self.value()
|
||||||
|
|
||||||
if score.pure is None or score.far is None:
|
if score.pure is None or score.far is None:
|
||||||
@ -184,6 +224,8 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
text = QCoreApplication.translate("ScoreEditor", "validate.ok")
|
text = QCoreApplication.translate("ScoreEditor", "validate.ok")
|
||||||
elif validate == ScoreValidateResult.ChartInvalid:
|
elif validate == ScoreValidateResult.ChartInvalid:
|
||||||
text = QCoreApplication.translate("ScoreEditor", "validate.chartInvalid")
|
text = QCoreApplication.translate("ScoreEditor", "validate.chartInvalid")
|
||||||
|
elif validate == ScoreValidateResult.ChartIncomplete:
|
||||||
|
text = QCoreApplication.translate("ScoreEditor", "validate.chartIncomple")
|
||||||
elif validate == ScoreValidateResult.ScoreMismatch:
|
elif validate == ScoreValidateResult.ScoreMismatch:
|
||||||
text = QCoreApplication.translate("ScoreEditor", "validate.scoreMismatch")
|
text = QCoreApplication.translate("ScoreEditor", "validate.scoreMismatch")
|
||||||
elif validate == ScoreValidateResult.ScoreEmpty:
|
elif validate == ScoreValidateResult.ScoreEmpty:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user