Commit a7c72dc0 authored by Florian Oetke's avatar Florian Oetke

ui hud tweaks

parent 4b9f919b
......@@ -13,7 +13,7 @@ namespace phase_shifter::ui {
using namespace mirrage::gui::literals;
namespace {
constexpr auto hud_height = 100;
constexpr auto hud_height = 130;
constexpr auto bar_height = 80;
constexpr auto beat_bar_height = 79;
constexpr auto bar_speed = 100;
......@@ -38,35 +38,24 @@ namespace phase_shifter::ui {
if(font.is_some())
ImGui::PushFont(font.get_or_throw());
ImGui::PositionNextWindow(glm::vec2(viewport.z, hud_height),
ImGui::WindowPosition_X::left,
ImGui::WindowPosition_Y::top);
if(ImGui::Begin("hud",
nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs)) {
ImGui::Text("%i", _beat_system.beat_state().beats_left);
ImGui::End();
}
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImColor(0, 0, 0, 180).Value);
ImGui::PushStyleColor(ImGuiCol_Border, ImColor(0, 0, 0, 0).Value);
ImGui::PositionNextWindow(glm::vec2(viewport.z, hud_height),
ImGui::WindowPosition_X::center,
ImGui::WindowPosition_Y::bottom);
if(ImGui::Begin("beat",
nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoInputs)) {
| ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoScrollbar)) {
ImGui::PushStyleColor(ImGuiCol_Border, "#00000000"_imcolor.Value); // Hide Border
ImVec2 cursor = ImGui::GetCursorScreenPos();
cursor.y += hud_height / 2.f - 10;
cursor.y += hud_height / 2.f + 10;
auto beat_state = _beat_system.beat_state();
auto beats = _beat_system.time_stamps();
auto beat_index = _beat_system.beat_index() + 1;
//auto line_offset = bar_speed * beat_state.avg_beat_time;
//auto beats = std::clamp(beat_state.beats_left, 0, 5);
ImGui::BeginChild("Line", {viewport.z, bar_height}, true);
ImGui::BeginChild("Line", {viewport.z, hud_height}, true);
ImDrawList* drawList = ImGui::GetWindowDrawList();
while(beat_index < static_cast<int>(beats.size())) {
......@@ -75,10 +64,10 @@ namespace phase_shifter::ui {
auto bar_color = beat_index < static_cast<int>(beats.size() * 0.8f) ? 0xFFFFFFFF : 0xFF0000FF;
ImVec2 p(cursor.x + viewport.z / 2 - x_offset, cursor.y - height / 2.f);
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 1);
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 2);
p.x = cursor.x + viewport.z / 2 + x_offset;
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 1);
drawList->AddLine(p, {p.x, p.y + height}, bar_color, 2);
if(x_offset > beat_bar_length + 50) {
break;
......@@ -87,7 +76,18 @@ namespace phase_shifter::ui {
}
ImVec2 middle(cursor.x + viewport.z / 2, cursor.y - bar_height / 2.f);
drawList->AddLine(middle, {middle.x, middle.y + bar_height}, 0xFFFF0000, 4);
drawList->AddLine(middle, {middle.x, middle.y + bar_height}, 0xFFFF0000, 6);
auto beat_color = (_beat_system.beat_state().beats_left < 50
&& _beat_system.beat_state().beats_left % 2 == 0)
? ImColor(255, 0, 0)
: ImColor(255, 255, 255);
auto beats_left = std::to_string(_beat_system.beat_state().beats_left);
auto text_size = ImGui::CalcTextSize(beats_left.c_str());
drawList->AddText(ImVec2(middle.x - text_size.x / 2.f, middle.y - text_size.y - 10),
beat_color,
beats_left.c_str());
ImGui::EndChild();
ImGui::PopStyleColor();
......@@ -102,6 +102,9 @@ namespace phase_shifter::ui {
}
}
ImGui::PopStyleColor();
ImGui::PopStyleColor();
if(font.is_some())
ImGui::PopFont();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment