12#include "absl/strings/str_cat.h"
13#include "absl/strings/substitute.h"
23constexpr float kTop = 146.0f;
24constexpr float kWidth = 520.0f;
25constexpr float kHeight = 18.0f;
30 const auto you = std::ranges::find_if(figures, &
Figure::you);
31 const Figure* shown =
nullptr;
33 for (
const Figure& figure : figures) {
34 if (!figure.monster || figure.phase == 0 ||
35 figure.to == protocol::MOTION_DEAD) {
38 if (figure.id == target) {
41 if (you == figures.end()) {
44 const float away = std::hypot(figure.position.x - you->position.x,
45 figure.position.z - you->position.z);
46 if (away <= nearest) {
55 ImDrawList* draw = ImGui::GetBackgroundDrawList();
56 const float width =
Ui(kWidth);
57 const float left = (ImGui::GetIO().DisplaySize.x - width) / 2.0f;
58 const float top =
Ui(kTop);
59 DrawTitle(draw, {left + width / 2.0f, top},
Ui(20.0f), boss.
name.c_str());
61 const ImVec2 min{left, top +
Ui(28.0f)};
62 const ImVec2 max{left + width, min.y +
Ui(kHeight)};
64 ?
static_cast<float>(boss.
health) /
67 const std::string health = absl::StrCat(boss.
health,
" / ", boss.
max_health);
73 int phases =
static_cast<int>(boss.
phase);
74 if (
const auto kind = monsters.
kinds.find(boss.
kind);
75 kind != monsters.
kinds.end()) {
76 phases = kind->second.phases_size();
77 for (
int i = 1; i < phases; ++i) {
79 static_cast<float>(kind->second.phases(i).health()) / 100.0f;
80 const float x = left + width * from;
81 draw->AddLine({x, min.y -
Ui(3.0f)}, {x, max.y +
Ui(3.0f)},
86 const std::string phase =
87 absl::Substitute(
Tr(
"Phase $0 of $1"), boss.
phase, phases);
90 bold->CalcTextSizeA(
Ui(13.0f), FLT_MAX, 0.0f, phase.c_str());
92 {left + (width - extent.x) / 2.0f, max.y +
Ui(5.0f)},
constexpr ImU32 kGoldLight
constexpr ImU32 kHealthDark
void DrawBossBar(const Figure &boss, const MonsterTable &monsters)
constexpr float kBossBarReach
void DrawBar(ImDrawList *draw, ImVec2 min, ImVec2 max, float share, ImU32 color, ImU32 dark, const char *text)
const Figure * ShownBoss(const std::vector< Figure > &figures, uint32_t target)
const char * Tr(const char *text)
void DrawTitle(ImDrawList *draw, ImVec2 top_centre, float size, const char *text)
A title in carved gold capitals, centred on the point at its top.
void DrawShadowedText(ImDrawList *draw, ImFont *font, float size, ImVec2 at, ImU32 color, const char *text)
Text with a shadow under it.
The kinds of monster, by id, and where they spawn.
std::map< uint32_t, monsters::Kind > kinds