text input in shell working

This commit is contained in:
Lendemor 2016-12-14 12:47:35 +01:00
parent 80a01cef2f
commit ebb77b7470
4 changed files with 16 additions and 14 deletions

View File

@ -35,7 +35,6 @@ void ContainerNode::removeChild(SceneNode* node)
it = m_children.erase(it);
node->m_parent = nullptr;
node->setSceneTree(nullptr);
// break;
}
else
++it;

View File

@ -44,14 +44,16 @@ void GraphicalContainerNode::removeChild(GraphicalNode *node)
{
if(node != nullptr)
{
for(auto it = m_children.begin(); it != m_children.end(); ++it)
for(auto it = m_children.begin(); it != m_children.end();)
{
if(*it == node)
{
m_children.erase(it);
it = m_children.erase(it);
node->m_parent = nullptr;
node->setSceneTree(nullptr);
}
else
++it;
}
}
}

View File

@ -22,6 +22,8 @@ const float SparrowShell::DEFAULT_FONT_SIZE = 16.f;
SparrowShell::SparrowShell(sf::Window* window):
m_position(glm::ivec2(0)),
m_buffer(new ShellBuffer(BUFFER_MAX_LENGTH)),
m_text_color(glm::vec3(0.7,1,0.3)),
m_input_mesh(nullptr),
m_input_cursor_pos(0)
{
sf::Vector2u size = window->getSize();
@ -33,8 +35,6 @@ SparrowShell::SparrowShell(sf::Window* window):
Font* fonte_des_neiges = Loader::loadFont("../data/consolas.fnt","../data/consolas.png");
RESOURCE_ADD(fonte_des_neiges,Font,"shellfont");
m_text_color = glm::vec3(0.7,1,0.3);
//Create mesh for background
Mesh* mesh = new Mesh();
mesh->addRectangle2D(glm::vec2(0),m_dimension);
@ -133,12 +133,13 @@ void SparrowShell::updateTextInput()
std::cout << text[i] << (int) text[i] << std::endl;
}
Font *shellfont = RESOURCE_GET(Font,"shellfont");
if(m_input_mesh)
this->removeChild(m_input_mesh);
m_input_mesh = shellfont->getTextNode(m_input_string,m_text_color,m_buffer->getFontSize(),false);
this->addChild(m_input_mesh);
// m_input_string.insert(m_input_cursor_pos,c);
// m_input_string.append();
// std::cout << m_input_string << std::endl;
if(m_input_string != "")
{
if(m_input_mesh)
this->removeChild(m_input_mesh);
m_input_mesh = shellfont->getTextNode(m_input_string,m_text_color,m_buffer->getFontSize(),false);
m_input_mesh->moveTo2D(glm::vec2(0,m_buffer->getFontSize()*BUFFER_DISPLAYED_LINES));
this->addChild(m_input_mesh);
m_input_mesh->setVisible(true);
}
}

View File

@ -129,7 +129,7 @@ int main(){
// this creates the opengl context
// the opengl context must exist before any opengl class is used (texture, pipeline, etc..)
engine.createWindow("Sparrow Engine Testing Environment", 1920, 1080, false);
engine.createWindow("Sparrow Engine Testing Environment");
// setting up SparrowEngine
engine.initPhysics();