I just added the patch to SVN, even if it changes the old behavior of DrawShadowText, which is used in e.g. GUISlideShow
MisterD
Awesome! Can't wait to use this since we currently use, inefficiently, double controls for shadows throughout aMPed! Thousand thanks for this one!
After some tests, I notice that controls with fade animation fade out the controls without shadow.
Thanks
<style Name="smallTitle">
<id>0</id>
<width>220</width>
<font>mediastream9c</font>
<textcolor>ffffffff</textcolor>
<shadowAngle>45</shadowAngle>
<shadowDistance>2</shadowDistance>
<shadowColor>ff222222</shadowColor>
</style>
<control Style="smallTitle">
<id>10005</id>
<label>#TVSeries.Episode.InfoPanelLine5Value</label>
<type>label</type>
<posX>500</posX>
<posY>454</posY>
<visible>Control.IsVisible(1239)+facadeview.list+Control.HasText(10005)</visible>
</control>
public void DrawShadowText(float fOriginX, float fOriginY, long dwColor,
string strText,
GUIControl.Alignment alignment,
[B]int fWidth,[/B]
int iShadowAngle,
int iShadowDistance,
long dwShadowColor)
{
// Draw the shadow
float fShadowX = (float)Math.Round((double)iShadowDistance * Math.Cos(ConvertDegreesToRadians((double)iShadowAngle)));
float fShadowY = (float)Math.Round((double)iShadowDistance * Math.Sin(ConvertDegreesToRadians((double)iShadowAngle)));
DrawText(fOriginX + fShadowX, fOriginY + fShadowY, dwShadowColor, strText, alignment, [B]fWidth[/B]);
// Draw the text
DrawText(fOriginX, fOriginY, dwColor, strText, alignment, [B]fWidth[/B]);
}
public void DrawText(float xpos, float ypos, long color, string label, GUIControl.Alignment alignment, int width)
{
uint c = (uint)color;
c = GUIGraphicsContext.MergeAlpha(c);
if (Shadow)
{
uint sc = (uint)_shadowColor;
sc = GUIGraphicsContext.MergeAlpha(sc);
_font.DrawShadowText(xpos, ypos, c, label, alignment, [B]width,[/B] _shadowAngle, _shadowDistance, sc);
}
else
{
_font.DrawText(xpos, ypos, c, label, alignment, width);
}
}
public void Render(double dTime)
{
int lTime = (int) (1000.0d*dTime);
foreach (Line line in m_subs)
{
if (lTime >= line.StartTime && lTime <= line.EndTime)
{
if (m_font != null)
{
try
{
float fw = 0, fh = 0;
m_font.GetTextExtent(line.Text, ref fw, ref fh);
int iposx = (GUIGraphicsContext.OverScanWidth - (int) fw)/2;
int iposy = (GUIGraphicsContext.Subtitles - (int) fh);
m_font.DrawShadowText((float) iposx, (float) iposy, m_iColor, line.Text, GUIControl.Alignment.ALIGN_LEFT,
[B](int)fw,[/B] m_iShadow, m_iShadow, 0xff000000);
}
if (Focus)
{
if (_shadow)
{
_font.DrawShadowText((float) dwTextPosX, (float) _positionY, _textColor, _label, Alignment.ALIGN_LEFT, [B]-1,[/B] 5,
5, 0xff000000);
}
else
{
_font.DrawText((float) dwTextPosX, (float) _positionY, _textColor, _label, Alignment.ALIGN_LEFT, -1);
}
}
// Draw non-focused text and shadow
else
{
if (_shadow)
{
_font.DrawShadowText((float) dwTextPosX, (float) _positionY, _disabledColor, _label, Alignment.ALIGN_LEFT, [B]-1,[/B]
5, 5, 0xff000000);
}
uint c = (uint) color;
c = GUIGraphicsContext.MergeAlpha(c);
if (_shadow)
{
_font.DrawShadowText(x, (float)_textOffsetY + _positionY, c, _label, _textAlignment, [B]-1,[/B] _shadowAngle, _shadowDistance, _shadowColor);
}
else
{
_font.DrawText(x, (float)_textOffsetY + _positionY, c, _label, _textAlignment, -1);
}
}
base.Render(timePassed);
GUIFont pFont = GUIFontManager.GetFont("font13");
if (pFont != null)
{
string szText = GUILocalizeStrings.Get(112);
pFont.DrawShadowText(500.0f, 60.0f, 0xffffffff, szText, GUIControl.Alignment.ALIGN_LEFT, [B]-1,[/B] 2, 2, 0xff000000);
}
return true;