parent
13f61d609c
commit
3b043b7f47
@ -12,7 +12,7 @@
|
||||
|
||||
<ratingbar id="rating" align="center" height="1f" width="3f"/>
|
||||
|
||||
<spacer height="4%" width="50"/>
|
||||
<spacer height="8%" width="50"/>
|
||||
|
||||
<buttonbar id="options" width="25%" height="20%" align="center">
|
||||
<icon-button id="cancel" width="64" height="64" icon="gui/icons/green_check.png"
|
||||
|
@ -1157,6 +1157,38 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect,
|
||||
|
||||
core::recti stars_rect(x_from, y_from, x_from + (star_number * star_w), y_from + star_h);
|
||||
|
||||
if (focused)
|
||||
{
|
||||
static float glow_effect = 0;
|
||||
|
||||
const float dt = GUIEngine::getLatestDt();
|
||||
glow_effect += dt*3;
|
||||
if (glow_effect > 6.2832f /* 2*PI */) glow_effect -= 6.2832f;
|
||||
float grow = 10*sinf(glow_effect);
|
||||
|
||||
const int glow_center_x = stars_rect.UpperLeftCorner.X + stars_rect.getWidth() / 2;
|
||||
const int glow_center_y = stars_rect.LowerRightCorner.Y + stars_rect.getHeight() / 2;
|
||||
|
||||
ITexture* tex_ficonhighlight =
|
||||
SkinConfig::m_render_params["focusHalo::neutral"].getImage();
|
||||
const int texture_w = tex_ficonhighlight->getSize().Width;
|
||||
const int texture_h = tex_ficonhighlight->getSize().Height;
|
||||
|
||||
core::recti source_area = core::recti(0, 0, texture_w, texture_h);
|
||||
|
||||
float scale = (float)irr_driver->getActualScreenSize().Height / 1080.0f;
|
||||
int size = (int)((90.0f + grow) * scale);
|
||||
const core::recti rect2(glow_center_x - size,
|
||||
glow_center_y - size / 2,
|
||||
glow_center_x + size,
|
||||
glow_center_y + size / 2);
|
||||
|
||||
draw2DImage(tex_ficonhighlight, rect2,
|
||||
source_area,
|
||||
0 /* no clipping */, 0,
|
||||
true /* alpha */);
|
||||
}
|
||||
|
||||
if(!w->m_deactivated)
|
||||
ratingBar->setStepValuesByMouse(irr_driver->getDevice()->getCursorControl()->getPosition(), stars_rect);
|
||||
|
||||
|
@ -34,6 +34,7 @@ using namespace irr;
|
||||
// -----------------------------------------------------------------------------
|
||||
RatingBarWidget::RatingBarWidget() : Widget(WTYPE_RATINGBAR)
|
||||
{
|
||||
//m_event_handler = this;
|
||||
m_allow_voting = false;
|
||||
m_rating = 0.0f;
|
||||
m_hover_rating = 0.0f;
|
||||
@ -48,7 +49,7 @@ RatingBarWidget::RatingBarWidget() : Widget(WTYPE_RATINGBAR)
|
||||
void RatingBarWidget::add()
|
||||
{
|
||||
const irr::core::recti widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
|
||||
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, getNewNoFocusID(), NULL, L"");
|
||||
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, getNewID(), NULL, L"");
|
||||
m_id = m_element->getID();
|
||||
m_element->setTabStop(false);
|
||||
m_element->setTabGroup(false);
|
||||
@ -88,7 +89,7 @@ void RatingBarWidget::setStepValues(float float_rating)
|
||||
|
||||
void RatingBarWidget::setRating(float rating)
|
||||
{
|
||||
m_rating = rating;
|
||||
m_hover_rating = m_rating = rating;
|
||||
setStepValues(m_rating);
|
||||
}
|
||||
|
||||
@ -104,21 +105,44 @@ void RatingBarWidget::setStepValuesByMouse(const core::position2di & mouse_posit
|
||||
m_hover_rating = roundf(exact_hover * (m_steps-1)) / (m_steps-1);
|
||||
setStepValues(m_hover_rating);
|
||||
}
|
||||
else if(m_hovering)
|
||||
{
|
||||
setStepValues(m_rating);
|
||||
m_hovering = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EventPropagation RatingBarWidget::onClick()
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
EventPropagation RatingBarWidget::leftPressed(const int playerID)
|
||||
{
|
||||
if(m_allow_voting)
|
||||
m_rating = m_hover_rating;
|
||||
|
||||
return EVENT_LET;
|
||||
if(m_allow_voting && m_hover_rating > 0.0f)
|
||||
{
|
||||
m_hover_rating -= 1.0f / (m_steps - 1);
|
||||
setStepValues(m_hover_rating);
|
||||
}
|
||||
return EVENT_BLOCK;
|
||||
}
|
||||
|
||||
EventPropagation RatingBarWidget::rightPressed(const int playerID)
|
||||
{
|
||||
if(m_allow_voting && m_hover_rating < m_stars)
|
||||
{
|
||||
m_hover_rating += 1.0f / (m_steps - 1);
|
||||
setStepValues(m_hover_rating);
|
||||
}
|
||||
return EVENT_BLOCK;
|
||||
}
|
||||
|
||||
|
||||
bool RatingBarWidget::updateRating()
|
||||
{
|
||||
if(m_allow_voting)
|
||||
{
|
||||
if (m_hover_rating <= 0.0f || m_hover_rating > m_stars)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_rating = m_hover_rating;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
@ -55,7 +56,7 @@ namespace GUIEngine
|
||||
|
||||
|
||||
|
||||
void add();
|
||||
void add() OVERRIDE;
|
||||
|
||||
/** Change the rating value of the widget. */
|
||||
void setRating(float rating);
|
||||
@ -73,7 +74,11 @@ namespace GUIEngine
|
||||
|
||||
void setStepValuesByMouse(const core::position2di & mouse_position, const core::recti & stars_rect);
|
||||
|
||||
virtual EventPropagation onClick();
|
||||
virtual EventPropagation rightPressed(const int playerID=0) OVERRIDE;
|
||||
virtual EventPropagation leftPressed (const int playerID=0) OVERRIDE;
|
||||
|
||||
/** True if succeed, false if fail */
|
||||
bool updateRating();
|
||||
|
||||
void allowVoting() { m_allow_voting = true; }
|
||||
};
|
||||
|
@ -135,7 +135,10 @@ GUIEngine::EventPropagation VoteDialog::processEvent(const std::string& event)
|
||||
|
||||
if (event == m_rating_widget->m_properties[PROP_ID])
|
||||
{
|
||||
sendVote();
|
||||
if (m_rating_widget->updateRating())
|
||||
{
|
||||
sendVote();
|
||||
}
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
||||
@ -227,6 +230,7 @@ void VoteDialog::onUpdate(float dt)
|
||||
m_info_widget->setText(_("Vote successful! You can now close "
|
||||
"the window."), false);
|
||||
m_cancel_widget->setActive(true);
|
||||
m_cancel_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
} // isSuccess
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user