mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
yes
This commit is contained in:
@@ -40,20 +40,17 @@ namespace mlx
|
|||||||
NonOwningPtr<Text> text = p_scene->GetTextFromPositionAndColor(str, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, vec_color);
|
NonOwningPtr<Text> text = p_scene->GetTextFromPositionAndColor(str, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, vec_color);
|
||||||
if(!text)
|
if(!text)
|
||||||
{
|
{
|
||||||
Text& new_text = p_scene->CreateText(str);
|
|
||||||
new_text.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
|
||||||
new_text.SetColor(std::move(vec_color));
|
|
||||||
if(m_pixelput_called)
|
if(m_pixelput_called)
|
||||||
{
|
{
|
||||||
m_draw_layer++;
|
m_draw_layer++;
|
||||||
m_pixelput_called = false;
|
m_pixelput_called = false;
|
||||||
}
|
}
|
||||||
|
Text& new_text = p_scene->CreateText(str);
|
||||||
|
new_text.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||||
|
new_text.SetColor(std::move(vec_color));
|
||||||
}
|
}
|
||||||
else if(!p_scene->IsTextAtGivenDrawLayer(str, m_draw_layer))
|
else if(!p_scene->IsTextAtGivenDrawLayer(str, m_draw_layer))
|
||||||
{
|
p_scene->BringToDrawLayer(text.Get(), m_draw_layer);
|
||||||
p_scene->BringToFront(text.Get());
|
|
||||||
m_draw_layer++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsSupport::TexturePut(NonOwningPtr<Texture> texture, int x, int y)
|
void GraphicsSupport::TexturePut(NonOwningPtr<Texture> texture, int x, int y)
|
||||||
@@ -62,20 +59,17 @@ namespace mlx
|
|||||||
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||||
if(!sprite)
|
if(!sprite)
|
||||||
{
|
{
|
||||||
|
|
||||||
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
|
||||||
new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
|
||||||
if(m_pixelput_called)
|
if(m_pixelput_called)
|
||||||
{
|
{
|
||||||
m_draw_layer++;
|
m_draw_layer++;
|
||||||
m_pixelput_called = false;
|
m_pixelput_called = false;
|
||||||
}
|
}
|
||||||
}
|
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
||||||
else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer))
|
new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||||
{
|
|
||||||
p_scene->BringToFront(sprite.Get());
|
|
||||||
m_draw_layer++;
|
|
||||||
}
|
}
|
||||||
|
else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer))
|
||||||
|
p_scene->BringToDrawLayer(sprite.Get(), m_draw_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsSupport::TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept
|
void GraphicsSupport::TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace mlx
|
|||||||
inline void BindFont(std::shared_ptr<Font> font) { Verify((bool)font, "invalid fond pointer"); p_bound_font = font; }
|
inline void BindFont(std::shared_ptr<Font> font) { Verify((bool)font, "invalid fond pointer"); p_bound_font = font; }
|
||||||
|
|
||||||
void BringToFront(NonOwningPtr<Drawable> drawable);
|
void BringToFront(NonOwningPtr<Drawable> drawable);
|
||||||
|
void BringToDrawLayer(NonOwningPtr<Drawable> drawable, std::uint64_t draw_layer);
|
||||||
|
|
||||||
inline void ResetScene() { m_drawables.clear(); }
|
inline void ResetScene() { m_drawables.clear(); }
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "Graphics/Enums.h"
|
|
||||||
#include <PreCompiled.h>
|
#include <PreCompiled.h>
|
||||||
#include <Graphics/Scene.h>
|
#include <Graphics/Scene.h>
|
||||||
#include <Renderer/Renderer.h>
|
#include <Renderer/Renderer.h>
|
||||||
@@ -124,4 +123,16 @@ namespace mlx
|
|||||||
return;
|
return;
|
||||||
std::rotate(it, it + 1, m_drawables.end());
|
std::rotate(it, it + 1, m_drawables.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::BringToDrawLayer(NonOwningPtr<Drawable> drawable, std::uint64_t draw_layer)
|
||||||
|
{
|
||||||
|
MLX_PROFILE_FUNCTION();
|
||||||
|
auto it = std::find_if(m_drawables.begin(), m_drawables.end(), [&drawable](std::shared_ptr<Drawable> drawable_ptr)
|
||||||
|
{
|
||||||
|
return drawable_ptr.get() == drawable.Get();
|
||||||
|
});
|
||||||
|
if (m_drawables.size() > draw_layer)
|
||||||
|
return;
|
||||||
|
std::swap(*it, *(m_drawables.begin() + draw_layer));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user