listboxes are rendered with dark background.
listboxes can be "leftControlled"
This commit is contained in:
parent
ea92fce58d
commit
49451e1184
|
@ -363,6 +363,7 @@ GraphicListBox::GraphicListBox(std::string containerName, std::string objName)
|
||||||
: GraphicComponent(containerName, objName), graphButton1(), graphButton2() {
|
: GraphicComponent(containerName, objName), graphButton1(), graphButton2() {
|
||||||
selectedItemIndex = 0;
|
selectedItemIndex = 0;
|
||||||
lighted = false;
|
lighted = false;
|
||||||
|
leftControlled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicListBox::init(int x, int y, int w, int h, Vec3f textColor){
|
void GraphicListBox::init(int x, int y, int w, int h, Vec3f textColor){
|
||||||
|
@ -418,10 +419,55 @@ void GraphicListBox::setSelectedItemIndex(int index, bool errorOnMissing){
|
||||||
setText(getSelectedItem());
|
setText(getSelectedItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicListBox::setLeftControlled(bool leftControlled) {
|
||||||
|
if(this->leftControlled!=leftControlled){
|
||||||
|
this->leftControlled= leftControlled;
|
||||||
|
if(leftControlled==true) {
|
||||||
|
graphButton2.setX(x+graphButton1.getW()-4);
|
||||||
|
graphButton2.setH(graphButton2.getH()-4);
|
||||||
|
graphButton2.setW(graphButton2.getW()-4);
|
||||||
|
graphButton1.setH(graphButton1.getH()-4);
|
||||||
|
graphButton1.setW(graphButton1.getW()-4);
|
||||||
|
graphButton2.setY(graphButton2.getY()+2);
|
||||||
|
graphButton1.setY(graphButton1.getY()+2);
|
||||||
|
|
||||||
|
// graphButton2.setX(x);
|
||||||
|
// graphButton2.setH(graphButton2.getH()/2);
|
||||||
|
// graphButton2.setW(graphButton2.getW()/2);
|
||||||
|
// graphButton1.setH(graphButton1.getH()/2);
|
||||||
|
// graphButton1.setW(graphButton1.getW()/2);
|
||||||
|
// graphButton2.setY(graphButton2.getY()+graphButton1.getH());
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
graphButton2.setX(x+w-graphButton2.getW()+4);
|
||||||
|
graphButton2.setH(graphButton2.getH()+4);
|
||||||
|
graphButton2.setW(graphButton2.getW()+4);
|
||||||
|
graphButton1.setH(graphButton1.getH()+4);
|
||||||
|
graphButton1.setW(graphButton1.getW()+4);
|
||||||
|
graphButton2.setY(graphButton2.getY()-2);
|
||||||
|
graphButton1.setY(graphButton1.getY()-2);
|
||||||
|
|
||||||
|
|
||||||
|
// graphButton2.setY(graphButton2.getY()-graphButton1.getH());
|
||||||
|
// graphButton2.setH(graphButton2.getH()*2);
|
||||||
|
// graphButton2.setW(graphButton2.getW()*2);
|
||||||
|
// graphButton1.setH(graphButton1.getH()*2);
|
||||||
|
// graphButton1.setW(graphButton1.getW()*2);
|
||||||
|
// graphButton2.setX(x+w-graphButton2.getW());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GraphicListBox::setX(int x) {
|
void GraphicListBox::setX(int x) {
|
||||||
this->x= x;
|
this->x= x;
|
||||||
graphButton1.setX(x);
|
graphButton1.setX(x);
|
||||||
graphButton2.setX(x+w-22);
|
if(leftControlled==true) {
|
||||||
|
graphButton2.setX(x+graphButton1.getW());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
graphButton2.setX(x+w-graphButton2.getW());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicListBox::setY(int y) {
|
void GraphicListBox::setY(int y) {
|
||||||
|
@ -491,7 +537,7 @@ bool GraphicListBox::mouseClick(int x, int y,string advanceToItemStartingWith) {
|
||||||
bool bFound = false;
|
bool bFound = false;
|
||||||
if(advanceToItemStartingWith != "") {
|
if(advanceToItemStartingWith != "") {
|
||||||
for(int i = selectedItemIndex - 1; i >= 0; --i) {
|
for(int i = selectedItemIndex - 1; i >= 0; --i) {
|
||||||
string item = items[i];
|
string item = translated_items[i];
|
||||||
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
||||||
bFound = true;
|
bFound = true;
|
||||||
selectedItemIndex = i;
|
selectedItemIndex = i;
|
||||||
|
@ -499,8 +545,8 @@ bool GraphicListBox::mouseClick(int x, int y,string advanceToItemStartingWith) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(bFound == false) {
|
if(bFound == false) {
|
||||||
for(int i = items.size() - 1; i >= selectedItemIndex; --i) {
|
for(int i = translated_items.size() - 1; i >= selectedItemIndex; --i) {
|
||||||
string item = items[i];
|
string item = translated_items[i];
|
||||||
//printf("Trying to match [%s] with item [%s]\n",advanceToItemStartingWith.c_str(),item.c_str());
|
//printf("Trying to match [%s] with item [%s]\n",advanceToItemStartingWith.c_str(),item.c_str());
|
||||||
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
||||||
bFound = true;
|
bFound = true;
|
||||||
|
@ -520,8 +566,8 @@ bool GraphicListBox::mouseClick(int x, int y,string advanceToItemStartingWith) {
|
||||||
else if(b2) {
|
else if(b2) {
|
||||||
bool bFound = false;
|
bool bFound = false;
|
||||||
if(advanceToItemStartingWith != "") {
|
if(advanceToItemStartingWith != "") {
|
||||||
for(int i = selectedItemIndex + 1; i < items.size(); ++i) {
|
for(int i = selectedItemIndex + 1; i < translated_items.size(); ++i) {
|
||||||
string item = items[i];
|
string item = translated_items[i];
|
||||||
//printf("Trying to match [%s] with item [%s]\n",advanceToItemStartingWith.c_str(),item.c_str());
|
//printf("Trying to match [%s] with item [%s]\n",advanceToItemStartingWith.c_str(),item.c_str());
|
||||||
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
||||||
bFound = true;
|
bFound = true;
|
||||||
|
@ -531,7 +577,7 @@ bool GraphicListBox::mouseClick(int x, int y,string advanceToItemStartingWith) {
|
||||||
}
|
}
|
||||||
if(bFound == false) {
|
if(bFound == false) {
|
||||||
for(int i = 0; i <= selectedItemIndex; ++i) {
|
for(int i = 0; i <= selectedItemIndex; ++i) {
|
||||||
string item = items[i];
|
string item = translated_items[i];
|
||||||
//printf("Trying to match [%s] with item [%s]\n",advanceToItemStartingWith.c_str(),item.c_str());
|
//printf("Trying to match [%s] with item [%s]\n",advanceToItemStartingWith.c_str(),item.c_str());
|
||||||
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
if(StartsWith(toLower(item),toLower(advanceToItemStartingWith)) == true) {
|
||||||
bFound = true;
|
bFound = true;
|
||||||
|
|
|
@ -238,6 +238,7 @@ private:
|
||||||
int selectedItemIndex;
|
int selectedItemIndex;
|
||||||
bool lighted;
|
bool lighted;
|
||||||
Vec3f textColor;
|
Vec3f textColor;
|
||||||
|
bool leftControlled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphicListBox(std::string containerName="", std::string objName="");
|
GraphicListBox(std::string containerName="", std::string objName="");
|
||||||
|
@ -251,6 +252,8 @@ public:
|
||||||
GraphicButton *getButton2() {return &graphButton2;}
|
GraphicButton *getButton2() {return &graphButton2;}
|
||||||
bool getLighted() const {return lighted;}
|
bool getLighted() const {return lighted;}
|
||||||
void setLighted(bool lighted) {this->lighted= lighted;}
|
void setLighted(bool lighted) {this->lighted= lighted;}
|
||||||
|
bool getLeftControlled() const {return leftControlled;}
|
||||||
|
void setLeftControlled(bool leftControlled);
|
||||||
Vec3f getTextColor() const {return textColor;}
|
Vec3f getTextColor() const {return textColor;}
|
||||||
void setTextColor(Vec3f color) {this->textColor= color;}
|
void setTextColor(Vec3f color) {this->textColor= color;}
|
||||||
|
|
||||||
|
|
|
@ -2087,8 +2087,6 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
if(showFullConsole) {
|
if(showFullConsole) {
|
||||||
CoreData &coreData= CoreData::getInstance();
|
|
||||||
|
|
||||||
int x= console->getXPos()-5;
|
int x= console->getXPos()-5;
|
||||||
int y= console->getYPos()-5;
|
int y= console->getYPos()-5;
|
||||||
int h= console->getLineHeight()*console->getStoredLineCount();
|
int h= console->getLineHeight()*console->getStoredLineCount();
|
||||||
|
@ -2106,6 +2104,7 @@ void Renderer::renderConsole(const Console *console,const bool showFullConsole,
|
||||||
glVertex2i(x+w, y);
|
glVertex2i(x+w, y);
|
||||||
glVertex2i(x+w, y+h);
|
glVertex2i(x+w, y+h);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
glPopAttrib();
|
||||||
}
|
}
|
||||||
for(int i = 0; i < console->getStoredLineCount(); ++i) {
|
for(int i = 0; i < console->getStoredLineCount(); ++i) {
|
||||||
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
const ConsoleLineInfo &lineInfo = console->getStoredLineItem(i);
|
||||||
|
@ -3390,7 +3389,28 @@ void Renderer::renderListBox(GraphicListBox *listBox) {
|
||||||
if(listBox->getVisible() == false) {
|
if(listBox->getVisible() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//if(listBox->getLeftControlled()==true)
|
||||||
|
{
|
||||||
|
int x= listBox->getX();
|
||||||
|
int y= listBox->getY();
|
||||||
|
int h= listBox->getH();
|
||||||
|
int w= listBox->getW();
|
||||||
|
if(h>0){
|
||||||
|
//background
|
||||||
|
glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
|
glColor4f(0.0f, 0.0f, 0.0f, 0.6f*listBox->getFade()) ;
|
||||||
|
|
||||||
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
|
glVertex2i(x, y);
|
||||||
|
glVertex2i(x, y+h);
|
||||||
|
glVertex2i(x+w, y);
|
||||||
|
glVertex2i(x+w, y+h);
|
||||||
|
glEnd();
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
}
|
||||||
renderButton(listBox->getButton1());
|
renderButton(listBox->getButton1());
|
||||||
renderButton(listBox->getButton2());
|
renderButton(listBox->getButton2());
|
||||||
|
|
||||||
|
@ -3398,7 +3418,12 @@ void Renderer::renderListBox(GraphicListBox *listBox) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
GraphicLabel label;
|
GraphicLabel label;
|
||||||
label.init(listBox->getX(), listBox->getY(), listBox->getW(), listBox->getH(), true,listBox->getTextColor());
|
if(listBox->getLeftControlled()==true){
|
||||||
|
label.init(listBox->getX()+listBox->getButton1()->getW()+listBox->getButton2()->getW()+2, listBox->getY(), listBox->getW(), listBox->getH(), false,listBox->getTextColor());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
label.init(listBox->getX(), listBox->getY(), listBox->getW(), listBox->getH(), true,listBox->getTextColor());
|
||||||
|
}
|
||||||
label.setText(listBox->getText());
|
label.setText(listBox->getText());
|
||||||
label.setTextNativeTranslation(listBox->getTextNativeTranslation());
|
label.setTextNativeTranslation(listBox->getTextNativeTranslation());
|
||||||
label.setFont(listBox->getFont());
|
label.setFont(listBox->getFont());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user