Documentation for module 'NDK'

Former-commit-id: a6c2075cfbfd0eccf2b77def71c0d42684bed590 [formerly 36ece2bc6a148bde6cacf45084821d20edcd115e] [formerly 4a6988792ec026e65be6850c46dfe8ddda92a885 [formerly fd3f4f975de5c427f3adc98b220446fd255be396]]
Former-commit-id: c87fdc9483202842267c60eff3d619f0df2963bf [formerly ee35202f1b2df7ca20da5b6d8b13147f2b92c933]
Former-commit-id: dad5de1b00bb4413f7aa191ca06b7d43b659f32a
This commit is contained in:
Gawaboumga
2016-08-21 13:48:52 +02:00
parent 1e219ef819
commit 95689f46fb
75 changed files with 3374 additions and 112 deletions

View File

@@ -19,6 +19,20 @@ namespace Ndk
constexpr std::size_t s_inputPrefixSize = Nz::CountOf(s_inputPrefix) - 1;
}
/*!
* \ingroup NDK
* \class Ndk::Console
* \brief NDK class that represents a console to help development with Lua scripting
*/
/*!
* \brief Constructs a Console object with a world to interact with
*
* \param world World to interact with
* \param size (Width, Height) of the console
* \param instance Lua instance that will interact with the world
*/
Console::Console(World& world, const Nz::Vector2f& size, Nz::LuaInstance& instance) :
m_historyPosition(0),
m_defaultFont(Nz::Font::GetDefault()),
@@ -86,18 +100,35 @@ namespace Ndk
Layout();
}
/*!
* \brief Adds a line to the console
*
* \param text New line of text
* \param color Color for the text
*/
void Console::AddLine(const Nz::String& text, const Nz::Color& color)
{
AddLineInternal(text, color);
RefreshHistory();
}
/*!
* \brief Clears the console
*/
void Console::Clear()
{
m_historyLines.clear();
RefreshHistory();
}
/*!
* \brief Sends a character to the console
*
* \param character Character that will be added to the console
*/
void Console::SendCharacter(char32_t character)
{
switch (character)
@@ -131,6 +162,12 @@ namespace Ndk
m_inputTextSprite->Update(m_inputDrawer);
}
/*!
* \brief Sends an event to the console
*
* \param event Event to be takin into consideration by the console
*/
void Console::SendEvent(Nz::WindowEvent event)
{
switch (event.type)
@@ -170,6 +207,12 @@ namespace Ndk
}
}
/*!
* \brief Sets the character size
*
* \param size Size of the font
*/
void Console::SetCharacterSize(unsigned int size)
{
m_characterSize = size;
@@ -182,6 +225,12 @@ namespace Ndk
Layout();
}
/*!
* \brief Sets the console size
*
* \param size (Width, Height) of the console
*/
void Console::SetSize(const Nz::Vector2f& size)
{
m_size = size;
@@ -189,6 +238,14 @@ namespace Ndk
Layout();
}
/*!
* \brief Sets the text font
*
* \param font Reference to a valid font
*
* \remark Produces a NazaraAssert if font is invalid or null
*/
void Console::SetTextFont(Nz::FontRef font)
{
NazaraAssert(font && font->IsValid(), "Invalid font");
@@ -200,6 +257,12 @@ namespace Ndk
Layout();
}
/*!
* \brief Shows the console
*
* \param show Should the console be showed
*/
void Console::Show(bool show)
{
if (m_opened != show)
@@ -213,11 +276,22 @@ namespace Ndk
}
}
/*!
* \brief Adds a line to the history of the console
*
* \param text New line of text
* \param color Color for the text
*/
void Console::AddLineInternal(const Nz::String& text, const Nz::Color& color)
{
m_historyLines.emplace_back(Line{color, text});
}
/*!
* \brief Performs this action when an input is added to the console
*/
void Console::ExecuteInput()
{
Nz::String input = m_inputDrawer.GetText();
@@ -237,12 +311,18 @@ namespace Ndk
RefreshHistory();
}
/*!
* \brief Places the console according to its layout
*/
void Console::Layout()
{
unsigned int lineHeight = m_defaultFont->GetSizeInfo(m_characterSize).lineHeight;
Ndk::NodeComponent& inputNode = m_input->GetComponent<Ndk::NodeComponent>();
NazaraError(inputNode.GetPosition().ToString());
inputNode.SetPosition(0.f, m_size.y - lineHeight - 5.f);
NazaraError(inputNode.GetPosition().ToString());
float historyHeight = m_size.y - lineHeight - 5.f - 2.f;
m_historyBackgroundSprite->SetSize(m_size.x, historyHeight);
@@ -250,14 +330,22 @@ namespace Ndk
m_maxHistoryLines = static_cast<unsigned int>(std::ceil(historyHeight / lineHeight));
Ndk::NodeComponent& historyNode = m_history->GetComponent<Ndk::NodeComponent>();
NazaraError(historyNode.GetPosition().ToString());
historyNode.SetPosition(0.f, historyHeight - m_maxHistoryLines * lineHeight);
NazaraError(historyNode.GetPosition().ToString());
Ndk::NodeComponent& inputBackgroundNode = m_inputBackground->GetComponent<Ndk::NodeComponent>();
NazaraError(inputBackgroundNode.GetPosition().ToString());
inputBackgroundNode.SetPosition(0.f, historyHeight + 2.f);
NazaraError(inputBackgroundNode.GetPosition().ToString());
m_inputBackgroundSprite->SetSize(m_size.x, m_size.y - historyHeight);
}
/*!
* \brief Refreshes the history of the console
*/
void Console::RefreshHistory()
{
m_historyDrawer.Clear();