mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 17:53:42 +01:00
Fix time tracking during pause
This commit is contained in:
1 parent
b1bc6caaf6
commit
707670cfcf
6 files changed
+33
-6
No files matched your search
@@ -13,9 +13,9 @@
|
||||
|
||||
#include "Core/KeyMap.h"
|
||||
|
||||
void Screen::focusChanged(ScreenFocusChange change) {
|
||||
void Screen::focusChanged(ScreenFocusChange focusChange) {
|
||||
char *eventName = "";
|
||||
switch (change) {
|
||||
switch (focusChange) {
|
||||
case ScreenFocusChange::FOCUS_LOST_TOP: eventName = "FOCUS_LOST_TOP"; break;
|
||||
case ScreenFocusChange::FOCUS_BECAME_TOP: eventName = "FOCUS_BECAME_TOP"; break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public:
|
||||
virtual void deviceLost() {}
|
||||
virtual void deviceRestored() {}
|
||||
|
||||
virtual void focusChanged(ScreenFocusChange change);
|
||||
virtual void focusChanged(ScreenFocusChange focusChange);
|
||||
|
||||
// Return value of UnsyncTouch is only used to let the overlay screen block touches.
|
||||
virtual bool UnsyncTouch(const TouchInput &touch) = 0;
|
||||
|
||||
+7
-3
@@ -1837,14 +1837,17 @@ int Config::GetPSPLanguage() {
|
||||
}
|
||||
|
||||
void PlayTimeTracker::Start(std::string gameId) {
|
||||
INFO_LOG(SYSTEM, "GameTimeTracker::Start(%s)", gameId.c_str());
|
||||
if (gameId.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = tracker_.find(std::string(gameId));
|
||||
if (iter != tracker_.end()) {
|
||||
iter->second.lastTimePlayed = time_now_unix_utc();
|
||||
iter->second.startTime = time_now_d();
|
||||
if (iter->second.startTime == 0.0) {
|
||||
iter->second.lastTimePlayed = time_now_unix_utc();
|
||||
iter->second.startTime = time_now_d();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1856,15 +1859,16 @@ void PlayTimeTracker::Start(std::string gameId) {
|
||||
}
|
||||
|
||||
void PlayTimeTracker::Stop(std::string gameId) {
|
||||
INFO_LOG(SYSTEM, "GameTimeTracker::Stop(%s)", gameId.c_str());
|
||||
_dbg_assert_(!gameId.empty());
|
||||
|
||||
auto iter = tracker_.find(std::string(gameId));
|
||||
if (iter != tracker_.end()) {
|
||||
if (iter->second.startTime != 0.0) {
|
||||
iter->second.totalTimePlayed += time_now_d() - iter->second.startTime;
|
||||
iter->second.startTime = 0.0;
|
||||
}
|
||||
iter->second.lastTimePlayed = time_now_unix_utc();
|
||||
iter->second.startTime = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
uint64_t lastTimePlayed; // UTC Unix time for portability.
|
||||
};
|
||||
|
||||
// It's OK to call these redundantly.
|
||||
void Start(std::string gameId);
|
||||
void Stop(std::string gameId);
|
||||
|
||||
|
||||
@@ -468,6 +468,24 @@ static void AfterStateBoot(SaveState::Status status, const std::string &message,
|
||||
System_Notify(SystemNotification::DISASSEMBLY);
|
||||
}
|
||||
|
||||
void EmuScreen::focusChanged(ScreenFocusChange focusChange) {
|
||||
Screen::focusChanged(focusChange);
|
||||
|
||||
std::string gameID = g_paramSFO.GetValueString("DISC_ID");
|
||||
if (gameID.empty()) {
|
||||
// startup or shutdown
|
||||
return;
|
||||
}
|
||||
switch (focusChange) {
|
||||
case ScreenFocusChange::FOCUS_LOST_TOP:
|
||||
g_Config.TimeTracker().Stop(gameID);
|
||||
break;
|
||||
case ScreenFocusChange::FOCUS_BECAME_TOP:
|
||||
g_Config.TimeTracker().Start(gameID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EmuScreen::sendMessage(UIMessage message, const char *value) {
|
||||
// External commands, like from the Windows UI.
|
||||
if (message == UIMessage::REQUEST_GAME_PAUSE && screenManager()->topScreen() == this) {
|
||||
|
||||
@@ -58,6 +58,10 @@ public:
|
||||
// We also need to do some special handling of queued UI events to handle closing the chat window.
|
||||
bool key(const KeyInput &key) override;
|
||||
|
||||
protected:
|
||||
|
||||
void focusChanged(ScreenFocusChange focusChange) override;
|
||||
|
||||
private:
|
||||
void CreateViews() override;
|
||||
UI::EventReturn OnDevTools(UI::EventParams ¶ms);
|
||||
|
||||
Reference in new issue
Block a user