SDK: Fix console layer having trouble with late constructed windows
Former-commit-id: 1af4cce1d920401963c3693661c19f0af5d23641 [formerly c5fb7cf9da6dd18a887b5d67fc2f43c135d5bee2] [formerly 9718a9b7c1bf161b46c085a82ab1bce46c045d6d [formerly cb26a07e6ce48b30727195e8f26e6fc6670ff86a]] Former-commit-id: ccd4866237e7d9d6cd3a83ff6a030d8acd053010 [formerly 9745165a6b024df81317dc96126e8209bee4bd32] Former-commit-id: 43b65ae9fb7793e9a9e79d1e8e9a718e4c3edce3
This commit is contained in:
parent
88b54cb43e
commit
11f4464d90
|
|
@ -88,7 +88,7 @@ namespace Ndk
|
|||
|
||||
NazaraSlot(Nz::EventHandler, OnEvent, eventSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnKeyPressed, keyPressedSlot);
|
||||
NazaraSlot(Nz::EventHandler, OnResized, resizedSlot);
|
||||
NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, resizedSlot);
|
||||
NazaraSlot(Nz::Log, OnLogWrite, logSlot);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -144,9 +144,16 @@ namespace Ndk
|
|||
{
|
||||
std::unique_ptr<ConsoleOverlay> overlay = std::make_unique<ConsoleOverlay>();
|
||||
|
||||
overlay->console = std::make_unique<Console>(*info.overlayWorld, Nz::Vector2f(Nz::Vector2ui(info.window->GetWidth(), info.window->GetHeight() / 4)), overlay->lua);
|
||||
Nz::Vector2ui windowDimensions;
|
||||
if (info.window->IsValid())
|
||||
windowDimensions.Set(info.window->GetWidth(), info.window->GetHeight() / 4);
|
||||
else
|
||||
windowDimensions.MakeZero();
|
||||
|
||||
overlay->console = std::make_unique<Console>(*info.overlayWorld, Nz::Vector2f(windowDimensions), overlay->lua);
|
||||
|
||||
Console& consoleRef = *overlay->console;
|
||||
|
||||
// Redirect logs toward the console
|
||||
overlay->logSlot.Connect(Nz::Log::OnLogWrite, [&consoleRef] (const Nz::String& str)
|
||||
{
|
||||
|
|
@ -201,9 +208,9 @@ namespace Ndk
|
|||
consoleRef.Show(!consoleRef.IsVisible());
|
||||
});
|
||||
|
||||
overlay->resizedSlot.Connect(eventHandler.OnResized, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::SizeEvent& event)
|
||||
overlay->resizedSlot.Connect(info.renderTarget->OnRenderTargetSizeChange, [&consoleRef] (const Nz::RenderTarget* renderTarget)
|
||||
{
|
||||
consoleRef.SetSize({float(event.width), event.height / 4.f});
|
||||
consoleRef.SetSize({float(renderTarget->GetWidth()), renderTarget->GetHeight() / 4.f});
|
||||
});
|
||||
|
||||
info.console = std::move(overlay);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ErrorFlags.hpp>
|
||||
#include <Nazara/Core/LockGuard.hpp>
|
||||
|
|
@ -60,25 +61,22 @@ namespace Nz
|
|||
else if (style & WindowStyle_Closable || style & WindowStyle_Resizable)
|
||||
style |= WindowStyle_Titlebar;
|
||||
|
||||
m_impl = new WindowImpl(this);
|
||||
if (!m_impl->Create(mode, title, style))
|
||||
std::unique_ptr<WindowImpl> impl = std::make_unique<WindowImpl>(this);
|
||||
if (!impl->Create(mode, title, style))
|
||||
{
|
||||
NazaraError("Failed to create window implementation");
|
||||
delete m_impl;
|
||||
m_impl = nullptr;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_impl = impl.release();
|
||||
CallOnExit destroyOnFailure([this] () { Destroy(); });
|
||||
|
||||
m_closed = false;
|
||||
m_ownsWindow = true;
|
||||
|
||||
if (!OnWindowCreated())
|
||||
{
|
||||
NazaraError("Failed to initialize window extension");
|
||||
delete m_impl;
|
||||
m_impl = nullptr;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +91,10 @@ namespace Nz
|
|||
if (opened)
|
||||
m_impl->SetPosition(position.x, position.y);
|
||||
|
||||
OnWindowResized();
|
||||
|
||||
destroyOnFailure.Reset();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue