2013-10-12 20:08:27 +00:00
|
|
|
#include "GuiMsgBoxOk.h"
|
|
|
|
#include "../Renderer.h"
|
|
|
|
|
2013-10-16 22:05:02 +00:00
|
|
|
#define MSG_WIDTH 0.8f
|
|
|
|
#define MSG_PADDING ((1 - MSG_WIDTH) / 2)
|
|
|
|
|
2013-10-12 20:08:27 +00:00
|
|
|
GuiMsgBoxOk::GuiMsgBoxOk(Window* window, const std::string& text, std::function<void()> callback) : GuiComponent(window),
|
|
|
|
mCallback(callback),
|
|
|
|
mText(window),
|
|
|
|
mOkText(window)
|
|
|
|
{
|
|
|
|
mText.setCentered(true);
|
|
|
|
mText.setColor(0x00BB00FF);
|
2013-10-16 22:05:02 +00:00
|
|
|
mText.setSize(Renderer::getScreenWidth() * MSG_WIDTH, 0);
|
2013-10-12 20:08:27 +00:00
|
|
|
mText.setText(text);
|
|
|
|
|
|
|
|
mOkText.setCentered(true);
|
|
|
|
mOkText.setColor(0x0044BBFF);
|
|
|
|
mOkText.setFont(Font::get(FONT_SIZE_SMALL));
|
2013-10-16 22:05:02 +00:00
|
|
|
mOkText.setSize(Renderer::getScreenWidth() * MSG_WIDTH, 0);
|
2013-10-12 20:08:27 +00:00
|
|
|
mOkText.setText("[A]");
|
|
|
|
|
2013-10-16 22:05:02 +00:00
|
|
|
mText.setPosition(Renderer::getScreenWidth() * MSG_PADDING, (Renderer::getScreenHeight() - mText.getSize().y() - mOkText.getSize().y()) / 2);
|
|
|
|
mOkText.setPosition(Renderer::getScreenWidth() * MSG_PADDING, mText.getPosition().y() + mText.getSize().y());
|
2013-10-12 20:08:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GuiMsgBoxOk::input(InputConfig* config, Input input)
|
|
|
|
{
|
|
|
|
if(input.value != 0 &&
|
|
|
|
(config->isMappedTo("a", input) || config->isMappedTo("b", input)))
|
|
|
|
{
|
|
|
|
if(mCallback)
|
|
|
|
mCallback();
|
|
|
|
|
|
|
|
delete this;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GuiMsgBoxOk::render(const Eigen::Affine3f& parentTrans)
|
|
|
|
{
|
|
|
|
float height = mText.getSize().y() + mOkText.getSize().y();
|
|
|
|
Renderer::setMatrix(parentTrans);
|
|
|
|
Renderer::drawRect(0, (int)((Renderer::getScreenHeight() - height) / 2), Renderer::getScreenWidth(), (int)height, 0x111111FF);
|
|
|
|
mText.render(parentTrans);
|
|
|
|
mOkText.render(parentTrans);
|
|
|
|
}
|