mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-28 14:20:30 +00:00
Qt: Implement reset play time for disc sets
This commit is contained in:
parent
74838e9bd8
commit
2c7d07b245
@ -1487,6 +1487,42 @@ void GameList::ClearPlayedTimeForSerial(const std::string& serial)
|
||||
}
|
||||
}
|
||||
|
||||
void GameList::ClearPlayedTimeForEntry(const GameList::Entry* entry)
|
||||
{
|
||||
std::unique_lock lock(s_mutex);
|
||||
std::vector<std::string> serials;
|
||||
|
||||
if (entry->IsDiscSet())
|
||||
{
|
||||
for (const GameList::Entry* member : GetDiscSetMembers(entry->path))
|
||||
{
|
||||
if (!member->serial.empty())
|
||||
serials.push_back(member->serial);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!entry->serial.empty())
|
||||
serials.push_back(entry->serial);
|
||||
}
|
||||
|
||||
auto played_time_file = GetPlayedTimeFile();
|
||||
for (const auto& serial : serials)
|
||||
{
|
||||
VERBOSE_LOG("Resetting played time for {}", serial);
|
||||
UpdatePlayedTimeFile(played_time_file, serial, 0, 0);
|
||||
}
|
||||
|
||||
for (GameList::Entry& list_entry : s_entries)
|
||||
{
|
||||
if (std::find(serials.begin(), serials.end(), list_entry.serial) == serials.end())
|
||||
continue;
|
||||
|
||||
list_entry.last_played_time = 0;
|
||||
list_entry.total_played_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::time_t GameList::GetCachedPlayedTimeForSerial(const std::string& serial)
|
||||
{
|
||||
if (serial.empty())
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
class ProgressCallback;
|
||||
|
||||
struct SystemBootParameters;
|
||||
|
||||
namespace GameList {
|
||||
enum class EntryType : u8
|
||||
{
|
||||
@ -116,8 +114,13 @@ EntryList TakeEntryList();
|
||||
|
||||
/// Add played time for the specified serial.
|
||||
void AddPlayedTimeForSerial(const std::string& serial, std::time_t last_time, std::time_t add_time);
|
||||
|
||||
/// Resets played time for the specified serial to zero.
|
||||
void ClearPlayedTimeForSerial(const std::string& serial);
|
||||
|
||||
/// Resets played time for the specified entry to zero.
|
||||
void ClearPlayedTimeForEntry(const Entry* entry);
|
||||
|
||||
/// Returns the total time played for a game. Requires the game to be scanned in the list.
|
||||
std::time_t GetCachedPlayedTimeForSerial(const std::string& serial);
|
||||
|
||||
@ -160,7 +163,7 @@ void UpdateAchievementData(const std::span<u8, 16> hash, u32 game_id, u32 num_ac
|
||||
u32 num_unlocked_hardcore);
|
||||
void UpdateAllAchievementData();
|
||||
|
||||
}; // namespace GameList
|
||||
} // namespace GameList
|
||||
|
||||
namespace Host {
|
||||
/// Asynchronously starts refreshing the game list.
|
||||
|
@ -1047,7 +1047,7 @@ void MainWindow::onCheatsMenuAboutToShow()
|
||||
const GameList::Entry* MainWindow::resolveDiscSetEntry(const GameList::Entry* entry,
|
||||
std::unique_lock<std::recursive_mutex>& lock)
|
||||
{
|
||||
if (!entry || entry->type != GameList::EntryType::DiscSet)
|
||||
if (!entry || !entry->IsDiscSet())
|
||||
return entry;
|
||||
|
||||
// disc set... need to figure out the disc we want
|
||||
@ -1523,14 +1523,6 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point)
|
||||
switchToEmulationView();
|
||||
});
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
connect(menu.addAction(tr("Exclude From List")), &QAction::triggered,
|
||||
[this, entry]() { getSettingsWindow()->getGameListSettingsWidget()->addExcludedPath(entry->path); });
|
||||
|
||||
connect(menu.addAction(tr("Reset Play Time")), &QAction::triggered,
|
||||
[this, entry]() { clearGameListEntryPlayTime(entry); });
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1555,12 +1547,15 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point)
|
||||
menu.addSeparator();
|
||||
|
||||
connect(menu.addAction(tr("Select Disc")), &QAction::triggered, this, &MainWindow::onGameListEntryActivated);
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
connect(menu.addAction(tr("Exclude From List")), &QAction::triggered,
|
||||
[this, entry]() { getSettingsWindow()->getGameListSettingsWidget()->addExcludedPath(entry->path); });
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
connect(menu.addAction(tr("Exclude From List")), &QAction::triggered,
|
||||
[this, entry]() { getSettingsWindow()->getGameListSettingsWidget()->addExcludedPath(entry->path); });
|
||||
|
||||
connect(menu.addAction(tr("Reset Play Time")), &QAction::triggered,
|
||||
[this, entry]() { clearGameListEntryPlayTime(entry); });
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
@ -1628,7 +1623,7 @@ void MainWindow::clearGameListEntryPlayTime(const GameList::Entry* entry)
|
||||
return;
|
||||
}
|
||||
|
||||
GameList::ClearPlayedTimeForSerial(entry->serial);
|
||||
GameList::ClearPlayedTimeForEntry(entry);
|
||||
m_game_list_widget->refresh(false);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user