예제 #1
0
void CMainGameWindow::drawViewContents(CScreenManager *screenManager) {
	// Get a reference to the reference, validating that it's present
	if (!screenManager)
		return;
	CViewItem *view = _gameManager->getView();
	if (!view)
		return;
	CNodeItem *node = view->findNode();
	if (!node)
		return;
	CRoomItem *room = node->findRoom();
	if (!room)
		return;

	double xVal = 0.0, yVal = 0.0;
	room->calcNodePosition(node->_nodePos, xVal, yVal);

	// Iterate through drawing all the items in the scene except any item
	// that's currently being dragged
	for (CTreeItem *treeItem = view; treeItem; treeItem = treeItem->scan(view)) {
		if (treeItem != _gameManager->_dragItem)
			treeItem->draw(screenManager);
	}

	// Finally draw the drag item if there is one
	if (_gameManager->_dragItem)
		_gameManager->_dragItem->draw(screenManager);
}
예제 #2
0
CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) {
	CViewItem *view = _gameManager->getView();
	if (!view)
		return nullptr;

	// Scan through the view items to find the item being dropped on
	CGameObject *target = nullptr;
	for (CTreeItem *treeItem = view->scan(view); treeItem; treeItem = treeItem->scan(view)) {
		CGameObject *gameObject = dynamic_cast<CGameObject *>(treeItem);
		if (gameObject && gameObject != dragItem) {
			if (gameObject->checkPoint(pt))
				target = gameObject;
		}
	}

	if (target) {
		// Check if the cursor is on the PET. If so, pass to the PET
		// to see what specific element the drag ended on
		CProjectItem *project = view->getRoot();
		if (project) {
			CPetControl *petControl = project->getPetControl();
			if (petControl && petControl->contains(pt)) {
				target = petControl->dragEnd(pt);
				if (!target)
					target = petControl;
			}
		}
	}

	return target;
}
예제 #3
0
CGameObject *CPetControl::findBot(const CString &name, CTreeItem *root) {
	for (CTreeItem *item = root; item; item = item->scan(root)) {
		if (!item->getName().compareToIgnoreCase(name)) {
			CGameObject *obj = dynamic_cast<CGameObject *>(item);
			if (obj)
				return obj;
		}
	}

	return nullptr;
}
예제 #4
0
void CGameManager::viewChange() {
	delete _movie;
	delete _movieSurface;

	_movie = nullptr;
	_movieSurface = CScreenManager::_screenManagerPtr->createSurface(600, 340);
	_trueTalkManager.clear();

	for (CTreeItem *treeItem = _project; treeItem; treeItem = treeItem->scan(_project))
		treeItem->viewChange();

	initBounds();
}
예제 #5
0
bool CPetControl::isDoorOrBellbotPresent() const {
	CGameManager *gameManager = getGameManager();
	if (!gameManager)
		return false;
	CViewItem *view = gameManager->getView();
	if (!view)
		return false;

	for (CTreeItem *treeItem = view->getFirstChild(); treeItem;
			treeItem = treeItem->scan(view)) {
		CString name = treeItem->getName();
		if (dynamic_cast<CGameObject *>(treeItem) &&
				(name.contains("Doorbot") || name.contains("BellBot")))
			return true;
	}

	return false;
}
예제 #6
0
bool CPetControl::isBotInView(const CString &name) const {
	CGameManager *gameManager = getGameManager();
	if (!gameManager)
		return false;
	CViewItem *view = gameManager->getView();
	if (!view)
		return false;

	// Iterate to find NPC
	for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) {
		CGameObject *gameObject = dynamic_cast<CGameObject *>(child);
		if (gameObject) {
			if (!gameObject->getName().compareToIgnoreCase(name))
				return true;
		}
	}

	return false;
}
예제 #7
0
void CGameManager::update() {
	updateMovies();
	frameMessage(getRoom());
	_timers.update(g_vm->_events->getTicksCount());
	_trueTalkManager.removeCompleted();

	CScreenManager::_screenManagerPtr->_mouseCursor->update();

	CViewItem *view = getView();
	if (view) {
		// Expand the game manager's bounds to encompass all the view's items
		for (CTreeItem *item = view; item; item = item->scan(view)) {
			Rect r = item->getBounds();
			if (!r.isEmpty())
				_bounds.extend(r);
		}

		// Also include the PET control in the bounds
		if (_project) {
			CPetControl *pet = _project->getPetControl();
			if (pet)
				_bounds.extend(pet->getBounds());
		}

		// And the text cursor
		CScreenManager *screenManager = CScreenManager::_screenManagerPtr;
		CTextCursor *textCursor = screenManager->_textCursor;
		if (textCursor && textCursor->_active)
			_bounds.extend(textCursor->getCursorBounds());
		
		// Set the surface bounds
		screenManager->setSurfaceBounds(SURFACE_BACKBUFFER, _bounds);

		// Handle redrawing the view
		if (!_bounds.isEmpty()) {
			_gameView->draw(_bounds);
			_bounds = Rect();
		}

		_gameState.checkForViewChange();
	}
}
예제 #8
0
bool CPetControl::dismissBot(const CString &name) {
	CGameManager *gameManager = getGameManager();
	if (!gameManager)
		return false;
	CViewItem *view = gameManager->getView();
	if (!view)
		return false;

	bool result = false;
	CDismissBotMsg dismissMsg;
	for (CTreeItem *treeItem = view->getFirstChild(); treeItem;
			treeItem = treeItem->scan(view)) {
		if (!treeItem->getName().compareToIgnoreCase(name))
			dismissMsg.execute(treeItem);
		else
			result = true;
	}

	return result;
}
예제 #9
0
bool CParrotLobbyLinkUpdater::ActMsg(CActMsg *msg) {
	if (msg->_action != "Refresh")
		return false;

	CNodeItem *node = findNode();
	LinkUpdatorEntries *entriesP;
	if (isEquals("ParrotLobbyUpdater_TOW")) {
		entriesP = &_entries[4];
	} else {
		if (node->_nodeNumber > 3)
			return true;
		entriesP = &_entries[node->_nodeNumber];
	}
	int count = entriesP->size();

	for (CTreeItem *item = node->getFirstChild(); item; item = item->scan(node)) {
		CLinkItem *link = dynamic_cast<CLinkItem *>(item);
		if (!link || count == 0)
			continue;

		CString linkName = link->getName();
		char c = linkName.lastChar();
		if (c >= 'a' && c <= 'd')
			linkName.deleteLastChar();

		for (uint idx = 0; idx < entriesP->size(); ++idx) {
			const LinkUpdatorEntry &entry = (*entriesP)[idx];
			if (entry._linkStr == linkName) {
				int val = entry._vals[CParrotLobbyObject::_flags];
				if (val)
					linkName += (char)(0x60 + val);

				link->_name = linkName;
				break;
			}
		}
	}

	return true;
}