mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 20:50:06 +00:00
Move ImGuiCheckFonts back to only being called in map_widget (lock makes this safe)
This commit is contained in:
parent
9bd5af03f9
commit
c6596b3e7d
2 changed files with 6 additions and 27 deletions
|
|
@ -25,8 +25,7 @@ public:
|
||||||
explicit DrawLayerImpl(std::shared_ptr<MapContext> context) :
|
explicit DrawLayerImpl(std::shared_ptr<MapContext> context) :
|
||||||
context_ {context},
|
context_ {context},
|
||||||
drawList_ {},
|
drawList_ {},
|
||||||
textureAtlas_ {GL_INVALID_INDEX},
|
textureAtlas_ {GL_INVALID_INDEX}
|
||||||
imGuiRendererInitialized_ {false}
|
|
||||||
{
|
{
|
||||||
static size_t currentMapId_ {0u};
|
static size_t currentMapId_ {0u};
|
||||||
imGuiContextName_ = fmt::format("Layer {}", ++currentMapId_);
|
imGuiContextName_ = fmt::format("Layer {}", ++currentMapId_);
|
||||||
|
|
@ -52,36 +51,17 @@ public:
|
||||||
model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_);
|
model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGuiCheckFonts();
|
|
||||||
|
|
||||||
std::shared_ptr<MapContext> context_;
|
std::shared_ptr<MapContext> context_;
|
||||||
std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_;
|
std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_;
|
||||||
GLuint textureAtlas_;
|
GLuint textureAtlas_;
|
||||||
|
|
||||||
std::uint64_t textureAtlasBuildCount_ {};
|
std::uint64_t textureAtlasBuildCount_ {};
|
||||||
|
|
||||||
std::string imGuiContextName_;
|
std::string imGuiContextName_;
|
||||||
ImGuiContext* imGuiContext_;
|
ImGuiContext* imGuiContext_;
|
||||||
bool imGuiRendererInitialized_;
|
bool imGuiRendererInitialized_{};
|
||||||
std::uint64_t imGuiFontsBuildCount_ {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void DrawLayerImpl::ImGuiCheckFonts()
|
|
||||||
{
|
|
||||||
// Update ImGui Fonts if required
|
|
||||||
std::uint64_t currentImGuiFontsBuildCount =
|
|
||||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
|
||||||
|
|
||||||
if (imGuiFontsBuildCount_ != currentImGuiFontsBuildCount ||
|
|
||||||
!model::ImGuiContextModel::Instance().font_atlas()->IsBuilt())
|
|
||||||
{
|
|
||||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
|
||||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
|
||||||
}
|
|
||||||
|
|
||||||
imGuiFontsBuildCount_ = currentImGuiFontsBuildCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context) :
|
DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context) :
|
||||||
GenericLayer(context), p(std::make_unique<DrawLayerImpl>(context))
|
GenericLayer(context), p(std::make_unique<DrawLayerImpl>(context))
|
||||||
{
|
{
|
||||||
|
|
@ -111,7 +91,6 @@ void DrawLayer::StartImGuiFrame()
|
||||||
// Start ImGui Frame
|
// Start ImGui Frame
|
||||||
ImGui_ImplQt_NewFrame(p->context_->widget());
|
ImGui_ImplQt_NewFrame(p->context_->widget());
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
p->ImGuiCheckFonts();
|
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
ImGui::PushFont(defaultFont->font());
|
ImGui::PushFont(defaultFont->font());
|
||||||
}
|
}
|
||||||
|
|
@ -131,8 +110,6 @@ void DrawLayer::ImGuiInitialize()
|
||||||
ImGui::SetCurrentContext(p->imGuiContext_);
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
ImGui_ImplQt_RegisterWidget(p->context_->widget());
|
ImGui_ImplQt_RegisterWidget(p->context_->widget());
|
||||||
ImGui_ImplOpenGL3_Init();
|
ImGui_ImplOpenGL3_Init();
|
||||||
p->imGuiFontsBuildCount_ =
|
|
||||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
|
||||||
p->imGuiRendererInitialized_ = true;
|
p->imGuiRendererInitialized_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1576,6 +1576,9 @@ void MapWidget::paintGL()
|
||||||
std::shared_lock imguiFontAtlasLock {
|
std::shared_lock imguiFontAtlasLock {
|
||||||
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
||||||
|
|
||||||
|
// Check ImGui fonts
|
||||||
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
|
p->ImGuiCheckFonts();
|
||||||
|
|
||||||
// Update pixel ratio
|
// Update pixel ratio
|
||||||
p->context_->set_pixel_ratio(pixelRatio());
|
p->context_->set_pixel_ratio(pixelRatio());
|
||||||
|
|
@ -1593,7 +1596,6 @@ void MapWidget::paintGL()
|
||||||
// Start ImGui Frame
|
// Start ImGui Frame
|
||||||
ImGui_ImplQt_NewFrame(this);
|
ImGui_ImplQt_NewFrame(this);
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
p->ImGuiCheckFonts();
|
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
// Set default font
|
// Set default font
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue