ImGui: match all begin()/end() (#470)

This commit is contained in:
bslhq 2022-11-09 09:45:40 +08:00 committed by GitHub
parent 5adb1e9618
commit be287a1f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 42 deletions

1
.gitignore vendored
View File

@ -13,6 +13,7 @@
*.out *.out
*.app *.app
.vs .vs
.vscode
.idea/ .idea/
build/ build/

View File

@ -123,8 +123,8 @@ void LatteOverlay_renderOverlay(ImVec2& position, ImVec2& pivot, sint32 directio
g_renderer->AppendOverlayDebugInfo(); g_renderer->AppendOverlayDebugInfo();
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
ImGui::End();
} }
ImGui::End();
} }
ImGui::PopStyleColor(); ImGui::PopStyleColor();
@ -170,8 +170,8 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di
ImGui::TextUnformatted(s_mii_name.c_str()); ImGui::TextUnformatted(s_mii_name.c_str());
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
ImGui::End();
} }
ImGui::End();
// controller // controller
std::vector<std::pair<int, std::string>> profiles; std::vector<std::pair<int, std::string>> profiles;
@ -209,8 +209,8 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di
} }
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
ImGui::End();
} }
ImGui::End();
} }
else else
s_init_overlay = true; s_init_overlay = true;
@ -254,10 +254,8 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di
} }
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
ImGui::End();
} }
ImGui::End();
} }
} }
@ -306,8 +304,8 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di
} }
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
ImGui::End();
} }
ImGui::End();
} }
} }
@ -363,8 +361,8 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di
} }
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
ImGui::End();
} }
ImGui::End();
} }
} }
@ -435,8 +433,8 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di
} }
#endif #endif
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
ImGui::End();
} }
ImGui::End();
} }
} }
} }
@ -475,10 +473,9 @@ void LatteOverlay_RenderNotifications(ImVec2& position, ImVec2& pivot, sint32 di
} }
position.y += (ImGui::GetWindowSize().y + 10.0f) * direction; position.y += (ImGui::GetWindowSize().y + 10.0f) * direction;
}
ImGui::End(); ImGui::End();
} }
}
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopFont(); ImGui::PopFont();
} }

View File

@ -350,11 +350,11 @@ void LatteShaderCache_load()
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureTVId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 }); ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureTVId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
} }
}
ImGui::End(); ImGui::End();
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
g_renderer->ImguiEnd(); g_renderer->ImguiEnd();
} }
}
g_renderer->BeginFrame(false); g_renderer->BeginFrame(false);
if (g_renderer->ImguiBegin(false)) if (g_renderer->ImguiBegin(false))
@ -383,11 +383,11 @@ void LatteShaderCache_load()
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureDRCId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 }); ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureDRCId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
} }
}
ImGui::End(); ImGui::End();
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
g_renderer->ImguiEnd(); g_renderer->ImguiEnd();
} }
}
g_renderer->SwapBuffers(true, true); g_renderer->SwapBuffers(true, true);
} }
@ -452,8 +452,8 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
} }
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureTVId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 }); ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureTVId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
ImGui::End();
} }
ImGui::End();
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
} }
@ -502,8 +502,8 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
text = fmt::format("{}/{} ({}%)", g_shaderCacheLoaderState.loadedShaderFiles, g_shaderCacheLoaderState.shaderFileCount, (int)(percentLoaded * 100)); text = fmt::format("{}/{} ({}%)", g_shaderCacheLoaderState.loadedShaderFiles, g_shaderCacheLoaderState.shaderFileCount, (int)(percentLoaded * 100));
ImGui::SetCursorPosX(width - ImGui::CalcTextSize(text.c_str()).x / 2); ImGui::SetCursorPosX(width - ImGui::CalcTextSize(text.c_str()).x / 2);
ImGui::Text("%s", text.c_str()); ImGui::Text("%s", text.c_str());
ImGui::End();
} }
ImGui::End();
ImGui::PopFont(); ImGui::PopFont();
ImGui::PopStyleColor(2); ImGui::PopStyleColor(2);
@ -529,13 +529,11 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
ImGui::Text("Geometry shaders"); ImGui::Text("Geometry shaders");
ImGui::SameLine(offset); ImGui::SameLine(offset);
ImGui::Text("%d", shaderCacheScreenStats.geometryShaderCount); ImGui::Text("%d", shaderCacheScreenStats.geometryShaderCount);
ImGui::End();
} }
ImGui::End();
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::PopFont(); ImGui::PopFont();
} }
g_renderer->ImguiEnd(); g_renderer->ImguiEnd();
lastFrameUpdate = tick_cached(); lastFrameUpdate = tick_cached();
} }
@ -565,11 +563,11 @@ void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateF
} }
ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureDRCId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 }); ImGui::GetWindowDrawList()->AddImage(g_shaderCacheLoaderState.textureDRCId, ImVec2(paddingLeftAndRight, paddingTopAndBottom), ImVec2(io.DisplaySize.x-paddingLeftAndRight, io.DisplaySize.y-paddingTopAndBottom), { 0,1 }, { 1,0 });
} }
}
ImGui::End(); ImGui::End();
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
g_renderer->ImguiEnd(); g_renderer->ImguiEnd();
} }
}
// finish frame // finish frame
g_renderer->SwapBuffers(true, true); g_renderer->SwapBuffers(true, true);

View File

@ -347,7 +347,6 @@ namespace erreula
if (appearArg.button2Text) if (appearArg.button2Text)
button2 = boost::nowide::narrow(GetText(appearArg.button2Text.GetPtr())); button2 = boost::nowide::narrow(GetText(appearArg.button2Text.GetPtr()));
float width1 = std::max(100.0f, ImGui::CalcTextSize(button1.c_str()).x + 10.0f); float width1 = std::max(100.0f, ImGui::CalcTextSize(button1.c_str()).x + 10.0f);
float width2 = std::max(100.0f, ImGui::CalcTextSize(button2.c_str()).x + 10.0f); float width2 = std::max(100.0f, ImGui::CalcTextSize(button2.c_str()).x + 10.0f);
ImGui::SetCursorPosX(startx - (width1 / 2.0f) - (width2 / 2.0f) - 10); ImGui::SetCursorPosX(startx - (width1 / 2.0f) - (width2 / 2.0f) - 10);
@ -359,10 +358,8 @@ namespace erreula
break; break;
} }
} }
ImGui::End();
} }
ImGui::End();
ImGui::PopFont(); ImGui::PopFont();
if(g_errEula.buttonPressed || g_errEula.rightButtonPressed) if(g_errEula.buttonPressed || g_errEula.rightButtonPressed)

View File

@ -373,7 +373,7 @@ void swkbd_render(bool mainWindow)
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0,0 }); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0,0 });
ImGui::SetNextWindowBgAlpha(0.8f); ImGui::SetNextWindowBgAlpha(0.8f);
if (ImGui::Begin("Background overlay", nullptr, kPopupFlags | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoFocusOnAppearing)) ImGui::Begin("Background overlay", nullptr, kPopupFlags | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBringToFrontOnFocus);
ImGui::End(); ImGui::End();
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
@ -412,10 +412,8 @@ void swkbd_render(bool mainWindow)
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();
position.y += ImGui::GetWindowSize().y + 100.0f; position.y += ImGui::GetWindowSize().y + 100.0f;
ImGui::End();
} }
ImGui::End();
ImGui::PopFont(); ImGui::PopFont();
ImGui::SetNextWindowPos(position, ImGuiCond_Always, pivot); ImGui::SetNextWindowPos(position, ImGuiCond_Always, pivot);
@ -490,10 +488,8 @@ void swkbd_render(bool mainWindow)
} }
} }
ImGui::NewLine(); ImGui::NewLine();
ImGui::End();
} }
ImGui::End();
if (io.NavInputs[ImGuiNavInput_Cancel] > 0) if (io.NavInputs[ImGuiNavInput_Cancel] > 0)
{ {