| 380 | |
| 381 | |
| 382 | void SampleUI::buildUI(void) |
| 383 | { |
| 384 | if (!m_ui.ShowUI) |
| 385 | return; |
| 386 | |
| 387 | RAII_SCOPE( ImGui::PushFont(m_defaultFont->GetScaledFont());, ImGui::PopFont(); ); |
| 388 | |
| 389 | // Ideally we'd want to rework UI scaling so that it is not based on m_currentScale but on ImGui::GetFontSize() so we can freely change fonts |
| 390 | auto& io = ImGui::GetIO(); |
| 391 | float scaledWidth = io.DisplaySize.x; |
| 392 | float scaledHeight = io.DisplaySize.y; |
| 393 | |
| 394 | const float defWindowWidth = 335.0f * m_currentScale; |
| 395 | const float defItemWidth = defWindowWidth * 0.3f * m_currentScale; |
| 396 | |
| 397 | auto imGuiCheckboxUInt32 = [ & ](const char* label, uint32_t* v) |
| 398 | { |
| 399 | bool pv = (*v) != 0; |
| 400 | bool ret = ImGui::Checkbox(label, &pv); |
| 401 | *v = pv ? (1) : (0); |
| 402 | return ret; |
| 403 | }; |
| 404 | |
| 405 | { |
| 406 | ImGui::SetNextWindowPos(ImVec2(10.f, 10.f), ImGuiCond_Appearing); |
| 407 | ImGui::SetNextWindowSize(ImVec2(defWindowWidth, scaledHeight - 20), ImGuiCond_Appearing); |
| 408 | |
| 409 | RAII_SCOPE( ImGui::Begin("Settings", 0, ImGuiWindowFlags_None /*AlwaysAutoResize*/); , ImGui::End(); ); |
| 410 | RAII_SCOPE( ImGui::PushItemWidth(defItemWidth); , ImGui::PopItemWidth(); ); |
| 411 | |
| 412 | const float indent = (int)ImGui::GetStyle().IndentSpacing*0.4f; |
| 413 | |
| 414 | ImGui::Text("%s, %s", GetDeviceManager()->GetRendererString(), m_app.GetResolutionInfo().c_str() ); |
| 415 | ImGui::Text(m_app.GetFPSInfo().c_str()); |
| 416 | |
| 417 | if (BuildUIScriptsAndEtc()) |
| 418 | { |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | if (ImGui::CollapsingHeader("Display and performance")) //, ImGuiTreeNodeFlags_DefaultOpen)) |
| 423 | { |
| 424 | RAII_SCOPE(ImGui::Indent(indent);, ImGui::Unindent(indent); ); |
| 425 | |
| 426 | { |
| 427 | if (ImGui::Button(StringFormat("Resolution: %dx%d (click to change)", m_app.GetDisplaySize().x, m_app.GetDisplaySize().y, m_app.GetRenderSize().x, m_app.GetRenderSize().y).c_str(), { -1, 0 })) |
| 428 | ImGui::OpenPopup("Resolution Picker"); |
| 429 | BuildUIResolutionPicker(); |
| 430 | } |
| 431 | |
| 432 | { |
| 433 | const char* currentPresetName = "Custom"; |
| 434 | for (const auto& preset : s_performancePresets) |
| 435 | if (MatchesPreset(m_ui, preset)) { currentPresetName = preset.Name; break; } |
| 436 | if (ImGui::Button(StringFormat("Perf. preset: %s (click to change)", currentPresetName).c_str(), { -1, 0 })) |
| 437 | ImGui::OpenPopup("Performance Preset"); |
| 438 | BuildUIPerformancePresets(); |
| 439 | } |
nothing calls this directly
no test coverage detected