Add a notifications mutex to the overlay.
parent
92218b08c6
commit
39d1d8dcdf
|
@ -300,7 +300,7 @@ void Steam_Overlay::FriendDisconnect(Friend _friend)
|
|||
|
||||
void Steam_Overlay::AddMessageNotification(std::string const& message)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||
int id = find_free_notification_id(notifications);
|
||||
if (id != 0)
|
||||
{
|
||||
|
@ -317,7 +317,7 @@ void Steam_Overlay::AddMessageNotification(std::string const& message)
|
|||
|
||||
void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||
int id = find_free_notification_id(notifications);
|
||||
if (id != 0)
|
||||
{
|
||||
|
@ -335,7 +335,7 @@ void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
|
|||
|
||||
void Steam_Overlay::AddInviteNotification(std::pair<const Friend, friend_window_state>& wnd_state)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||
int id = find_free_notification_id(notifications);
|
||||
if (id != 0)
|
||||
{
|
||||
|
@ -522,7 +522,10 @@ void Steam_Overlay::BuildNotifications(int width, int height)
|
|||
|
||||
int font_size = ImGui::GetFontSize();
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||
std::queue<Friend> friend_actions_temp;
|
||||
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
|
||||
|
||||
for (auto it = notifications.begin(); it != notifications.end(); ++it, ++i)
|
||||
{
|
||||
|
@ -564,7 +567,7 @@ void Steam_Overlay::BuildNotifications(int width, int height)
|
|||
ImGui::TextWrapped("%s", it->message.c_str());
|
||||
if (ImGui::Button("Join"))
|
||||
{
|
||||
has_friend_action.push(it->frd->first);
|
||||
friend_actions_temp.push(it->frd->first);
|
||||
it->start_time = std::chrono::seconds(0);
|
||||
}
|
||||
}
|
||||
|
@ -582,6 +585,15 @@ void Steam_Overlay::BuildNotifications(int width, int height)
|
|||
}), notifications.end());
|
||||
}
|
||||
|
||||
if (!friend_actions_temp.empty()) {
|
||||
std::lock_guard<std::recursive_mutex> lock(overlay_mutex);
|
||||
while (!friend_actions_temp.empty()) {
|
||||
has_friend_action.push(friend_actions_temp.front());
|
||||
friend_actions_temp.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Steam_Overlay::CreateFonts()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
|
|
@ -92,6 +92,8 @@ class Steam_Overlay
|
|||
// Callback infos
|
||||
std::queue<Friend> has_friend_action;
|
||||
std::vector<Notification> notifications;
|
||||
std::recursive_mutex notifications_mutex;
|
||||
|
||||
bool overlay_state_changed;
|
||||
|
||||
std::recursive_mutex overlay_mutex;
|
||||
|
|
Loading…
Reference in New Issue