mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
UI text alignment work
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#include <src/Resource/FGD/FGDFile.h>
|
||||
#include <src/Rendering/Shaders/ShaderManager.h>
|
||||
#include <src/Rendering/Renderer.h>
|
||||
|
||||
#include "src/UI/UserInterface.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -30,14 +30,28 @@ int main()
|
||||
Ref<Nuake::Texture> lightTexture = Nuake::TextureManager::Get()->GetTexture("resources/Icons/Gizmo/Light.png");
|
||||
Ref<Nuake::Texture> camTexture = Nuake::TextureManager::Get()->GetTexture("resources/Icons/Gizmo/Camera.png");
|
||||
Ref<Nuake::Shader> GuizmoShader = Nuake::ShaderManager::GetShader("resources/Shaders/gizmo.shader");
|
||||
|
||||
Ref<Nuake::UI::UserInterface> uinterface = Nuake::UI::UserInterface::New("Editor");
|
||||
|
||||
while (!Nuake::Engine::GetCurrentWindow()->ShouldClose())
|
||||
{
|
||||
Nuake::RenderCommand::Clear();
|
||||
Nuake::Engine::Tick();
|
||||
Nuake::Engine::Draw();
|
||||
|
||||
uinterface->Update(0.0f);
|
||||
Nuake::Engine::Draw();
|
||||
//
|
||||
if (Nuake::Input::IsKeyPressed(GLFW_KEY_F1))
|
||||
uinterface->Reload();
|
||||
if (Nuake::Input::IsKeyPressed(GLFW_KEY_F8))
|
||||
Nuake::Engine::ExitPlayMode();
|
||||
|
||||
Nuake::Vector2 WindowSize = Nuake::Engine::GetCurrentWindow()->GetSize();
|
||||
glViewport(0, 0, WindowSize.x, WindowSize.y);
|
||||
Nuake::Renderer2D::BeginDraw(WindowSize);
|
||||
//Nuake::Renderer2D::DrawRect(Nuake::Vector2(100, 100), Nuake::Vector2(100, 100), Nuake::Color(1.0, 0.0, 0.0, 1.0), 2.0f);
|
||||
|
||||
|
||||
uinterface->Draw(WindowSize);
|
||||
|
||||
Ref<Nuake::FrameBuffer> sceneFramebuffer = Nuake::Engine::GetCurrentWindow()->GetFrameBuffer();
|
||||
sceneFramebuffer->Bind();
|
||||
@@ -52,37 +66,41 @@ int main()
|
||||
auto camView = currentScene->m_Registry.view<Nuake::TransformComponent, Nuake::CameraComponent>();
|
||||
for (auto e : camView) {
|
||||
auto [transformComponent, cam] = camView.get<Nuake::TransformComponent, Nuake::CameraComponent>(e);
|
||||
|
||||
|
||||
GuizmoShader->SetUniformMat4f("model", transformComponent.GetTransform());
|
||||
GuizmoShader->SetUniformMat4f("view", currentScene->m_EditorCamera->GetTransform());
|
||||
GuizmoShader->SetUniformMat4f("projection", currentScene->m_EditorCamera->GetPerspective());
|
||||
|
||||
|
||||
camTexture->Bind(2);
|
||||
GuizmoShader->SetUniform1i("gizmo_texture", 2);
|
||||
|
||||
|
||||
Nuake::Renderer::DrawQuad(transformComponent.GetTransform());
|
||||
}
|
||||
|
||||
|
||||
auto view = currentScene->m_Registry.view<Nuake::TransformComponent, Nuake::LightComponent>();
|
||||
for (auto e : view) {
|
||||
auto [transformComponent, light] = view.get<Nuake::TransformComponent, Nuake::LightComponent>(e);
|
||||
|
||||
|
||||
GuizmoShader->SetUniformMat4f("model", transformComponent.GetTransform());
|
||||
GuizmoShader->SetUniformMat4f("view", currentScene->m_EditorCamera->GetTransform());
|
||||
GuizmoShader->SetUniformMat4f("projection", currentScene->m_EditorCamera->GetPerspective());
|
||||
|
||||
|
||||
lightTexture->Bind(2);
|
||||
GuizmoShader->SetUniform1i("gizmo_texture", 2);
|
||||
|
||||
Nuake::Renderer::DrawQuad(transformComponent.GetTransform());
|
||||
}
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
GuizmoShader->Unbind();
|
||||
}
|
||||
|
||||
sceneFramebuffer->Unbind();
|
||||
editor.Draw();
|
||||
|
||||
|
||||
//if (ImGui::Begin("test")) {}
|
||||
//ImGui::End();
|
||||
//editor.Draw();
|
||||
Nuake::Engine::EndDraw();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,51 @@
|
||||
.screen{
|
||||
.screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: row;
|
||||
align-content:flex-start;
|
||||
}
|
||||
|
||||
.rect{
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
.logo {
|
||||
width: 500px;
|
||||
height: 50%;
|
||||
margin: 0px 0px 0px 0px;
|
||||
justify-content: center;
|
||||
align-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
.panel {
|
||||
display: flex;
|
||||
height: 33%;
|
||||
width: 33%;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
.panel-top {
|
||||
width: 100%;
|
||||
height: 75%;
|
||||
justify-content: flex-start;
|
||||
flex-direction:column;
|
||||
}
|
||||
|
||||
.panel-bottom {
|
||||
width:100%;
|
||||
height: 25%;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
align-content: flex-end;
|
||||
}
|
||||
|
||||
.rect {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.normal-text {
|
||||
font-size: 2.0;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,32 @@
|
||||
<Canvas
|
||||
script="Scripts/test Test"
|
||||
stylesheet="Interface/Testing.css"
|
||||
stylesheet="resources/Interface/Testing.css"
|
||||
groups="screen"
|
||||
color="33 33 33 255"
|
||||
height="100%"
|
||||
width="100%"
|
||||
padding="8px 8px 8px 8px"
|
||||
>
|
||||
<p groups="header">Hello, world!</p>
|
||||
|
||||
<Rect onclick="hello()"
|
||||
groups="rect">
|
||||
<Rect groups="logo"
|
||||
color="25 25 25 0">
|
||||
<p font-size="1.5" margin="0 0 0 12px">Nuake Engine</p>
|
||||
<p groups="normal-text">You can load a project, or create a new one.</p>
|
||||
<Rect groups="panel-bottom">
|
||||
<Rect
|
||||
groups="rect"
|
||||
height="50px"
|
||||
width="49%"
|
||||
border="8px 8px 8px 8px"
|
||||
color="18 18 18 255">
|
||||
<p groups="normal-text">New Project</p>
|
||||
</Rect>
|
||||
<Rect
|
||||
groups="rect"
|
||||
height="50px"
|
||||
width="49%"
|
||||
border="8px 8px 8px 8px"
|
||||
color="18 18 18 255">
|
||||
<p groups="normal-text">Load Project</p>
|
||||
</Rect>
|
||||
</Rect>
|
||||
</Rect>
|
||||
</Canvas>
|
||||
|
||||
@@ -18,7 +18,7 @@ void main()
|
||||
#version 460 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 a_UV;
|
||||
in sample vec2 a_UV;
|
||||
|
||||
uniform vec2 texPos;
|
||||
uniform vec2 texScale;
|
||||
@@ -41,12 +41,13 @@ float median(float r, float g, float b) {
|
||||
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));
|
||||
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));
|
||||
|
||||
vec3 msd = texture(msdf, uv).rgb;
|
||||
float sd = median(msd.r, msd.g, msd.b);
|
||||
float screenPxDistance = screenPxRange(uv) * (sd - 0.5);
|
||||
float alpha = smoothstep(0.5 - 1/16.0, 0.5 + 1 / 16.0, sd);
|
||||
FragColor = mix(bgColor, fgColor, alpha);
|
||||
float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
||||
|
||||
FragColor = mix(bgColor, fgColor, opacity);
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
#version 460 core
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec2 UV;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 projection;
|
||||
|
||||
|
||||
out sample vec2 a_UV;
|
||||
|
||||
void main()
|
||||
@@ -17,9 +17,9 @@ void main()
|
||||
#shader fragment
|
||||
#version 460 core
|
||||
|
||||
uniform vec4 background_color;
|
||||
uniform float u_border_radius;
|
||||
uniform vec2 u_size;
|
||||
uniform vec4 u_BackgroundColor;
|
||||
uniform float u_BorderRadius;
|
||||
uniform vec2 u_Size;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
@@ -53,11 +53,11 @@ bool ShouldDiscard(vec2 coords, vec2 dimensions, float radius)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 coords = a_UV * u_size;
|
||||
vec2 center = u_size / 2.0;
|
||||
vec2 coords = a_UV * u_Size;
|
||||
vec2 center = u_Size / 2.0;
|
||||
|
||||
// Border rounding
|
||||
if (ShouldDiscard(coords, u_size, u_border_radius))
|
||||
if (ShouldDiscard(coords, u_Size, u_BorderRadius))
|
||||
discard;
|
||||
FragColor = background_color;
|
||||
FragColor = u_BackgroundColor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user