Example #1
0
void Application::RequestExit()
{
    emit ExitRequested();

    // If no-one canceled the exit as a response to the signal, exit
    if (framework->IsExiting())
        quit();
}
Example #2
0
void CGame::ComputerKeyDown(MSG msg)
{
  static BOOL bRDown = FALSE;
  // if computer is not active
  if (_pGame->gm_csComputerState!=CS_ON && _pGame->gm_csComputerState!=CS_TURNINGON) {
    // do nothing
    return;
  }

  // if escape pressed
  if (msg.message==WM_KEYDOWN && msg.wParam==VK_ESCAPE) {
    ExitRequested();
  }

  // if right mouse pressed
  if (msg.message==WM_RBUTTONDOWN || msg.message==WM_RBUTTONDBLCLK) {
    bRDown = TRUE;
  }
  // if right mouse released
  if (bRDown && msg.message==WM_RBUTTONUP) {
    bRDown = FALSE;
    // mark current message as read
    MarkCurrentRead();
    // find a group with first unread message
    BOOL bHasUnread = FindGroupWithUnread();
    // if some
    if (bHasUnread) {
      // select first unread message in it
      NextUnreadMessage();
    } else {
      ExitRequested();
    }
  }
  
  if (msg.message==WM_KEYDOWN) {
    switch (msg.wParam) {
    // change message types on number keys
    case '1': _cmtWantedType = CMT_INFORMATION ; return;
    case '2': _cmtWantedType = CMT_WEAPONS     ; return;
    case '3': _cmtWantedType = CMT_ENEMIES     ; return;
    case '4': _cmtWantedType = CMT_BACKGROUND  ; return;
    case '5': _cmtWantedType = CMT_STATISTICS  ; return;
    // go to next unread
    case 'U':
    case VK_SPACE:
      NextUnreadMessage(); return;
    // scroll message list
    case 219: PrevMessage(); return;
    case 221: NextMessage(); return;
    // mark current message as read and go to next
    case VK_RETURN: MarkCurrentRead(); NextUnreadMessage(); return;
    // scroll message text
    case VK_UP:   MessageTextUp(1); return;
    case VK_DOWN: MessageTextDn(1); return;
    case VK_PRIOR:MessageTextUp(_ctTextLinesOnScreen-1); return;
    case VK_NEXT: MessageTextDn(_ctTextLinesOnScreen-1); return;
    };
  }

  // if left mouse pressed
  if (msg.message==WM_LBUTTONDOWN || msg.message==WM_LBUTTONDBLCLK) {
    BOOL bOverMsgSlider = FALSE;
    // if over slider
    {PIXaabbox2D boxSlider = GetTextSliderBox();
    PIXaabbox2D boxSliderTrans = boxSlider;
    boxSliderTrans+=_boxMsgText.Min();
    if (boxSliderTrans>=_vpixMouse) {
      bOverMsgSlider = TRUE;
      // start dragging
      _bSliderDragText = TRUE;
      _pixSliderDragJ=_vpixMouse(2);
      _iSliderDragLine = _iTextLineOnScreen;
    }}

    // if over slider
    {PIXaabbox2D boxSlider = GetMsgSliderBox();
    PIXaabbox2D boxSliderTrans = boxSlider;
    boxSliderTrans+=_boxMsgList.Min();
    if (boxSliderTrans>=_vpixMouse) {
      // start dragging
      _bSliderDragText = FALSE;
      _pixSliderDragJ=_vpixMouse(2);
      _iSliderDragLine = _iFirstMessageOnScreen;
    }}
    // if over some button
    {for(INDEX i=0; i<CMT_COUNT; i++) {
      if (_boxButton[i]>=_vpixMouse) {
        // switch to that message type
        _cmtWantedType = (CompMsgType)i;
      }
    }}
    // if over some message
    {for(INDEX i=0; i<_ctMessagesOnScreen; i++) {
      if (GetMsgListBox(i)>=_vpixMouse && !bOverMsgSlider) {
        // switch to that message
        SelectMessage(_iFirstMessageOnScreen+i);
      }
    }}
  }

  // if left mouse released
  if (msg.message==WM_LBUTTONUP) {
    // stop dragging
    _pixSliderDragJ=-1;
    // if over exit
    if (_boxExit>=_vpixMouse) {
      // exit
      ExitRequested();
    }
  }
}