diff --git a/src/ui.cpp b/src/ui.cpp index 98126b2..88b20ac 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -26,8 +26,6 @@ constexpr float INDICATOR_SPEED = 2; constexpr float ITEM_SIZE = 96; constexpr float ROUNDING = 10; constexpr float BAR_EASE = 6; -constexpr float BAR_SHAKE = 2; -constexpr float BAR_SHAKE_SPEED = 40; constexpr float FLOATER_SHADOW = 3; constexpr float OVERSTUFFED_PULSE = 0.35f; constexpr float OVERSTUFFED_SPEED = 6; @@ -492,11 +490,23 @@ void Ui::taskbar_draw(Play& play, ImVec2 screen) float fills[] = {body.stage_progress_get(), stats.calories / std::max(1.0f, body.capacity_max_get()), digestion}; float overstuffed = std::clamp((stats.calories - stats.capacity) / (body.capacity_max_get() - stats.capacity), 0.0f, 1.0f); + auto widest_get = [](std::string text) { + for (char& character : text) + if (character >= '0' && character <= '9') + character = '8'; + return ImGui::CalcTextSize(text.c_str()).x; + }; + Traits& traits = data.traits; + std::string heaviest = weight_format(traits.weightMax, *measurement); + float fullest = traits.capacityMax * traits.overstuffedMultiplier; + float texts[] = {widest_get(heaviest + " / " + heaviest), + widest_get(text_format("%.0f / %.0f kcal", fullest, fullest)), + std::max(widest_get("Digesting..."), widest_get("100%"))}; float widths[std::size(labels)]; float used = 0; for (int i = 0; i < (int)std::size(labels); i++) { - widths[i] = std::max(BAR_WIDTH_MIN, ImGui::CalcTextSize(bars[i].c_str()).x + style.FramePadding.x * 4); + widths[i] = std::max(BAR_WIDTH_MIN, texts[i] + style.FramePadding.x * 4); used += ImGui::CalcTextSize(labels[i]).x + style.ItemSpacing.x + widths[i]; } int count = BUTTONS_FIXED + (int)data.interactTypes.size() + play.isCheats; @@ -569,13 +579,9 @@ void Ui::taskbar_draw(Play& play, ImVec2 screen) ImGui::SameLine(); float time = (float)ImGui::GetTime(); barFills[i] += (fills[i] - barFills[i]) * std::min(1.0f, BAR_EASE * ImGui::GetIO().DeltaTime); + float red = 1 - overstuffed * (1 - OVERSTUFFED_PULSE * (1 + std::sin(time * OVERSTUFFED_SPEED)) / 2); if (i == 1 && overstuffed > 0) - { - float red = 1 - overstuffed * (1 - OVERSTUFFED_PULSE * (1 + std::sin(time * OVERSTUFFED_SPEED)) / 2); ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(1, red, red, 1)); - ImVec2 cursor = ImGui::GetCursorScreenPos(); - ImGui::SetCursorScreenPos({cursor.x + std::sin(time * BAR_SHAKE_SPEED) * BAR_SHAKE * overstuffed, cursor.y}); - } ImGui::ProgressBar(barFills[i], {widths[i], 0}, bars[i].c_str()); if (i == 1 && overstuffed > 0) ImGui::PopStyleColor();