mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Minimal changes from mouse state change: fix editor & input
This commit is contained in:
parent
0d17665137
commit
c7ae79aec5
|
@ -365,7 +365,12 @@ int CInput::Update()
|
|||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
if(m_InputGrabbed)
|
||||
MouseModeRelative();
|
||||
{
|
||||
// Enable this in case SDL 2.0.16 has major bugs or 2.0.18 still doesn't fix tabbing out with relative mouse
|
||||
// MouseModeRelative();
|
||||
// Clear pending relative mouse motion
|
||||
SDL_GetRelativeMouseState(0x0, 0x0);
|
||||
}
|
||||
m_MouseFocus = true;
|
||||
IgnoreKeys = true;
|
||||
break;
|
||||
|
@ -374,7 +379,8 @@ int CInput::Update()
|
|||
IgnoreKeys = true;
|
||||
if(m_InputGrabbed)
|
||||
{
|
||||
MouseModeAbsolute();
|
||||
// Enable this in case SDL 2.0.16 has major bugs or 2.0.18 still doesn't fix tabbing out with relative mouse
|
||||
// MouseModeAbsolute();
|
||||
// Remember that we had relative mouse
|
||||
m_InputGrabbed = true;
|
||||
}
|
||||
|
|
|
@ -701,14 +701,14 @@ void CGameConsole::OnRender()
|
|||
{
|
||||
m_MouseIsPress = true;
|
||||
Input()->NativeMousePos(&m_MousePressX, &m_MousePressY);
|
||||
m_MousePressX = (m_MousePressX / (float)Graphics()->ScreenWidth()) * Screen.w;
|
||||
m_MousePressY = (m_MousePressY / (float)Graphics()->ScreenHeight()) * Screen.h;
|
||||
m_MousePressX = (m_MousePressX / (float)Graphics()->WindowWidth()) * Screen.w;
|
||||
m_MousePressY = (m_MousePressY / (float)Graphics()->WindowHeight()) * Screen.h;
|
||||
}
|
||||
if(m_MouseIsPress)
|
||||
{
|
||||
Input()->NativeMousePos(&m_MouseCurX, &m_MouseCurY);
|
||||
m_MouseCurX = (m_MouseCurX / (float)Graphics()->ScreenWidth()) * Screen.w;
|
||||
m_MouseCurY = (m_MouseCurY / (float)Graphics()->ScreenHeight()) * Screen.h;
|
||||
m_MouseCurX = (m_MouseCurX / (float)Graphics()->WindowWidth()) * Screen.w;
|
||||
m_MouseCurY = (m_MouseCurY / (float)Graphics()->WindowHeight()) * Screen.h;
|
||||
}
|
||||
if(m_MouseIsPress && !Input()->NativeMousePressed(1))
|
||||
{
|
||||
|
|
|
@ -2566,8 +2566,8 @@ bool CMenus::OnMouseMove(float x, float y)
|
|||
m_MousePos.x += x;
|
||||
m_MousePos.y += y;
|
||||
}
|
||||
m_MousePos.x = clamp(m_MousePos.x, 0.f, (float)Graphics()->ScreenWidth());
|
||||
m_MousePos.y = clamp(m_MousePos.y, 0.f, (float)Graphics()->ScreenHeight());
|
||||
m_MousePos.x = clamp(m_MousePos.x, 0.f, (float)Graphics()->WindowWidth());
|
||||
m_MousePos.y = clamp(m_MousePos.y, 0.f, (float)Graphics()->WindowHeight());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2698,8 +2698,8 @@ void CMenus::OnRender()
|
|||
|
||||
// update the ui
|
||||
CUIRect *pScreen = UI()->Screen();
|
||||
float mx = (m_MousePos.x / (float)Graphics()->ScreenWidth()) * pScreen->w;
|
||||
float my = (m_MousePos.y / (float)Graphics()->ScreenHeight()) * pScreen->h;
|
||||
float mx = (m_MousePos.x / (float)Graphics()->WindowWidth()) * pScreen->w;
|
||||
float my = (m_MousePos.y / (float)Graphics()->WindowHeight()) * pScreen->h;
|
||||
|
||||
int Buttons = 0;
|
||||
if(m_UseMouseButtons)
|
||||
|
|
|
@ -6309,22 +6309,18 @@ void CEditor::UpdateAndRender()
|
|||
Input()->MouseRelative(&rx, &ry);
|
||||
UI()->ConvertMouseMove(&rx, &ry);
|
||||
|
||||
// TODO: Why do we have to halve this?
|
||||
rx /= 2;
|
||||
ry /= 2;
|
||||
|
||||
m_MouseDeltaX = rx;
|
||||
m_MouseDeltaY = ry;
|
||||
|
||||
if(!m_LockMouse)
|
||||
{
|
||||
s_MouseX = clamp(s_MouseX + rx, 0.0f, UI()->Screen()->w);
|
||||
s_MouseY = clamp(s_MouseY + ry, 0.0f, UI()->Screen()->h);
|
||||
s_MouseX = clamp<float>(s_MouseX + rx, 0.0f, Graphics()->WindowWidth());
|
||||
s_MouseY = clamp<float>(s_MouseY + ry, 0.0f, Graphics()->WindowHeight());
|
||||
}
|
||||
|
||||
// update the ui
|
||||
mx = s_MouseX;
|
||||
my = s_MouseY;
|
||||
mx = UI()->Screen()->w * ((float)s_MouseX / Graphics()->WindowWidth());
|
||||
my = UI()->Screen()->h * ((float)s_MouseY / Graphics()->WindowHeight());
|
||||
Mwx = 0;
|
||||
Mwy = 0;
|
||||
|
||||
|
@ -6338,10 +6334,11 @@ void CEditor::UpdateAndRender()
|
|||
float WorldWidth = aPoints[2] - aPoints[0];
|
||||
float WorldHeight = aPoints[3] - aPoints[1];
|
||||
|
||||
Mwx = aPoints[0] + WorldWidth * (s_MouseX / UI()->Screen()->w);
|
||||
Mwy = aPoints[1] + WorldHeight * (s_MouseY / UI()->Screen()->h);
|
||||
m_MouseDeltaWx = m_MouseDeltaX * (WorldWidth / UI()->Screen()->w);
|
||||
m_MouseDeltaWy = m_MouseDeltaY * (WorldHeight / UI()->Screen()->h);
|
||||
Mwx = aPoints[0] + WorldWidth * ((float)s_MouseX / Graphics()->WindowWidth());
|
||||
Mwy = aPoints[1] + WorldHeight * ((float)s_MouseY / Graphics()->WindowHeight());
|
||||
|
||||
m_MouseDeltaWx = m_MouseDeltaX * (WorldWidth / Graphics()->ScreenWidth());
|
||||
m_MouseDeltaWy = m_MouseDeltaY * (WorldHeight / Graphics()->ScreenHeight());
|
||||
}
|
||||
|
||||
int Buttons = 0;
|
||||
|
|
Loading…
Reference in a new issue