forked from OpenGamers/abaddon
show crown next to owner
This commit is contained in:
@@ -126,6 +126,7 @@ For example, memory_db would be set by adding `memory_db = true` under the line
|
|||||||
* emojis (true or false, default true) - resolve unicode and custom emojis to images. this needs to be false to allow GTK to render emojis by itself
|
* emojis (true or false, default true) - resolve unicode and custom emojis to images. this needs to be false to allow GTK to render emojis by itself
|
||||||
* css (string) - path to the main CSS file
|
* css (string) - path to the main CSS file
|
||||||
* animations (true or false, default true) - use animated images where available (e.g. server icons, emojis, avatars). false means static images will be used
|
* animations (true or false, default true) - use animated images where available (e.g. server icons, emojis, avatars). false means static images will be used
|
||||||
|
* owner_crown (true or false, default true) - show a crown next to the owner
|
||||||
|
|
||||||
#### misc
|
#### misc
|
||||||
* linkcolor (string) - color to use for links in messages
|
* linkcolor (string) - color to use for links in messages
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
constexpr static const int MaxMemberListRows = 200;
|
constexpr static const int MaxMemberListRows = 200;
|
||||||
|
|
||||||
MemberListUserRow::MemberListUserRow(Snowflake guild_id, const UserData *data) {
|
MemberListUserRow::MemberListUserRow(const GuildData &guild, const UserData *data) {
|
||||||
ID = data->ID;
|
ID = data->ID;
|
||||||
m_ev = Gtk::manage(new Gtk::EventBox);
|
m_ev = Gtk::manage(new Gtk::EventBox);
|
||||||
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
|
m_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
|
||||||
@@ -14,6 +14,16 @@ MemberListUserRow::MemberListUserRow(Snowflake guild_id, const UserData *data) {
|
|||||||
m_avatar = Gtk::manage(new LazyImage(16, 16));
|
m_avatar = Gtk::manage(new LazyImage(16, 16));
|
||||||
m_status_indicator = Gtk::manage(new StatusIndicator(ID));
|
m_status_indicator = Gtk::manage(new StatusIndicator(ID));
|
||||||
|
|
||||||
|
static bool crown = Abaddon::Get().GetSettings().GetShowOwnerCrown();
|
||||||
|
if (crown && guild.OwnerID == data->ID) {
|
||||||
|
try {
|
||||||
|
auto pixbuf = Gdk::Pixbuf::create_from_file("./res/crown.png", 12, 12);
|
||||||
|
m_crown = Gtk::manage(new Gtk::Image(pixbuf));
|
||||||
|
m_crown->set_valign(Gtk::ALIGN_CENTER);
|
||||||
|
m_crown->set_margin_end(8);
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
|
||||||
m_status_indicator->set_margin_start(3);
|
m_status_indicator->set_margin_start(3);
|
||||||
|
|
||||||
if (data->HasAvatar())
|
if (data->HasAvatar())
|
||||||
@@ -31,7 +41,7 @@ MemberListUserRow::MemberListUserRow(Snowflake guild_id, const UserData *data) {
|
|||||||
std::string display = data->Username;
|
std::string display = data->Username;
|
||||||
if (show_discriminator)
|
if (show_discriminator)
|
||||||
display += "#" + data->Discriminator;
|
display += "#" + data->Discriminator;
|
||||||
auto col_id = data->GetHoistedRole(guild_id, true);
|
auto col_id = data->GetHoistedRole(guild.ID, true);
|
||||||
if (col_id.IsValid()) {
|
if (col_id.IsValid()) {
|
||||||
auto color = Abaddon::Get().GetDiscordClient().GetRole(col_id)->Color;
|
auto color = Abaddon::Get().GetDiscordClient().GetRole(col_id)->Color;
|
||||||
m_label->set_use_markup(true);
|
m_label->set_use_markup(true);
|
||||||
@@ -49,6 +59,8 @@ MemberListUserRow::MemberListUserRow(Snowflake guild_id, const UserData *data) {
|
|||||||
m_box->add(*m_avatar);
|
m_box->add(*m_avatar);
|
||||||
m_box->add(*m_status_indicator);
|
m_box->add(*m_status_indicator);
|
||||||
m_box->add(*m_label);
|
m_box->add(*m_label);
|
||||||
|
if (m_crown != nullptr)
|
||||||
|
m_box->add(*m_crown);
|
||||||
m_ev->add(*m_box);
|
m_ev->add(*m_box);
|
||||||
add(*m_ev);
|
add(*m_ev);
|
||||||
show_all();
|
show_all();
|
||||||
@@ -118,10 +130,8 @@ void MemberList::UpdateMemberList() {
|
|||||||
|
|
||||||
for (const auto &id : ids) {
|
for (const auto &id : ids) {
|
||||||
auto user = discord.GetUser(id);
|
auto user = discord.GetUser(id);
|
||||||
if (!user.has_value()) {
|
if (!user.has_value() || user->IsDeleted())
|
||||||
roleless_users.push_back(id);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
auto pos_role_id = discord.GetMemberHoistedRole(m_guild_id, id); // role for positioning
|
auto pos_role_id = discord.GetMemberHoistedRole(m_guild_id, id); // role for positioning
|
||||||
auto col_role_id = discord.GetMemberHoistedRole(m_guild_id, id, true); // role for color
|
auto col_role_id = discord.GetMemberHoistedRole(m_guild_id, id, true); // role for color
|
||||||
@@ -140,9 +150,10 @@ void MemberList::UpdateMemberList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int num_rows = 0;
|
int num_rows = 0;
|
||||||
auto add_user = [this, &user_to_color, &num_rows](const UserData *data) -> bool {
|
const auto guild = *discord.GetGuild(m_guild_id);
|
||||||
|
auto add_user = [this, &user_to_color, &num_rows, guild](const UserData *data) -> bool {
|
||||||
if (num_rows++ > MaxMemberListRows) return false;
|
if (num_rows++ > MaxMemberListRows) return false;
|
||||||
auto *row = Gtk::manage(new MemberListUserRow(m_guild_id, data));
|
auto *row = Gtk::manage(new MemberListUserRow(guild, data));
|
||||||
m_id_to_row[data->ID] = row;
|
m_id_to_row[data->ID] = row;
|
||||||
AttachUserMenuHandler(row, data->ID);
|
AttachUserMenuHandler(row, data->ID);
|
||||||
m_listbox->add(*row);
|
m_listbox->add(*row);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class LazyImage;
|
|||||||
class StatusIndicator;
|
class StatusIndicator;
|
||||||
class MemberListUserRow : public Gtk::ListBoxRow {
|
class MemberListUserRow : public Gtk::ListBoxRow {
|
||||||
public:
|
public:
|
||||||
MemberListUserRow(Snowflake guild_id, const UserData *data);
|
MemberListUserRow(const GuildData& guild, const UserData *data);
|
||||||
|
|
||||||
Snowflake ID;
|
Snowflake ID;
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ private:
|
|||||||
LazyImage *m_avatar;
|
LazyImage *m_avatar;
|
||||||
StatusIndicator *m_status_indicator;
|
StatusIndicator *m_status_indicator;
|
||||||
Gtk::Label *m_label;
|
Gtk::Label *m_label;
|
||||||
|
Gtk::Image *m_crown = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MemberList {
|
class MemberList {
|
||||||
|
|||||||
BIN
res/crown.png
Normal file
BIN
res/crown.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
@@ -77,3 +77,7 @@ std::string SettingsManager::GetMainCSS() const {
|
|||||||
bool SettingsManager::GetShowAnimations() const {
|
bool SettingsManager::GetShowAnimations() const {
|
||||||
return GetSettingBool("gui", "animations", true);
|
return GetSettingBool("gui", "animations", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsManager::GetShowOwnerCrown() const {
|
||||||
|
return GetSettingBool("gui", "owner_crown", true);
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
bool GetPrefetch() const;
|
bool GetPrefetch() const;
|
||||||
std::string GetMainCSS() const;
|
std::string GetMainCSS() const;
|
||||||
bool GetShowAnimations() const;
|
bool GetShowAnimations() const;
|
||||||
|
bool GetShowOwnerCrown() const;
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
|||||||
@@ -40,11 +40,12 @@ GuildSettingsMembersPaneMembers::GuildSettingsMembersPaneMembers(Snowflake id)
|
|||||||
|
|
||||||
auto &discord = Abaddon::Get().GetDiscordClient();
|
auto &discord = Abaddon::Get().GetDiscordClient();
|
||||||
auto members = discord.GetUsersInGuild(id);
|
auto members = discord.GetUsersInGuild(id);
|
||||||
|
const auto guild = *discord.GetGuild(GuildID);
|
||||||
for (const auto member_id : members) {
|
for (const auto member_id : members) {
|
||||||
auto member = *discord.GetMember(member_id, GuildID);
|
auto member = *discord.GetMember(member_id, GuildID);
|
||||||
member.User = discord.GetUser(member_id);
|
member.User = discord.GetUser(member_id);
|
||||||
if (member.User->IsDeleted()) continue;
|
if (member.User->IsDeleted()) continue;
|
||||||
auto *row = Gtk::manage(new GuildSettingsMembersListItem(GuildID, member));
|
auto *row = Gtk::manage(new GuildSettingsMembersListItem(guild, member));
|
||||||
row->show();
|
row->show();
|
||||||
m_list.add(*row);
|
m_list.add(*row);
|
||||||
}
|
}
|
||||||
@@ -81,9 +82,9 @@ GuildSettingsMembersPaneMembers::type_signal_member_select GuildSettingsMembersP
|
|||||||
return m_signal_member_select;
|
return m_signal_member_select;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildSettingsMembersListItem::GuildSettingsMembersListItem(Snowflake guild_id, const GuildMember &member)
|
GuildSettingsMembersListItem::GuildSettingsMembersListItem(const GuildData &guild, const GuildMember &member)
|
||||||
: UserID(member.User->ID)
|
: UserID(member.User->ID)
|
||||||
, GuildID(guild_id)
|
, GuildID(guild.ID)
|
||||||
, m_avatar(32, 32) {
|
, m_avatar(32, 32) {
|
||||||
m_avatar.SetAnimated(true);
|
m_avatar.SetAnimated(true);
|
||||||
|
|
||||||
@@ -113,14 +114,29 @@ GuildSettingsMembersListItem::GuildSettingsMembersListItem(Snowflake guild_id, c
|
|||||||
discord.signal_guild_member_update().connect(sigc::track_obj(member_update_cb, *this));
|
discord.signal_guild_member_update().connect(sigc::track_obj(member_update_cb, *this));
|
||||||
UpdateColor();
|
UpdateColor();
|
||||||
|
|
||||||
|
static bool crown = Abaddon::Get().GetSettings().GetShowOwnerCrown();
|
||||||
|
if (crown && guild.OwnerID == member.User->ID) {
|
||||||
|
try {
|
||||||
|
auto pixbuf = Gdk::Pixbuf::create_from_file("./res/crown.png", 12, 12);
|
||||||
|
m_crown = Gtk::manage(new Gtk::Image(pixbuf));
|
||||||
|
m_crown->set_valign(Gtk::ALIGN_CENTER);
|
||||||
|
m_crown->set_margin_start(10);
|
||||||
|
m_crown->show();
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
|
||||||
m_avatar.set_margin_end(5);
|
m_avatar.set_margin_end(5);
|
||||||
m_avatar.set_halign(Gtk::ALIGN_START);
|
m_avatar.set_halign(Gtk::ALIGN_START);
|
||||||
m_avatar.set_valign(Gtk::ALIGN_CENTER);
|
m_avatar.set_valign(Gtk::ALIGN_CENTER);
|
||||||
m_name.set_halign(Gtk::ALIGN_START);
|
m_name.set_halign(Gtk::ALIGN_START);
|
||||||
m_name.set_valign(Gtk::ALIGN_CENTER);
|
m_name.set_valign(Gtk::ALIGN_CENTER);
|
||||||
|
|
||||||
|
m_main.set_hexpand(true);
|
||||||
|
|
||||||
m_main.add(m_avatar);
|
m_main.add(m_avatar);
|
||||||
m_main.add(m_name);
|
m_main.add(m_name);
|
||||||
|
if (m_crown != nullptr)
|
||||||
|
m_main.add(*m_crown);
|
||||||
|
|
||||||
m_ev.add(m_main);
|
m_ev.add(m_main);
|
||||||
add(m_ev);
|
add(m_ev);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
#include "../../discord/member.hpp"
|
#include "../../discord/member.hpp"
|
||||||
|
#include "../../discord/guild.hpp"
|
||||||
#include "../../components/lazyimage.hpp"
|
#include "../../components/lazyimage.hpp"
|
||||||
|
|
||||||
class GuildSettingsMembersPaneRolesItem : public Gtk::ListBoxRow {
|
class GuildSettingsMembersPaneRolesItem : public Gtk::ListBoxRow {
|
||||||
@@ -103,7 +104,7 @@ public:
|
|||||||
|
|
||||||
class GuildSettingsMembersListItem : public Gtk::ListBoxRow {
|
class GuildSettingsMembersListItem : public Gtk::ListBoxRow {
|
||||||
public:
|
public:
|
||||||
GuildSettingsMembersListItem(Snowflake guild_id, const GuildMember &member);
|
GuildSettingsMembersListItem(const GuildData &guild, const GuildMember &member);
|
||||||
|
|
||||||
Glib::ustring DisplayTerm;
|
Glib::ustring DisplayTerm;
|
||||||
|
|
||||||
@@ -117,6 +118,7 @@ private:
|
|||||||
LazyImage m_avatar;
|
LazyImage m_avatar;
|
||||||
Gtk::Label m_name;
|
Gtk::Label m_name;
|
||||||
Gtk::Box m_main;
|
Gtk::Box m_main;
|
||||||
|
Gtk::Image *m_crown = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GuildSettingsMembersPane : public Gtk::Box {
|
class GuildSettingsMembersPane : public Gtk::Box {
|
||||||
|
|||||||
Reference in New Issue
Block a user