[core, android] Initial playtime implementation #2535

Merged
MaranBr merged 9 commits from kleidis/eden:playtime-android into master 2025-10-17 22:47:44 +02:00
Member

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.

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.
Author
Member

I am aware of the frontend_common rework, files can be moved once that's merged.

I am aware of the frontend_common rework, files can be moved once that's merged.
Owner

I would argue the playtime manager should be moved into frontend_common. A similar thing was done with the firmware manager

I would argue the playtime manager should be moved into frontend_common. A similar thing was done with the firmware manager
Owner

Also--qt_common is already merged so you can probably move that stuff to qt_common/qt_playtime_manager.*

Also--qt_common is already merged so you can probably move that stuff to `qt_common/qt_playtime_manager.*`
kleidis force-pushed playtime-android from d71814a68b
Some checks failed
eden-license / license-header (pull_request) Failing after 17s
to 4c7c2957ac
Some checks failed
eden-license / license-header (pull_request) Failing after 27s
2025-10-09 18:38:54 +02:00
Compare
kleidis changed title from WIP: [core, android] Initial playtime implementation to [core, android] Initial playtime implementation 2025-10-09 18:40:50 +02:00
Author
Member

Also--qt_common is already merged so you can probably move that stuff to qt_common/qt_playtime_manager.*

I moved the qt specific code there

> Also--qt_common is already merged so you can probably move that stuff to `qt_common/qt_playtime_manager.*` I moved the qt specific code there
crueter requested changes 2025-10-09 18:49:08 +02:00
Dismissed
@ -0,0 +37,4 @@
default:
return QStringLiteral("0");
}
}
Owner

In these cases I would recommend making them FrontendCommon methods that return std::strings. For the ReadablePlayTime you can use fmt::format like in my DataManager PR

In these cases I would recommend making them FrontendCommon methods that return std::strings. For the ReadablePlayTime you can use fmt::format like in my DataManager PR
crueter marked this conversation as resolved
@ -565,2 +564,4 @@
QAction* remove_shader_cache = remove_menu->addAction(tr("Remove All Pipeline Caches"));
QAction* remove_all_content = remove_menu->addAction(tr("Remove All Installed Contents"));
QMenu* play_time_menu = context_menu.addMenu(tr("Manage Play Time"));
QAction* set_play_time = play_time_menu->addAction(tr("Set Play Time Data"));
Owner

"Edit" would work better here

"Edit" would work better here
crueter marked this conversation as resolved
@ -2637,0 +2639,4 @@
void GMainWindow::OnGameListSetPlayTime(u64 program_id) {
QDialog dialog(this);
dialog.setWindowTitle(tr("Set Play Time Data"));
dialog.setModal(true);
Owner

We can probably make this a .ui file

We can probably make this a .ui file
crueter marked this conversation as resolved
@ -2637,0 +2645,4 @@
auto* input_layout = new QHBoxLayout();
auto* hours_edit = new QLineEdit(&dialog);
auto* minutes_edit = new QLineEdit(&dialog);
auto* seconds_edit = new QLineEdit(&dialog);
Owner

These can be spin boxes

These can be spin boxes
crueter marked this conversation as resolved
@ -2637,0 +2649,4 @@
hours_edit->setValidator(new QIntValidator(0, 9999, hours_edit));
minutes_edit->setValidator(new QIntValidator(0, 59, minutes_edit));
seconds_edit->setValidator(new QIntValidator(0, 59, seconds_edit));
Owner

And if we do go with QSpinBox you can just set the range and this won't be necessary

And if we do go with QSpinBox you can just set the range and this won't be necessary
crueter marked this conversation as resolved
@ -2637,0 +2651,4 @@
minutes_edit->setValidator(new QIntValidator(0, 59, minutes_edit));
seconds_edit->setValidator(new QIntValidator(0, 59, seconds_edit));
using QtCommon::PlayTimeManager::TimeUnit;
Owner

You can remove the TimeUnit and then QtCommon::PlayTimeManager::GetPlayTimeUnit can also be shortened

You can remove the TimeUnit and then `QtCommon::PlayTimeManager::GetPlayTimeUnit` can also be shortened
crueter marked this conversation as resolved
@ -2637,0 +2681,4 @@
connect(button_box, &QDialogButtonBox::accepted, [&]() {
const int hours = hours_edit->text().toInt();
const int minutes = minutes_edit->text().toInt();
const int seconds = seconds_edit->text().toInt();
Owner

Theoretically, this "should" be done as text is edited rather than as it's accepted.

Theoretically, this "should" be done as text is edited rather than as it's accepted.
crueter marked this conversation as resolved
crueter added this to the 0.0.4 (real) milestone 2025-10-10 02:45:54 +02:00
kleidis force-pushed playtime-android from 99f516e892
All checks were successful
eden-license / license-header (pull_request) Successful in 29s
to 57e3145ef9
All checks were successful
eden-license / license-header (pull_request) Successful in 29s
2025-10-16 02:04:01 +02:00
Compare
crueter approved these changes 2025-10-17 22:09:35 +02:00
Dismissed
CamilleLaVey approved these changes 2025-10-17 22:12:08 +02:00
Dismissed
Lizzie approved these changes 2025-10-17 22:14:06 +02:00
Dismissed
kleidis force-pushed playtime-android from 57e3145ef9
All checks were successful
eden-license / license-header (pull_request) Successful in 29s
to 2923711e65
All checks were successful
eden-license / license-header (pull_request) Successful in 26s
2025-10-17 22:26:59 +02:00
Compare
kleidis dismissed crueter's review 2025-10-17 22:26:59 +02:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

kleidis dismissed CamilleLaVey's review 2025-10-17 22:26:59 +02:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

kleidis dismissed Lizzie's review 2025-10-17 22:26:59 +02:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

crueter approved these changes 2025-10-17 22:27:49 +02:00
MaranBr approved these changes 2025-10-17 22:47:07 +02:00
MaranBr merged commit 6bdf479488 into master 2025-10-17 22:47:44 +02:00
Sign in to join this conversation.
No description provided.