diff --git a/src/discord/user.cpp b/src/discord/user.cpp index 8129273b..a5bb0aef 100644 --- a/src/discord/user.cpp +++ b/src/discord/user.cpp @@ -220,34 +220,34 @@ void UserData::update_from_json(const nlohmann::json &j) { } const char *UserData::GetFlagName(uint64_t flag) { - switch (flag) { - case DiscordEmployee: + switch (static_cast(flag)) { + case UserData::EFlags::DiscordEmployee: return "discordstaff"; - case PartneredServerOwner: + case UserData::EFlags::PartneredServerOwner: return "partneredowner"; - case HypeSquadEvents: + case UserData::EFlags::HypeSquadEvents: return "hypesquadevents"; - case BugHunterLevel1: + case UserData::EFlags::BugHunterLevel1: return "discordbughunter"; - case HouseBravery: + case UserData::EFlags::HouseBravery: return "hypesquadbravery"; - case HouseBrilliance: + case UserData::EFlags::HouseBrilliance: return "hypesquadbrilliance"; - case HouseBalance: + case UserData::EFlags::HouseBalance: return "hypesquadbalance"; - case EarlySupporter: + case UserData::EFlags::EarlySupporter: return "earlysupporter"; - case TeamUser: + case UserData::EFlags::TeamUser: return "teamuser"; - case System: + case UserData::EFlags::System: return "system"; - case BugHunterLevel2: + case UserData::EFlags::BugHunterLevel2: return "discordbughunter2"; - case VerifiedBot: + case UserData::EFlags::VerifiedBot: return "verifiedbot"; - case EarlyVerifiedBotDeveloper: + case UserData::EFlags::EarlyVerifiedBotDeveloper: return "earlyverifiedbotdeveloper"; - case CertifiedModerator: + case UserData::EFlags::CertifiedModerator: return "certifiedmoderator"; default: return "unknown"; @@ -255,34 +255,34 @@ const char *UserData::GetFlagName(uint64_t flag) { } const char *UserData::GetFlagReadableName(uint64_t flag) { - switch (flag) { - case DiscordEmployee: + switch (static_cast(flag)) { + case UserData::EFlags::DiscordEmployee: return "Discord Staff"; - case PartneredServerOwner: + case UserData::EFlags::PartneredServerOwner: return "Partnered Server Owner"; - case HypeSquadEvents: + case UserData::EFlags::HypeSquadEvents: return "HypeSquad Events"; - case BugHunterLevel1: + case UserData::EFlags::BugHunterLevel1: return "Discord Bug Hunter"; - case HouseBravery: + case UserData::EFlags::HouseBravery: return "HypeSquad Bravery"; - case HouseBrilliance: + case UserData::EFlags::HouseBrilliance: return "HypeSquad Brilliance"; - case HouseBalance: + case UserData::EFlags::HouseBalance: return "HypeSquad Balance"; - case EarlySupporter: + case UserData::EFlags::EarlySupporter: return "Early Supporter"; - case TeamUser: + case UserData::EFlags::TeamUser: return "Team User"; // ??? - case System: + case UserData::EFlags::System: return "System"; - case BugHunterLevel2: + case UserData::EFlags::BugHunterLevel2: return "Discord Bug Hunter Level 2"; - case VerifiedBot: + case UserData::EFlags::VerifiedBot: return "Verified Bot"; - case EarlyVerifiedBotDeveloper: + case UserData::EFlags::EarlyVerifiedBotDeveloper: return "Early Verified Bot Developer"; - case CertifiedModerator: + case UserData::EFlags::CertifiedModerator: return "Discord Certified Moderator"; default: return ""; diff --git a/src/discord/user.hpp b/src/discord/user.hpp index 3e356a45..6aee6bef 100644 --- a/src/discord/user.hpp +++ b/src/discord/user.hpp @@ -11,8 +11,7 @@ enum class EPremiumType { }; struct UserData { - // todo: enum class? (for consistencys sake) - enum { + enum class EFlags : uint64_t { DiscordEmployee = 1 << 0, PartneredServerOwner = 1 << 1, HypeSquadEvents = 1 << 2, diff --git a/src/windows/profilewindow.cpp b/src/windows/profilewindow.cpp index 8c4b67f0..4547ae41 100644 --- a/src/windows/profilewindow.cpp +++ b/src/windows/profilewindow.cpp @@ -1,6 +1,7 @@ #include "profilewindow.hpp" #include "abaddon.hpp" +#include "discord/user.hpp" #include "util.hpp" ProfileWindow::ProfileWindow(Snowflake user_id) @@ -116,13 +117,13 @@ void ProfileWindow::OnFetchProfile(const UserProfileData &data) { if (!data.User.PublicFlags.has_value()) return; const auto x = *data.User.PublicFlags; - for (uint64_t i = 1; i <= UserData::MaxFlag; i <<= 1) { + for (uint64_t i = 1; i <= static_cast(UserData::EFlags::MaxFlag); i <<= 1) { if (!(x & i)) continue; const std::string name = UserData::GetFlagName(i); if (name == "unknown") continue; Glib::RefPtr pixbuf; try { - if (name == "verifiedbot") + if (i == static_cast(UserData::EFlags::VerifiedBot)) pixbuf = Gdk::Pixbuf::create_from_file(Abaddon::GetResPath("/checkmark.png"), 24, 24); else pixbuf = Gdk::Pixbuf::create_from_file(Abaddon::GetResPath("/" + name + ".png"), 24, 24);