2013-07-05 17:17:00 +00:00
|
|
|
#include "controllers.hpp"
|
|
|
|
|
2014-08-01 15:14:35 +00:00
|
|
|
#include <MyGUI_InputManager.h>
|
2015-01-10 01:50:43 +00:00
|
|
|
#include <MyGUI_Widget.h>
|
2014-08-01 15:14:35 +00:00
|
|
|
|
2013-07-05 17:17:00 +00:00
|
|
|
namespace MWGui
|
|
|
|
{
|
|
|
|
namespace Controllers
|
|
|
|
{
|
|
|
|
|
2014-09-13 06:00:24 +00:00
|
|
|
ControllerRepeatEvent::ControllerRepeatEvent() :
|
2015-03-08 00:07:29 +00:00
|
|
|
mInit(0.5f),
|
|
|
|
mStep(0.1f),
|
2013-07-05 17:17:00 +00:00
|
|
|
mEnabled(true),
|
|
|
|
mTimeLeft(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-13 06:00:24 +00:00
|
|
|
ControllerRepeatEvent::~ControllerRepeatEvent()
|
2013-07-05 17:17:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-13 06:00:24 +00:00
|
|
|
bool ControllerRepeatEvent::addTime(MyGUI::Widget* _widget, float _time)
|
2013-07-05 17:17:00 +00:00
|
|
|
{
|
|
|
|
if(mTimeLeft == 0)
|
|
|
|
mTimeLeft = mInit;
|
|
|
|
|
|
|
|
mTimeLeft -= _time;
|
2013-07-06 14:40:57 +00:00
|
|
|
while (mTimeLeft <= 0)
|
2013-07-05 17:17:00 +00:00
|
|
|
{
|
2013-07-06 14:40:57 +00:00
|
|
|
mTimeLeft += mStep;
|
2013-07-05 17:17:00 +00:00
|
|
|
eventRepeatClick(_widget, this);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-13 06:00:24 +00:00
|
|
|
void ControllerRepeatEvent::setRepeat(float init, float step)
|
2013-07-05 17:17:00 +00:00
|
|
|
{
|
|
|
|
mInit = init;
|
|
|
|
mStep = step;
|
|
|
|
}
|
|
|
|
|
2014-09-13 06:00:24 +00:00
|
|
|
void ControllerRepeatEvent::setEnabled(bool enable)
|
2013-07-05 17:17:00 +00:00
|
|
|
{
|
|
|
|
mEnabled = enable;
|
|
|
|
}
|
|
|
|
|
2014-09-13 06:00:24 +00:00
|
|
|
void ControllerRepeatEvent::setProperty(const std::string& _key, const std::string& _value)
|
2013-07-05 17:17:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-13 06:00:24 +00:00
|
|
|
void ControllerRepeatEvent::prepareItem(MyGUI::Widget* _widget)
|
2013-07-05 17:17:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-01 15:14:35 +00:00
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
|
|
|
void ControllerFollowMouse::prepareItem(MyGUI::Widget *_widget)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ControllerFollowMouse::addTime(MyGUI::Widget *_widget, float _time)
|
|
|
|
{
|
|
|
|
_widget->setPosition(MyGUI::InputManager::getInstance().getMousePosition());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-05 17:17:00 +00:00
|
|
|
}
|
|
|
|
}
|