Skip to content

Commit

Permalink
[editor] centered yes and no buttons in the download assets prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosK92 committed Oct 31, 2024
1 parent 25b0b25 commit d527baa
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions editor/EditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,22 +457,34 @@ namespace
ImGui::Text("No default worlds are present. Would you like to download them?");
ImGui::Separator();

if (ImGui::Button("Yes"))
{
Spartan::FileSystem::Command("python download_assets.py", world_on_download_finished, false);
Spartan::ProgressTracker::SetLoadingStateGlobal(true);
visible_download = false;
}
ImGui::SameLine();
if (ImGui::Button("No"))
// calculate the offset to center the group
float button_width = ImGui::CalcTextSize("Yes").x + ImGui::CalcTextSize("No").x + ImGui::GetStyle().ItemSpacing.x * 3.0f;
float offset_x = (ImGui::GetContentRegionAvail().x - button_width) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + offset_x);

// group yes and no buttons
ImGui::BeginGroup();
{
visible_download = false;
visible = false;
if (ImGui::Button("Yes"))
{
Spartan::FileSystem::Command("python download_assets.py", world_on_download_finished, false);
Spartan::ProgressTracker::SetLoadingStateGlobal(true);
visible_download = false;
}

ImGui::SameLine();

if (ImGui::Button("No"))
{
visible_download = false;
visible = false;
}
}
ImGui::EndGroup();
}
ImGui::End();
}

if (visible)
{
ImGui::SetNextWindowPos(editor->GetWidget<Viewport>()->GetCenter(), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
Expand Down

0 comments on commit d527baa

Please sign in to comment.