MCPcopy Create free account
hub / github.com/ddnet/ddnet / OnInput

Method OnInput

src/game/client/components/spectator.cpp:168–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168bool CSpectator::OnInput(const IInput::CEvent &Event)
169{
170 if(IsActive() && Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_ESCAPE)
171 {
172 OnRelease();
173 return true;
174 }
175
176 if(g_Config.m_ClSpectatorMouseclicks)
177 {
178 if(GameClient()->m_Snap.m_SpecInfo.m_Active && !IsActive() && !GameClient()->m_MultiViewActivated &&
179 !Ui()->IsPopupOpen() && !GameClient()->m_GameConsole.IsActive() && !GameClient()->m_Menus.IsActive())
180 {
181 if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_MOUSE_1)
182 {
183 if(GameClient()->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW)
184 Spectate(SPEC_FREEVIEW);
185 else
186 SpectateClosest();
187 return true;
188 }
189 }
190 }
191
192 if(GameClient()->m_Camera.SpectatingPlayer() && GameClient()->m_Camera.CanUseAutoSpecCamera())
193 {
194 if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_MOUSE_2)
195 {
196 GameClient()->m_Camera.ResetAutoSpecCamera();
197 return true;
198 }
199 }
200
201 return false;
202}
203
204void CSpectator::OnRelease()
205{

Callers

nothing calls this directly

Calls 6

UiFunction · 0.85
IsPopupOpenMethod · 0.80
SpectatingPlayerMethod · 0.80
CanUseAutoSpecCameraMethod · 0.80
ResetAutoSpecCameraMethod · 0.80
IsActiveMethod · 0.45

Tested by

no test coverage detected