mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-03 16:02:26 +00:00
queue to handle multiple trophies at once
This commit is contained in:
parent
6dc8ef3f70
commit
794770f94e
@ -588,7 +588,7 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr
|
|||||||
it->attribute("unlockstate").set_value("unlocked");
|
it->attribute("unlockstate").set_value("unlocked");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_trophy_ui = TrophyUI(trophyId, currentTrophyName, TrophyType::BRONZE);
|
g_trophy_ui.AddTrophyToQueue(trophyId, currentTrophyName, TrophyType::BRONZE);
|
||||||
|
|
||||||
//doc.save_file((trophyDir.string() + "\\trophy00\\Xml\\TROP.XML").c_str());
|
//doc.save_file((trophyDir.string() + "\\trophy00\\Xml\\TROP.XML").c_str());
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
#include <chrono>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "imgui/imgui_std.h"
|
#include "imgui/imgui_std.h"
|
||||||
#include "trophy_ui.h"
|
#include "trophy_ui.h"
|
||||||
@ -9,12 +10,6 @@
|
|||||||
using namespace ImGui;
|
using namespace ImGui;
|
||||||
using namespace Libraries::NpTrophy;
|
using namespace Libraries::NpTrophy;
|
||||||
|
|
||||||
TrophyUI::TrophyUI(int trophyId, std::string trophyName, TrophyType trophyType)
|
|
||||||
: trophyId(trophyId), trophyName(trophyName), trophyType(trophyType) {
|
|
||||||
first_render = true;
|
|
||||||
AddLayer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrophyUI::TrophyUI() {
|
TrophyUI::TrophyUI() {
|
||||||
first_render = true;
|
first_render = true;
|
||||||
AddLayer(this);
|
AddLayer(this);
|
||||||
@ -25,10 +20,22 @@ TrophyUI::~TrophyUI() {
|
|||||||
Finish();
|
Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Libraries::NpTrophy::TrophyUI::AddTrophyToQueue(int trophyId, std::string trophyName,
|
||||||
|
TrophyType trophyType) {
|
||||||
|
TrophyInfo newInfo;
|
||||||
|
newInfo.trophyId = trophyId;
|
||||||
|
newInfo.trophyName = trophyName;
|
||||||
|
newInfo.trophyType = trophyType;
|
||||||
|
trophyQueue.push_back(newInfo);
|
||||||
|
}
|
||||||
|
|
||||||
void TrophyUI::Finish() {
|
void TrophyUI::Finish() {
|
||||||
RemoveLayer(this);
|
RemoveLayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool displayingTrophy;
|
||||||
|
std::chrono::steady_clock::time_point trophyStartedTime;
|
||||||
|
|
||||||
void TrophyUI::Draw() {
|
void TrophyUI::Draw() {
|
||||||
const auto& io = GetIO();
|
const auto& io = GetIO();
|
||||||
|
|
||||||
@ -45,13 +52,30 @@ void TrophyUI::Draw() {
|
|||||||
PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
||||||
KeepNavHighlight();
|
KeepNavHighlight();
|
||||||
|
|
||||||
if (trophyId != -1) {
|
if (trophyQueue.size() != 0) {
|
||||||
if (Begin("Trophy Window", nullptr,
|
if (!displayingTrophy) {
|
||||||
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) {
|
displayingTrophy = true;
|
||||||
Text("Trophy earned!");
|
trophyStartedTime = std::chrono::steady_clock::now();
|
||||||
Text(trophyName.c_str());
|
}
|
||||||
|
|
||||||
End();
|
std::chrono::steady_clock::time_point timeNow = std::chrono::steady_clock::now();
|
||||||
|
std::chrono::seconds duration =
|
||||||
|
std::chrono::duration_cast<std::chrono::seconds>(timeNow - trophyStartedTime);
|
||||||
|
|
||||||
|
if (duration.count() >= 5) {
|
||||||
|
trophyQueue.erase(trophyQueue.begin());
|
||||||
|
displayingTrophy = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trophyQueue.size() != 0) {
|
||||||
|
TrophyInfo currentTrophyInfo = trophyQueue[0];
|
||||||
|
if (Begin("Trophy Window", nullptr,
|
||||||
|
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) {
|
||||||
|
Text("Trophy earned!");
|
||||||
|
Text(currentTrophyInfo.trophyName.c_str());
|
||||||
|
|
||||||
|
End();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "common/fixed_value.h"
|
#include "common/fixed_value.h"
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
@ -20,19 +22,22 @@ enum TrophyType {
|
|||||||
BRONZE,
|
BRONZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
class TrophyUI final : public ImGui::Layer {
|
struct TrophyInfo {
|
||||||
bool first_render{false};
|
|
||||||
|
|
||||||
int trophyId = -1;
|
int trophyId = -1;
|
||||||
std::string trophyName;
|
std::string trophyName;
|
||||||
std::string trophyDescription;
|
|
||||||
TrophyType trophyType;
|
TrophyType trophyType;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TrophyUI final : public ImGui::Layer {
|
||||||
|
bool first_render{false};
|
||||||
|
std::vector<TrophyInfo> trophyQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TrophyUI(int trophyId, std::string trophyName, TrophyType trophyType);
|
|
||||||
TrophyUI();
|
TrophyUI();
|
||||||
~TrophyUI() override;
|
~TrophyUI() override;
|
||||||
|
|
||||||
|
void AddTrophyToQueue(int trophyId, std::string trophyName, TrophyType trophyType);
|
||||||
|
|
||||||
void Finish();
|
void Finish();
|
||||||
|
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user