diff options
| author | inix <Nixy01@proton.me> | 2025-10-17 22:47:43 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2025-10-17 22:47:43 +0200 |
| commit | 6bdf479488dd87a35bf5ccf9ec334f49bf43ffc7 (patch) | |
| tree | 166376be36272e3177cc2fd474cc24c7eb9d1360 /src/yuzu/set_play_time_dialog.cpp | |
| parent | 9c7ed0f59dd41ec0bbbfbc81678209ae60a36016 (diff) | |
[core, android] Initial playtime implementation (#2535)
So firstly, playtime code is moved to src/common and qt specific code to yuzu/utils.cpp.
The dependency on ProfileManager was removed because it was working properly on Android, and I think a shared playtime is better behavior.
Now, playtime is stored in a file called "playtime.bin".
JNI code is from Azahar although modified by me, as well as that I added code to reset the game's playtime which was missing for some reason on there.
Before this gets merged, I plan to add the ability to manually edit the database as well.
Note: Code still needs a bit of cleanup.
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2535
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: Lizzie <lizzie@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Co-authored-by: inix <Nixy01@proton.me>
Co-committed-by: inix <Nixy01@proton.me>
Diffstat (limited to 'src/yuzu/set_play_time_dialog.cpp')
| -rw-r--r-- | src/yuzu/set_play_time_dialog.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/yuzu/set_play_time_dialog.cpp b/src/yuzu/set_play_time_dialog.cpp new file mode 100644 index 0000000000..c0f1f0be22 --- /dev/null +++ b/src/yuzu/set_play_time_dialog.cpp @@ -0,0 +1,49 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "yuzu/set_play_time_dialog.h" +#include "frontend_common/play_time_manager.h" +#include "ui_set_play_time_dialog.h" + +SetPlayTimeDialog::SetPlayTimeDialog(QWidget* parent, u64 current_play_time) + : QDialog(parent), ui{std::make_unique<Ui::SetPlayTimeDialog>()} { + ui->setupUi(this); + + ui->hoursSpinBox->setValue( + QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeHours(current_play_time)).toInt()); + ui->minutesSpinBox->setValue( + QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeMinutes(current_play_time)).toInt()); + ui->secondsSpinBox->setValue( + QString::fromStdString(PlayTime::PlayTimeManager::GetPlayTimeSeconds(current_play_time)).toInt()); + + connect(ui->hoursSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, + &SetPlayTimeDialog::OnValueChanged); + connect(ui->minutesSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, + &SetPlayTimeDialog::OnValueChanged); + connect(ui->secondsSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, + &SetPlayTimeDialog::OnValueChanged); +} + +SetPlayTimeDialog::~SetPlayTimeDialog() = default; + +u64 SetPlayTimeDialog::GetTotalSeconds() const { + const u64 hours = static_cast<u64>(ui->hoursSpinBox->value()); + const u64 minutes = static_cast<u64>(ui->minutesSpinBox->value()); + const u64 seconds = static_cast<u64>(ui->secondsSpinBox->value()); + + return hours * 3600 + minutes * 60 + seconds; +} + +void SetPlayTimeDialog::OnValueChanged() { + if (ui->errorLabel->isVisible()) { + ui->errorLabel->setVisible(false); + } + + const u64 total_seconds = GetTotalSeconds(); + constexpr u64 max_reasonable_time = 9999ULL * 3600; + + if (total_seconds > max_reasonable_time) { + ui->errorLabel->setText(tr("Total play time reached maximum.")); + ui->errorLabel->setVisible(true); + } +} |
