mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-28 22:30:11 +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)
|
std::time_t GameList::GetCachedPlayedTimeForSerial(const std::string& serial)
|
||||||
{
|
{
|
||||||
if (serial.empty())
|
if (serial.empty())
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
class ProgressCallback;
|
class ProgressCallback;
|
||||||
|
|
||||||
struct SystemBootParameters;
|
|
||||||
|
|
||||||
namespace GameList {
|
namespace GameList {
|
||||||
enum class EntryType : u8
|
enum class EntryType : u8
|
||||||
{
|
{
|
||||||
@ -116,8 +114,13 @@ EntryList TakeEntryList();
|
|||||||
|
|
||||||
/// Add played time for the specified serial.
|
/// Add played time for the specified serial.
|
||||||
void AddPlayedTimeForSerial(const std::string& serial, std::time_t last_time, std::time_t add_time);
|
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);
|
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.
|
/// 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);
|
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);
|
u32 num_unlocked_hardcore);
|
||||||
void UpdateAllAchievementData();
|
void UpdateAllAchievementData();
|
||||||
|
|
||||||
}; // namespace GameList
|
} // namespace GameList
|
||||||
|
|
||||||
namespace Host {
|
namespace Host {
|
||||||
/// Asynchronously starts refreshing the game list.
|
/// Asynchronously starts refreshing the game list.
|
||||||
|
@ -1047,7 +1047,7 @@ void MainWindow::onCheatsMenuAboutToShow()
|
|||||||
const GameList::Entry* MainWindow::resolveDiscSetEntry(const GameList::Entry* entry,
|
const GameList::Entry* MainWindow::resolveDiscSetEntry(const GameList::Entry* entry,
|
||||||
std::unique_lock<std::recursive_mutex>& lock)
|
std::unique_lock<std::recursive_mutex>& lock)
|
||||||
{
|
{
|
||||||
if (!entry || entry->type != GameList::EntryType::DiscSet)
|
if (!entry || !entry->IsDiscSet())
|
||||||
return entry;
|
return entry;
|
||||||
|
|
||||||
// disc set... need to figure out the disc we want
|
// disc set... need to figure out the disc we want
|
||||||
@ -1523,14 +1523,6 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point)
|
|||||||
switchToEmulationView();
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -1555,12 +1547,15 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point)
|
|||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
connect(menu.addAction(tr("Select Disc")), &QAction::triggered, this, &MainWindow::onGameListEntryActivated);
|
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();
|
menu.addSeparator();
|
||||||
@ -1628,7 +1623,7 @@ void MainWindow::clearGameListEntryPlayTime(const GameList::Entry* entry)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList::ClearPlayedTimeForSerial(entry->serial);
|
GameList::ClearPlayedTimeForEntry(entry);
|
||||||
m_game_list_widget->refresh(false);
|
m_game_list_widget->refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user