diff --git a/listbox.cpp b/listbox.cpp index 29caa16..693ec30 100644 --- a/listbox.cpp +++ b/listbox.cpp @@ -45,11 +45,6 @@ namespace vb01Gui{ Vector2 mousePos = getCursorPos(); guiNode = Root::getSingleton()->getGuiNode(); - string texUni = "texturingEnabled", diffColUni = "diffuseColor"; - textMat = new Material(root->getLibPath() + "text"); - textMat->addBoolUniform(texUni, false); - textMat->addVec4Uniform(diffColUni, Vector4::VEC_IJKL); - if(!lines.empty()){ for(int i = 0; i < lines.size(); i++) addLine(stringToWstring(lines[i])); @@ -66,8 +61,8 @@ namespace vb01Gui{ Quad *selRect = new Quad(Vector3(size.x, size.y, 0), false); selRectNode = new Node(Vector3(size.x, size.y, -.05)); Material *mat = new Material(root->getLibPath() + "gui"); - mat->addBoolUniform(texUni, false); - mat->addVec4Uniform(diffColUni, Vector4(.6, .35, .05, 1)); + mat->addBoolUniform("texturingEnabled", false); + mat->addVec4Uniform("diffuseColor", Vector4(.6, .35, .05, 1)); selRect->setMaterial(mat); selRectNode->attachMesh(selRect); selRectNode->setVisible(false); @@ -218,9 +213,14 @@ namespace vb01Gui{ void Listbox::addLine(wstring line){ float sc = .2; Node *node = new Node(pos + Vector3(0, size.y * (lines.size() + 1), 0) + textOffset, Quaternion::QUAT_W, Vector3(sc, sc, 1)); - Root::getSingleton()->getGuiNode()->attachChild(node); + Root *root = Root::getSingleton(); + root->getGuiNode()->attachChild(node); node->setVisible(false); + Material *textMat = new Material(root->getLibPath() + "text"); + textMat->addBoolUniform("texturingEnabled", false); + textMat->addVec4Uniform("diffuseColor", Vector4::VEC_IJKL); + Text *text = new Text(fontPath, line); text->setMaterial(textMat); node->addText(text); diff --git a/listbox.h b/listbox.h index 7c13d77..43e571a 100644 --- a/listbox.h +++ b/listbox.h @@ -35,6 +35,7 @@ namespace vb01Gui{ void scrollToHeight(float); virtual void onOpen(){} virtual void onClose(){} + inline vb01::Text* getLineText(int i){return lines[i];} inline void setName(std::string n){this->name = n;} inline std::string getName(){return name;} inline int getScrollOffset(){return scrollOffset;} @@ -69,7 +70,6 @@ namespace vb01Gui{ ScrollingButton *scrollingButton; vb01::Node *selRectNode, *guiNode; std::vector lines; - vb01::Material *textMat = nullptr; protected: int selectedOption = 0; public: