-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "Common/IniFile.h" | ||
#include "Common/FileUtil.h" | ||
#include "TimePlayed.h" | ||
|
||
TimePlayed::TimePlayed(std::string game_id) | ||
{ | ||
m_game_id = game_id; | ||
} | ||
|
||
void TimePlayed::AddTime(u64 time_emulated) | ||
{ | ||
IniFile ini; | ||
std::string ini_path = File::GetUserPath(D_CONFIG_IDX) + "TimePlayed.ini"; | ||
ini.Load(ini_path); | ||
|
||
auto time_list = ini.GetOrCreateSection("Time Played"); | ||
int previous_time = 0; | ||
|
||
time_list->Get(m_game_id, &previous_time); | ||
time_list->Set(m_game_id, previous_time + int(time_emulated)); //unlikely u64 to int conversion issue | ||
ini.Save(ini_path); | ||
} | ||
|
||
int TimePlayed::GetTimePlayed() | ||
{ | ||
IniFile ini; | ||
std::string ini_path = File::GetUserPath(D_CONFIG_IDX) + "TimePlayed.ini"; | ||
ini.Load(ini_path); | ||
|
||
auto time_list = ini.GetOrCreateSection("Time Played"); | ||
int previous_time; | ||
time_list->Get(m_game_id, &previous_time); | ||
return previous_time; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
#include "Common/CommonTypes.h" | ||
|
||
class TimePlayed | ||
{ | ||
public: | ||
TimePlayed(std::string game_id); | ||
|
||
void AddTime(u64 time_emulated); | ||
|
||
int GetTimePlayed(); | ||
|
||
private: | ||
std::string m_game_id; | ||
}; |