SDK: Fix console layer having trouble with late constructed windows
Former-commit-id: 133d95cfd48f629cc9902c06861f3e6a73723a53 [formerly 7dde3eef66fc5274daf95b76b61d2b81fc6c9d16] [formerly e8e97d8cbaf703353b263a15cf51ed590f926818 [formerly f01a48da96b3fb545bb4d42d35e443c79f1bdfa0]] Former-commit-id: 67a9b3b9591490f94185b8ec917b5e1aab1a8e4e [formerly 90badb351e6406eb175dab65d9bb76f4f13bfd63] Former-commit-id: 37de44e5597c8cea7fcbd7455136eef8cb4cfee0
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user