mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Small cleanup: simplify member type and computation
This commit is contained in:
parent
5b27062ded
commit
2dcbaf605e
|
@ -40,7 +40,7 @@ void CDamageInd::Create(vec2 Pos, vec2 Dir, float Alpha)
|
||||||
{
|
{
|
||||||
pItem->m_Pos = Pos;
|
pItem->m_Pos = Pos;
|
||||||
pItem->m_StartTime = LocalTime();
|
pItem->m_StartTime = LocalTime();
|
||||||
pItem->m_Dir = Dir * -1;
|
pItem->m_Dir = -Dir;
|
||||||
pItem->m_StartAngle = -random_angle();
|
pItem->m_StartAngle = -random_angle();
|
||||||
pItem->m_Color = ColorRGBA(1.0f, 1.0f, 1.0f, Alpha);
|
pItem->m_Color = ColorRGBA(1.0f, 1.0f, 1.0f, Alpha);
|
||||||
pItem->m_StartAlpha = Alpha;
|
pItem->m_StartAlpha = Alpha;
|
||||||
|
|
|
@ -22,6 +22,7 @@ CScrollRegion::CScrollRegion()
|
||||||
m_AnimInitScrollY = 0.0f;
|
m_AnimInitScrollY = 0.0f;
|
||||||
m_AnimTargetScrollY = 0.0f;
|
m_AnimTargetScrollY = 0.0f;
|
||||||
|
|
||||||
|
m_SliderGrabPos = 0.0f;
|
||||||
m_ContentScrollOff = vec2(0.0f, 0.0f);
|
m_ContentScrollOff = vec2(0.0f, 0.0f);
|
||||||
m_Params = CScrollRegionParams();
|
m_Params = CScrollRegionParams();
|
||||||
}
|
}
|
||||||
|
@ -146,8 +147,8 @@ void CScrollRegion::End()
|
||||||
if(UI()->CheckActiveItem(pID) && UI()->MouseButton(0))
|
if(UI()->CheckActiveItem(pID) && UI()->MouseButton(0))
|
||||||
{
|
{
|
||||||
float MouseY = UI()->MouseY();
|
float MouseY = UI()->MouseY();
|
||||||
m_ScrollY += (MouseY - (Slider.y + m_SliderGrabPos.y)) / MaxSlider * MaxScroll;
|
m_ScrollY += (MouseY - (Slider.y + m_SliderGrabPos)) / MaxSlider * MaxScroll;
|
||||||
m_SliderGrabPos.y = clamp(m_SliderGrabPos.y, 0.0f, SliderHeight);
|
m_SliderGrabPos = clamp(m_SliderGrabPos, 0.0f, SliderHeight);
|
||||||
m_AnimTargetScrollY = m_ScrollY;
|
m_AnimTargetScrollY = m_ScrollY;
|
||||||
m_AnimTime = 0.0f;
|
m_AnimTime = 0.0f;
|
||||||
Grabbed = true;
|
Grabbed = true;
|
||||||
|
@ -159,7 +160,7 @@ void CScrollRegion::End()
|
||||||
if(!UI()->CheckActiveItem(pID) && UI()->MouseButtonClicked(0))
|
if(!UI()->CheckActiveItem(pID) && UI()->MouseButtonClicked(0))
|
||||||
{
|
{
|
||||||
UI()->SetActiveItem(pID);
|
UI()->SetActiveItem(pID);
|
||||||
m_SliderGrabPos.y = UI()->MouseY() - Slider.y;
|
m_SliderGrabPos = UI()->MouseY() - Slider.y;
|
||||||
m_AnimTargetScrollY = m_ScrollY;
|
m_AnimTargetScrollY = m_ScrollY;
|
||||||
m_AnimTime = 0.0f;
|
m_AnimTime = 0.0f;
|
||||||
m_Params.m_Active = true;
|
m_Params.m_Active = true;
|
||||||
|
@ -170,7 +171,7 @@ void CScrollRegion::End()
|
||||||
m_ScrollY += (UI()->MouseY() - (Slider.y + Slider.h / 2.0f)) / MaxSlider * MaxScroll;
|
m_ScrollY += (UI()->MouseY() - (Slider.y + Slider.h / 2.0f)) / MaxSlider * MaxScroll;
|
||||||
UI()->SetHotItem(pID);
|
UI()->SetHotItem(pID);
|
||||||
UI()->SetActiveItem(pID);
|
UI()->SetActiveItem(pID);
|
||||||
m_SliderGrabPos.y = Slider.h / 2.0f;
|
m_SliderGrabPos = Slider.h / 2.0f;
|
||||||
m_AnimTargetScrollY = m_ScrollY;
|
m_AnimTargetScrollY = m_ScrollY;
|
||||||
m_AnimTime = 0.0f;
|
m_AnimTime = 0.0f;
|
||||||
m_Params.m_Active = true;
|
m_Params.m_Active = true;
|
||||||
|
|
|
@ -117,7 +117,7 @@ private:
|
||||||
CUIRect m_ClipRect;
|
CUIRect m_ClipRect;
|
||||||
CUIRect m_RailRect;
|
CUIRect m_RailRect;
|
||||||
CUIRect m_LastAddedRect; // saved for ScrollHere()
|
CUIRect m_LastAddedRect; // saved for ScrollHere()
|
||||||
vec2 m_SliderGrabPos; // where did user grab the slider
|
float m_SliderGrabPos; // where did user grab the slider
|
||||||
vec2 m_ContentScrollOff;
|
vec2 m_ContentScrollOff;
|
||||||
CScrollRegionParams m_Params;
|
CScrollRegionParams m_Params;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue