sparrowshell disabled when starting engine
This commit is contained in:
parent
7c710b1656
commit
4372c11720
@ -6,9 +6,14 @@ GraphicalNode::GraphicalNode() : m_visible(true)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GraphicalNode::GraphicalNode(bool visible) : m_visible(visible)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicalNode::setSceneTree(SceneTree *tree){
|
void GraphicalNode::setSceneTree(SceneTree *tree){
|
||||||
SceneNode::setSceneTree(tree);
|
SceneNode::setSceneTree(tree);
|
||||||
if(tree)
|
if(tree && m_visible)
|
||||||
tree->addToIndex(this);
|
tree->addToIndex(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ protected:
|
|||||||
bool m_visible;
|
bool m_visible;
|
||||||
public:
|
public:
|
||||||
GraphicalNode();
|
GraphicalNode();
|
||||||
|
GraphicalNode(bool);
|
||||||
|
|
||||||
void toggleVisibility();
|
void toggleVisibility();
|
||||||
virtual void setSceneTree(SceneTree* tree);
|
virtual void setSceneTree(SceneTree* tree);
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
glm::mat4 m_movement;
|
glm::mat4 m_movement;
|
||||||
glm::mat4 m_acceleration;
|
glm::mat4 m_acceleration;
|
||||||
|
|
||||||
MeshNode(Mesh* mesh) : m_geometry(mesh, glm::mat4()), bulletMesh(nullptr) {}
|
MeshNode(Mesh* mesh, bool visible = true) : GraphicalNode(visible), m_geometry(mesh, glm::mat4()), bulletMesh(nullptr) {}
|
||||||
|
|
||||||
virtual void update()
|
virtual void update()
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "shellbuffer.h"
|
#include "shellbuffer.h"
|
||||||
#include "scene/meshnode.h"
|
#include "scene/meshnode.h"
|
||||||
#include "scene/textnode.h"
|
#include "scene/textnode.h"
|
||||||
|
#include "sparrowshell/sparrowshell.h"
|
||||||
|
#include "tools/utils.h"
|
||||||
|
|
||||||
void ShellBuffer::toggleBuffer(){
|
void ShellBuffer::toggleBuffer(){
|
||||||
for(auto child : m_children){
|
for(auto child : m_children){
|
||||||
@ -12,7 +14,28 @@ void ShellBuffer::toggleBuffer(){
|
|||||||
|
|
||||||
void ShellBuffer::update()
|
void ShellBuffer::update()
|
||||||
{
|
{
|
||||||
|
TextNode* tnode;
|
||||||
|
glm::vec2 text_pos(0);
|
||||||
|
|
||||||
|
SparrowShell* shell = dynamic_cast<SparrowShell*>(m_parent);
|
||||||
|
// if(shell && shell->isEnabled())
|
||||||
|
// {
|
||||||
|
// for(unsigned int i = 0; i< size();i++)
|
||||||
|
// {
|
||||||
|
// tnode = (TextNode*) this+i;
|
||||||
|
// if (i >= m_index && i < m_index+SparrowShell::BUFFER_DISPLAYED_NUMBER)
|
||||||
|
// {
|
||||||
|
// utils::setPosition2D(tnode,text_pos);
|
||||||
|
// text_pos.y += m_font_size;
|
||||||
|
// //m_scene
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// utils::setPosition2D(tnode,glm::vec2(-100,-100));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellBuffer::push(TextNode* s){
|
void ShellBuffer::push(TextNode* s){
|
||||||
|
@ -10,6 +10,7 @@ private:
|
|||||||
unsigned int m_max_size;
|
unsigned int m_max_size;
|
||||||
int m_zero_offset;
|
int m_zero_offset;
|
||||||
float m_font_size;
|
float m_font_size;
|
||||||
|
unsigned int m_index = 0;
|
||||||
public:
|
public:
|
||||||
ShellBuffer(int buffer_size):m_max_size(buffer_size), m_zero_offset(0),m_font_size(16.f){}
|
ShellBuffer(int buffer_size):m_max_size(buffer_size), m_zero_offset(0),m_font_size(16.f){}
|
||||||
GraphicalNode* operator[](int i){return m_children[(m_zero_offset+i)%m_max_size];}
|
GraphicalNode* operator[](int i){return m_children[(m_zero_offset+i)%m_max_size];}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
#define SHELLSCROLLBAR_H
|
#define SHELLSCROLLBAR_H
|
||||||
|
|
||||||
#include "glm/vec2.hpp"
|
#include "glm/vec2.hpp"
|
||||||
|
#include "scene/meshnode.h"
|
||||||
|
|
||||||
class MeshNode;
|
|
||||||
class SparrowShell;
|
class SparrowShell;
|
||||||
|
|
||||||
class ShellScrollBar
|
class ShellScrollBar// : public MeshNode
|
||||||
{
|
{
|
||||||
SparrowShell* m_shell;
|
SparrowShell* m_shell;
|
||||||
glm::ivec2 m_position;
|
glm::ivec2 m_position;
|
||||||
|
@ -32,7 +32,7 @@ SparrowShell::SparrowShell(sf::Window* window, Input* input):
|
|||||||
mesh->setMaterial(mat);
|
mesh->setMaterial(mat);
|
||||||
mesh->setDepth(SHELL_DEPTH);
|
mesh->setDepth(SHELL_DEPTH);
|
||||||
mesh->initGL();
|
mesh->initGL();
|
||||||
m_background = new MeshNode(mesh);
|
m_background = new MeshNode(mesh,false);
|
||||||
this->addChild(m_background);
|
this->addChild(m_background);
|
||||||
this->addChild(m_buffer);
|
this->addChild(m_buffer);
|
||||||
m_scrollbar = ShellScrollBar(this);
|
m_scrollbar = ShellScrollBar(this);
|
||||||
@ -44,7 +44,8 @@ void SparrowShell::out(std::string s)
|
|||||||
TextNode* tnode = shellfont->getTextNode(s,glm::vec3(0.7,1,0.3),m_buffer->getFontSize());
|
TextNode* tnode = shellfont->getTextNode(s,glm::vec3(0.7,1,0.3),m_buffer->getFontSize());
|
||||||
tnode->setDepth(SHELL_DEPTH+1);
|
tnode->setDepth(SHELL_DEPTH+1);
|
||||||
m_buffer->push(tnode);
|
m_buffer->push(tnode);
|
||||||
m_scene->addToIndex(tnode);
|
if(m_shellEnabled)
|
||||||
|
m_scene->addToIndex(tnode);
|
||||||
if (m_buffer->size() > SparrowShell::BUFFER_DISPLAYED_NUMBER)
|
if (m_buffer->size() > SparrowShell::BUFFER_DISPLAYED_NUMBER)
|
||||||
m_resizeBuffer = true;
|
m_resizeBuffer = true;
|
||||||
}
|
}
|
||||||
@ -65,37 +66,21 @@ void SparrowShell::scrollDown(){
|
|||||||
|
|
||||||
void SparrowShell::toggleShell(){
|
void SparrowShell::toggleShell(){
|
||||||
m_shellEnabled = !m_shellEnabled;
|
m_shellEnabled = !m_shellEnabled;
|
||||||
for(auto child : m_children){
|
// for(auto child : m_children){
|
||||||
MeshNode* meshchild = dynamic_cast<MeshNode*>(child);
|
// MeshNode* meshchild = dynamic_cast<MeshNode*>(child);
|
||||||
// if(meshchild)
|
// // if(meshchild)
|
||||||
// meshchild->toggleVisibility();
|
// // meshchild->toggleVisibility();
|
||||||
}
|
// }
|
||||||
// m_buffer->toggleBuffer();
|
//// m_buffer->toggleBuffer();
|
||||||
m_background->toggleVisibility();
|
//// m_background->toggleVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SparrowShell::update(){
|
void SparrowShell::update(){
|
||||||
TextNode* tnode;
|
|
||||||
glm::vec2 text_pos(0);
|
|
||||||
|
|
||||||
for(auto action : m_input->getActions()){
|
for(auto action : m_input->getActions()){
|
||||||
if(action == 15){
|
if(action == 15){
|
||||||
toggleShell();
|
toggleShell();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//move position of shellBuffer
|
|
||||||
// position textnode inside shellBuffer
|
|
||||||
|
|
||||||
m_buffer->update();
|
m_buffer->update();
|
||||||
/* if(m_shellEnabled){
|
|
||||||
for(unsigned int i = 0; i<m_buffer->size(); i++){
|
|
||||||
tnode = (TextNode*)(m_buffer+i);
|
|
||||||
if (i >= m_index && i < m_index + BUFFER_DISPLAYED_NUMBER){
|
|
||||||
utils::setPosition2D(tnode,text_pos);
|
|
||||||
text_pos.y += m_buffer->getFontSize();
|
|
||||||
m_scene->addToIndex(tnode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
m_scrollbar.update();
|
m_scrollbar.update();
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,11 @@ public:
|
|||||||
|
|
||||||
void toggleShell();
|
void toggleShell();
|
||||||
void out(std::string);
|
void out(std::string);
|
||||||
|
|
||||||
void setSceneTree(SceneTree* tree)
|
void setSceneTree(SceneTree* tree)
|
||||||
{
|
{
|
||||||
GraphicalContainerNode::setSceneTree(tree);
|
GraphicalContainerNode::setSceneTree(tree);
|
||||||
m_buffer->setSceneTree(tree);
|
// m_buffer->setSceneTree(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::ivec2 getPosition(){return m_position;}
|
glm::ivec2 getPosition(){return m_position;}
|
||||||
@ -63,6 +64,7 @@ public:
|
|||||||
unsigned int getIndex(){return m_index;}
|
unsigned int getIndex(){return m_index;}
|
||||||
ShellBuffer* getBuffer(){return m_buffer;}
|
ShellBuffer* getBuffer(){return m_buffer;}
|
||||||
|
|
||||||
|
bool isEnabled(){return m_shellEnabled;}
|
||||||
bool isBufferResized(){return m_resizeBuffer;}
|
bool isBufferResized(){return m_resizeBuffer;}
|
||||||
bool indexMoved(){return m_indexMoved;}
|
bool indexMoved(){return m_indexMoved;}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user