104 style.WindowPadding = {16.0f, 12.0f};
105 style.FramePadding = {10.0f, 6.0f};
106 style.ItemSpacing = {8.0f, 7.0f};
107 style.ItemInnerSpacing = {6.0f, 5.0f};
108 style.CellPadding = {6.0f, 4.0f};
109 style.IndentSpacing = 18.0f;
110 style.ScrollbarSize = 10.0f;
111 style.GrabMinSize = 12.0f;
112 style.WindowRounding = 0.0f;
113 style.ChildRounding = 0.0f;
114 style.FrameRounding = 2.0f;
115 style.PopupRounding = 2.0f;
116 style.ScrollbarRounding = 2.0f;
117 style.GrabRounding = 2.0f;
118 style.TabRounding = 2.0f;
120 style.WindowBorderSize = 0.0f;
121 style.ChildBorderSize = 0.0f;
122 style.FrameBorderSize = 1.0f;
123 style.PopupBorderSize = 1.0f;
124 style.WindowTitleAlign = {0.5f, 0.5f};
125 style.SeparatorTextAlign = {0.5f, 0.5f};
126 style.SeparatorTextBorderSize = 1.0f;
128 ImVec4* c = style.Colors;
133 c[ImGuiCol_PopupBg] = Float4(IM_COL32(22, 10, 12, 255), 0.97f);
137 c[ImGuiCol_FrameBgHovered] = Float4(IM_COL32(40, 10, 15, 255));
138 c[ImGuiCol_FrameBgActive] = Float4(IM_COL32(56, 12, 19, 255));
179 c[ImGuiCol_TableRowBgAlt] = ImVec4(1.0f, 1.0f, 1.0f, 0.03f);
186 c[ImGuiCol_NavWindowingHighlight] = Float4(
colors::kGold, 0.7f);
187 c[ImGuiCol_NavWindowingDimBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.5f);
188 c[ImGuiCol_ModalWindowDimBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.6f);
190 style.ScaleAllSizes(at);
193 style.FrameBorderSize = std::max(style.FrameBorderSize, 1.0f);
194 style.PopupBorderSize = std::max(style.PopupBorderSize, 1.0f);
195 style.SeparatorTextBorderSize = std::max(style.SeparatorTextBorderSize, 1.0f);
197 style.FontScaleMain = at;
198 ImGui::GetStyle() = style;
213void DrawDiamond(ImDrawList* draw, ImVec2 centre,
float radius, ImU32 fill,
215 const ImVec2 top{centre.x, centre.y - radius};
216 const ImVec2 right{centre.x + radius, centre.y};
217 const ImVec2 bottom{centre.x, centre.y + radius};
218 const ImVec2 left{centre.x - radius, centre.y};
219 draw->AddQuadFilled(top, right, bottom, left, fill);
220 draw->AddQuad(top, right, bottom, left, outline, std::max(1.0f,
Ui(1.0f)));
223void DrawPanel(ImDrawList* draw, ImVec2 min, ImVec2 max,
float alpha) {
224 const float cut =
Ui(10.0f);
226 const ImVec2 drop =
Ui(ImVec2{3.0f, 4.0f});
227 PathPanel(draw, {min.x + drop.x, min.y + drop.y},
228 {max.x + drop.x, max.y + drop.y}, cut);
229 draw->PathFillConvex(
Faded(IM_COL32_BLACK, 0.45f * alpha));
232 const int first = draw->VtxBuffer.Size;
235 ImGui::ShadeVertsLinearColorGradientKeepAlpha(
236 draw, first, draw->VtxBuffer.Size, min, {min.x, max.y},
colors::kCoal,
240 const float glow = std::min(
Ui(46.0f), (max.y - min.y) * 0.5f);
241 draw->AddRectFilledMultiColor(
242 {min.x + cut * 0.6f, min.y +
Ui(2.0f)},
250 const float inset =
Ui(3.5f);
251 PathPanel(draw, {min.x + inset, min.y + inset},
252 {max.x - inset, max.y - inset}, cut * 0.75f);
254 std::max(1.0f,
Ui(0.8f)));
284 ImU32 top, ImU32 bottom,
const char* text) {
285 const float offset = std::max(1.0f, size / 14.0f);
287 static_cast<float>((top >> IM_COL32_A_SHIFT) & 0xFF) / 255.0f;
288 draw->AddText(font, size, {at.x + offset, at.y + offset},
289 Faded(IM_COL32_BLACK, 0.85f * alpha), text);
290 const int first = draw->VtxBuffer.Size;
291 draw->AddText(font, size, at, top, text);
294 ImGui::ShadeVertsLinearColorGradientKeepAlpha(
295 draw, first, draw->VtxBuffer.Size, {at.x, at.y + size * 0.2f},
296 {at.x, at.y + size * 0.85f}, top, bottom);
320bool BeginPanel(
const char* name,
bool* open, ImGuiWindowFlags flags,
323 const bool shown = ImGui::Begin(
325 flags | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBackground |
326 ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar);
327 ImDrawList* draw = ImGui::GetWindowDrawList();
328 const ImVec2 min = ImGui::GetWindowPos();
329 const ImVec2 size = ImGui::GetWindowSize();
330 const ImVec2 max{min.x + size.x, min.y + size.y};
332 draw->PushClipRectFullScreen();
336 const std::string title =
Tr(
Shown(name).c_str());
337 const float title_size =
Ui(19.0f);
338 if (!title.empty()) {
339 DrawTitle(draw, {min.x + size.x / 2.0f, min.y +
Ui(9.0f)}, title_size,
341 DrawDivider(draw, {min.x +
Ui(18.0f), min.y + TitleHeight()},
346 if (open !=
nullptr) {
350 const float button =
Ui(20.0f);
351 const float inset = ImGui::GetStyle().WindowPadding.x;
352 const ImVec2 corner{max.x - button - inset, min.y +
Ui(8.0f)};
353 const ImVec2 saved = ImGui::GetCursorPos();
354 ImGui::SetCursorScreenPos(corner);
355 if (ImGui::InvisibleButton(
"##close", {button, button})) {
358 const bool hovered = ImGui::IsItemHovered();
359 const ImVec2 middle{corner.x + button / 2.0f, corner.y + button / 2.0f};
360 const float arm = button * 0.22f;
365 draw->AddLine({middle.x - arm, middle.y - arm},
366 {middle.x + arm, middle.y + arm}, ink,
Ui(2.0f));
367 draw->AddLine({middle.x - arm, middle.y + arm},
368 {middle.x + arm, middle.y - arm}, ink,
Ui(2.0f));
369 ImGui::SetCursorPos(saved);
371 if (!title.empty()) {
373 ImGui::SetCursorPosY(
374 std::max(ImGui::GetCursorPosY(), TitleHeight() +
Ui(10.0f)));
381bool GameButton(
const char* label, ImVec2 size,
bool primary,
bool enabled) {
382 const std::string text =
Tr(
Shown(label).c_str());
384 const float text_size = primary ?
Ui(17.0f) :
Ui(15.0f);
385 const ImVec2 extent =
386 font->CalcTextSizeA(text_size, FLT_MAX, 0.0f, text.c_str());
388 size.x = ImGui::GetContentRegionAvail().x;
389 }
else if (size.x == 0.0f) {
390 size.x = extent.x +
Ui(36.0f);
392 if (size.y <= 0.0f) {
393 size.y = primary ?
Ui(44.0f) :
Ui(34.0f);
395 ImGui::BeginDisabled(!enabled);
396 const bool clicked = ImGui::InvisibleButton(label, size) && enabled;
397 ImGui::EndDisabled();
398 const bool hovered = enabled && ImGui::IsItemHovered();
399 const bool held = enabled && ImGui::IsItemActive();
400 const ImVec2 min = ImGui::GetItemRectMin();
401 const ImVec2 max = ImGui::GetItemRectMax();
402 ImDrawList* draw = ImGui::GetWindowDrawList();
403 const float cut = std::min(
Ui(7.0f), size.y * 0.3f);
405 ImU32 top = primary ?
colors::kRed : IM_COL32(64, 14, 21, 255);
406 ImU32 bottom = primary ?
colors::kWine : IM_COL32(28, 8, 11, 255);
407 if (primary && hovered) {
410 }
else if (hovered) {
411 top = IM_COL32(110, 20, 30, 255);
412 bottom = IM_COL32(48, 10, 15, 255);
415 std::swap(top, bottom);
417 const float alpha = enabled ? 1.0f : 0.45f;
418 if (primary && hovered) {
420 for (
int ring = 3; ring >= 1; --ring) {
421 const float spread =
Ui(2.5f) *
static_cast<float>(ring);
422 PathPanel(draw, {min.x - spread, min.y - spread},
423 {max.x + spread, max.y + spread}, cut + spread);
427 const int first = draw->VtxBuffer.Size;
429 draw->PathFillConvex(
Faded(top, alpha));
430 ImGui::ShadeVertsLinearColorGradientKeepAlpha(
431 draw, first, draw->VtxBuffer.Size, min, {min.x, max.y}, top, bottom);
433 draw->AddRectFilledMultiColor(
434 {min.x + cut, min.y +
Ui(1.5f)}, {max.x - cut, (min.y + max.y) / 2.0f},
435 Faded(IM_COL32_WHITE, 0.10f * alpha),
436 Faded(IM_COL32_WHITE, 0.10f * alpha),
Faded(IM_COL32_WHITE, 0.0f),
437 Faded(IM_COL32_WHITE, 0.0f));
443 ImDrawFlags_Closed,
Ui(primary ? 1.6f : 1.2f));
444 const ImVec2 at{(min.x + max.x - extent.x) / 2.0f,
445 (min.y + max.y - extent.y) / 2.0f + (held ?
Ui(1.0f) : 0.0f)};
452void DrawBar(ImDrawList* draw, ImVec2 min, ImVec2 max,
float share, ImU32 color,
453 ImU32 dark,
const char* text) {
454 share = std::clamp(share, 0.0f, 1.0f);
457 const ImVec2 full{min.x + (max.x - min.x) * share, max.y};
458 draw->AddRectFilledMultiColor(min, full, color, color, dark, dark);
460 draw->AddRectFilledMultiColor(
461 min, {full.x, min.y + (max.y - min.y) * 0.45f},
462 Faded(IM_COL32_WHITE, 0.25f),
Faded(IM_COL32_WHITE, 0.25f),
463 Faded(IM_COL32_WHITE, 0.0f),
Faded(IM_COL32_WHITE, 0.0f));
465 draw->AddLine({full.x, min.y}, {full.x, max.y},
469 if (text !=
nullptr && text[0] !=
'\0') {
471 const float size = std::min(
Ui(15.0f), (max.y - min.y) * 0.95f);
472 const ImVec2 extent = font->CalcTextSizeA(size, FLT_MAX, 0.0f, text);
475 {(min.x + max.x - extent.x) / 2.0f, (min.y + max.y - extent.y) / 2.0f},
480void DrawSlot(ImDrawList* draw, ImVec2 min, ImVec2 max, ImU32 edge) {
481 draw->AddRectFilled({min.x +
Ui(1.0f), min.y +
Ui(2.0f)},
482 {max.x +
Ui(1.0f), max.y +
Ui(2.0f)},
483 Faded(IM_COL32_BLACK, 0.5f));
485 draw->AddRectFilledMultiColor(
486 min, max, IM_COL32(6, 3, 4, 240), IM_COL32(6, 3, 4, 240),
487 IM_COL32(34, 16, 18, 240), IM_COL32(34, 16, 18, 240));
489 const float inset =
Ui(2.5f);
490 draw->AddRect({min.x + inset, min.y + inset}, {max.x - inset, max.y - inset},
492 if (((edge >> IM_COL32_A_SHIFT) & 0xFF) != 0) {
493 draw->AddRect({min.x -
Ui(1.0f), min.y -
Ui(1.0f)},
494 {max.x +
Ui(1.0f), max.y +
Ui(1.0f)}, edge, 0.0f, 0,
496 draw->AddRectFilledMultiColor({min.x + inset, min.y + inset},
497 {max.x - inset, max.y - inset},
566 IM_COL32(40, 8, 12, 255));
568 const ImVec2 fire{size.x / 2.0f, size.y * 1.05f};
569 for (
int ring = 10; ring >= 1; --ring) {
570 const float share =
static_cast<float>(ring) / 10.0f;
571 draw->AddEllipseFilled(fire,
572 {size.x * 0.7f * share, size.y * 0.55f * share},
576 constexpr int kEmbers = 90;
577 for (
int i = 0; i < kEmbers; ++i) {
578 const auto seed =
static_cast<uint32_t
>(i) * 4u;
579 const float speed = 0.03f + 0.07f * Scatter(seed);
580 const float rise = std::fmod(time * speed + Scatter(seed + 1), 1.0f);
581 const float x = size.x * Scatter(seed + 2) +
582 std::sin(time * 0.7f +
static_cast<float>(i)) *
Ui(14.0f);
583 const float y = size.y * (1.05f - 1.1f * rise);
584 const float radius =
Ui(1.0f + 2.2f * Scatter(seed + 3));
586 const float flicker =
587 0.6f + 0.4f * std::sin(time * 6.0f +
static_cast<float>(i) * 1.7f);
588 const float alpha = (1.0f - rise) * flicker;
591 draw->AddCircleFilled({x, y}, radius * 3.0f,
Faded(color, 0.12f * alpha));
592 draw->AddCircleFilled({x, y}, radius,
Faded(color, alpha));
595 const float edge = std::min(size.x, size.y) * 0.25f;
596 const ImU32 dark =
Faded(IM_COL32_BLACK, 0.6f);
597 const ImU32 clear =
Faded(IM_COL32_BLACK, 0.0f);
598 draw->AddRectFilledMultiColor({0.0f, 0.0f}, {edge, size.y}, dark, clear,
600 draw->AddRectFilledMultiColor({size.x - edge, 0.0f}, size, clear, dark, dark,
602 draw->AddRectFilledMultiColor({0.0f, 0.0f}, {size.x, edge}, dark, dark, clear,