mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-06 06:09:52 +03:00
Added SceneSwitching, Better font rendering, DOM inspector, Font-family prop
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -44,6 +44,7 @@ namespace Nuake
|
||||
static Ref<Window> GetCurrentWindow();
|
||||
|
||||
static bool SetCurrentScene(Ref<Scene> scene);
|
||||
static bool QueueSceneSwitch(const std::string& scene);
|
||||
static Ref<Scene> GetCurrentScene();
|
||||
|
||||
static bool LoadProject(Ref<Project> project);
|
||||
@@ -53,6 +54,7 @@ namespace Nuake
|
||||
static Ref<Window> currentWindow;
|
||||
static Ref<Project> currentProject;
|
||||
static Ref<Scene> currentScene;
|
||||
static std::string queuedScene;
|
||||
|
||||
static GameState gameState;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <Tracy.hpp>
|
||||
#include <src/UI/Renderer.h>
|
||||
|
||||
#include "src/UI/Inspector.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
@@ -464,6 +465,8 @@ namespace Nuake
|
||||
Renderer::DrawQuad();
|
||||
}
|
||||
framebuffer.Unbind();
|
||||
|
||||
NuakeUI::DrawInspector(uiResource->GetCanvas());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "Texture.h"
|
||||
#include "src/Core/Logger.h"
|
||||
#include <glad/glad.h>
|
||||
#include <iostream>
|
||||
#include "src/FileSystem/FileSystem.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
Texture::Texture(const std::string& path)
|
||||
@@ -41,21 +43,18 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
Texture::Texture(Vector2 size, void* data)
|
||||
Texture::Texture(const TextureFlags& flags, Vector2 size, void* data)
|
||||
{
|
||||
m_Width = size.x;
|
||||
m_Height = size.y;
|
||||
|
||||
glGenTextures(1, &m_RendererId);
|
||||
glBindTexture(GL_TEXTURE_2D, m_RendererId);
|
||||
//glGenerateMipmap(GL_TEXTURE_2D);
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -1.0f);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)GL_RGBA, size.x, size.y, 0, (GLenum)GL_RGBA, (GLenum)GL_UNSIGNED_BYTE, data);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)flags.pixelFormat, size.x, size.y, 0, (GLenum)flags.pixelFormat, (GLenum)flags.pixelDataType, data);
|
||||
|
||||
SetMagnificationFilter(flags.magFilter);
|
||||
SetMinificationFilter(flags.minFilter);
|
||||
SetWrapping(flags.wrapping);
|
||||
}
|
||||
|
||||
Texture::Texture(Vector2 size, GLenum format, GLenum format2, GLenum format3, void* data)
|
||||
@@ -95,11 +94,6 @@ namespace Nuake
|
||||
glGenTextures(1, &m_RendererId);
|
||||
glBindTexture(GL_TEXTURE_2D, m_RendererId);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -1.0f);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_LocalBuffer);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
@@ -160,6 +154,25 @@ namespace Nuake
|
||||
Unbind();
|
||||
}
|
||||
|
||||
void Texture::SetMagnificationFilter(const SamplerFilter& filter)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, m_RendererId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)filter);
|
||||
}
|
||||
|
||||
void Texture::SetMinificationFilter(const SamplerFilter& filter)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, m_RendererId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter);
|
||||
}
|
||||
|
||||
void Texture::SetWrapping(const SamplerWrapping& wrapping)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, m_RendererId);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (GLint)wrapping);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (GLint)wrapping);
|
||||
}
|
||||
|
||||
json Texture::Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
@@ -11,6 +11,41 @@ namespace Nuake
|
||||
{
|
||||
typedef unsigned int GLenum;
|
||||
|
||||
enum class PixelFormat
|
||||
{ // TODO: ADD MORE FORMATS
|
||||
RGB8 = 0x1907,
|
||||
RGBA8 = 0x1908
|
||||
};
|
||||
|
||||
enum class PixelDataType
|
||||
{ // TODO: ADD MORE FORMATS
|
||||
UBYTE = 0x1401,
|
||||
FLOAT = 0x1406
|
||||
};
|
||||
|
||||
enum class SamplerFilter
|
||||
{ // TODO: ADD MORE FILTERS
|
||||
LINEAR = 0x2601,
|
||||
NEAREST = 0x2600
|
||||
};
|
||||
|
||||
enum class SamplerWrapping
|
||||
{ // TODO: ADD MORE WRAPPING
|
||||
CLAMP_TO_EDGE = 0x2900,
|
||||
REPEAT = 0x2901
|
||||
};
|
||||
|
||||
struct TextureFlags
|
||||
{
|
||||
PixelFormat pixelFormat = PixelFormat::RGBA8;
|
||||
PixelDataType pixelDataType = PixelDataType::UBYTE;
|
||||
|
||||
SamplerFilter minFilter = SamplerFilter::LINEAR;
|
||||
SamplerFilter magFilter = SamplerFilter::LINEAR;
|
||||
SamplerWrapping wrapping = SamplerWrapping::REPEAT;
|
||||
bool flipVertical = false;
|
||||
};
|
||||
|
||||
class Texture : ISerializable
|
||||
{
|
||||
private:
|
||||
@@ -30,7 +65,7 @@ namespace Nuake
|
||||
public:
|
||||
Texture(const std::string& path); // Load texture from file
|
||||
Texture(unsigned char* data, int len); // Used to load texture from a memory buffer
|
||||
Texture(Vector2 size, void* data);
|
||||
Texture(const TextureFlags& flags, Vector2 size, void* data);
|
||||
Texture(Vector2 size, GLenum format, GLenum format2 = 0, GLenum format3 = 0, void* data = 0); // Used to load texture from memeory with known size
|
||||
~Texture();
|
||||
|
||||
@@ -42,6 +77,10 @@ namespace Nuake
|
||||
|
||||
void SetParameter(const GLenum& param, const GLenum& value);
|
||||
|
||||
void SetMagnificationFilter(const SamplerFilter& filter);
|
||||
void SetMinificationFilter(const SamplerFilter& filter);
|
||||
void SetWrapping(const SamplerWrapping& wrapping);
|
||||
|
||||
unsigned int GetID() const { return m_RendererId; }
|
||||
inline std::string GetPath() { return m_FilePath; }
|
||||
inline int GetWidth() const { return m_Width; }
|
||||
|
||||
@@ -275269,148 +275269,52 @@ namespace Nuake {
|
||||
0x75, 0x72, 0x6E, 0x20, 0x6D, 0x61, 0x78, 0x28, 0x6D, 0x69, 0x6E, 0x28,
|
||||
0x72, 0x2C, 0x20, 0x67, 0x29, 0x2C, 0x20, 0x6D, 0x69, 0x6E, 0x28, 0x6D,
|
||||
0x61, 0x78, 0x28, 0x72, 0x2C, 0x20, 0x67, 0x29, 0x2C, 0x20, 0x62, 0x29,
|
||||
0x29, 0x3B, 0x0D, 0x0A, 0x7D, 0x0D, 0x0A, 0x0D, 0x0A, 0x66, 0x6C, 0x6F,
|
||||
0x61, 0x74, 0x20, 0x6F, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x28, 0x76,
|
||||
0x65, 0x63, 0x34, 0x20, 0x73, 0x64, 0x66, 0x53, 0x61, 0x6D, 0x70, 0x6C,
|
||||
0x65, 0x29, 0x0D, 0x0A, 0x7B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66,
|
||||
0x6C, 0x6F, 0x61, 0x74, 0x20, 0x72, 0x20, 0x3D, 0x20, 0x73, 0x64, 0x66,
|
||||
0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x72, 0x3B, 0x0D, 0x0A, 0x20,
|
||||
0x20, 0x20, 0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20, 0x67, 0x20, 0x3D,
|
||||
0x20, 0x73, 0x64, 0x66, 0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65, 0x2E, 0x67,
|
||||
0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74,
|
||||
0x20, 0x62, 0x20, 0x3D, 0x20, 0x73, 0x64, 0x66, 0x53, 0x61, 0x6D, 0x70,
|
||||
0x6C, 0x65, 0x2E, 0x62, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66,
|
||||
0x6C, 0x6F, 0x61, 0x74, 0x20, 0x73, 0x69, 0x67, 0x6E, 0x65, 0x64, 0x5F,
|
||||
0x64, 0x69, 0x73, 0x74, 0x20, 0x3D, 0x20, 0x6D, 0x65, 0x64, 0x69, 0x61,
|
||||
0x6E, 0x28, 0x72, 0x2C, 0x20, 0x67, 0x2C, 0x20, 0x62, 0x29, 0x20, 0x2D,
|
||||
0x20, 0x30, 0x2E, 0x35, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66,
|
||||
0x6C, 0x6F, 0x61, 0x74, 0x20, 0x64, 0x20, 0x3D, 0x20, 0x66, 0x77, 0x69,
|
||||
0x64, 0x74, 0x68, 0x28, 0x73, 0x69, 0x67, 0x6E, 0x65, 0x64, 0x5F, 0x64,
|
||||
0x69, 0x73, 0x74, 0x29, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66,
|
||||
0x6C, 0x6F, 0x61, 0x74, 0x20, 0x6F, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79,
|
||||
0x20, 0x3D, 0x20, 0x73, 0x6D, 0x6F, 0x6F, 0x74, 0x68, 0x73, 0x74, 0x65,
|
||||
0x70, 0x28, 0x2D, 0x64, 0x2C, 0x20, 0x64, 0x2C, 0x20, 0x73, 0x69, 0x67,
|
||||
0x6E, 0x65, 0x64, 0x5F, 0x64, 0x69, 0x73, 0x74, 0x29, 0x3B, 0x0D, 0x0A,
|
||||
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x20, 0x6F,
|
||||
0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x3B, 0x0D, 0x0A, 0x7D, 0x0D, 0x0A,
|
||||
0x0D, 0x0A, 0x76, 0x6F, 0x69, 0x64, 0x20, 0x6D, 0x61, 0x69, 0x6E, 0x28,
|
||||
0x29, 0x20, 0x7B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63,
|
||||
0x32, 0x20, 0x74, 0x65, 0x78, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x20, 0x3D,
|
||||
0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x69, 0x7A, 0x65,
|
||||
0x28, 0x75, 0x5F, 0x41, 0x74, 0x6C, 0x61, 0x73, 0x2C, 0x20, 0x30, 0x29,
|
||||
0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63,
|
||||
0x32, 0x20, 0x75, 0x76, 0x20, 0x3D, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28,
|
||||
0x6D, 0x69, 0x78, 0x28, 0x75, 0x5F, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72,
|
||||
0x65, 0x50, 0x6F, 0x73, 0x2E, 0x78, 0x20, 0x2F, 0x20, 0x74, 0x65, 0x78,
|
||||
0x74, 0x53, 0x69, 0x7A, 0x65, 0x2E, 0x78, 0x2C, 0x20, 0x75, 0x5F, 0x54,
|
||||
0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63, 0x61, 0x6C, 0x65, 0x2E,
|
||||
0x29, 0x3B, 0x0D, 0x0A, 0x7D, 0x0D, 0x0A, 0x0D, 0x0A, 0x76, 0x6F, 0x69,
|
||||
0x64, 0x20, 0x6D, 0x61, 0x69, 0x6E, 0x28, 0x29, 0x20, 0x7B, 0x0D, 0x0A,
|
||||
0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x74, 0x65, 0x78,
|
||||
0x74, 0x53, 0x69, 0x7A, 0x65, 0x20, 0x3D, 0x20, 0x74, 0x65, 0x78, 0x74,
|
||||
0x75, 0x72, 0x65, 0x53, 0x69, 0x7A, 0x65, 0x28, 0x75, 0x5F, 0x41, 0x74,
|
||||
0x6C, 0x61, 0x73, 0x2C, 0x20, 0x30, 0x29, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A,
|
||||
0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x75, 0x76, 0x20,
|
||||
0x3D, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x6D, 0x69, 0x78, 0x28, 0x75,
|
||||
0x5F, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x50, 0x6F, 0x73, 0x2E,
|
||||
0x78, 0x20, 0x2F, 0x20, 0x74, 0x65, 0x78, 0x74, 0x53, 0x69, 0x7A, 0x65,
|
||||
0x2E, 0x78, 0x2C, 0x20, 0x76, 0x5F, 0x55, 0x56, 0x2E, 0x78, 0x29, 0x2C,
|
||||
0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6D, 0x69, 0x78,
|
||||
0x28, 0x75, 0x5F, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63,
|
||||
0x61, 0x6C, 0x65, 0x2E, 0x79, 0x20, 0x2F, 0x20, 0x74, 0x65, 0x78, 0x74,
|
||||
0x53, 0x69, 0x7A, 0x65, 0x2E, 0x79, 0x2C, 0x20, 0x75, 0x5F, 0x54, 0x65,
|
||||
0x78, 0x74, 0x75, 0x72, 0x65, 0x50, 0x6F, 0x73, 0x2E, 0x79, 0x20, 0x2F,
|
||||
0x20, 0x74, 0x65, 0x78, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x2E, 0x79, 0x2C,
|
||||
0x20, 0x31, 0x2E, 0x30, 0x20, 0x2D, 0x20, 0x76, 0x5F, 0x55, 0x56, 0x2E,
|
||||
0x79, 0x29, 0x29, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20,
|
||||
0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20, 0x73, 0x75, 0x62, 0x50, 0x69, 0x78,
|
||||
0x65, 0x6C, 0x41, 0x6D, 0x6F, 0x75, 0x6E, 0x74, 0x20, 0x3D, 0x20, 0x75,
|
||||
0x5F, 0x53, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x41, 0x6D, 0x6F,
|
||||
0x75, 0x6E, 0x74, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65,
|
||||
0x63, 0x32, 0x20, 0x75, 0x6E, 0x69, 0x74, 0x52, 0x61, 0x6E, 0x67, 0x65,
|
||||
0x20, 0x3D, 0x20, 0x31, 0x2E, 0x30, 0x20, 0x2F, 0x20, 0x74, 0x65, 0x78,
|
||||
0x74, 0x53, 0x69, 0x7A, 0x65, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20,
|
||||
0x76, 0x65, 0x63, 0x32, 0x20, 0x75, 0x76, 0x4C, 0x65, 0x66, 0x74, 0x20,
|
||||
0x3D, 0x20, 0x75, 0x76, 0x20, 0x2D, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28,
|
||||
0x75, 0x6E, 0x69, 0x74, 0x52, 0x61, 0x6E, 0x67, 0x65, 0x2E, 0x78, 0x20,
|
||||
0x2A, 0x20, 0x73, 0x75, 0x62, 0x50, 0x69, 0x78, 0x65, 0x6C, 0x41, 0x6D,
|
||||
0x6F, 0x75, 0x6E, 0x74, 0x2C, 0x20, 0x30, 0x29, 0x3B, 0x0D, 0x0A, 0x20,
|
||||
0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x75, 0x76, 0x52, 0x69,
|
||||
0x67, 0x68, 0x74, 0x20, 0x3D, 0x20, 0x75, 0x76, 0x20, 0x2B, 0x20, 0x76,
|
||||
0x65, 0x63, 0x32, 0x28, 0x75, 0x6E, 0x69, 0x74, 0x52, 0x61, 0x6E, 0x67,
|
||||
0x65, 0x2E, 0x78, 0x20, 0x2A, 0x20, 0x73, 0x75, 0x62, 0x50, 0x69, 0x78,
|
||||
0x65, 0x6C, 0x41, 0x6D, 0x6F, 0x75, 0x6E, 0x74, 0x2C, 0x20, 0x30, 0x29,
|
||||
0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20,
|
||||
0x75, 0x76, 0x55, 0x70, 0x20, 0x3D, 0x20, 0x75, 0x76, 0x20, 0x2B, 0x20,
|
||||
0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2C, 0x20, 0x75, 0x6E, 0x69, 0x74,
|
||||
0x52, 0x61, 0x6E, 0x67, 0x65, 0x2E, 0x79, 0x20, 0x2A, 0x20, 0x73, 0x75,
|
||||
0x62, 0x50, 0x69, 0x78, 0x65, 0x6C, 0x41, 0x6D, 0x6F, 0x75, 0x6E, 0x74,
|
||||
0x29, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6C,
|
||||
0x6F, 0x61, 0x74, 0x20, 0x6D, 0x69, 0x64, 0x64, 0x6C, 0x65, 0x20, 0x3D,
|
||||
0x20, 0x6F, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x28, 0x74, 0x65, 0x78,
|
||||
0x74, 0x75, 0x72, 0x65, 0x28, 0x75, 0x5F, 0x41, 0x74, 0x6C, 0x61, 0x73,
|
||||
0x2C, 0x20, 0x75, 0x76, 0x29, 0x29, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20, 0x6C, 0x65, 0x66, 0x74, 0x20,
|
||||
0x3D, 0x20, 0x6F, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x28, 0x74, 0x65,
|
||||
0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x75, 0x5F, 0x41, 0x74, 0x6C, 0x61,
|
||||
0x73, 0x2C, 0x20, 0x75, 0x76, 0x4C, 0x65, 0x66, 0x74, 0x29, 0x29, 0x3B,
|
||||
0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20,
|
||||
0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3D, 0x20, 0x6F, 0x70, 0x61, 0x63,
|
||||
0x69, 0x74, 0x79, 0x28, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x28,
|
||||
0x75, 0x5F, 0x41, 0x74, 0x6C, 0x61, 0x73, 0x2C, 0x20, 0x75, 0x76, 0x52,
|
||||
0x69, 0x67, 0x68, 0x74, 0x29, 0x29, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20, 0x75, 0x70, 0x20, 0x3D, 0x20,
|
||||
0x6F, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0x28, 0x74, 0x65, 0x78, 0x74,
|
||||
0x75, 0x72, 0x65, 0x28, 0x75, 0x5F, 0x41, 0x74, 0x6C, 0x61, 0x73, 0x2C,
|
||||
0x20, 0x75, 0x76, 0x55, 0x70, 0x29, 0x29, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A,
|
||||
0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6F, 0x6C,
|
||||
0x6F, 0x72, 0x20, 0x3D, 0x20, 0x75, 0x5F, 0x46, 0x6F, 0x6E, 0x74, 0x43,
|
||||
0x6F, 0x6C, 0x6F, 0x72, 0x2E, 0x72, 0x67, 0x62, 0x3B, 0x0D, 0x0A, 0x20,
|
||||
0x20, 0x20, 0x20, 0x62, 0x6F, 0x6F, 0x6C, 0x20, 0x64, 0x69, 0x72, 0x65,
|
||||
0x63, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x3D, 0x20, 0x66, 0x61, 0x6C, 0x73,
|
||||
0x65, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74,
|
||||
0x20, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x20, 0x3D, 0x20, 0x31, 0x2E, 0x36,
|
||||
0x36, 0x36, 0x36, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6C,
|
||||
0x6F, 0x61, 0x74, 0x20, 0x63, 0x75, 0x72, 0x76, 0x65, 0x5F, 0x74, 0x6F,
|
||||
0x6C, 0x65, 0x72, 0x61, 0x6E, 0x63, 0x65, 0x20, 0x3D, 0x20, 0x75, 0x5F,
|
||||
0x43, 0x75, 0x72, 0x76, 0x65, 0x54, 0x6F, 0x6C, 0x65, 0x72, 0x61, 0x6E,
|
||||
0x63, 0x65, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6F, 0x6E,
|
||||
0x73, 0x74, 0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20, 0x68, 0x5F, 0x74,
|
||||
0x6F, 0x6C, 0x65, 0x72, 0x61, 0x6E, 0x63, 0x65, 0x20, 0x3D, 0x20, 0x30,
|
||||
0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x20, 0x62, 0x6F, 0x6F, 0x6C, 0x20,
|
||||
0x73, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x20, 0x3D, 0x20, 0x66,
|
||||
0x61, 0x6C, 0x73, 0x65, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66,
|
||||
0x6C, 0x6F, 0x61, 0x74, 0x20, 0x73, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65,
|
||||
0x6C, 0x5F, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6F, 0x6C, 0x64, 0x20,
|
||||
0x3D, 0x20, 0x75, 0x5F, 0x53, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C,
|
||||
0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6F, 0x6C, 0x64, 0x3B, 0x0D, 0x0A,
|
||||
0x20, 0x20, 0x20, 0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20, 0x63, 0x75,
|
||||
0x72, 0x76, 0x65, 0x41, 0x6D, 0x6F, 0x75, 0x6E, 0x74, 0x20, 0x3D, 0x20,
|
||||
0x75, 0x70, 0x20, 0x2D, 0x20, 0x6D, 0x69, 0x64, 0x64, 0x6C, 0x65, 0x3B,
|
||||
0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6F, 0x6F, 0x6C, 0x20, 0x6D,
|
||||
0x69, 0x64, 0x20, 0x3D, 0x20, 0x6D, 0x69, 0x64, 0x64, 0x6C, 0x65, 0x20,
|
||||
0x3C, 0x20, 0x28, 0x73, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x5F,
|
||||
0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6F, 0x6C, 0x64, 0x29, 0x3B, 0x0D,
|
||||
0x0A, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6F, 0x6F, 0x6C, 0x20, 0x6C, 0x65,
|
||||
0x66, 0x74, 0x74, 0x20, 0x3D, 0x20, 0x6C, 0x65, 0x66, 0x74, 0x20, 0x3C,
|
||||
0x20, 0x73, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x5F, 0x74, 0x68,
|
||||
0x72, 0x65, 0x73, 0x68, 0x6F, 0x6C, 0x64, 0x3B, 0x0D, 0x0A, 0x20, 0x20,
|
||||
0x20, 0x20, 0x62, 0x6F, 0x6F, 0x6C, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74,
|
||||
0x74, 0x20, 0x3D, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3C, 0x20,
|
||||
0x73, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x5F, 0x74, 0x68, 0x72,
|
||||
0x65, 0x73, 0x68, 0x6F, 0x6C, 0x64, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x69, 0x66, 0x28, 0x73, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C,
|
||||
0x20, 0x26, 0x26, 0x28, 0x6D, 0x69, 0x64, 0x64, 0x6C, 0x65, 0x20, 0x3C,
|
||||
0x20, 0x73, 0x75, 0x62, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x5F, 0x74, 0x68,
|
||||
0x72, 0x65, 0x73, 0x68, 0x6F, 0x6C, 0x64, 0x29, 0x20, 0x26, 0x26, 0x20,
|
||||
0x63, 0x75, 0x72, 0x76, 0x65, 0x41, 0x6D, 0x6F, 0x75, 0x6E, 0x74, 0x20,
|
||||
0x3C, 0x20, 0x63, 0x75, 0x72, 0x76, 0x65, 0x5F, 0x74, 0x6F, 0x6C, 0x65,
|
||||
0x72, 0x61, 0x6E, 0x63, 0x65, 0x29, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20,
|
||||
0x7B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63,
|
||||
0x6F, 0x6C, 0x6F, 0x72, 0x2E, 0x72, 0x20, 0x3D, 0x20, 0x6C, 0x65, 0x66,
|
||||
0x74, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x2E, 0x67, 0x20, 0x3D, 0x20, 0x6D, 0x69,
|
||||
0x64, 0x64, 0x6C, 0x65, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x2E, 0x62, 0x20, 0x3D,
|
||||
0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x7D, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x0D, 0x0A, 0x20, 0x20,
|
||||
0x20, 0x20, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x20,
|
||||
0x3D, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6F, 0x6C, 0x6F, 0x72,
|
||||
0x2E, 0x72, 0x67, 0x62, 0x2C, 0x20, 0x6D, 0x69, 0x64, 0x64, 0x6C, 0x65,
|
||||
0x2E, 0x78, 0x2C, 0x20, 0x75, 0x5F, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72,
|
||||
0x65, 0x53, 0x63, 0x61, 0x6C, 0x65, 0x2E, 0x78, 0x20, 0x2F, 0x20, 0x74,
|
||||
0x65, 0x78, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x2E, 0x78, 0x2C, 0x20, 0x76,
|
||||
0x5F, 0x55, 0x56, 0x2E, 0x78, 0x29, 0x2C, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x6D, 0x69, 0x78, 0x28, 0x75, 0x5F, 0x54, 0x65,
|
||||
0x78, 0x74, 0x75, 0x72, 0x65, 0x53, 0x63, 0x61, 0x6C, 0x65, 0x2E, 0x79,
|
||||
0x20, 0x2F, 0x20, 0x74, 0x65, 0x78, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x2E,
|
||||
0x79, 0x2C, 0x20, 0x75, 0x5F, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65,
|
||||
0x50, 0x6F, 0x73, 0x2E, 0x79, 0x20, 0x2F, 0x20, 0x74, 0x65, 0x78, 0x74,
|
||||
0x53, 0x69, 0x7A, 0x65, 0x2E, 0x79, 0x2C, 0x20, 0x31, 0x2E, 0x30, 0x20,
|
||||
0x2D, 0x20, 0x76, 0x5F, 0x55, 0x56, 0x2E, 0x79, 0x29, 0x29, 0x3B, 0x0D,
|
||||
0x0A, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20,
|
||||
0x6D, 0x73, 0x64, 0x20, 0x3D, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72,
|
||||
0x65, 0x28, 0x75, 0x5F, 0x41, 0x74, 0x6C, 0x61, 0x73, 0x2C, 0x20, 0x75,
|
||||
0x76, 0x29, 0x2E, 0x72, 0x67, 0x62, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x66, 0x6C, 0x6F, 0x61, 0x74, 0x20, 0x73, 0x64, 0x20, 0x3D, 0x20,
|
||||
0x6D, 0x65, 0x64, 0x69, 0x61, 0x6E, 0x28, 0x6D, 0x73, 0x64, 0x2E, 0x72,
|
||||
0x2C, 0x20, 0x6D, 0x73, 0x64, 0x2E, 0x67, 0x2C, 0x20, 0x6D, 0x73, 0x64,
|
||||
0x2E, 0x62, 0x29, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6C,
|
||||
0x6F, 0x61, 0x74, 0x20, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6E, 0x50, 0x78,
|
||||
0x44, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x20, 0x3D, 0x20, 0x73,
|
||||
0x63, 0x72, 0x65, 0x65, 0x6E, 0x50, 0x78, 0x52, 0x61, 0x6E, 0x67, 0x65,
|
||||
0x28, 0x75, 0x76, 0x29, 0x20, 0x2A, 0x20, 0x28, 0x73, 0x64, 0x20, 0x2D,
|
||||
0x20, 0x30, 0x2E, 0x35, 0x29, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20,
|
||||
0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x20, 0x3D,
|
||||
0x20, 0x75, 0x5F, 0x46, 0x6F, 0x6E, 0x74, 0x43, 0x6F, 0x6C, 0x6F, 0x72,
|
||||
0x2E, 0x72, 0x67, 0x62, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x66,
|
||||
0x6C, 0x6F, 0x61, 0x74, 0x20, 0x6F, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79,
|
||||
0x20, 0x3D, 0x20, 0x63, 0x6C, 0x61, 0x6D, 0x70, 0x28, 0x73, 0x63, 0x72,
|
||||
0x65, 0x65, 0x6E, 0x50, 0x78, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63,
|
||||
0x65, 0x20, 0x2B, 0x20, 0x30, 0x2E, 0x35, 0x2C, 0x20, 0x30, 0x2E, 0x30,
|
||||
0x2C, 0x20, 0x31, 0x2E, 0x30, 0x29, 0x3B, 0x0D, 0x0A, 0x20, 0x20, 0x20,
|
||||
0x20, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x20, 0x3D,
|
||||
0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x2E,
|
||||
0x72, 0x67, 0x62, 0x2C, 0x20, 0x6F, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79,
|
||||
0x29, 0x3B, 0x0D, 0x0A, 0x7D,
|
||||
};
|
||||
unsigned int Resources_Shaders_ui_text_shader_len = sizeof(Resources_Shaders_ui_text_shader);
|
||||
|
||||
@@ -227,10 +227,13 @@ namespace Nuake
|
||||
if (netScriptComponent.ScriptPath.empty())
|
||||
continue;
|
||||
|
||||
// Creates an instance of the entity script in C#
|
||||
auto entity = Entity{ e, m_Scene };
|
||||
auto scriptInstance = scriptingEngineNet.GetEntityScript(entity);
|
||||
scriptInstance.InvokeMethod("OnDestroy");
|
||||
if (entity.IsValid() && scriptingEngineNet.HasEntityScriptInstance(entity))
|
||||
{
|
||||
Logger::Log(entity.GetComponent<NameComponent>().Name);
|
||||
auto scriptInstance = scriptingEngineNet.GetEntityScript(entity);
|
||||
scriptInstance.InvokeMethod("OnDestroy");
|
||||
}
|
||||
}
|
||||
|
||||
ScriptingEngine::Close();
|
||||
|
||||
@@ -101,8 +101,20 @@ namespace Nuake {
|
||||
return ConvertHitsToArray(hits);
|
||||
}
|
||||
|
||||
void LoadScene(Coral::String path)
|
||||
{
|
||||
if (!FileSystem::FileExists(path))
|
||||
{
|
||||
Logger::Log("Failed to load scene with path: " + std::string(path), ".net/scene", CRITICAL);
|
||||
return;
|
||||
}
|
||||
|
||||
Engine::QueueSceneSwitch(std::string(path));
|
||||
}
|
||||
|
||||
void EngineNetAPI::RegisterMethods()
|
||||
{
|
||||
RegisterMethod("Engine.LoadSceneIcall", &LoadScene);
|
||||
RegisterMethod("Engine.LoggerLogIcall", (void*)(&Log));
|
||||
|
||||
// Debug renderer
|
||||
|
||||
@@ -57,9 +57,10 @@ namespace NuakeUI
|
||||
// Create bitmap
|
||||
msdfgen::BitmapConstRef<T, N> bitmap = (msdfgen::BitmapConstRef<T, N>) generator.atlasStorage();
|
||||
|
||||
// Creat1e Texture from bitmap
|
||||
//msdf_atlas::exportJSON(fonts.data(), fonts.size(), config.emSize, config.pxRange, config.width, config.height, config.imageType, config.yDirection, "yayayayya.json", config.kerning);
|
||||
font->mAtlas = std::make_shared<Texture>(Vector2(config.width, config.height), (void*)bitmap.pixels);
|
||||
TextureFlags flags;
|
||||
flags.minFilter = SamplerFilter::LINEAR;
|
||||
flags.magFilter = SamplerFilter::LINEAR;
|
||||
font->mAtlas = std::make_shared<Texture>(flags, Vector2(config.width, config.height), (void*)bitmap.pixels);
|
||||
|
||||
// Create Char structure
|
||||
return true;
|
||||
@@ -71,7 +72,7 @@ namespace NuakeUI
|
||||
|
||||
// Create atlas settings
|
||||
Config config{};
|
||||
config.pxRange = 3;
|
||||
config.pxRange = 8.0;
|
||||
config.emSize = 0.0;
|
||||
config.coloringSeed = 125155;
|
||||
config.imageType = msdf_atlas::ImageType::MTSDF;
|
||||
@@ -92,7 +93,7 @@ namespace NuakeUI
|
||||
msdf_atlas::Charset charset = msdf_atlas::Charset::ASCII;
|
||||
|
||||
// Load Create charset
|
||||
float fontScale = 36;
|
||||
float fontScale = 36.0f;
|
||||
|
||||
bool preprocess = false;
|
||||
int loaded = fontGeometry.loadCharset(font->GetFontHandle(), fontScale, charset, config.preprocessGeometry, config.kerning);
|
||||
@@ -110,7 +111,6 @@ namespace NuakeUI
|
||||
msdf_atlas::ImageType imageType = msdf_atlas::ImageType::MTSDF;
|
||||
atlasPacker.setPadding(imageType == msdf_atlas::ImageType::MSDF || imageType == msdf_atlas::ImageType::MTSDF ? 0 : -1);
|
||||
atlasPacker.setPixelRange(config.pxRange);
|
||||
atlasPacker.setUnitRange(config.emSize);
|
||||
atlasPacker.setMiterLimit(config.miterLimit);
|
||||
|
||||
// Pack atlas
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "Styles/StyleSheet.h"
|
||||
|
||||
#include <memory>
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <Dependencies/NuakeRenderer/NuakeRenderer/NuakeRenderer.h>
|
||||
|
||||
namespace NuakeUI
|
||||
{
|
||||
@@ -97,17 +97,13 @@ namespace NuakeUI
|
||||
|
||||
static void DrawInspector(std::shared_ptr<Canvas> canvas)
|
||||
{
|
||||
NuakeRenderer::BeginImGuiFrame();
|
||||
|
||||
ImGui::ShowDemoWindow();
|
||||
|
||||
if (ImGui::Begin("Inspector"))
|
||||
{
|
||||
if (ImGui::BeginTabBar("MyTabBar"))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Tree"))
|
||||
{
|
||||
const float treeWidth = ImGui::GetWindowContentRegionWidth();
|
||||
const float treeWidth = ImGui::GetContentRegionAvail().x;
|
||||
const float availHeight = ImGui::GetContentRegionAvail().y;
|
||||
const ImVec2 size = ImVec2(treeWidth * 0.5f, availHeight);
|
||||
const ImVec2 size2 = ImVec2(treeWidth * 0.5f, availHeight);
|
||||
@@ -218,7 +214,5 @@ namespace NuakeUI
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
NuakeRenderer::EndImGuiFrame();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <nanosvg.h>
|
||||
#include <nanosvgrast.h>
|
||||
#include <src/UI/Font/FontManager.h>
|
||||
|
||||
|
||||
namespace NuakeUI
|
||||
@@ -464,6 +465,12 @@ namespace NuakeUI
|
||||
case StyleProperties::ZIndex:
|
||||
ComputedStyle.ZIndex = value.value.Number;
|
||||
break;
|
||||
case StyleProperties::Font:
|
||||
if (FileSystem::FileExists(value.string, true))
|
||||
{
|
||||
ComputedStyle.FontFamily = FontManager::Get().GetFont(value.string);
|
||||
}
|
||||
break;
|
||||
case StyleProperties::BackgroundImage:
|
||||
{
|
||||
if (ComputedStyle.BackgroundImage == nullptr)
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include <src/Core/Maths.h>
|
||||
#include <src/Rendering/Textures/Texture.h>
|
||||
#include "src/UI/Renderer.h"
|
||||
#include "src/UI/Font/Font.h"
|
||||
|
||||
|
||||
using namespace Nuake;
|
||||
namespace NuakeUI
|
||||
@@ -52,6 +55,7 @@ namespace NuakeUI
|
||||
float BorderRadius = 0.f;
|
||||
Color BorderColor = Color(0, 0, 0, 0);
|
||||
float FontSize = 64.0f;
|
||||
Ref<Font> FontFamily = Renderer::Get().mDefaultFont;
|
||||
TextAlignType TextAlign = TextAlignType::Left;
|
||||
Color FontColor = Color(1, 1, 1, 1);
|
||||
OverflowType Overflow = OverflowType::Show;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "../Renderer.h"
|
||||
|
||||
#include "src/Rendering/Renderer.h"
|
||||
#include "src/UI/Font/FontManager.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace NuakeUI
|
||||
@@ -61,7 +63,7 @@ namespace NuakeUI
|
||||
float y = YGNodeLayoutGetTop(mNode);
|
||||
|
||||
// Centers the text in the line height.
|
||||
y += (mFont->LineHeight / 64.0f) * (ComputedStyle.FontSize) / 2.0f;
|
||||
y += (ComputedStyle.FontFamily->LineHeight / 64.0f) * (ComputedStyle.FontSize) / 2.0f;
|
||||
|
||||
x += YGNodeLayoutGetPadding(mNode, YGEdgeLeft);
|
||||
y += YGNodeLayoutGetPadding(mNode, YGEdgeTop);
|
||||
@@ -98,12 +100,12 @@ namespace NuakeUI
|
||||
//glScissor(clipX, clipY, clipWidth, clipHeight);
|
||||
}
|
||||
|
||||
const float lineYOffset = (mFont->LineHeight / 32.0f) * (ComputedStyle.FontSize);
|
||||
const float lineYOffset = (ComputedStyle.FontFamily->LineHeight / 32.0f) * (ComputedStyle.FontSize);
|
||||
// Draw each line and offset the Y of the position by the line height.
|
||||
for(int i = 0; i < Lines.size(); i++)
|
||||
{
|
||||
// Draw the first line
|
||||
Renderer::Get().DrawString(Lines[i], ComputedStyle, mFont, position);
|
||||
Renderer::Get().DrawString(Lines[i], ComputedStyle, ComputedStyle.FontFamily, position);
|
||||
// Update the Y position to the next line.
|
||||
position.y += lineYOffset;
|
||||
}
|
||||
@@ -142,7 +144,7 @@ namespace NuakeUI
|
||||
|
||||
void Text::Calculate()
|
||||
{
|
||||
const float halfLineHeight = mFont->LineHeight / 32.f;
|
||||
const float halfLineHeight = ComputedStyle.FontFamily->LineHeight / 32.f;
|
||||
const float linesHeight = Lines.size() * ComputedStyle.FontSize;
|
||||
YGNodeStyleSetHeight(mNode, halfLineHeight * linesHeight);
|
||||
YGNodeStyleSetWidth(mNode, CalculateWidth());
|
||||
|
||||
@@ -24,9 +24,10 @@ namespace NuakeUI
|
||||
std::string GetText() const;
|
||||
|
||||
void Calculate() override;
|
||||
void UpdateInput(InputManager* manager) override {};
|
||||
void Draw(int z) override;
|
||||
|
||||
void SetFont(const std::string& fontPath);
|
||||
|
||||
float CalculateWidth();
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -156,6 +156,7 @@ StyleProperties GetPropFromString(const std::string& prop)
|
||||
else if (prop == "left") return StyleProperties::Left;
|
||||
else if (prop == "right") return StyleProperties::Right;
|
||||
else if (prop == "background-image") return StyleProperties::BackgroundImage;
|
||||
else if (prop == "font") return StyleProperties::Font;
|
||||
return StyleProperties::None;
|
||||
}
|
||||
|
||||
@@ -230,9 +231,9 @@ void StyleSheetParser::ParseStyleRule(KatanaRule* rule, StyleSheetPtr styleSheet
|
||||
case KatanaValueUnit::KATANA_VALUE_STRING:
|
||||
{
|
||||
std::string stringValue = value->string;
|
||||
if (propType == StyleProperties::BackgroundImage)
|
||||
if (propType == StyleProperties::BackgroundImage || propType == StyleProperties::Font)
|
||||
{
|
||||
stringValue = _parsingPath + "/../" + stringValue;
|
||||
stringValue = FileSystem::RelativeToAbsolute(stringValue);
|
||||
}
|
||||
propValue.string = stringValue;
|
||||
propValue.type = PropValueType::String;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "src/Rendering/Buffers/VertexBufferLayout.h"
|
||||
#include "src/Rendering/Shaders/ShaderManager.h"
|
||||
#include "src/Rendering/Vertex.h"
|
||||
#include "Nodes/Node.h"
|
||||
#include "Nodes/Text.h"
|
||||
|
||||
#include <glad/glad.h>
|
||||
|
||||
@@ -15,7 +17,6 @@
|
||||
using namespace NuakeUI;
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<Font> Renderer::mDefaultFont;
|
||||
float Renderer::subpixelAmount = 1.3333f ;
|
||||
float Renderer::curveTolerance = 1.0f;
|
||||
@@ -168,7 +169,7 @@ void Renderer::DrawString(const std::string& string, NodeStyle& nodeStyle, std::
|
||||
{ "u_Scale", 1.0f},
|
||||
{ "u_SDF_BorderSize", 0.0f},
|
||||
{ "u_FontColor", nodeStyle.FontColor },
|
||||
{ "u_PxRange", fontSize },
|
||||
{ "u_PxRange", 4.0f },
|
||||
{ "u_SDF_BorderSize", {1.0, 1.0}},
|
||||
{ "u_SubpixelThreshold", subpixelThreshold},
|
||||
{ "u_CurveTolerance", curveTolerance},
|
||||
@@ -201,7 +202,6 @@ void Renderer::DrawString(const std::string& string, NodeStyle& nodeStyle, std::
|
||||
{ "u_TextureScale", Vector2(letter.AtlasBounds.Size.x, letter.AtlasBounds.Size.y) },
|
||||
});
|
||||
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
#include <src/Rendering/Buffers/VertexBuffer.h>
|
||||
#include <src/Rendering/Buffers/VertexArray.h>
|
||||
|
||||
#include "Nodes/Node.h"
|
||||
#include "Nodes/Text.h"
|
||||
|
||||
#include "Font/Font.h"
|
||||
|
||||
#include <msdf-atlas-gen/msdf-atlas-gen.h>
|
||||
@@ -14,6 +13,10 @@
|
||||
|
||||
namespace NuakeUI
|
||||
{
|
||||
class Node;
|
||||
class NodeStyle;
|
||||
class Text;
|
||||
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace NuakeUI
|
||||
JustifyContent, AlignContent, LayoutDirection,
|
||||
BorderSize, BorderRadius, BorderColor,
|
||||
BackgroundColor, TextAlign, Color, Overflow, FontSize, Visibility, ZIndex,
|
||||
BackgroundImage
|
||||
BackgroundImage, Font
|
||||
};
|
||||
enum class PositionType { Relative, Absolute };
|
||||
enum class AlignItemsType { Auto, FlexStart, Center, FlexEnd, Stretch, Baseline, SpaceBetween, SpaceAround };
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Nuake.Net
|
||||
public class Node
|
||||
{
|
||||
internal static unsafe delegate*<NativeString, NativeString, NativeString, NativeString> FindChildByIDICall;
|
||||
internal static unsafe delegate*<NativeString, NativeString, NativeString, bool> HasNativeInstanceICall;
|
||||
internal static unsafe delegate*<NativeString, NativeString, bool> HasNativeInstanceICall;
|
||||
internal static unsafe delegate*<NativeString, NativeString, NativeInstance<Node>> GetNativeInstanceNodeICall;
|
||||
|
||||
public string UUID;
|
||||
@@ -107,24 +107,21 @@ namespace Nuake.Net
|
||||
throw new Exception("Node not found");
|
||||
}
|
||||
|
||||
T? newNode = null;
|
||||
//if (HasNativeInstanceICall(CanvasUUID, CanvasUUID, UUID))
|
||||
//{
|
||||
// NativeInstance<Node> handle;
|
||||
// unsafe { handle = GetNativeInstanceNodeICall(CanvasUUID, UUID); }
|
||||
// newNode = handle.Get();
|
||||
//}
|
||||
|
||||
if(newNode == null)
|
||||
if (HasNativeInstanceICall(CanvasUUID, uuid))
|
||||
{
|
||||
newNode = Activator.CreateInstance<T>();
|
||||
newNode.UUID = uuid;
|
||||
newNode.CanvasUUID = CanvasUUID;
|
||||
|
||||
return newNode as T;
|
||||
NativeInstance<Node> handle;
|
||||
unsafe { handle = GetNativeInstanceNodeICall(CanvasUUID, uuid); }
|
||||
Node? newNodeInstance = handle.Get();
|
||||
if(newNodeInstance != null && newNodeInstance is T)
|
||||
{
|
||||
return newNodeInstance as T;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
T? newNode = Activator.CreateInstance<T>();
|
||||
newNode.UUID = uuid;
|
||||
newNode.CanvasUUID = CanvasUUID;
|
||||
return newNode as T;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,14 @@ namespace Nuake.Net
|
||||
public class Engine
|
||||
{
|
||||
internal static unsafe delegate*<NativeString, void> LoggerLogIcall;
|
||||
|
||||
internal static unsafe delegate*<NativeString, void> LoadSceneIcall;
|
||||
public Engine() { }
|
||||
|
||||
public static void LoadScene(string path)
|
||||
{
|
||||
unsafe { LoadSceneIcall(path); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prints a message to the console log
|
||||
/// </summary>
|
||||
|
||||
@@ -43,53 +43,16 @@ float median(float r, float g, float b) {
|
||||
return max(min(r, g), min(max(r, g), b));
|
||||
}
|
||||
|
||||
float opacity(vec4 sdfSample)
|
||||
{
|
||||
float r = sdfSample.r;
|
||||
float g = sdfSample.g;
|
||||
float b = sdfSample.b;
|
||||
float signed_dist = median(r, g, b) - 0.5;
|
||||
float d = fwidth(signed_dist);
|
||||
float opacity = smoothstep(-d, d, signed_dist);
|
||||
return opacity;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 textSize = textureSize(u_Atlas, 0);
|
||||
|
||||
vec2 uv = vec2(mix(u_TexturePos.x / textSize.x, u_TextureScale.x / textSize.x, v_UV.x),
|
||||
mix(u_TextureScale.y / textSize.y, u_TexturePos.y / textSize.y, 1.0 - v_UV.y));
|
||||
|
||||
float subPixelAmount = u_SubpixelAmount;
|
||||
vec2 unitRange = 1.0 / textSize;
|
||||
vec2 uvLeft = uv - vec2(unitRange.x * subPixelAmount, 0);
|
||||
vec2 uvRight = uv + vec2(unitRange.x * subPixelAmount, 0);
|
||||
vec2 uvUp = uv + vec2(0, unitRange.y * subPixelAmount);
|
||||
|
||||
float middle = opacity(texture(u_Atlas, uv));
|
||||
float left = opacity(texture(u_Atlas, uvLeft));
|
||||
float right = opacity(texture(u_Atlas, uvRight));
|
||||
float up = opacity(texture(u_Atlas, uvUp));
|
||||
|
||||
vec3 msd = texture(u_Atlas, uv).rgb;
|
||||
float sd = median(msd.r, msd.g, msd.b);
|
||||
float screenPxDistance = screenPxRange(uv) * (sd - 0.5);
|
||||
vec3 color = u_FontColor.rgb;
|
||||
bool direction = false;
|
||||
|
||||
const float ratio = 1.6666;
|
||||
float curve_tolerance = u_CurveTolerance;
|
||||
const float h_tolerance = 0;
|
||||
|
||||
const bool subpixel = false;
|
||||
float subpixel_threshold = u_SubpixelThreshold;
|
||||
float curveAmount = up - middle;
|
||||
bool mid = middle < (subpixel_threshold);
|
||||
bool leftt = left < subpixel_threshold;
|
||||
bool rightt = right < subpixel_threshold;
|
||||
if(subpixel &&(middle < subpixel_threshold) && curveAmount < curve_tolerance)
|
||||
{
|
||||
color.r = left;
|
||||
color.g = middle;
|
||||
color.b = right;
|
||||
}
|
||||
|
||||
FragColor = vec4(color.rgb, middle);
|
||||
float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
||||
FragColor = vec4(color.rgb, opacity);
|
||||
}
|
||||
Reference in New Issue
Block a user