Merge pull request #49 from antopilo/feature/NK-144-splash-screen

NK-144 Added splash screen
This commit is contained in:
Antoine Pilote
2023-07-23 01:03:28 -04:00
committed by GitHub
7 changed files with 176 additions and 20 deletions

View File

@@ -180,6 +180,12 @@ namespace Nuake
glfwSetWindowSize(m_Window, size.x, size.y);
}
void Window::SetPosition(const Vector2& position)
{
m_Position = position;
glfwSetWindowPos(m_Window, position.x, position.y);
}
void Window::SetMonitor(int monitorIdx)
{
int monitorCount;
@@ -193,6 +199,23 @@ namespace Nuake
}
}
void Window::Center()
{
const int windowWidth = 640;
const int windowHeight = 360;
// Get the primary monitor's video mode
const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
// Calculate the position to center the window
const int xPos = (mode->width - m_Width) / 2;
const int yPos = (mode->height - m_Height) / 2;
// Set the window's position
Nuake::Window::Get()->SetSize({ m_Width, m_Height });
Nuake::Window::Get()->SetPosition({ xPos, yPos });
}
Ref<Scene> Window::GetScene()
{
return m_Scene;
@@ -228,6 +251,11 @@ namespace Nuake
glfwSwapInterval(enabled ? 0 : 1);
}
void Window::SetDecorated(bool enabled)
{
glfwSetWindowAttrib(m_Window, GLFW_DECORATED, enabled);
}
void Window::InitImgui()
{
ImGui::CreateContext();

View File

@@ -22,7 +22,8 @@ namespace Nuake
std::string m_Title;
uint32_t m_Width;
uint32_t m_Height;
Vector2 m_Position;
Ref<FrameBuffer> m_Framebuffer;
Ref<Scene> m_Scene;
@@ -48,8 +49,12 @@ namespace Nuake
Vector2 GetSize() const;
void SetSize(const Vector2& size);
void SetPosition(const Vector2& position);
void SetMonitor(int monitor);
void Center();
Ref<Scene> GetScene();
bool SetScene(Ref<Scene> scene);
@@ -59,6 +64,7 @@ namespace Nuake
void SetWindowIcon(const std::string& path);
void SetVSync(bool enabled);
void SetDecorated(bool enabled);
private:
void InitImgui();
};