49 const protocol::Guild& yours, uint32_t you) {
50 std::optional<protocol::GuildAction> action = BuildQuestion();
53 if (yours.war().left() != war_left_) {
54 war_left_ = yours.war().left();
55 war_news_at_ = ImGui::GetTime();
60 const ImVec2 display = ImGui::GetIO().DisplaySize;
61 ImGui::SetNextWindowPos({display.x * 0.5f, display.y * 0.4f},
62 ImGuiCond_FirstUseEver, {0.5f, 0.5f});
64 ImGuiWindowFlags_AlwaysAutoResize |
65 ImGuiWindowFlags_NoSavedSettings)) {
66 const float width =
Ui(280.0f);
67 const bool named = name_[0] !=
'\0';
68 if (yours.name().empty()) {
69 ImGui::TextUnformatted(
Tr(
"You're in no guild. Found one:"));
70 ImGui::TextDisabled(
"%s",
71 Tr(
"3 to 24 letters, one space between words."));
72 ImGui::SetNextItemWidth(width);
73 const bool entered = ImGui::InputTextWithHint(
74 "##name",
Tr(
"Its name"), name_.data(), name_.size(),
75 ImGuiInputTextFlags_EnterReturnsTrue);
76 if ((
GameButton(
"Found the guild", {width, 0.0f},
true, named) ||
79 action.emplace().set_create(name_.data());
82 ImGui::TextUnformatted(yours.name().c_str());
83 ImGui::TextDisabled(
"%s",
RankName(yours.rank()));
85 if (yours.has_war()) {
86 const protocol::GuildWar& war = yours.war();
88 static_cast<uint32_t
>(ImGui::GetTime() - war_news_at_);
92 absl::Substitute(
Tr(
"At war with $0"), war.enemy()).c_str());
93 ImGui::TextUnformatted(absl::Substitute(
Tr(
"Kills: $0 to $1"),
94 war.kills(), war.enemy_kills())
98 "%s", absl::Substitute(
100 TimeLeft(war.left() > since ? war.left() - since : 0))
105 if (ImGui::BeginTable(
107 ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp,
109 ImGui::TableSetupColumn(
TrLabel(
"Name"));
110 ImGui::TableSetupColumn(
TrLabel(
"Rank"));
111 ImGui::TableSetupColumn(
TrLabel(
"Level"));
112 ImGui::TableHeadersRow();
113 const bool leader = yours.rank() == protocol::RANK_LEADER;
114 for (
const protocol::GuildMember& member : yours.members()) {
115 ImGui::TableNextRow();
116 ImGui::PushID(
static_cast<int>(member.id()));
118 const ImVec4 color = ImGui::GetStyleColorVec4(
119 member.online() ? ImGuiCol_Text : ImGuiCol_TextDisabled);
120 ImGui::PushStyleColor(ImGuiCol_Text, color);
121 ImGui::TableNextColumn();
122 ImGui::Selectable(member.name().c_str(),
false,
123 ImGuiSelectableFlags_SpanAllColumns);
124 ImGui::PopStyleColor();
125 if (member.id() != you && yours.rank() > member.rank() &&
126 ImGui::BeginPopupContextItem(
"Member")) {
127 if (leader && member.rank() == protocol::RANK_MEMBER &&
128 ImGui::MenuItem(
TrLabel(
"Make an officer"))) {
129 action.emplace().set_promote(member.id());
131 if (leader && member.rank() == protocol::RANK_OFFICER &&
132 ImGui::MenuItem(
TrLabel(
"Make a member"))) {
133 action.emplace().set_demote(member.id());
135 if (ImGui::MenuItem(
TrLabel(
"Remove from the guild"))) {
136 action.emplace().set_kick(member.id());
140 ImGui::PushStyleColor(ImGuiCol_Text, color);
141 ImGui::TableNextColumn();
142 ImGui::TextUnformatted(
RankName(member.rank()));
143 ImGui::TableNextColumn();
144 ImGui::Text(
"%u", member.level());
145 ImGui::PopStyleColor();
150 const auto online = std::ranges::count_if(
152 [](
const protocol::GuildMember& member) { return member.online(); });
153 ImGui::TextDisabled(
"%s", absl::Substitute(
Tr(
"$0 of $1 playing now."),
154 online, yours.members_size())
157 if (yours.rank() != protocol::RANK_MEMBER) {
159 ImGui::SetNextItemWidth(width);
160 const bool entered = ImGui::InputTextWithHint(
161 "##player",
Tr(
"Someone playing here"), player_.data(),
162 player_.size(), ImGuiInputTextFlags_EnterReturnsTrue);
163 const bool someone = player_[0] !=
'\0';
164 if ((
GameButton(
"Ask them in", {width, 0.0f},
false, someone) ||
167 action.emplace().set_invite(player_.data());
172 if (
GameButton(
"Leave the guild", {width, 0.0f})) {
173 action.emplace().set_leave(
true);
175 if (yours.rank() == protocol::RANK_LEADER &&
176 GameButton(
"Disband the guild", {width, 0.0f})) {
182 if (disbanding_ && !yours.name().empty()) {
183 if (std::optional<protocol::GuildAction> disband =
184 BuildDisband(yours.name())) {
185 action = std::move(disband);