mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Merge pull request #49 from antopilo/feature/NK-144-splash-screen
NK-144 Added splash screen
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
#include "../Misc/InterfaceFonts.h"
|
||||
|
||||
#include "WelcomeWindow.h"
|
||||
#include "LoadingSplash.h"
|
||||
|
||||
#include "src/Rendering/SceneRenderer.h"
|
||||
#include <dependencies/glfw/include/GLFW/glfw3.h>
|
||||
#include <src/Rendering/Buffers/Framebuffer.h>
|
||||
@@ -1505,10 +1507,41 @@ namespace Nuake {
|
||||
}
|
||||
}
|
||||
|
||||
bool isLoadingProject = false;
|
||||
bool isLoadingProjectQueue = false;
|
||||
|
||||
int frameCount = 2;
|
||||
void EditorInterface::Draw()
|
||||
{
|
||||
Init();
|
||||
|
||||
if (isLoadingProjectQueue)
|
||||
{
|
||||
_WelcomeWindow->LoadQueuedProject();
|
||||
isLoadingProjectQueue = false;
|
||||
|
||||
auto& window = Window::Get();
|
||||
window->SetDecorated(true);
|
||||
window->SetSize({ 1900, 1000 });
|
||||
window->Center();
|
||||
frameCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_WelcomeWindow->IsProjectQueued() && frameCount > 0)
|
||||
{
|
||||
// draw splash
|
||||
LoadingSplash::Get().Draw();
|
||||
|
||||
frameCount--;
|
||||
if (frameCount == 0)
|
||||
{
|
||||
isLoadingProjectQueue = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Engine::GetProject())
|
||||
{
|
||||
_WelcomeWindow->Draw();
|
||||
|
||||
51
Editor/src/Windows/LoadingSplash.cpp
Normal file
51
Editor/src/Windows/LoadingSplash.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "LoadingSplash.h"
|
||||
|
||||
#include "../Misc/InterfaceFonts.h"
|
||||
|
||||
#include <src/Core/Maths.h>
|
||||
#include "src/Window.h"
|
||||
|
||||
|
||||
#include <src/Vendors/imgui/imgui.h>
|
||||
|
||||
#include <dependencies/glfw/include/GLFW/glfw3.h>
|
||||
#include <src/Rendering/Textures/TextureManager.h>
|
||||
|
||||
|
||||
LoadingSplash::LoadingSplash()
|
||||
{
|
||||
_NuakeLogo = Nuake::TextureManager::Get()->GetTexture(NUAKE_LOGO_PATH);
|
||||
|
||||
Nuake::Window::Get()->SetDecorated(false);
|
||||
Nuake::Window::Get()->SetSize({ 640, 480 });
|
||||
Nuake::Window::Get()->Center();
|
||||
}
|
||||
|
||||
void LoadingSplash::Draw()
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
// Make viewport fullscreen
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->Pos);
|
||||
ImGui::SetNextWindowSize(viewport->Size);
|
||||
ImGui::SetNextWindowViewport(viewport->ID);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(32.0f, 32.0f));
|
||||
ImGui::Begin("Welcome Screen", 0, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize);
|
||||
{
|
||||
// Draw Nuake logo
|
||||
{
|
||||
const Vector2 logoSize = _NuakeLogo->GetSize();
|
||||
const ImVec2 imguiSize = ImVec2(logoSize.x, logoSize.y);
|
||||
ImGui::Image((ImTextureID)_NuakeLogo->GetID(), imguiSize, ImVec2(0, 1), ImVec2(1, 0));
|
||||
}
|
||||
|
||||
ImGui::Text("LOADING SCENE...");
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
29
Editor/src/Windows/LoadingSplash.h
Normal file
29
Editor/src/Windows/LoadingSplash.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include <src/Core/Core.h>
|
||||
#include <src/Rendering/Textures/Texture.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
class Texture;
|
||||
}
|
||||
|
||||
class LoadingSplash
|
||||
{
|
||||
private:
|
||||
const std::string NUAKE_LOGO_PATH = "resources/Images/logo_white.png";
|
||||
Ref<Nuake::Texture> _NuakeLogo;
|
||||
|
||||
public:
|
||||
static LoadingSplash& LoadingSplash::Get()
|
||||
{
|
||||
static LoadingSplash instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
LoadingSplash();
|
||||
~LoadingSplash() = default;
|
||||
|
||||
void Draw();
|
||||
};
|
||||
@@ -82,6 +82,30 @@ namespace Nuake
|
||||
_NuakeLogo = TextureManager::Get()->GetTexture(NUAKE_LOGO_PATH);
|
||||
}
|
||||
|
||||
void WelcomeWindow::LoadQueuedProject()
|
||||
{
|
||||
auto project = Project::New();
|
||||
auto projectFileData = FileSystem::ReadFile(queuedProjectPath, true);
|
||||
try
|
||||
{
|
||||
project->Deserialize(projectFileData);
|
||||
project->FullPath = queuedProjectPath;
|
||||
|
||||
Engine::LoadProject(project);
|
||||
|
||||
_Editor->filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
|
||||
}
|
||||
catch (std::exception exception)
|
||||
{
|
||||
Logger::Log("Error loading project: " + queuedProjectPath, "editor", CRITICAL);
|
||||
Logger::Log(exception.what());
|
||||
return;
|
||||
}
|
||||
|
||||
queuedProjectPath = "";
|
||||
Engine::GetCurrentWindow()->SetTitle("Nuake Engine - Editing " + project->Name);
|
||||
}
|
||||
|
||||
void WelcomeWindow::Draw()
|
||||
{
|
||||
// Make viewport fullscreen
|
||||
@@ -257,24 +281,7 @@ namespace Nuake
|
||||
std::string projectPath = _Projects[SelectedProject].Path;
|
||||
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
|
||||
|
||||
auto project = Project::New();
|
||||
auto projectFileData = FileSystem::ReadFile(projectPath, true);
|
||||
try
|
||||
{
|
||||
project->Deserialize(projectFileData);
|
||||
project->FullPath = projectPath;
|
||||
|
||||
Engine::LoadProject(project);
|
||||
|
||||
_Editor->filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
|
||||
}
|
||||
catch (std::exception exception)
|
||||
{
|
||||
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
|
||||
Logger::Log(exception.what());
|
||||
}
|
||||
|
||||
Engine::GetCurrentWindow()->SetTitle("Nuake Engine - Editing " + project->Name);
|
||||
queuedProjectPath = projectPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +41,15 @@ namespace Nuake
|
||||
|
||||
uint32_t SelectedProject = 0;
|
||||
std::vector<ProjectPreview> _Projects;
|
||||
|
||||
std::string queuedProjectPath;
|
||||
public:
|
||||
WelcomeWindow(Nuake::EditorInterface* editor);
|
||||
~WelcomeWindow() = default;
|
||||
|
||||
void Draw();
|
||||
|
||||
bool IsProjectQueued() const { return !queuedProjectPath.empty(); };
|
||||
void LoadQueuedProject();
|
||||
private:
|
||||
void DrawRecentProjectsSection();
|
||||
void DrawProjectItem(const uint32_t projectPreview);
|
||||
|
||||
Reference in New Issue
Block a user