2013-06-19 01:12:30 +00:00
|
|
|
#include "SwitchComponent.h"
|
|
|
|
#include "../Renderer.h"
|
|
|
|
#include "../Font.h"
|
2013-07-03 07:54:55 +00:00
|
|
|
#include "../Window.h"
|
2013-06-19 01:12:30 +00:00
|
|
|
|
|
|
|
SwitchComponent::SwitchComponent(Window* window, bool state) : GuiComponent(window), mState(state)
|
|
|
|
{
|
|
|
|
//mSize = Vector2u((unsigned int)(Renderer::getScreenWidth() * 0.05),
|
|
|
|
// (unsigned int)(Renderer::getScreenHeight() * 0.05));
|
|
|
|
|
2013-07-03 07:54:55 +00:00
|
|
|
mWindow->getResourceManager()->getFont(Font::getDefaultPath(), FONT_SIZE_MEDIUM)->sizeText("OFF", (int*)&mSize.x, (int*)&mSize.y);
|
2013-06-19 01:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SwitchComponent::input(InputConfig* config, Input input)
|
|
|
|
{
|
|
|
|
if(config->isMappedTo("a", input) && input.value)
|
|
|
|
{
|
|
|
|
mState = !mState;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwitchComponent::onRender()
|
|
|
|
{
|
|
|
|
Renderer::pushClipRect(getGlobalOffset(), getSize());
|
|
|
|
|
2013-07-03 07:54:55 +00:00
|
|
|
mWindow->getResourceManager()->getFont(Font::getDefaultPath(), FONT_SIZE_MEDIUM)->drawText(mState ? "ON" : "OFF", 0, 0, mState ? 0x00FF00FF : 0xFF0000FF);
|
2013-06-19 01:12:30 +00:00
|
|
|
|
|
|
|
Renderer::popClipRect();
|
|
|
|
|
|
|
|
GuiComponent::onRender();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SwitchComponent::getState()
|
|
|
|
{
|
|
|
|
return mState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwitchComponent::setState(bool state)
|
|
|
|
{
|
|
|
|
mState = state;
|
|
|
|
}
|