yuzu-qt: Track play time
This commit is contained in:
parent
6c4abd23be
commit
5464423667
15 changed files with 334 additions and 0 deletions
|
@ -146,6 +146,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
|||
#include "yuzu/install_dialog.h"
|
||||
#include "yuzu/loading_screen.h"
|
||||
#include "yuzu/main.h"
|
||||
#include "yuzu/play_time.h"
|
||||
#include "yuzu/startup_checks.h"
|
||||
#include "yuzu/uisettings.h"
|
||||
#include "yuzu/util/clickable_label.h"
|
||||
|
@ -334,6 +335,8 @@ GMainWindow::GMainWindow(std::unique_ptr<Config> config_, bool has_broken_vulkan
|
|||
SetDiscordEnabled(UISettings::values.enable_discord_presence.GetValue());
|
||||
discord_rpc->Update();
|
||||
|
||||
play_time_manager = std::make_unique<PlayTime::PlayTimeManager>();
|
||||
|
||||
system->GetRoomNetwork().Init();
|
||||
|
||||
RegisterMetaTypes();
|
||||
|
@ -1446,6 +1449,8 @@ void GMainWindow::ConnectWidgetEvents() {
|
|||
connect(game_list, &GameList::RemoveInstalledEntryRequested, this,
|
||||
&GMainWindow::OnGameListRemoveInstalledEntry);
|
||||
connect(game_list, &GameList::RemoveFileRequested, this, &GMainWindow::OnGameListRemoveFile);
|
||||
connect(game_list, &GameList::RemovePlayTimeRequested, this,
|
||||
&GMainWindow::OnGameListRemovePlayTimeData);
|
||||
connect(game_list, &GameList::DumpRomFSRequested, this, &GMainWindow::OnGameListDumpRomFS);
|
||||
connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID);
|
||||
connect(game_list, &GameList::NavigateToGamedbEntryRequested, this,
|
||||
|
@ -2458,6 +2463,20 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
|
|||
}
|
||||
}
|
||||
|
||||
void GMainWindow::OnGameListRemovePlayTimeData(u64 program_id) {
|
||||
if (QMessageBox::question(this, tr("Remove Play Time Data"), tr("Reset play time?"),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::No) != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
if (!play_time_manager->ResetProgramPlayTime(program_id)) {
|
||||
QMessageBox::warning(this, tr("Error Resetting Play Time Data"),
|
||||
tr("Play time couldn't be cleared"));
|
||||
return;
|
||||
}
|
||||
game_list->PopulateAsync(UISettings::values.game_dirs);
|
||||
}
|
||||
|
||||
void GMainWindow::RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target) {
|
||||
const auto target_file_name = [target] {
|
||||
switch (target) {
|
||||
|
@ -3230,6 +3249,9 @@ void GMainWindow::OnStartGame() {
|
|||
UpdateMenuState();
|
||||
OnTasStateChanged();
|
||||
|
||||
play_time_manager->SetProgramId(system->GetApplicationProcessProgramID());
|
||||
play_time_manager->Start();
|
||||
|
||||
discord_rpc->Update();
|
||||
}
|
||||
|
||||
|
@ -3245,6 +3267,7 @@ void GMainWindow::OnRestartGame() {
|
|||
|
||||
void GMainWindow::OnPauseGame() {
|
||||
emu_thread->SetRunning(false);
|
||||
play_time_manager->Stop();
|
||||
UpdateMenuState();
|
||||
AllowOSSleep();
|
||||
}
|
||||
|
@ -3265,6 +3288,9 @@ void GMainWindow::OnStopGame() {
|
|||
return;
|
||||
}
|
||||
|
||||
play_time_manager->Stop();
|
||||
// Update game list to show new play time
|
||||
game_list->PopulateAsync(UISettings::values.game_dirs);
|
||||
if (OnShutdownBegin()) {
|
||||
OnShutdownBeginDialog();
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue