From 6edc143013cb41cfc9987fe36340ff166c2a64c0 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Mon, 3 Aug 2026 15:45:18 +0300 Subject: [PATCH] updated GUI classes --- button.cpp | 12 ++++++------ listbox.cpp | 12 ++++++------ slider.cpp | 9 ++++----- textbox.cpp | 17 +++++++++-------- textbox.h | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/button.cpp b/button.cpp index 40df1b0..b4435b2 100644 --- a/button.cpp +++ b/button.cpp @@ -1,7 +1,3 @@ -#include -#include -#include - #include "root.h" #include "quad.h" #include "node.h" @@ -11,6 +7,10 @@ #include "util.h" #include "button.h" +#include +#include +#include + using namespace std; using namespace vb01; @@ -28,7 +28,7 @@ namespace vb01Gui{ guiNode = root->getGuiNode(); rect = new Quad(Vector3(size.x, size.y, 0), false); rectNode = new Node(pos); - Material *mat = new Material(root->getLibPath() + "gui"); + Material *mat = new Material(root->getGuiShader()); if(imagePath == ""){ mat->addBoolUniform(texUni, false); @@ -54,7 +54,7 @@ namespace vb01Gui{ textNode = new Node(pos + textOffset, Quaternion::QUAT_W, Vector3(sc, sc, 1)); textNode->addText(text); - Material *textMat = new Material(root->getLibPath() + "text"); + Material *textMat = new Material(root->getGuiShader()); textMat->addBoolUniform(texUni, false); textMat->addVec4Uniform(diffColUni, Vector4::VEC_IJKL); text->setMaterial(textMat); diff --git a/listbox.cpp b/listbox.cpp index 29caa16..688c397 100644 --- a/listbox.cpp +++ b/listbox.cpp @@ -1,5 +1,3 @@ -#include - #include "listbox.h" #include "util.h" #include "node.h" @@ -8,6 +6,8 @@ #include "root.h" #include "material.h" +#include + using namespace vb01; using namespace std; @@ -46,7 +46,7 @@ namespace vb01Gui{ guiNode = Root::getSingleton()->getGuiNode(); string texUni = "texturingEnabled", diffColUni = "diffuseColor"; - textMat = new Material(root->getLibPath() + "text"); + textMat = new Material(root->getGuiShader()); textMat->addBoolUniform(texUni, false); textMat->addVec4Uniform(diffColUni, Vector4::VEC_IJKL); @@ -65,7 +65,7 @@ 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"); + Material *mat = new Material(root->getGuiShader()); mat->addBoolUniform(texUni, false); mat->addVec4Uniform(diffColUni, Vector4(.6, .35, .05, 1)); selRect->setMaterial(mat); @@ -203,14 +203,14 @@ namespace vb01Gui{ } void Listbox::changeLine(int id, wstring change){ - lines[id]->setText(change); + lines[id]->setEntry(change); } std::vector Listbox::getContents(){ std::vector lines; for(Text *t : this->lines) - lines.push_back(t->getText()); + lines.push_back(t->getEntry()); return lines; } diff --git a/slider.cpp b/slider.cpp index 4976359..c02d147 100644 --- a/slider.cpp +++ b/slider.cpp @@ -1,12 +1,11 @@ -#include - -#include -#include - #include "slider.h" #include "root.h" #include "util.h" +#include + +#include +#include using namespace std; using namespace vb01; diff --git a/textbox.cpp b/textbox.cpp index 53feae7..88e8c7d 100644 --- a/textbox.cpp +++ b/textbox.cpp @@ -27,9 +27,10 @@ namespace vb01Gui{ textboxButton = new TextboxButton(this, pos, size, "TextboxButton"); string libPath = Root::getSingleton()->getLibPath(); - guiNode = Root::getSingleton()->getGuiNode(); + Root *root = Root::getSingleton(); + guiNode = root->getGuiNode(); text = new Text(fontPath, entry); - Material *textMat = new Material(libPath + "text"); + Material *textMat = new Material(root->getGuiShader()); textMat->addBoolUniform("texturingEnabled", false); textMat->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1)); text->setMaterial(textMat); @@ -42,7 +43,7 @@ namespace vb01Gui{ cursorPosOffset = entry.length(); cursorRect = new Quad(Vector3(cursorWidth, size.y, 0), false); cursorNode = new Node(Vector3(pos.x + text->getLength(), pos.y, pos.z + cursorZCoord)); - Material *mat = new Material(libPath + "gui"); + Material *mat = new Material(root->getGuiShader()); mat->addBoolUniform("texturingEnabled", false); mat->addVec4Uniform("diffuseColor", Vector4(1, 1, 1, 1)); cursorRect->setMaterial(mat); @@ -73,8 +74,8 @@ namespace vb01Gui{ void Textbox::type(u32 c, bool capitalLetters){ entry += c; - text->setText(entry); - moveCursor(false, text->getGlyph(c)->size.x); + text->setEntry(entry); + moveCursor(false, text->getFont()->getGlyph(c).size.x); } void Textbox::moveCursor(bool left, float charWidth){ @@ -94,8 +95,8 @@ namespace vb01Gui{ if(entry.length() > 0 && canDeleteChar()){ char c = entry.c_str()[entry.length() - 1]; entry = entry.substr(0, entry.length() - 1); - text->setText(entry); - moveCursor(true, text->getGlyph(c)->size.x); + text->setEntry(entry); + moveCursor(true, text->getFont()->getGlyph(c).size.x); lastDeleteTime = getTime(); } } @@ -124,7 +125,7 @@ namespace vb01Gui{ void Textbox::setEntry(wstring entry){ this->entry = entry; - text->setText(entry); + text->setEntry(entry); cursorNode->setPosition(Vector3(pos.x + text->getLength(), pos.y, cursorZCoord)); cursorPosOffset = entry.length(); } diff --git a/textbox.h b/textbox.h index 007e062..4e42c58 100644 --- a/textbox.h +++ b/textbox.h @@ -27,7 +27,7 @@ namespace vb01Gui{ void remove(); inline void setSlider(Slider *s){this->slider = s;} inline bool isEnabled(){return enabled;} - inline std::wstring getText(){return text->getText();} + inline std::wstring getText(){return text->getEntry();} inline void setDeleteCharacters(bool del){this->deleteCharacters = del;} inline bool isDeleteCharacters(){return deleteCharacters;} private: