[core, android] Initial playtime implementation #2535

Open
inix wants to merge 10 commits from inix/eden:playtime-android into master
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.
inix added 1 commit 2025-09-20 08:10:16 +02:00
WIP: [core, android] Initial playtime implementation
Some checks failed
eden-license / license-header (pull_request) Failing after 17s
d71814a68b
JNI code is from Azahar although modified
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.*`
inix force-pushed playtime-android from d71814a68b to 4c7c2957ac 2025-10-09 18:38:54 +02:00 Compare
inix added 1 commit 2025-10-09 18:40:26 +02:00
license fix
Some checks failed
eden-license / license-header (pull_request) Failing after 25s
a4ac75d963
inix changed title from WIP: [core, android] Initial playtime implementation to [core, android] Initial playtime implementation 2025-10-09 18:40:50 +02:00
requested reviews from MaranBr, Lizzie, crueter, CamilleLaVey, Maufeat, MrPurple666 2025-10-09 18:40:51 +02:00
inix added 1 commit 2025-10-09 18:42:50 +02:00
frontend common license fix
All checks were successful
eden-license / license-header (pull_request) Successful in 24s
8c75831911
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
@ -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
inix added 3 commits 2025-10-10 07:01:18 +02:00
inix added 1 commit 2025-10-10 07:05:58 +02:00
Set -> Edit
All checks were successful
eden-license / license-header (pull_request) Successful in 29s
99f516e892
All checks were successful
eden-license / license-header (pull_request) Successful in 29s
Required
Details
This pull request doesn't have enough approvals yet. 0 of 2 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u playtime-android:inix-playtime-android
git checkout inix-playtime-android
Sign in to join this conversation.
No description provided.