MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / handleInputEvent

Method handleInputEvent

source/frontend/StarMainInterface.cpp:277–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277bool MainInterface::handleInputEvent(InputEvent const& event) {
278 auto player = m_client->mainPlayer();
279 auto inv = player->inventory();
280 auto& root = Root::singleton();
281
282 if (auto mouseMove = event.ptr<MouseMoveEvent>())
283 m_cursorScreenIPos = Vec2I::round(m_cursorScreenPos = mouseMove->mousePosition);
284
285 if (m_paneManager.sendInputEvent(event)) {
286 if (!event.is<MouseButtonUpEvent>() && !event.is<KeyUpEvent>())
287 return true;
288 }
289
290 if (event.is<KeyDownEvent>()) {
291 if (m_chat->hasFocus()) {
292 if (m_guiContext->actions(event).contains(InterfaceAction::ChatSendLine)) {
293 doChat(m_chat->currentChat(), true);
294 m_chat->clearCurrentChat();
295 m_chat->stopChat();
296 return true;
297 }
298 } else if (!m_paneManager.keyboardCapturedWidget()) {
299 Maybe<InventorySlot> swapSlot;
300
301 for (auto action : m_guiContext->actions(event)) {
302 switch (action) {
303 default:
304 break;
305 case InterfaceAction::GuiShifting:
306 m_guiContext->setShiftHeld(true);
307 break;
308 case InterfaceAction::ChatBegin:
309 m_chat->startChat();
310 break;
311
312 case InterfaceAction::InterfaceHideHud:
313 m_disableHud = !m_disableHud;
314 break;
315
316 case InterfaceAction::InterfaceRepeatCommand:
317 if (!m_lastCommand.empty())
318 doChat(m_lastCommand, false);
319 break;
320
321 case InterfaceAction::InterfaceToggleFullscreen:
322 m_optionsMenu->toggleFullscreen();
323 break;
324
325 case InterfaceAction::InterfaceReload:
326 root.reload();
327 root.fullyLoad();
328 break;
329
330 case InterfaceAction::ChatBeginCommand:
331 m_chat->startCommand();
332 break;
333
334 case InterfaceAction::InterfaceEscapeMenu:

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
roundFunction · 0.85
mainPlayerMethod · 0.80
inventoryMethod · 0.80
sendInputEventMethod · 0.80
currentChatMethod · 0.80
clearCurrentChatMethod · 0.80
stopChatMethod · 0.80
setShiftHeldMethod · 0.80
startChatMethod · 0.80
fullyLoadMethod · 0.80

Tested by

no test coverage detected