added a different type of seleection for karts and tracks

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3380 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-11 19:57:10 +00:00
parent a826fc0311
commit 2e7de89e69
7 changed files with 81 additions and 51 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -9,7 +9,7 @@
<model id="modelview" width="40%" proportion="3" align="center"/> <model id="modelview" width="40%" proportion="3" align="center"/>
<label width="100%" height="25" text="Wilber" align="center" text_align="center" /> <label width="100%" height="25" text="Wilber" align="center" text_align="center" />
<ribbon_grid id="karts" proportion="2" width="100%" align="center" child_width="80" child_height="80"/> <ribbon_grid id="karts" proportion="2" square_items="true" width="100%" align="center" child_width="80" child_height="80"/>
<tabs width="100%" height="25" id="kartgroups"> <tabs width="100%" height="25" id="kartgroups">
<button text="Standard"/> <button text="Standard"/>

View File

@ -2,7 +2,7 @@
<label width="100%" height="25" text="Grand Prix" align="center" text_align="center" /> <label width="100%" height="25" text="Grand Prix" align="center" text_align="center" />
<buttonbar id="gps" height="175" width="100%" align="center"> <buttonbar id="gps" height="175" width="100%" align="center" square_items="true">
<icon-button id="gp1" width="171" height="128" icon="gui/track1.png" text="Penguin Playground"/> <icon-button id="gp1" width="171" height="128" icon="gui/track1.png" text="Penguin Playground"/>
<icon-button id="gp2" width="171" height="128" icon="gui/track2.png" text="Snag Drive"/> <icon-button id="gp2" width="171" height="128" icon="gui/track2.png" text="Snag Drive"/>
<icon-button id="gp3" width="171" height="128" icon="gui/track3.png" text="To the Moon and Back"/> <icon-button id="gp3" width="171" height="128" icon="gui/track3.png" text="To the Moon and Back"/>
@ -11,8 +11,7 @@
<label width="100%" height="25" text="All Tracks" align="center" text_align="center" /> <label width="100%" height="25" text="All Tracks" align="center" text_align="center" />
<ribbon_grid id="tracks" proportion="1" width="100%" text="-" align="center" child_width="160" child_height="120" /> <ribbon_grid id="tracks" proportion="1" width="100%" square_items="true" text="-" align="center" child_width="160" child_height="120" />
<tabs width="100%" height="25" id="trackgroups"> <tabs width="100%" height="25" id="trackgroups">
<button text="Standard"/> <button text="Standard"/>

View File

@ -136,6 +136,7 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = prop_name; else widget.m_
READ_PROPERTY(text_align, PROP_TEXT_ALIGN); READ_PROPERTY(text_align, PROP_TEXT_ALIGN);
READ_PROPERTY(min_value, PROP_MIN_VALUE); READ_PROPERTY(min_value, PROP_MIN_VALUE);
READ_PROPERTY(max_value, PROP_MAX_VALUE); READ_PROPERTY(max_value, PROP_MAX_VALUE);
READ_PROPERTY(square_items, PROP_SQUARE);
#undef READ_PROPERTY #undef READ_PROPERTY
//std::cout << "loaded widget " << id << std::endl; //std::cout << "loaded widget " << id << std::endl;

View File

