Completed skin-file implementation + documented it

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3612 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-06-13 19:37:43 +00:00
parent 6dd30317ae
commit 8af725a5ab
2 changed files with 65 additions and 12 deletions

View File

@ -1,3 +1,61 @@
<!--
To make your own skin, I suggest simply duplicating this file and modifying it as needed.
There are two types of images : some will be simply stretched as a whole, others will
have non-stretchable borders (you cannot choose which one you must use, it's hardcoded
for each element type; though, as you will see below, for all "advanced stretching" images
you can easily fake "simple stretch")
All elements will have at least 2 properties :
type="X" sets what you're skinning with this entry
image="skinDirectory/imageName.png" sets which image is used for this element
Most elements also support states :
state="neutral"
state="focused"
state="down"
You can thus give different looks for different states. Not all widgets support all states,
see entries and comments below to know what's supported.
Note that checkboxes are an exception and have the following styles :
"neutral+unchecked"
""neutral+checked"
"focused+unchecked"
"focused+checked"
"Advanced stretching" images are split this way :
+----+--------------------+----+
| | | |
+----+--------------------+----+
| | | |
| | | |
| | | |
+----+--------------------+----+
| | | |
+----+--------------------+----+
The center border will be stretched in all directions. The 4 corners will not stretch at all.
Horizontal borders will stretch horizontally, verticallt borders will stretch vertically.
Use properties left_border="X" right_border="X" top_border="X" bottom_border="X" to specify
the size of each border in pixels (setting all borders to '0' makes the whole image scaled).
In some cases, you may not want vertical stretching to occur (like if the left and right sides
of the image must not be stretched vertically, e.g. for the spinner). In this case, pass
parameter preserve_h_aspect_ratios="true" to make the left and right areas stretch by keeping
their aspect ratio.
Some components may fill the full inner area with stuff; others will only take a smaller
area at the center. To adjust for this, there are properties "hborder_out_portion" and "vborder_out_portion"
that take a float from 0 to 1, representing the percentage of each border that goes out of the widget's
area (this might include stuff like shadows, etc.). The 'h' one is for horizontal borders,
the 'v' one is for vertical borders.
Finnally : the image is split, as shown above, into 9 areas. In osme cases, you may not want
all areas to be rendered. Then you can pass parameter areas="body+left+right+top+bottom"
and explicitely specify which parts you want to see. The 4 corner areas are only visible
when the border that intersect at this corner are enabled.
-->
<skin name="Glass" author="Marianne Gagnon (Auria)">
<!-- Stateless -->
@ -28,13 +86,14 @@
<!-- Stateless -->
<element type="squareSelectionHalo" image="glass/glass_square_focused.png"
<element type="squareFocusHalo" image="glass/glass_square_focused.png"
left_border="6" right_border ="6" top_border="6" bottom_border="6"
hborder_out_portion="1.0" />
<!-- TODO : Allow elementning the selection bubble and focus halo too -->
<!-- Stateless. No splitting into 9 areas is done; the image is just stretched. -->
<element type="selectionHalo" image="glass/bubble.png" />
<element type="focusHalo" image="glass/glass_iconhighlight_focus.png" />
<element type="spinner" state="neutral" image="glass/glassspinner.png"
left_border="110" right_border="110" top_border="0" bottom_border="36"

View File

@ -55,7 +55,6 @@ namespace SkinConfig
BoxRenderParams newParam;
// TODO : look for images in a skin-specific directory
newParam.image = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/skins/" + image).c_str() );
newParam.left_border = leftborder;
newParam.right_border = rightborder;
@ -139,10 +138,8 @@ Skin::Skin(IGUISkin* fallback_skin)
m_fallback_skin->grab();
assert(fallback_skin != NULL);
// TODO : make those configurable in skin files
m_tex_ficonhighlight = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/skins/glass/glass_iconhighlight_focus.png").c_str() );
m_tex_bubble = GUIEngine::getDriver()->getTexture( (file_manager->getGUIDir() + "/skins/glass/bubble.png").c_str() );
m_tex_ficonhighlight = SkinConfig::m_render_params["focusHalo::neutral"].image;
m_tex_bubble = SkinConfig::m_render_params["selectionHalo::neutral"].image;
}
Skin::~Skin()
@ -541,7 +538,6 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
core::rect<s32> source_area = core::rect<s32>(0, 0, texture_w, texture_h);
// TODO : read from skin file
GUIEngine::getDriver()->draw2DImage(m_tex_bubble, rect2, source_area,
0 /* no clipping */, 0, true /* alpha */);
}
@ -576,7 +572,6 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
glow_center_x + 45 + grow,
glow_center_y + 25 + grow/2);
// TODO : read from skin file
GUIEngine::getDriver()->draw2DImage(m_tex_ficonhighlight, rect2, source_area,
0 /* no clipping */, 0, true /* alpha */);
}
@ -591,7 +586,7 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget,
//const int texture_h = m_tex_squarefocus->getSize().Height;
//core::rect<s32> source_area = core::rect<s32>(0, 0, texture_w, texture_h);
drawBoxFromStretchableTexture(rect, SkinConfig::m_render_params["squareSelectionHalo::neutral"]);
drawBoxFromStretchableTexture(rect, SkinConfig::m_render_params["squareFocusHalo::neutral"]);
}
} // end if mark_focused
@ -912,7 +907,6 @@ video::SColor Skin::getColor (EGUI_DEFAULT_COLOR color) const
EGDC_ICON_HIGH_LIGHT Selected icons in a list or tree.
*/
// TODO : make configurable
switch(color)
{
case EGDC_GRAY_TEXT: