int run(void* taskArg)
      {
         char mynum[3];
         sprintf(mynum, "%02d", getUserData());
         UtlString startMsg("  start  ");
         UtlString finishMsg("  finish ");
         startMsg.append(mynum);
         finishMsg.append(mynum);

         timer.addEvent(startMsg.data());
         doListOperations();
         timer.addEvent(finishMsg.data());
         return 0;
      }
void
Tranquility::ReadyToRun()
{
	fBrowserWindow = new BrowserWindow();

	be_roster->StartWatching(be_app_messenger, B_REQUEST_QUIT);

	BMessage startMsg(kMsgStartRenderApp);
	startMsg.AddRect("renderFrame", fBrowserWindow->Bounds());
	startMsg.AddInt32("teamID", be_app->Team());

	team_id renderTeam;
	if (be_roster->Launch(kRenderAppSignature, &startMsg, &renderTeam) != B_OK) {
		BAlert* alert = new BAlert("Error!",
			"There was an error trying to launch the render process!", "Damn!");
		alert->Go();
	} else {
		fMessenger = new BMessenger(kRenderAppSignature, renderTeam);
	}

	fBrowserWindow->Show();
}
bool CMusicConsoleButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
	if (_isActive) {
		CStopMusicMsg stopMsg(this);
		stopMsg.execute(this);
		stopMovie();
		loadFrame(0);
	} else {
		CStartMusicMsg startMsg(this);
		startMsg.execute(this);
		playMovie(MOVIE_REPEAT);

		CMusicHasStartedMsg startedMsg;
		startedMsg.execute("Music Room Phonograph");
	
		if (CMusicRoom::_musicHandler->checkSound(1)
				&& CMusicRoom::_musicHandler->checkSound(2)
				&& CMusicRoom::_musicHandler->checkSound(3)) {
			CCorrectMusicPlayedMsg correctMsg;
			correctMsg.execute(findRoom());
		}
	}

	return true;
}
Exemple #4
0
void CInputHandler::processMessage(CMessage *msg) {
	const CMouseMsg *mouseMsg = dynamic_cast<const CMouseMsg *>(msg);
	_singleton = false;
	dispatchMessage(msg);

	if (_singleton) {
		_singleton = false;
	} else if (mouseMsg) {
		// Keep the game state mouse position up to date
		if (_mousePos != mouseMsg->_mousePos) {
			_mousePos = mouseMsg->_mousePos;
			_gameManager->_gameState.setMousePos(mouseMsg->_mousePos);
		}

		// Set flag for whether a mouse button is currently being pressed
		if (mouseMsg->isButtonDownMsg())
			_buttonDown = true;
		else if (mouseMsg->isButtonUpMsg())
			_buttonDown = false;

		// Drag events generation
		if (_dragging) {
			if (mouseMsg->isMouseMoveMsg()) {
				if (_dragItem) {
					CMouseDragMoveMsg moveMsg(_mousePos);
					moveMsg.execute(_dragItem);
				}
			} else {
				if (mouseMsg->isButtonUpMsg() && _dragItem) {
					// Mouse drag ended
					CGameObject *target = dragEnd(_mousePos, _dragItem);
					CMouseDragEndMsg endMsg(_mousePos, target);
					endMsg.execute(_dragItem);
				}

				_dragging = false;
				_dragItem = nullptr;
			}
		} else if (_buttonDown) {
			if (!mouseMsg->isMouseMoveMsg()) {
				// Save where the drag movement started from
				_dragStartPos = _mousePos;
			} else {
				Point delta = mouseMsg->_mousePos - _dragStartPos;
				int distance = (int)sqrt(double(delta.x * delta.x + delta.y * delta.y));

				if (distance > 4) {
					// We've moved far enough with the mouse button held down
					// to trigger an official dragging operation
					CMouseDragStartMsg startMsg(_dragStartPos);
					dispatchMessage(&startMsg);

					// Set the drag item, if any, that a handler will have set on the message
					_dragItem = startMsg._dragItem;
					_gameManager->_dragItem = startMsg._dragItem;

					if (_dragItem) {
						CMouseDragMoveMsg moveMsg(_dragStartPos);
						dispatchMessage(&moveMsg);
					}

					_dragging = true;
				}
			}
		}
	}
}
Exemple #5
0
//**********************************************************************************************************************
void SimpleTerminal::modifyDspText(DspType type, const QString &text)
{
    // Format text according to type of message
    static DspType last_type = DspType::NONE;

    // Need to end the last message?
    if (last_type != type && _is_msg_open)
        emit endMsg();

    switch(type)
    {
        case DspType::READ_MESSAGE:
        {
            static QString prev_msg("");

            // Parse message and look for EOM string(s) - there could be 0 - n in this message
            // Emit approriate details to system - end of message? Start of message? Append message?
            QString msg(text.toHtmlEscaped());

            // Find all occurences of EOM
            int start_pos = 0;
            int eom_pos = 0;
            do
            {
                QString shared_msg(prev_msg + msg);
                eom_pos = shared_msg.indexOf(_eom, start_pos);
                if (eom_pos >= 0)
                {
                    // Found EOM!
                    if (!_is_msg_open)
                        emit startMsg();

                    if (eom_pos < prev_msg.length())
                        // Found EOM start before start of actual message; need to correct start position
                        // to be first character after previous message
                        start_pos += prev_msg.length();

                    int len = (eom_pos + _eom.length()) - start_pos;

                    emit appendMsg(shared_msg.mid(start_pos, len));
                    emit endMsg();

                    start_pos = eom_pos + _eom.length();
                }
                else if (start_pos < shared_msg.length())
                {
                    // No EOMs left; send rest of message
                    if (!_is_msg_open)
                        emit startMsg();

                    emit appendMsg(shared_msg.mid(start_pos));
                }
            } while(eom_pos >= 0);

            // Keep end of msg for next time
            if (_eom.length() > 0)
            {
                int num_prev_msg_keep = _eom.length() - msg.length();
                if (num_prev_msg_keep > 0)
                    prev_msg = prev_msg.right(num_prev_msg_keep) + msg;

                else
                    prev_msg = msg.right(_eom.length() - 1);
            }
            else
                prev_msg = "";

            break;
        }

        case DspType::WRITE_MESSAGE:
        {
            QString msg = "<span><b>" + text.toHtmlEscaped() + "</b></span>";
            emit newMsg(msg);

            break;
        }

        case DspType::COMMAND:
        {
            QString msg = "<span style = \"color: blue;\"><b>$ " + text.toHtmlEscaped() + "</b></span>";
            emit newMsg(msg);

            break;
        }

        case DspType::COMMAND_RSP:
        {
            QString msg = "<span style = \"color: green;\">" + text + "</span>";
            emit newMsg(msg);

            break;
        }

        case DspType::ERROR:
        {
            QString msg = "<span style = \"color: red;\">ERROR: " + text + "</span>";
            emit newMsg(msg);

            break;
        }

        default:
            break;
    }

    last_type = type;
}