@ -28,6 +28,7 @@ Skin::Skin(IGUISkin* fallback_skin)
m_tex_iconhighlight = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glass_iconhighlight.png").c_str() ); m_tex_iconhighlight = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glass_iconhighlight.png").c_str() );
m_tex_ficonhighlight = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glass_iconhighlight_focus.png").c_str() ); m_tex_ficonhighlight = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glass_iconhighlight_focus.png").c_str() );
m_tex_squarefocus = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/glass_square_focused.png").c_str() );
} }
@ -117,11 +118,13 @@ void Skin::drawBoxFromStretchableTexture(const core::rect< s32 > &dest, ITexture
const int dest_x2 = dest.LowerRightCorner.X; const int dest_x2 = dest.LowerRightCorner.X;
const int dest_y2 = dest.LowerRightCorner.Y; const int dest_y2 = dest.LowerRightCorner.Y;
const float scale = (float)(dest_y2-dest_y)/texture_h; const float xscale = (float)(dest_x2-dest_x)/texture_w;
const int dest_left_border = left_border*scale; const float yscale = (float)(dest_y2-dest_y)/texture_h;
const int dest_right_border = right_border*scale;
const int dest_top_border = top_border*scale; const int dest_left_border = left_border*std::min<float>(yscale, 1.0);
const int dest_bottom_border = bottom_border*scale; const int dest_right_border = right_border*std::min<float>(yscale, 1.0);
const int dest_top_border = top_border*std::min<float>(xscale, 1.0);
const int dest_bottom_border = bottom_border*std::min<float>(xscale, 1.0);
const float border_in_portion = 1 - border_out_portion; const float border_in_portion = 1 - border_out_portion;
@ -317,11 +320,20 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
/* icon ribbons */ /* icon ribbons */
else else
{ {
bool use_glow = true;
if (widget->m_parent != NULL && widget->m_parent->m_properties[PROP_SQUARE] == "true") use_glow = false;
if (widget->m_parent != NULL && widget->m_parent->m_parent != NULL &&
widget->m_parent->m_parent->m_properties[PROP_SQUARE] == "true") use_glow = false;
if(widget->m_parent != NULL && widget->m_parent->m_type == WTYPE_RIBBON && if(widget->m_parent != NULL && widget->m_parent->m_type == WTYPE_RIBBON &&
((RibbonWidget*)widget->m_parent)->getRibbonType() == RIBBON_TOOLBAR && ((RibbonWidget*)widget->m_parent)->getRibbonType() == RIBBON_TOOLBAR &&
!GUIEngine::getGUIEnv()->hasFocus(widget->m_parent->m_element)) mark_selected = false; !GUIEngine::getGUIEnv()->hasFocus(widget->m_parent->m_element)) mark_selected = false;
if(mark_selected) if(mark_selected)
{
if (use_glow)
{ {
int grow = 45; int grow = 45;
static float glow_effect = 0; static float glow_effect = 0;
@ -334,12 +346,6 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
grow = 45 + 10*sin(glow_effect); 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_x = rect.UpperLeftCorner.X + rect.getWidth()/2;
const int glow_center_y = rect.UpperLeftCorner.Y + rect.getHeight() - 5; const int glow_center_y = rect.UpperLeftCorner.Y + rect.getHeight() - 5;
@ -366,6 +372,28 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
GUIEngine::getDriver()->draw2DImage(m_tex_ficonhighlight, rect2, source_area, GUIEngine::getDriver()->draw2DImage(m_tex_ficonhighlight, rect2, source_area,
0 /* no clipping */, 0, true /* alpha */); 0 /* no clipping */, 0, true /* alpha */);
} }
}
/* if we're not using glow */
else
{
const int texture_w = m_tex_squarefocus->getSize().Width;
const int texture_h = m_tex_squarefocus->getSize().Height;
core::rect<s32> source_area = core::rect<s32>(0, 0, texture_w, texture_h);
//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()->draw2DImage(m_tex_squarefocus, rect2, source_area,
// 0 /* no clipping */, 0, true /* alpha */);
drawBoxFromStretchableTexture(rect, m_tex_squarefocus,
6 /* left border */, 6 /* rightborder */,
6 /* top border */, 6 /* bottom border */, 1);
}
} }
} }

View File

@ -35,6 +35,7 @@ class Skin : public IGUISkin
ITexture* m_tex_dtab; ITexture* m_tex_dtab;
ITexture* m_tex_iconhighlight; ITexture* m_tex_iconhighlight;
ITexture* m_tex_ficonhighlight; ITexture* m_tex_ficonhighlight;
ITexture* m_tex_squarefocus;
void drawBoxFromStretchableTexture(const core::rect< s32 > &dest, ITexture* source, void drawBoxFromStretchableTexture(const core::rect< s32 > &dest, ITexture* source,
const int left_border, const int right_border, const int left_border, const int right_border,

View File

@ -46,7 +46,8 @@ namespace GUIEngine
PROP_ICON, PROP_ICON,
PROP_TEXT_ALIGN, PROP_TEXT_ALIGN,
PROP_MIN_VALUE, PROP_MIN_VALUE,
PROP_MAX_VALUE PROP_MAX_VALUE,
PROP_SQUARE
}; };
class Widget class Widget