diff --git a/Editor/resources/Fonts/OpenSans-Regular.ttf b/Editor/resources/Fonts/OpenSans-Regular.ttf new file mode 100644 index 00000000..db433349 Binary files /dev/null and b/Editor/resources/Fonts/OpenSans-Regular.ttf differ diff --git a/Editor/resources/Interface/Testing.interface b/Editor/resources/Interface/Testing.interface index 79b86565..c8a25d58 100644 --- a/Editor/resources/Interface/Testing.interface +++ b/Editor/resources/Interface/Testing.interface @@ -8,6 +8,7 @@ groups="container" padding="8px 8px 8px 8px" > +

Hello world!

diff --git a/Editor/resources/Shaders/sdf_text.shader b/Editor/resources/Shaders/sdf_text.shader index 1e94e193..909df323 100644 --- a/Editor/resources/Shaders/sdf_text.shader +++ b/Editor/resources/Shaders/sdf_text.shader @@ -6,7 +6,7 @@ layout(location = 1) in vec2 UV; uniform mat4 model; uniform mat4 projection; -out vec2 a_UV; +out sample vec2 a_UV; void main() { @@ -42,7 +42,7 @@ void main() { vec2 textSize = textureSize(msdf, 0); vec2 uv = vec2(mix(texPos.x / textSize.x,texScale.x / textSize.x, a_UV.x), - mix(texScale.y / textSize.y, texPos.y / textSize.y, a_UV.y)); + mix(texScale.y / textSize.y, texPos.y / textSize.y, a_UV.y)); vec3 msd = texture(msdf, uv).rgb; float sd = median(msd.r, msd.g, msd.b); diff --git a/Editor/resources/Shaders/ui.shader b/Editor/resources/Shaders/ui.shader index 8de694a1..2245faaf 100644 --- a/Editor/resources/Shaders/ui.shader +++ b/Editor/resources/Shaders/ui.shader @@ -6,7 +6,7 @@ uniform mat4 model; uniform mat4 projection; -out vec2 a_UV; +out sample vec2 a_UV; void main() { diff --git a/Nuake/Engine.h b/Nuake/Engine.h index d274bbca..27b54f0e 100644 --- a/Nuake/Engine.h +++ b/Nuake/Engine.h @@ -1,4 +1,5 @@ #pragma once + #include "src/Core/Core.h" #include "src/Window.h" #include "src/Scene/Scene.h" diff --git a/Nuake/src/Rendering/Renderer2D.cpp b/Nuake/src/Rendering/Renderer2D.cpp index 5bb1083a..0fd3c26d 100644 --- a/Nuake/src/Rendering/Renderer2D.cpp +++ b/Nuake/src/Rendering/Renderer2D.cpp @@ -66,6 +66,7 @@ Vector2 Renderer2D::CalculateStringSize(const std::string& str, Ref font, void Renderer2D::DrawString(const std::string& str, Ref font, Vector2 position, float fontSize) { + TextShader->Bind(); TextShader->SetUniformMat4f("projection", Projection); float advance = 0.0f; diff --git a/Nuake/src/Scripting/ScriptingAPI/HelloWorld.cpp b/Nuake/src/Scripting/ScriptingAPI/HelloWorld.cpp new file mode 100644 index 00000000..192d5517 --- /dev/null +++ b/Nuake/src/Scripting/ScriptingAPI/HelloWorld.cpp @@ -0,0 +1,10 @@ +#include "HelloWorld.h" + + + +int ScriptingAPI::HelloWorld(lua_State* L) +{ + + + return 1; // Successful +} diff --git a/Nuake/src/Scripting/ScriptingAPI/HelloWorld.h b/Nuake/src/Scripting/ScriptingAPI/HelloWorld.h new file mode 100644 index 00000000..c550d2ff --- /dev/null +++ b/Nuake/src/Scripting/ScriptingAPI/HelloWorld.h @@ -0,0 +1,6 @@ +#pragma once +struct lua_State; +namespace ScriptingAPI +{ + int HelloWorld(lua_State* L); +} \ No newline at end of file diff --git a/Nuake/src/UI/Font/Font.h b/Nuake/src/UI/Font/Font.h index fd5af8a0..ffa1c281 100644 --- a/Nuake/src/UI/Font/Font.h +++ b/Nuake/src/UI/Font/Font.h @@ -1,7 +1,9 @@ #pragma once +#include "../Core/Core.h" #include #include #include +#include "src/Core/Maths.h" struct CharPos { double left; diff --git a/Nuake/src/UI/Font/FontManager.cpp b/Nuake/src/UI/Font/FontManager.cpp new file mode 100644 index 00000000..d2119545 --- /dev/null +++ b/Nuake/src/UI/Font/FontManager.cpp @@ -0,0 +1,20 @@ +#include "FontManager.h" + +std::map > FontManager::m_Fonts = std::map>(); + +Ref FontManager::GetFont(const std::string& font) +{ + // Fonts exists in memory + if (m_Fonts.find(font) != m_Fonts.end()) + { + return m_Fonts[font]; + } + + // Load font + Ref newFont = FontLoader::LoadFont(font); + if (newFont) + return newFont; + + Logger::Log("Error: failed to load font " + font); + return nullptr; +} \ No newline at end of file diff --git a/Nuake/src/UI/Font/FontManager.h b/Nuake/src/UI/Font/FontManager.h new file mode 100644 index 00000000..4afb6ac5 --- /dev/null +++ b/Nuake/src/UI/Font/FontManager.h @@ -0,0 +1,12 @@ +#pragma once +#include + +#include "FontLoader.h" +class FontManager +{ +private: + static std::map > m_Fonts; + +public: + static Ref GetFont(const std::string& font); +}; \ No newline at end of file diff --git a/Nuake/src/UI/InterfaceParser.h b/Nuake/src/UI/InterfaceParser.h index 1ed417f1..abbaa0d8 100644 --- a/Nuake/src/UI/InterfaceParser.h +++ b/Nuake/src/UI/InterfaceParser.h @@ -1,12 +1,12 @@ #pragma once #include #include -#include -#include +#include +#include #include #include #include - +#include "Nodes/TextNode.h" class InterfaceParser { static Ref Root; @@ -51,6 +51,11 @@ public: node->Childrens.push_back(newNode); Iterate(e, newNode); } + else if (type == "p") + { + //Ref textnode = CreateTextNode(e); + + } } } diff --git a/Nuake/src/UI/Canvas.cpp b/Nuake/src/UI/Nodes/Canvas.cpp similarity index 100% rename from Nuake/src/UI/Canvas.cpp rename to Nuake/src/UI/Nodes/Canvas.cpp diff --git a/Nuake/src/UI/Canvas.h b/Nuake/src/UI/Nodes/Canvas.h similarity index 100% rename from Nuake/src/UI/Canvas.h rename to Nuake/src/UI/Nodes/Canvas.h diff --git a/Nuake/src/UI/Node.cpp b/Nuake/src/UI/Nodes/Node.cpp similarity index 100% rename from Nuake/src/UI/Node.cpp rename to Nuake/src/UI/Nodes/Node.cpp diff --git a/Nuake/src/UI/Node.h b/Nuake/src/UI/Nodes/Node.h similarity index 99% rename from Nuake/src/UI/Node.h rename to Nuake/src/UI/Nodes/Node.h index 32054f7d..cc22b0b9 100644 --- a/Nuake/src/UI/Node.h +++ b/Nuake/src/UI/Nodes/Node.h @@ -4,7 +4,8 @@ #include "yoga/Yoga.h" #include "../Rendering/Renderer2D.h" #include "../Core/Logger.h" -#include "Style.h" +#include + namespace Layout { diff --git a/Nuake/src/UI/Rect.h b/Nuake/src/UI/Nodes/Rect.h similarity index 100% rename from Nuake/src/UI/Rect.h rename to Nuake/src/UI/Nodes/Rect.h diff --git a/Nuake/src/UI/Nodes/TextNode.h b/Nuake/src/UI/Nodes/TextNode.h new file mode 100644 index 00000000..bdffa6d4 --- /dev/null +++ b/Nuake/src/UI/Nodes/TextNode.h @@ -0,0 +1,23 @@ +#pragma once +#include "Node.h" + + +struct TextStyle +{ + Ref font; + float fontSize; + Color color; +}; + +class TextNode : public Node +{ +public: + std::string content = "Hello World!"; + TextStyle style; + + + void Draw() + { + //Renderer2D::DrawString(content, style.font, Vector2(Position.Left, Position.Top), 2.0); + } +}; \ No newline at end of file diff --git a/Nuake/src/UI/Style.h b/Nuake/src/UI/Styling/Style.h similarity index 100% rename from Nuake/src/UI/Style.h rename to Nuake/src/UI/Styling/Style.h diff --git a/Nuake/src/UI/StyleSheetParser.cpp b/Nuake/src/UI/Styling/StyleSheetParser.cpp similarity index 100% rename from Nuake/src/UI/StyleSheetParser.cpp rename to Nuake/src/UI/Styling/StyleSheetParser.cpp diff --git a/Nuake/src/UI/StyleSheetParser.h b/Nuake/src/UI/Styling/StyleSheetParser.h similarity index 100% rename from Nuake/src/UI/StyleSheetParser.h rename to Nuake/src/UI/Styling/StyleSheetParser.h diff --git a/Nuake/src/UI/Stylesheet.cpp b/Nuake/src/UI/Styling/Stylesheet.cpp similarity index 100% rename from Nuake/src/UI/Stylesheet.cpp rename to Nuake/src/UI/Styling/Stylesheet.cpp diff --git a/Nuake/src/UI/Stylesheet.h b/Nuake/src/UI/Styling/Stylesheet.h similarity index 99% rename from Nuake/src/UI/Stylesheet.h rename to Nuake/src/UI/Styling/Stylesheet.h index 2bd1c20c..2aac27c7 100644 --- a/Nuake/src/UI/Stylesheet.h +++ b/Nuake/src/UI/Styling/Stylesheet.h @@ -8,11 +8,10 @@ #include "katana-parser/katana.h" #include #include -#include +#include #include #include #include -#include namespace UI { diff --git a/Nuake/src/UI/Text.h b/Nuake/src/UI/Text.h deleted file mode 100644 index 6e432145..00000000 --- a/Nuake/src/UI/Text.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "Node.h" - - -class Text : public Node -{ - - -public: - std::string content = "Hello World!"; - - - void Draw() - { - - } -}; \ No newline at end of file diff --git a/Nuake/src/UI/UserInterface.cpp b/Nuake/src/UI/UserInterface.cpp index f6229755..1efb1a8f 100644 --- a/Nuake/src/UI/UserInterface.cpp +++ b/Nuake/src/UI/UserInterface.cpp @@ -1,7 +1,7 @@ #include "UserInterface.h" #include -#include "Stylesheet.h" +#include "Styling/Stylesheet.h" #include "yoga/YGConfig.h" #include "InterfaceParser.h" #include @@ -11,7 +11,7 @@ namespace UI { m_Name = name; - font = FontLoader::LoadFont("resources/Fonts/OpenSans-Regular.ttf"); + font = FontLoader::LoadFont("resources/Fonts/RobotoMono-Regular.ttf"); m_Stylesheet = StyleSheet::New("/Interface\\Testing.css"); @@ -111,7 +111,7 @@ namespace UI DrawRecursive(Root, 0); - Renderer2D::DrawString("Hello SDF World!", font, charPos, 2.0f); + Renderer2D::DrawString("J'appelle ca grainer", font, charPos, 4.0f); //Renderer2D::DrawChar(charr, font, charPos, size); } diff --git a/Nuake/src/UI/UserInterface.h b/Nuake/src/UI/UserInterface.h index 2af4de76..f1237f3c 100644 --- a/Nuake/src/UI/UserInterface.h +++ b/Nuake/src/UI/UserInterface.h @@ -1,12 +1,12 @@ #pragma once #include #include -#include +#include #include "yoga/Yoga.h" -#include "Node.h" -#include +#include "Nodes/Node.h" +#include "Nodes/Canvas.h" #include "../Core/Maths.h" -#include "Stylesheet.h" +#include "Styling/Stylesheet.h" #include "Font/Font.h" namespace UI {