121 const std::map<uint32_t, Telegraph>& telegraphs,
122 std::string_view enemy,
const Noticed& noticed) {
124 ImDrawList* draw = ImGui::GetBackgroundDrawList();
125 ImFont* font = ImGui::GetFont();
126 const float font_size = ImGui::GetFontSize() * 1.4f;
127 const Vector3 forward =
128 Vector3Normalize(Vector3Subtract(camera.target, camera.position));
129 for (
const Figure& figure : figures) {
133 const bool named =
ShowsName(figure, noticed);
135 if (!named && !(figure.npc && figure.mark != 0)) {
138 const Vector3& position = figure.position;
139 const Vector3 away = Vector3Subtract(position, camera.position);
141 if (Vector3Length(away) > kFarthest ||
142 Vector3DotProduct(away, forward) <= 0.0f) {
145 const Vector2 at = GetWorldToScreen(
146 {position.x, position.y +
Above(figure), position.z}, camera);
147 const std::optional<Color> faction =
FactionMark(figure);
151 font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, figure.name.c_str());
153 const float marked = MarkWidth(faction, size.y);
154 const ImVec2 top{at.x - (marked + size.x) / 2, at.y - size.y};
156 DrawFactionMark(draw, *faction, top, size.y);
161 if (figure.mark != 0) {
162 const std::string mark(1, figure.mark);
163 const float mark_size = font_size * kMarkScale;
165 font->CalcTextSizeA(mark_size, FLT_MAX, 0.0f, mark.c_str());
167 {at.x - over.x / 2, at.y - size.y - over.y}, kMark,
173 const ImVec2 bar_min{at.x - kBar.x / 2, at.y - kBar.y};
174 const ImVec2 bar_max{at.x + kBar.x / 2, at.y};
176 const float share = figure.max_health > 0
177 ? std::clamp(
static_cast<float>(figure.health) /
181 draw->AddRectFilled(bar_min, bar_max, kShadow);
182 draw->AddRectFilled(bar_min, {bar_min.x + kBar.x * share, bar_max.y},
183 figure.monster ? kMonsterHealth : kPlayerHealth);
187 if (
const auto cast = telegraphs.find(figure.id);
188 figure.monster && cast != telegraphs.end()) {
189 const Telegraph& telegraph = cast->second;
190 const Color color = GetColor(telegraph.
skill.color());
191 const ImVec2 cast_min{bar_min.x, bar_max.y + kCastGap};
192 const ImVec2 cast_max{bar_max.x, cast_min.y + kCastBar};
193 draw->AddRectFilled(cast_min, cast_max, kShadow);
195 cast_min, {cast_min.x + kBar.x * telegraph.
Filled(), cast_max.y},
196 IM_COL32(color.r, color.g, color.b, 255));
197 const float cast_size = font_size * kCastScale;
198 const char* skill =
NameOf(figure.kind, telegraph.
skill);
199 const ImVec2 extent =
200 font->CalcTextSizeA(cast_size, FLT_MAX, 0.0f, skill);
202 IM_COL32_WHITE, skill);
205 const std::string level =
206 with.
levels ? std::to_string(figure.level) +
" " :
"";
207 const float level_width =
208 font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, level.c_str()).x;
209 const ImVec2 name_size =
210 font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, figure.name.c_str());
212 float top = with.
health ? bar_min.y - 2.0f : at.y;
215 if (with.
guilds && !figure.guild.empty()) {
216 const std::string guild =
"<" + figure.guild +
">";
217 const float guild_size = font_size * kGuildScale;
218 const ImVec2 extent =
219 font->CalcTextSizeA(guild_size, FLT_MAX, 0.0f, guild.c_str());
225 const float marked = MarkWidth(faction, name_size.y);
226 const float left = at.x - (marked + level_width + name_size.x) / 2;
228 DrawFactionMark(draw, *faction, {left, top}, name_size.y);
232 NameColor(figure, enemy), figure.name);