New module: Platform - Split window management from Utility module (#128)
* New module: Platform - Split window management from Utility module Final touch * NDK/SDK: Bring back initialization of Utility
This commit is contained in:
committed by
Jérôme Leclercq
parent
41a1b5d493
commit
5aa072cee3
35
tests/Engine/Platform/EventHandler/Text.cpp
Normal file
35
tests/Engine/Platform/EventHandler/Text.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "Text.hpp"
|
||||
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||
#include <NDK/StateMachine.hpp>
|
||||
#include <NDK/World.hpp>
|
||||
#include <NDK/Components/GraphicsComponent.hpp>
|
||||
#include <NDK/Components/NodeComponent.hpp>
|
||||
|
||||
Text::Text(StateContext& stateContext) :
|
||||
m_context(stateContext)
|
||||
{
|
||||
m_text = m_context.world.CreateEntity();
|
||||
m_text->AddComponent<Ndk::NodeComponent>();
|
||||
Ndk::GraphicsComponent& graphicsComponent = m_text->AddComponent<Ndk::GraphicsComponent>();
|
||||
|
||||
m_textSprite = Nz::TextSprite::New();
|
||||
graphicsComponent.Attach(m_textSprite);
|
||||
}
|
||||
|
||||
Text::~Text()
|
||||
{
|
||||
m_textSprite->Clear();
|
||||
m_text->Kill();
|
||||
}
|
||||
|
||||
void Text::SetContent(const Nz::String& string, unsigned int size)
|
||||
{
|
||||
m_textSprite->Update(Nz::SimpleTextDrawer::Draw(string, size));
|
||||
}
|
||||
|
||||
void Text::SetVisible(bool shouldBeVisible)
|
||||
{
|
||||
m_text->Enable(shouldBeVisible);
|
||||
}
|
||||
Reference in New Issue
Block a user