Fixed strange selection ring fadeout on unit deselection in Atlas

This was SVN commit r11634.
This commit is contained in:
vts 2012-04-22 17:49:43 +00:00
parent 4830cebf5e
commit 61fad4a2b5
3 changed files with 12 additions and 4 deletions

View File

@ -147,10 +147,14 @@ public:
m_Color.r = color.r;
m_Color.g = color.g;
m_Color.b = color.b;
SetSelectionHighlightAlpha(color.a);
}
virtual void SetSelectionHighlightAlpha(float alpha)
{
// set up fading from the current value (as the baseline) to the target value
m_FadeBaselineAlpha = m_Color.a;
m_FadeDeltaAlpha = color.a - m_FadeBaselineAlpha;
m_FadeDeltaAlpha = alpha - m_FadeBaselineAlpha;
m_FadeProgress = 0.f;
}

View File

@ -54,10 +54,15 @@ public:
/**
* Set the color of the selection highlight (typically a circle/square
* around the unit). Set a = 0 to disable.
* around the unit). Set a = 0 to disable the highlight.
*/
virtual void SetSelectionHighlight(CColor color) = 0;
/**
* Set the alpha of the selection highlight. Set to 0 to disable the highlight.
*/
virtual void SetSelectionHighlightAlpha(float alpha) = 0;
DECLARE_INTERFACE_TYPE(Selectable)
// TODO: this is slightly ugly design; it would be nice to change the component system to support per-component-type data

View File

@ -111,8 +111,7 @@ MESSAGEHANDLER(SetSelectionPreview)
{
CmpPtr<ICmpSelectable> cmpSelectable(sim, g_Selection[i]);
if (cmpSelectable)
// TODO: change only alpha component
cmpSelectable->SetSelectionHighlight(CColor(1, 1, 1, 0));
cmpSelectable->SetSelectionHighlightAlpha(0);
}
g_Selection = *msg->ids;