MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / OnUpdate

Method OnUpdate

LuaSTGPlus/AppFrame.cpp:1639–1931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1637
1638#pragma region 游戏循环
1639fBool AppFrame::OnUpdate(fDouble ElapsedTime, f2dFPSController* pFPSController, f2dMsgPump* pMsgPump)
1640{
1641#if (defined LDEVVERSION) || (defined LDEBUG)
1642 TimerScope tProfileScope(m_UpdateTimer);
1643#endif
1644
1645 m_fFPS = (float)pFPSController->GetFPS();
1646
1647 m_LastChar = 0;
1648 m_LastKey = 0;
1649
1650 // 处理消息
1651 f2dMsg tMsg;
1652 while (FCYOK(pMsgPump->GetMsg(&tMsg)))
1653 {
1654 switch (tMsg.Type)
1655 {
1656 case F2DMSG_WINDOW_ONCLOSE:
1657 return false; // 关闭窗口时结束循环
1658 case F2DMSG_WINDOW_ONGETFOCUS:
1659 if (!SafeCallGlobalFunction(LFUNC_GAINFOCUS))
1660 return false;
1661 case F2DMSG_WINDOW_ONLOSTFOCUS:
1662 if (!SafeCallGlobalFunction(LFUNC_LOSEFOCUS))
1663 return false;
1664 case F2DMSG_WINDOW_ONCHARINPUT:
1665 m_LastChar = (fCharW)tMsg.Param1;
1666 break;
1667 case F2DMSG_WINDOW_ONKEYDOWN:
1668 // ctrl+enter全屏
1669 if (tMsg.Param1 == VK_RETURN && !m_KeyStateMap[VK_RETURN] && m_KeyStateMap[VK_CONTROL]) // 防止反复触发
1670 ChangeVideoMode((int)m_OptionResolution.x, (int)m_OptionResolution.y, !m_OptionWindowed, m_OptionVsync);
1671
1672 if (0 < tMsg.Param1 && tMsg.Param1 < _countof(m_KeyStateMap) &&
1673 !(LJOYSTICK1_MAPPING_START <= tMsg.Param1 && tMsg.Param1 <= LJOYSTICK1_MAPPING_END) && // joystick1映射区域
1674 !(LJOYSTICK2_MAPPING_START <= tMsg.Param1 && tMsg.Param1 <= LJOYSTICK2_MAPPING_END)) // joystick2映射区域
1675 {
1676 m_LastKey = (fInt)tMsg.Param1;
1677 m_KeyStateMap[tMsg.Param1] = true;
1678 }
1679
1680#if (defined LDEVVERSION) || (defined LDEBUG)
1681 if (tMsg.Param1 == VK_F8)
1682 m_bShowCollider = !m_bShowCollider;
1683#endif
1684 break;
1685 case F2DMSG_WINDOW_ONKEYUP:
1686 if (m_LastKey == tMsg.Param1)
1687 m_LastKey = 0;
1688 if (0 < tMsg.Param1 && tMsg.Param1 < _countof(m_KeyStateMap) &&
1689 !(LJOYSTICK1_MAPPING_START <= tMsg.Param1 && tMsg.Param1 <= LJOYSTICK1_MAPPING_END) && // joystick1映射区域
1690 !(LJOYSTICK2_MAPPING_START <= tMsg.Param1 && tMsg.Param1 <= LJOYSTICK2_MAPPING_END)) // joystick2映射区域
1691 {
1692 m_KeyStateMap[tMsg.Param1] = false;
1693 }
1694 break;
1695 case F2DMSG_WINDOW_ONMOUSELDOWN:
1696 m_MouseState[0] = true;

Callers

nothing calls this directly

Calls 3

GetFPSMethod · 0.80
GetObjectCountMethod · 0.80

Tested by

no test coverage detected