mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-04 16:23:52 +00:00
Add Ignore tab to social frame with view/unignore/add support
Social frame now has Friends and Ignore tabs. Friends tab shows online players first, then offline with a separator, and supports right-click Whisper/Invite/Remove. Ignore tab lists all ignored players from ignoreCache with right-click Unignore and an inline add-ignore field.
This commit is contained in:
parent
06456faa63
commit
fb6630a7ae
2 changed files with 119 additions and 62 deletions
|
|
@ -343,6 +343,7 @@ public:
|
||||||
void setFriendNote(const std::string& playerName, const std::string& note);
|
void setFriendNote(const std::string& playerName, const std::string& note);
|
||||||
void addIgnore(const std::string& playerName);
|
void addIgnore(const std::string& playerName);
|
||||||
void removeIgnore(const std::string& playerName);
|
void removeIgnore(const std::string& playerName);
|
||||||
|
const std::unordered_map<std::string, uint64_t>& getIgnoreCache() const { return ignoreCache; }
|
||||||
|
|
||||||
// Random roll
|
// Random roll
|
||||||
void randomRoll(uint32_t minRoll = 1, uint32_t maxRoll = 100);
|
void randomRoll(uint32_t minRoll = 1, uint32_t maxRoll = 100);
|
||||||
|
|
|
||||||
|
|
@ -7885,24 +7885,29 @@ void GameScreen::renderSocialFrame(game::GameHandler& gameHandler) {
|
||||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.1f, 0.1f, 0.1f, 0.92f));
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.1f, 0.1f, 0.1f, 0.92f));
|
||||||
|
|
||||||
bool open = showSocialFrame_;
|
bool open = showSocialFrame_;
|
||||||
if (ImGui::Begin("Friends##SocialFrame", &open,
|
char socialTitle[32];
|
||||||
|
snprintf(socialTitle, sizeof(socialTitle), "Social (%d online)##SocialFrame", onlineCount);
|
||||||
|
if (ImGui::Begin(socialTitle, &open,
|
||||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||||
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) {
|
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar)) {
|
||||||
|
|
||||||
// Online friends
|
if (ImGui::BeginTabBar("##SocialTabs")) {
|
||||||
char onlineHeader[32];
|
// ---- Friends tab ----
|
||||||
snprintf(onlineHeader, sizeof(onlineHeader), "Online (%d)", onlineCount);
|
if (ImGui::BeginTabItem("Friends")) {
|
||||||
ImGui::TextDisabled("%s", onlineHeader);
|
ImGui::BeginChild("##FriendsList", ImVec2(200, 200), false);
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
|
// Online friends first
|
||||||
int shown = 0;
|
int shown = 0;
|
||||||
|
for (int pass = 0; pass < 2; ++pass) {
|
||||||
|
bool wantOnline = (pass == 0);
|
||||||
for (size_t ci = 0; ci < contacts.size(); ++ci) {
|
for (size_t ci = 0; ci < contacts.size(); ++ci) {
|
||||||
const auto& c = contacts[ci];
|
const auto& c = contacts[ci];
|
||||||
if (!c.isFriend()) continue;
|
if (!c.isFriend()) continue;
|
||||||
|
if (c.isOnline() != wantOnline) continue;
|
||||||
|
|
||||||
ImGui::PushID(static_cast<int>(ci));
|
ImGui::PushID(static_cast<int>(ci));
|
||||||
|
|
||||||
// Status dot: green=online, yellow=AFK, orange=DND, grey=offline
|
// Status dot
|
||||||
ImU32 dotColor;
|
ImU32 dotColor;
|
||||||
if (!c.isOnline()) dotColor = IM_COL32(100, 100, 100, 200);
|
if (!c.isOnline()) dotColor = IM_COL32(100, 100, 100, 200);
|
||||||
else if (c.status == 2) dotColor = IM_COL32(255, 200, 50, 255); // AFK
|
else if (c.status == 2) dotColor = IM_COL32(255, 200, 50, 255); // AFK
|
||||||
|
|
@ -7923,7 +7928,7 @@ void GameScreen::renderSocialFrame(game::GameHandler& gameHandler) {
|
||||||
|
|
||||||
if (c.isOnline() && c.level > 0) {
|
if (c.isOnline() && c.level > 0) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled("%u", c.level);
|
ImGui::TextDisabled("Lv%u", c.level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right-click context menu
|
// Right-click context menu
|
||||||
|
|
@ -7949,21 +7954,72 @@ void GameScreen::renderSocialFrame(game::GameHandler& gameHandler) {
|
||||||
++shown;
|
++shown;
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
// Separator between online and offline if there are both
|
||||||
if (shown == 0) {
|
if (pass == 0 && shown > 0) {
|
||||||
ImGui::TextDisabled("No friends.");
|
ImGui::Separator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shown == 0) {
|
||||||
|
ImGui::TextDisabled("No friends yet.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
// Add friend inline
|
|
||||||
|
// Add friend
|
||||||
static char addFriendBuf[64] = {};
|
static char addFriendBuf[64] = {};
|
||||||
ImGui::SetNextItemWidth(140.0f);
|
ImGui::SetNextItemWidth(140.0f);
|
||||||
ImGui::InputText("##sf_addfriend", addFriendBuf, sizeof(addFriendBuf));
|
ImGui::InputText("##sf_addfriend", addFriendBuf, sizeof(addFriendBuf));
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("+") && addFriendBuf[0] != '\0') {
|
if (ImGui::Button("+##addfriend") && addFriendBuf[0] != '\0') {
|
||||||
gameHandler.addFriend(addFriendBuf);
|
gameHandler.addFriend(addFriendBuf);
|
||||||
addFriendBuf[0] = '\0';
|
addFriendBuf[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::EndTabItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Ignore tab ----
|
||||||
|
if (ImGui::BeginTabItem("Ignore")) {
|
||||||
|
const auto& ignores = gameHandler.getIgnoreCache();
|
||||||
|
ImGui::BeginChild("##IgnoreList", ImVec2(200, 200), false);
|
||||||
|
|
||||||
|
if (ignores.empty()) {
|
||||||
|
ImGui::TextDisabled("Ignore list is empty.");
|
||||||
|
} else {
|
||||||
|
for (const auto& kv : ignores) {
|
||||||
|
ImGui::PushID(kv.first.c_str());
|
||||||
|
ImGui::TextUnformatted(kv.first.c_str());
|
||||||
|
if (ImGui::BeginPopupContextItem("IgnoreCtx")) {
|
||||||
|
ImGui::TextDisabled("%s", kv.first.c_str());
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::MenuItem("Unignore"))
|
||||||
|
gameHandler.removeIgnore(kv.first);
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// Add ignore
|
||||||
|
static char addIgnBuf[64] = {};
|
||||||
|
ImGui::SetNextItemWidth(140.0f);
|
||||||
|
ImGui::InputText("##sf_addignore", addIgnBuf, sizeof(addIgnBuf));
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("+##addignore") && addIgnBuf[0] != '\0') {
|
||||||
|
gameHandler.addIgnore(addIgnBuf);
|
||||||
|
addIgnBuf[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTabItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTabBar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
showSocialFrame_ = open;
|
showSocialFrame_ = open;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue