more on skinning : replaced ugly blue rectangle with a subtle glow. more tweakings necessary to make it good everywhere

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3378 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-11 19:02:33 +00:00
parent 6955c8214c
commit b057267db1
7 changed files with 62 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -329,7 +329,7 @@ void IrrDriver::update(float dt)
m_device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140));
m_scene_manager->drawAll();
GUIEngine::render();
GUIEngine::render(dt);
m_device->getVideoDriver()->endScene();
} // update

View File

@ -19,6 +19,12 @@ namespace GUIEngine
std::vector<Screen*> g_loaded_screens;
Screen* g_current_screen = NULL;
float dt = 0;
float getLatestDt()
{
return dt;
}
// -----------------------------------------------------------------------------
IrrlichtDevice* getDevice()
{
@ -111,8 +117,10 @@ void transmitEvent(Widget* widget, std::string& name)
g_event_callback(widget, name);
}
// -----------------------------------------------------------------------------
void render()
void render(float elapsed_time)
{
GUIEngine::dt = elapsed_time;
// on one end, making these static is not too clean.
// on another end, these variables are really only used locally,
// and making them static avoids doing the same stupid computations every frame

View File

@ -22,13 +22,15 @@ namespace GUIEngine
extern IVideoDriver* getDriver();
extern IGUIFont* getFont();
float getLatestDt();
void init(irr::IrrlichtDevice* device, irr::video::IVideoDriver* driver, void (*eventCallback)(Widget* widget, std::string& name) );
void switchToScreen(const char* );
void clear();
Screen* getCurrentScreen();
void render();
void render(float dt);
void transmitEvent(Widget* widget, std::string& name);
}

View File

@ -253,6 +253,8 @@ void Skin::drawButton(const core::rect< s32 > &rect, const bool pressed, const b
}
void Skin::drawRibbon(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, bool focused)
{
return;
// only combo ribbons need a border
if ( ((RibbonWidget*)widget)->getRibbonType() != RIBBON_COMBO ) return;
@ -284,6 +286,7 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
const bool parent_focused = GUIEngine::getGUIEnv()->getFocus() == widget->m_parent->m_element;
/* tab-bar ribbons */
if(widget->m_type == WTYPE_BUTTON)
{
// ribbons containing buttons are actually tabs
@ -309,13 +312,9 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
left_border, right_border,
border_above, border_below, 0);
}
/*
if(mark_selected)
GUIEngine::getDriver()->draw2DRectangle( SColor(255, 0, 150, 150), rect );
else
GUIEngine::getDriver()->draw2DRectangle( SColor(255, 150, 0, 0), rect );
*/
}
/* icon ribbons */
else
{
if(widget->m_parent != NULL && widget->m_parent->m_type == WTYPE_RIBBON &&
@ -324,10 +323,50 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
if(mark_selected)
{
const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X - 5, rect.UpperLeftCorner.Y - 5,
rect.UpperLeftCorner.X + rect.getWidth() + 5,
rect.UpperLeftCorner.Y + rect.getHeight() + 5);
GUIEngine::getDriver()->draw2DRectangle( SColor(2555, 0, 175, 255), rect2 );
int grow = 45;
static float glow_effect = 0;
if(focused || parent_focused)
{
const float dt = GUIEngine::getLatestDt();
glow_effect += dt*3;
if (glow_effect > 6.2832 /* 2*PI */) glow_effect -= 6.2832;
grow = 45 + 10*sin(glow_effect);
}
/*
const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X - 5 - grow,
rect.UpperLeftCorner.Y - 5 - grow,
rect.UpperLeftCorner.X + rect.getWidth() + 5 + grow,
rect.UpperLeftCorner.Y + rect.getHeight() + 5 + grow);
*/
const int glow_center_x = rect.UpperLeftCorner.X + rect.getWidth()/2;
const int glow_center_y = rect.UpperLeftCorner.Y + rect.getHeight() - 5;
const core::rect< s32 > rect2 = core::rect< s32 >(glow_center_x - 45 - grow,
glow_center_y - 25 - grow/2,
glow_center_x + 45 + grow,
glow_center_y + 25 + grow/2);
// GUIEngine::getDriver()->draw2DRectangle( SColor(2555, 0, 175, 255), rect2 );
const int texture_w = m_tex_ficonhighlight->getSize().Width;
const int texture_h = m_tex_ficonhighlight->getSize().Height;
core::rect<s32> source_area = core::rect<s32>(0, 0, texture_w, texture_h);
if(!focused && !parent_focused)
{
GUIEngine::getDriver()->draw2DImage(m_tex_iconhighlight, rect2, source_area,
0 /* no clipping */, 0, true /* alpha */);
}
else
{
GUIEngine::getDriver()->draw2DImage(m_tex_ficonhighlight, rect2, source_area,
0 /* no clipping */, 0, true /* alpha */);
}
}
}