mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-05 13:29:33 -06:00

When you use TimePlayed, you have to provide a game ID either when creating the object or when calling GetTimePlayed on it. If you don't provide a game ID when creating the object, function calls that don't take a game ID will silently fail, except for Reload. This isn't very obvious, and there's no strong benefit to storing the game ID inside TimePlayed anyway (it just lets TimePlayed skip calling EscapeFileName), so this commit removes the TimePlayed constructor that takes a game ID and instead makes the functions that need game IDs always take a game ID argument.
36 lines
806 B
C++
36 lines
806 B
C++
// Copyright 2025 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <string>
|
|
|
|
#include "Common/CommonTypes.h"
|
|
#include "Common/IniFile.h"
|
|
|
|
class TimePlayed
|
|
{
|
|
public:
|
|
TimePlayed();
|
|
|
|
// not copyable due to the stored section pointer
|
|
TimePlayed(const TimePlayed& other) = delete;
|
|
TimePlayed(TimePlayed&& other) = delete;
|
|
TimePlayed& operator=(const TimePlayed& other) = delete;
|
|
TimePlayed& operator=(TimePlayed&& other) = delete;
|
|
|
|
~TimePlayed();
|
|
|
|
void AddTime(const std::string& game_id, std::chrono::milliseconds time_emulated);
|
|
|
|
std::chrono::milliseconds GetTimePlayed(const std::string& game_id) const;
|
|
|
|
void Reload();
|
|
|
|
private:
|
|
std::string m_ini_path;
|
|
Common::IniFile m_ini;
|
|
Common::IniFile::Section* m_time_list;
|
|
};
|