Пример #1
0
// FIXME: Parallaction_br::parseLocation() is now a verbatim copy of the same routine from Parallaction_ns.
void Parallaction_br::parseLocation(const char *filename) {
	debugC(1, kDebugParser, "parseLocation('%s')", filename);

	// find a new available slot
	allocateLocationSlot(filename);
	Script *script = _disk->loadLocation(filename);

	// parse the text file
	LocationParserOutput_br out;
	_locationParser->parse(script, &out);
	assert(out._info);
	delete script;

	bool visited = getLocationFlags() & kFlagsVisited;

	// load background, mask and path
	_disk->loadScenery(*out._info,
		out._backgroundName.empty() ? 0 : out._backgroundName.c_str(),
		out._maskName.empty()       ? 0 : out._maskName.c_str(),
		out._pathName.empty()       ? 0 : out._pathName.c_str());
	// assign background
	_gfx->setBackground(kBackgroundLocation, out._info);


	// process zones
	ZoneList::iterator zit = _location._zones.begin();
	for ( ; zit != _location._zones.end(); ++zit) {
		ZonePtr z = *zit;
		// restore the flags if the location has already been visited
		restoreOrSaveZoneFlags(z, visited);

		// (re)link the bounding animation if needed
		if (z->_flags & kFlagsAnimLinked) {
			z->_linkedAnim = _location.findAnimation(z->_linkedName.c_str());
		}

		bool visible = (z->_flags & kFlagsRemove) == 0;
		if (visible) {
			showZone(z, visible);
		}
	}

	// load the character (must be done before animations are processed)
	if (!out._characterName.empty()) {
		changeCharacter(out._characterName.c_str());
	}

	// process animations
	AnimationList::iterator ait = _location._animations.begin();
	for ( ; ait != _location._animations.end(); ++ait) {
		// restore the flags if the location has already been visited
		restoreOrSaveZoneFlags(*ait, visited);

		// load the script
		if ((*ait)->_scriptName) {
			loadProgram(*ait, (*ait)->_scriptName);
		}
	}

	debugC(1, kDebugParser, "parseLocation('%s') done", filename);
	return;
}
Пример #2
0
//	changeLocation handles transitions between locations, and is able to display slides
//	between one and the other.
//
void Parallaction_ns::changeLocation() {
	if (_newLocationName.empty()) {
		return;
	}

	char location[200];
	strcpy(location, _newLocationName.c_str());
	strcpy(_location._name, _newLocationName.c_str());

	debugC(1, kDebugExec, "changeLocation(%s)", location);

	MouseTriState oldMouseState = _input->getMouseState();
	_input->setMouseState(MOUSE_DISABLED);

	if (!_intro) {
		// prevent music changes during the introduction
		_soundManI->playLocationMusic(location);
	}

	_input->stopHovering();
	// this is still needed to remove the floatingLabel
	_gfx->freeLabels();

	_zoneTrap.reset();

	_input->setArrowCursor();

	_gfx->showGfxObj(_char._ani->gfxobj, false);

	LocationName locname;
	locname.bind(location);

	freeLocation(false);

	if (locname.hasSlide()) {
		showSlide(locname.slide());
		GfxObj *label = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
		_gfx->showLabel(label, CENTER_LABEL_HORIZONTAL, 14);
		_gfx->updateScreen();

		_input->waitForButtonEvent(kMouseLeftUp);
		_gfx->unregisterLabel(label);
		delete label;
	}

	if (locname.hasCharacter()) {
		changeCharacter(locname.character());
	}

	strcpy(g_saveData1, locname.location());
	parseLocation(g_saveData1);

	if (_location._startPosition.x != -1000) {
		_char._ani->setX(_location._startPosition.x);
		_char._ani->setY(_location._startPosition.y);
		_char._ani->setF(_location._startFrame);
		_location._startPosition.y = -1000;
		_location._startPosition.x = -1000;
	}


	_gfx->setBlackPalette();
	_gfx->updateScreen();

	// BUG #1837503: kEngineChangeLocation flag must be cleared *before* commands
	// and acommands are executed, so that it can be set again if needed.
	g_engineFlags &= ~kEngineChangeLocation;

	_cmdExec->run(_location._commands);

	doLocationEnterTransition();

	_cmdExec->run(_location._aCommands);

	if (_location._hasSound)
		_soundManI->playSfx(_location._soundFile, 0, true);

	if (!_intro) {
		_input->setMouseState(oldMouseState);
		// WORKAROUND: Fix a script bug in the Multilingual DOS version of
		// Nippon Safes: the mouse cursor is incorrectly hidden outside the
		// cave at the end of the game. Fix it here.
		if (!strcmp(_location._name, "ingressocav"))
			_input->setMouseState(MOUSE_ENABLED_SHOW);
	}

	debugC(1, kDebugExec, "changeLocation() done");
	_newLocationName.clear();
}