mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
parent
8ea304bd54
commit
9dea5f5f3e
3 changed files with 22 additions and 8 deletions
|
|
@ -53,6 +53,10 @@ bool ImGuiImpl::Initialize(DeviceResources& deviceResources) noexcept {
|
|||
io.ConfigFlags |= ImGuiConfigFlags_NavNoCaptureKeyboard | ImGuiConfigFlags_NoMouseCursorChange;
|
||||
// 禁用 ini 配置文件
|
||||
io.IniFilename = nullptr;
|
||||
#ifndef _DEBUG
|
||||
// Release 配置下禁用重复 ID 检查
|
||||
io.ConfigDebugHighlightIdConflicts = false;
|
||||
#endif
|
||||
|
||||
if (!_backend.Initialize(deviceResources)) {
|
||||
Logger::Get().Error("初始化 ImGuiBackend 失败");
|
||||
|
|
|
|||
|
|
@ -110,12 +110,14 @@ void OverlayDrawer::Draw(
|
|||
_imguiImpl.NewFrame(_overlayOptions->windows, fittsLawAdjustment, _dpiScale);
|
||||
|
||||
bool needRedraw = false;
|
||||
// 防止 ID 冲突
|
||||
int itemId = 0;
|
||||
|
||||
if (_isToolbarVisible && _DrawToolbar(fps)) {
|
||||
if (_isToolbarVisible && _DrawToolbar(fps, itemId)) {
|
||||
needRedraw = true;
|
||||
}
|
||||
|
||||
if (_isProfilerVisible && _DrawProfiler(effectTimings, fps)) {
|
||||
if (_isProfilerVisible && _DrawProfiler(effectTimings, fps, itemId)) {
|
||||
needRedraw = true;
|
||||
}
|
||||
|
||||
|
|
@ -642,7 +644,7 @@ static std::string IconLabel(ImWchar iconChar) noexcept {
|
|||
return StrHelper::UTF16ToUTF8(text);
|
||||
}
|
||||
|
||||
bool OverlayDrawer::_DrawToolbar(uint32_t fps) noexcept {
|
||||
bool OverlayDrawer::_DrawToolbar(uint32_t fps, int& itemId) noexcept {
|
||||
bool needRedraw = false;
|
||||
|
||||
const float windowWidth = 360 * _dpiScale;
|
||||
|
|
@ -770,6 +772,7 @@ bool OverlayDrawer::_DrawToolbar(uint32_t fps) noexcept {
|
|||
|
||||
if (isDeveloperMode && effectDesc.passes.size() > 1) {
|
||||
// 开发者模式允许保存任意通道的输出
|
||||
ImGui::PushID(itemId++);
|
||||
if (ImGui::BeginMenu(effectName.data())) {
|
||||
const uint32_t passCount = (uint32_t)effectDesc.passes.size();
|
||||
for (uint32_t j = 0; j < passCount; ++j) {
|
||||
|
|
@ -777,28 +780,37 @@ bool OverlayDrawer::_DrawToolbar(uint32_t fps) noexcept {
|
|||
const uint32_t outputCount = (uint32_t)passDesc.outputs.size();
|
||||
|
||||
if (outputCount == 1) {
|
||||
ImGui::PushID(itemId++);
|
||||
if (ImGui::MenuItem(passDesc.desc.c_str())) {
|
||||
ScalingWindow::Get().Renderer().TakeScreenshot(i, j);
|
||||
}
|
||||
ImGui::PopID();
|
||||
} else {
|
||||
ImGui::PushID(itemId++);
|
||||
if (ImGui::BeginMenu(passDesc.desc.c_str())) {
|
||||
for (uint32_t k = 0; k < outputCount; ++k) {
|
||||
ImGui::PushID(itemId++);
|
||||
if (ImGui::MenuItem(effectDesc.textures[passDesc.outputs[k]].name.c_str())) {
|
||||
ScalingWindow::Get().Renderer().TakeScreenshot(i, j, k);
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::PopID();
|
||||
} else {
|
||||
ImGui::PushID(itemId++);
|
||||
if (ImGui::MenuItem(effectName.data())) {
|
||||
ScalingWindow::Get().Renderer().TakeScreenshot(i);
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -895,7 +907,7 @@ static std::string RectToStr(const RECT& rect) noexcept {
|
|||
#endif
|
||||
|
||||
// 返回 true 表示应再渲染一次
|
||||
bool OverlayDrawer::_DrawProfiler(const SmallVector<float>& effectTimings, uint32_t fps) noexcept {
|
||||
bool OverlayDrawer::_DrawProfiler(const SmallVector<float>& effectTimings, uint32_t fps, int& itemId) noexcept {
|
||||
const ScalingOptions& options = ScalingWindow::Get().Options();
|
||||
const Renderer& renderer = ScalingWindow::Get().Renderer();
|
||||
|
||||
|
|
@ -1097,8 +1109,6 @@ bool OverlayDrawer::_DrawProfiler(const SmallVector<float>& effectTimings, uint3
|
|||
}
|
||||
|
||||
static int selectedIdx = -1;
|
||||
// 防止 ID 冲突
|
||||
int itemId = 0;
|
||||
|
||||
if (nEffect > 1 || showPasses) {
|
||||
ImGui::Spacing();
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@ private:
|
|||
bool selected = false
|
||||
);
|
||||
|
||||
bool _DrawToolbar(uint32_t fps) noexcept;
|
||||
bool _DrawToolbar(uint32_t fps, int& itemId) noexcept;
|
||||
|
||||
bool _DrawProfiler(const SmallVector<float>& effectTimings, uint32_t fps) noexcept;
|
||||
bool _DrawProfiler(const SmallVector<float>& effectTimings, uint32_t fps, int& itemId) noexcept;
|
||||
|
||||
const std::string& _GetResourceString(const std::wstring_view& key) noexcept;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue