-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFriendsUI.cpp
More file actions
107 lines (95 loc) · 2.4 KB
/
FriendsUI.cpp
File metadata and controls
107 lines (95 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "FriendsUI.h"
#include "imgui.h"
void ShowUI(FriendsViewModel& vm)
{
auto friends = vm.getFriends();
ImVec4 const oReadyColor = friends.isReady ? ImVec4(0.0f, 1.0f, 0.0f, 1.0f) : ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
ImGui::TextColored(oReadyColor, "%s", friends.isReady ? "ready" : "not ready");
if (friends.isReady)
{
for (auto& f : friends.friends)
{
DrawSingleFriend(vm, f);
}
}
}
void DrawSingleFriend(FriendsViewModel& vm, Stormancer::Friends::Friend const& f)
{
if (ImGui::TreeNode(f.userIds.front().toString().c_str()))
{
if (ImGui::TreeNode("user ids"))
{
for (auto& userId : f.userIds)
{
ImGui::Text(userId.toString().c_str());
}
ImGui::TreePop();
}
std::string status;
ImVec4 statusColor;
switch (f.getStatusForPlatform("stormancer"))
{
case Stormancer::Friends::FriendStatus::Connected:
status = "Online";
statusColor = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
break;
case Stormancer::Friends::FriendStatus::Away:
status = "Away";
statusColor = ImVec4(1.0f, 1.0f, 0.0f, 1.0f);
break;
case Stormancer::Friends::FriendStatus::Disconnected:
status = "Disconnected";
statusColor = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
break;
}
ImGui::TextUnformatted("status:");
ImGui::SameLine();
ImGui::TextColored(statusColor, "%s", status.c_str());
if (std::find(f.tags.begin(), f.tags.end(), "friends.invitation.received") != f.tags.end())
{
if (ImGui::Button("Accept"))
{
vm.AnswerFriendRequest(f.userIds.front(), true);
}
ImGui::SameLine();
if (ImGui::Button("Reject"))
{
vm.AnswerFriendRequest(f.userIds.front(), false);
}
}
else if (std::find(f.tags.begin(), f.tags.end(), "friends.blocked") != f.tags.end())
{
if (ImGui::Button("Unblock"))
{
vm.UnblockUser(f.userIds.front());
}
}
else if (std::find(f.tags.begin(), f.tags.end(), "recentlyMet") != f.tags.end())
{
if (ImGui::Button("Invite"))
{
vm.AddFriend(f.userIds.front());
}
ImGui::SameLine();
if (ImGui::Button("Block"))
{
vm.BlockUser(f.userIds.front());
}
}
if (ImGui::Button("Remove"))
{
vm.RemoveFriend(f.userIds.front());
}
if (ImGui::Button("Invite to party"))
{
vm.InvitePlayer(f.userIds.front());
}
ImGui::TextUnformatted("Tags:");
for (std::string const& tag : f.tags)
{
ImGui::BulletText(tag.c_str());
}
ImGui::Text("Custom data: %s", f.customData.c_str());
ImGui::TreePop();
}
}