|
|
@@ -3,14 +3,18 @@
|
|
|
#include "Util.h"
|
|
|
#include "Vector.h"
|
|
|
|
|
|
-Button::Button(const std::string & text, Vec2f position, float width, float height) : MenuElement(position)
|
|
|
+Button::Button(const std::string & text, Vec2f position, float width, float height) : Text(text,position)
|
|
|
{
|
|
|
this->width = width;
|
|
|
this->height = height;
|
|
|
- this->text = text;
|
|
|
+ this->planePosition = position;
|
|
|
|
|
|
background = Vec3f(10, 10, 10);
|
|
|
- foreground = Vec3f(255, 255, 255);
|
|
|
+ //foreground = Vec3f(255, 255, 255);
|
|
|
+ this->setColor(Vec3f(255, 255, 255));
|
|
|
+
|
|
|
+ this->position.x += width / 2 - textWidth / 2;
|
|
|
+ this->position.y += height / 2 - textHeight / 2;
|
|
|
}
|
|
|
|
|
|
Button::~Button()
|
|
|
@@ -23,15 +27,15 @@ void Button::draw(void)
|
|
|
glColor4f(background.x/255.0f, background.y / 255.0f, background.z / 255.0f, 1.0f);
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
- glVertex2f(position.x, position.y);
|
|
|
- glVertex2f(position.x, position.y + height);
|
|
|
- glVertex2f(position.x + width, position.y + height);
|
|
|
- glVertex2f(position.x + width, position.y);
|
|
|
+ glVertex2f(planePosition.x, planePosition.y);
|
|
|
+ glVertex2f(planePosition.x, planePosition.y + height);
|
|
|
+ glVertex2f(planePosition.x + width, planePosition.y + height);
|
|
|
+ glVertex2f(planePosition.x + width, planePosition.y);
|
|
|
glEnd();
|
|
|
|
|
|
- glColor4f(foreground.x / 255.0f, foreground.y / 255.0f, foreground.z / 255.0f, 1.0f);
|
|
|
- Util::glutBitmapString(text, position.x, position.y+height/2+18/2);
|
|
|
-
|
|
|
+ /*glColor4f(foreground.x / 255.0f, foreground.y / 255.0f, foreground.z / 255.0f, 1.0f);
|
|
|
+ Util::glutBitmapString(text, position.x, position.y+height/2+14/2);*/
|
|
|
+ Text::draw();
|
|
|
}
|
|
|
|
|
|
void Button::update(int x, int y)
|
|
|
@@ -41,7 +45,7 @@ void Button::update(int x, int y)
|
|
|
|
|
|
void Button::setForeground(Vec3f color)
|
|
|
{
|
|
|
- foreground = color;
|
|
|
+ this->setColor(color);
|
|
|
}
|
|
|
|
|
|
void Button::setBackground(Vec3f color)
|