Added SceneSwitching, Better font rendering, DOM inspector, Font-family prop

This commit is contained in:
antopilo
2024-09-13 17:18:09 -04:00
parent 4c76e9e493
commit 89ea32a4b3
22 changed files with 241 additions and 248 deletions

View File

@@ -24,6 +24,7 @@ namespace Nuake
{
Ref<Project> Engine::currentProject;
Ref<Window> Engine::currentWindow;
std::string Engine::queuedScene = "";
GameState Engine::gameState = GameState::Stopped;
@@ -60,6 +61,33 @@ namespace Nuake
timeStep = time - lastFrameTime;
lastFrameTime = time;
if (Engine::IsPlayMode())
{
if (!queuedScene.empty())
{
Ref<Scene> nextScene = Scene::New();
if (FileSystem::FileExists(queuedScene))
{
const std::string& fileContent = FileSystem::ReadFile(queuedScene);
nextScene->Path = queuedScene;
nextScene->Deserialize(json::parse(fileContent));
// Uninit current scene
GetCurrentScene()->OnExit();
// Set new scene
SetCurrentScene(nextScene);
// Init new scene
PhysicsManager::Get().ReInit();
GetCurrentScene()->OnInit();
queuedScene = "";
}
}
}
// Dont update if no scene is loaded.
if (currentWindow->GetScene())
{
@@ -167,6 +195,18 @@ namespace Nuake
return currentWindow->SetScene(scene);
}
bool Engine::QueueSceneSwitch(const std::string& scenePath)
{
if (!IsPlayMode())
{
return false;
}
queuedScene = scenePath;
return true;
}
Ref<Project> Engine::GetProject()
{
return currentProject;