Small cleanup: simplify member type and computation

This commit is contained in:
Chairn 2023-11-19 17:35:48 +01:00
parent 5b27062ded
commit 2dcbaf605e
3 changed files with 7 additions and 6 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;