Example #1
0
Common::String BuriedEngine::getFilePath(uint32 stringID) {
	Common::String path = getString(stringID);
	Common::String output;

	if (path.empty())
		return output;

	uint i = 0;

	// The non-demo paths have CD info followed by a backslash.
	// We ignore this.
	// In the demo, we remove the "BITDATA" prefix because the
	// binaries are in the same directory.
	if (isDemo())
		i += 8;
	else
		i += 2;

	for (; i < path.size(); i++) {
		if (path[i] == '\\')
			output += '/';
		else
			output += path[i];
	}

	return output;
}
Example #2
0
static void upgradeTargetIfNecessary(const ADParams &params) {
    if (params.obsoleteList == 0)
        return;

    Common::String gameid = ConfMan.get("gameid");

    for (const ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) {
        if (gameid.equalsIgnoreCase(o->from)) {
            gameid = o->to;
            ConfMan.set("gameid", gameid);

            if (o->platform != Common::kPlatformUnknown)
                ConfMan.set("platform", Common::getPlatformCode(o->platform));

            warning("Target upgraded from %s to %s", o->from, o->to);

            // WORKAROUND: Fix for bug #1719463: "DETECTOR: Launching
            // undefined target adds launcher entry"
            if (ConfMan.hasKey("id_came_from_command_line")) {
                warning("Target came from command line. Skipping save");
            } else {
                ConfMan.flushToDisk();
            }
            break;
        }
    }
}
Example #3
0
bool StarTrekEngine::showSaveMenu() {
	GUI::SaveLoadChooser *dialog;
	Common::String desc;
	int slot;

	dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);

	slot = dialog->runModalWithCurrentTarget();
	desc = dialog->getResultString();

	if (desc.empty()) {
		// create our own description for the saved game, the user didnt enter it
		desc = dialog->createDefaultSaveDescription(slot);
	}

	if (desc.size() > 28)
		desc = Common::String(desc.c_str(), 28);

	delete dialog;

	if (slot < 0)
		return true;

	return saveGame(slot, desc);
}
Example #4
0
/**********************************************************
 * Theme XML loading
 *********************************************************/
void ThemeEngine::loadTheme(const Common::String &themeId) {
	unloadTheme();

	debug(6, "Loading theme %s", themeId.c_str());

	if (themeId == "builtin") {
		_themeOk = loadDefaultXML();
	} else {
		// Load the archive containing image and XML data
		_themeOk = loadThemeXML(themeId);
	}

	if (!_themeOk) {
		warning("Failed to load theme '%s'", themeId.c_str());
		return;
	}

	for (int i = 0; i < kDrawDataMAX; ++i) {
		if (_widgets[i] == 0) {
			warning("Missing data asset: '%s'", kDrawDataDefaults[i].name);
		} else {
			_widgets[i]->calcBackgroundOffset();
		}
	}
}
Example #5
0
void BasePersistenceManager::putDouble(double val) {
    int exponent = 0;
    double significand = frexp(val, &exponent);
    Common::String str = Common::String::format("DS%f", significand);
    putString(str.c_str());
    _saveStream->writeSint32LE(exponent);
}
Example #6
0
const ExtraGuiOptions AdvancedMetaEngine::getExtraGuiOptions(const Common::String &target) const {
	if (!_extraGuiOptions)
		return ExtraGuiOptions();

	ExtraGuiOptions options;

	// If there isn't any target specified, return all available GUI options.
	// Only used when an engine starts in order to set option defaults.
	if (target.empty()) {
		for (const ADExtraGuiOptionsMap *entry = _extraGuiOptions; entry->guioFlag; ++entry)
			options.push_back(entry->option);

		return options;
	}

	// Query the GUI options
	const Common::String guiOptionsString = ConfMan.get("guioptions", target);
	const Common::String guiOptions = parseGameGUIOptions(guiOptionsString);

	// Add all the applying extra GUI options.
	for (const ADExtraGuiOptionsMap *entry = _extraGuiOptions; entry->guioFlag; ++entry) {
		if (guiOptions.contains(entry->guioFlag))
			options.push_back(entry->option);
	}

	return options;
}
Example #7
0
bool ThemeEngine::themeConfigParseHeader(Common::String header, Common::String &themeName) {
	// Check that header is not corrupted
	if ((byte)header[0] > 127) {
		warning("Corrupted theme header found");
		return false;
	}

	header.trim();

	if (header.empty())
		return false;

	if (header[0] != '[' || header.lastChar() != ']')
		return false;

	header.deleteChar(0);
	header.deleteLastChar();

	Common::StringTokenizer tok(header, ":");

	if (tok.nextToken() != SCUMMVM_THEME_VERSION_STR)
		return false;

	themeName = tok.nextToken();
	Common::String author = tok.nextToken();

	return tok.empty();
}
Example #8
0
bool TotFunctions::call(const Common::String &totFile,
		const Common::String &function) const {

	int index = find(totFile);
	if (index < 0) {
		warning("TotFunctions::call(): No such TOT \"%s\"", totFile.c_str());
		return false;
	}

	const Tot &tot = _tots[index];

	uint16 offset = 0;
	Common::List<Function>::const_iterator it;
	for (it = tot.functions.begin(); it != tot.functions.end(); ++it) {
		if (it->name.equalsIgnoreCase(function)) {
			offset = it->offset;
			break;
		}
	}

	if (offset == 0) {
		warning("TotFunctions::call(): No such function \"%s\" in \"%s\"",
				function.c_str(), totFile.c_str());
		return false;
	}

	return call(tot, offset);
}
Example #9
0
bool MoviePlayerDXA::load() {
	if ((_vm->getPlatform() == Common::kPlatformAmiga || _vm->getPlatform() == Common::kPlatformMacintosh) &&
		_vm->_language != Common::EN_ANY) {
		_sequenceNum = 0;
		for (uint i = 0; i < 90; i++) {
			if (!scumm_stricmp(baseName, _sequenceList[i]))
				_sequenceNum = i;
		}
	}

	Common::String videoName = Common::String::format("%s.dxa", baseName);
	Common::SeekableReadStream *videoStream = _vm->_archives.open(videoName);
	if (!videoStream)
		error("Failed to load video file %s", videoName.c_str());
	if (!loadStream(videoStream))
		error("Failed to load video stream from file %s", videoName.c_str());

	debug(0, "Playing video %s", videoName.c_str());

	CursorMan.showMouse(false);

	_firstFrameOffset = _fileStream->pos();

	return true;
}
Example #10
0
void SciEngine::loadMacExecutable() {
	if (getPlatform() != Common::kPlatformMacintosh || getSciVersion() < SCI_VERSION_1_EARLY || getSciVersion() > SCI_VERSION_1_1)
		return;

	Common::String filename;

	switch (getGameId()) {
	case GID_KQ6:
		filename = "King's Quest VI";
		break;
	case GID_FREDDYPHARKAS:
		filename = "Freddy Pharkas";
		break;
	default:
		break;
	}

	if (filename.empty())
		return;

	if (!_macExecutable.open(filename) || !_macExecutable.hasResFork()) {
		// KQ6/Freddy require the executable to load their icon bar palettes
		if (hasMacIconBar())
			error("Could not load Mac resource fork '%s'", filename.c_str());

		// TODO: Show some sort of warning dialog saying they can't get any
		// high-res Mac fonts, when we get to that point ;)
	}
}
Example #11
0
bool TotFunctions::load(const Common::String &totFile) {
	if (find(totFile) >= 0) {
		warning("TotFunctions::load(): \"%s\" already loaded", totFile.c_str());
		return false;
	}

	int index = findFree();
	if (index < 0) {
		warning("TotFunctions::load(): No free space for \"%s\"", totFile.c_str());
		return false;
	}

	Tot &tot = _tots[index];
	if (!loadTot(tot, totFile))
		return false;

	tot.file = totFile;

	if (!loadIDE(tot)) {
		freeTot(tot);
		return false;
	}

	return true;
}
Example #12
0
bool LabEngine::saveRestoreGame() {
	bool isOK = false;

	// The original had one screen for saving/loading. We have two.
	// Ask the user which screen to use.
	GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));

	int choice = saveOrLoad.runModal();
	if (choice == GUI::kMessageOK) {
		// Save
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
		int slot = dialog->runModalWithCurrentTarget();
		if (slot >= 0) {
			Common::String desc = dialog->getResultString();

			if (desc.empty()) {
				// create our own description for the saved game, the user didn't enter it
				desc = dialog->createDefaultSaveDescription(slot);
			}

			isOK = saveGame(slot, desc);
		}
		delete dialog;
	} else {
		// Restore
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
		int slot = dialog->runModalWithCurrentTarget();
		if (slot >= 0) {
			isOK = loadGame(slot);
		}
		delete dialog;
	}

	return isOK;
}
Example #13
0
bool BaseImage::loadFile(const Common::String &filename) {
	_filename = filename;
	_filename.toLowercase();
	if (filename.hasPrefix("savegame:") || _filename.hasSuffix(".bmp")) {
		_decoder = new Image::BitmapDecoder();
	} else if (_filename.hasSuffix(".png")) {
		_decoder = new Image::PNGDecoder();
	} else if (_filename.hasSuffix(".tga")) {
		_decoder = new Image::TGADecoder();
	} else if (_filename.hasSuffix(".jpg")) {
		_decoder = new Image::JPEGDecoder();
	} else {
		error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str());
	}
	_filename = filename;
	Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str());
	if (!file) {
		return false;
	}

	_decoder->loadStream(*file);
	_surface = _decoder->getSurface();
	_palette = _decoder->getPalette();
	_fileManager->closeFile(file);

	return true;
}
Example #14
0
int MenuSystem::loadSavegamesList() {
	int maxSlotNum = -1;

	_savegameListTopIndex = 0;
	_savegames.clear();

	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	Toltecs::ToltecsEngine::SaveHeader header;
	Common::String pattern = _vm->getTargetName();
	pattern += ".???";

	Common::StringArray filenames;
	filenames = saveFileMan->listSavefiles(pattern.c_str());
	Common::sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)

	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
		// Obtain the last 3 digits of the filename, since they correspond to the save slot
		int slotNum = atoi(file->c_str() + file->size() - 3);
		if (slotNum > maxSlotNum)
			maxSlotNum = slotNum;

		if (slotNum >= 0 && slotNum <= 999) {
			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
			if (in) {
				if (Toltecs::ToltecsEngine::readSaveHeader(in, false, header) == Toltecs::ToltecsEngine::kRSHENoError) {
					_savegames.push_back(SavegameItem(slotNum, header.description));
					//debug("%s -> %s", file->c_str(), header.description.c_str());
				}
				delete in;
			}
		}
	}

	return maxSlotNum;
}
Example #15
0
void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) {
	//warning("[Win32TaskbarManager::setOverlayIcon] Setting overlay icon to: %s (%s)", name.c_str(), description.c_str());

	if (_taskbar == NULL)
		return;

	if (name.empty()) {
		_taskbar->SetOverlayIcon(getHwnd(), NULL, L"");
		return;
	}

	// Compute full icon path
	Common::String path = getIconPath(name);
	if (path.empty())
		return;

	HICON pIcon = (HICON)::LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
	if (!pIcon) {
		warning("[Win32TaskbarManager::setOverlayIcon] Cannot load icon!");
		return;
	}

	// Sets the overlay icon
	LPWSTR desc = ansiToUnicode(description.c_str());
	_taskbar->SetOverlayIcon(getHwnd(), pIcon, desc);

	DestroyIcon(pIcon);

	delete[] desc;
}
Example #16
0
Script *Game::changeSceneLoadScript(uint8 sceneId, bool partB) {
	if (isCurrentSceneMap()) {
		_gui.markDirty();
	}

	_gameData->_lastScene = _gameData->_currentScene;
	_gameData->_currentScene = sceneId;
	_gameData->_partB = partB;

	_room->load(_gameData->_currentScene, partB);
	_room->redraw();

	EncryptedFile scriptFile;
	Common::String fileName = Common::String::format("scrn%d%s.atn", sceneId, partB ? "b" : "");
	scriptFile.open(fileName);
	if (!scriptFile.isOpen()) {
		reportFileMissingError(fileName.c_str());
		return nullptr;
	}

	// TODO Actually parse this.
	Common::String dummy;
	dummy = scriptFile.readLine(); // Skip first line.
	scriptFile.seek(126, SEEK_CUR); // Skip 126 bytes.

	Script *localScript = new Script;
	localScript->loadFromStream(scriptFile);
	scriptFile.close();

	_vm->updateCursor();

	return localScript;
}
Example #17
0
Common::String Win32TaskbarManager::getIconPath(Common::String target) {
	// We first try to look for a iconspath configuration variable then
	// fallback to the extra path
	//
	// Icons can be either in a subfolder named "icons" or directly in the path

	Common::String iconsPath = ConfMan.get("iconspath");
	Common::String extraPath = ConfMan.get("extrapath");

#define TRY_ICON_PATH(path) { \
	Common::FSNode node((path)); \
	if (node.exists()) \
		return (path); \
}

	if (!iconsPath.empty()) {
		TRY_ICON_PATH(iconsPath + "/" + target + ".ico");
		TRY_ICON_PATH(iconsPath + "/" + ConfMan.get("gameid") + ".ico");
		TRY_ICON_PATH(iconsPath + "/icons/" + target + ".ico");
		TRY_ICON_PATH(iconsPath + "/icons/" + ConfMan.get("gameid") + ".ico");
	}

	if (!extraPath.empty()) {
		TRY_ICON_PATH(extraPath + "/" + target + ".ico");
		TRY_ICON_PATH(extraPath + "/" + ConfMan.get("gameid") + ".ico");
		TRY_ICON_PATH(extraPath + "/icons/" + target + ".ico");
		TRY_ICON_PATH(extraPath + "/icons/" + ConfMan.get("gameid") + ".ico");
	}

	return "";
}
Example #18
0
bool MohawkEngine_Riven::checkDatafiles() {
	Common::String missingFiles;

	const char **datafiles = listExpectedDatafiles();
	for (int i = 0; datafiles[i] != nullptr; i++) {
		if (!SearchMan.hasFile(datafiles[i])) {
			if (strcmp(datafiles[i], "j_Data3.mhk") == 0
					|| strcmp(datafiles[i], "b_Data1.mhk") == 0) {
				// j_Data3.mhk and b_Data1.mhk come from the 1.02 patch. They are not required to play.
				continue;
			}

			if (!missingFiles.empty()) {
				missingFiles += ", ";
			}
			missingFiles += datafiles[i];
		}
	}

	if (missingFiles.empty()) {
		return true;
	}

	Common::String message = _("You are missing the following required Riven data files:\n") + missingFiles;
	warning("%s", message.c_str());
	GUIErrorMessage(message);

	return false;
}
Example #19
0
void AdvancedMetaEngine::reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds) const {
	Common::String report = Common::String::format(
			_("The game in '%s' seems to be an unknown %s engine game "
			  "variant.\n\nPlease report the following data to the ResidualVM "
			  "team at %s along with the name of the game you tried to add and "
			  "its version, language, etc.:"),
			path.getPath().c_str(), getName(), "https://github.com/residualvm/residualvm/issues");

	if (matchedGameIds.size()) {
		report += "\n\n";
		report += _("Matched game IDs:");
		report += " ";

		for (ADGameIdList::const_iterator gameId = matchedGameIds.begin(); gameId != matchedGameIds.end(); ++gameId) {
			if (gameId != matchedGameIds.begin()) {
				report += ", ";
			}
			report += *gameId;
		}
	}

	report += "\n\n";

	report.wordWrap(80);

	for (ADFilePropertiesMap::const_iterator file = filesProps.begin(); file != filesProps.end(); ++file)
		report += Common::String::format("  {\"%s\", 0, \"%s\", %d},\n", file->_key.c_str(), file->_value.md5.c_str(), file->_value.size);

	report += "\n";

	g_system->logMessage(LogMessageType::kInfo, report.c_str());
}
Example #20
0
bool LabelCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
	if (line.lastChar() != ':') {
		return false;
	}

	Common::String label = line;
	label.deleteLastChar();

	LabelCommand *labelCmd = new LabelCommand(label);
	if (!parseCtx._labels.contains(label)) {
		parseCtx._labels[label] = labelCmd;
	} else {
		warning("Label '%s' already exists", label.c_str());
	}

	if (parseCtx._pendingGotos.contains(label)) {
		GotoCommands &gotos = parseCtx._pendingGotos[label];
		for (GotoCommands::const_iterator it = gotos.begin(); it != gotos.end(); ++it) {
			(*it)->setLabelCommand(labelCmd);
		}
		gotos.clear();
	}

	command = labelCmd;
	return true;
}
Example #21
0
Common::String ThemeEngine::getThemeFile(const Common::String &id) {
	// FIXME: Actually "default" rather sounds like it should use
	// our default theme which would mean "scummmodern" instead
	// of the builtin one.
	if (id.equalsIgnoreCase("default"))
		return Common::String();

	// For our builtin theme we don't have to do anything for now too
	if (id.equalsIgnoreCase("builtin"))
		return Common::String();

	Common::FSNode node(id);

	// If the given id is a full path we'll just use it
	if (node.exists() && (node.isDirectory() || node.getName().matchString("*.zip", true)))
		return id;

	// FIXME:
	// A very ugly hack to map a id to a filename, this will generate
	// a complete theme list, thus it is slower than it could be.
	// But it is the easiest solution for now.
	Common::List<ThemeDescriptor> list;
	listUsableThemes(list);

	for (Common::List<ThemeDescriptor>::const_iterator i = list.begin(); i != list.end(); ++i) {
		if (id.equalsIgnoreCase(i->id))
			return i->filename;
	}

	warning("Could not find theme '%s' falling back to builtin", id.c_str());

	// If no matching id has been found we will
	// just fall back to the builtin theme
	return Common::String();
}
Example #22
0
void Lingo::c_whencode() {
	Datum d;
	uint start = g_lingo->_pc;
	uint end = READ_UINT32(&(*g_lingo->_currentScript)[start]) + start - 1;
	Common::String eventname((char *)&(*g_lingo->_currentScript)[start + 1]);

	start += g_lingo->calcStringAlignment(eventname.c_str()) + 1;

	debugC(1, kDebugLingoExec, "c_whencode([%5d][%5d], %s)", start, end, eventname.c_str());

	int entity = g_lingo->_currentEntityId;
	g_lingo->_currentEntityId = 0;

	g_lingo->define(eventname, start, 0, NULL, end);

	g_lingo->_currentEntityId = entity;

	if (debugChannelSet(1, kDebugLingoExec)) {
		uint pc = start;
		while (pc <= end) {
			Common::String instr = g_lingo->decodeInstruction(pc, &pc);
			debugC(1, kDebugLingoExec, "[%5d] %s", pc, instr.c_str());
		}
	}

	g_lingo->_pc = end;
}
Example #23
0
int Overlays::play(const Common::String &name, int loopId, bool loopForever, bool startNow, int a6) {
	assert(name.size() <= 12);

	int32 hash = MIXArchive::getHash(name);
	int index = findByHash(hash);
	if (index < 0) {
		index = findEmpty();
		if (index < 0) {
			return index;
		}
		_videos[index].loaded = true;
		_videos[index].name = name;
		_videos[index].hash = hash;
		_videos[index].vqaPlayer = new VQAPlayer(_vm, &_vm->_surfaceFront);

		// repeat forever
		_videos[index].vqaPlayer->setBeginAndEndFrame(0, 0, -1, kLoopSetModeJustStart, nullptr, nullptr);
	}

	Common::String resourceName = Common::String::format("%s.VQA", name.c_str());
	_videos[index].vqaPlayer->open(resourceName);
	_videos[index].vqaPlayer->setLoop(
		loopId,
		loopForever ? -1 : 0,
		startNow ? kLoopSetModeImmediate : kLoopSetModeEnqueue,
		nullptr, nullptr);

	return index;
}
Example #24
0
uint8 Widget::parseHotkey(const Common::String &label) {
    if (!label.contains('~'))
        return 0;

    int state = 0;
    uint8 hotkey = 0;

    for (uint i = 0; i < label.size() && state != 3; i++) {
        switch (state) {
        case 0:
            if (label[i] == '~')
                state = 1;
            break;
        case 1:
            if (label[i] != '~') {
                state = 2;
                hotkey = label[i];
            } else
                state = 0;
            break;
        case 2:
            if (label[i] == '~')
                state = 3;
            else
                state = 0;
            break;
        }
    }

    if (state == 3)
        return hotkey;

    return 0;
}
Example #25
0
void RemoteBrowserDialog::updateListing() {
	// Update the path display
	Common::String path = _node.path();
	if (path.empty())
		path = "/"; //root
	if (_navigationLocked)
		path = "Loading... " + path;
	_currentPath->setLabel(path);

	if (!_navigationLocked) {
		// Populate the ListWidget
		ListWidget::StringArray list;
		ListWidget::ColorList colors;
		for (Common::Array<Cloud::StorageFile>::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
			if (i->isDirectory()) {
				list.push_back(i->name() + "/");
				colors.push_back(ThemeEngine::kFontColorNormal);
			} else {
				list.push_back(i->name());
				colors.push_back(ThemeEngine::kFontColorAlternate);
			}
		}

		_fileList->setList(list, &colors);
		_fileList->scrollTo(0);
	}

	_fileList->setEnabled(!_navigationLocked);

	// Finally, redraw
	g_gui.scheduleTopDialogRedraw();
}
Example #26
0
bool ActionStreamVideo::execute() {
	Video::VideoDecoder *decoder;
	Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1);
	Common::String subname = _fileName;
	subname.setChar('s', subname.size() - 3);
	subname.setChar('u', subname.size() - 2);
	subname.setChar('b', subname.size() - 1);
	bool subtitleExists = _engine->getSearchManager()->hasFile(subname);
	bool switchToHires = false;

// NOTE: We only show the hires MPEG2 videos when libmpeg2 is compiled in,
// otherwise we fall back to the lowres ones
#ifdef USE_MPEG2
	Common::String hiresFileName = _fileName;
	hiresFileName.setChar('d', hiresFileName.size() - 8);
	hiresFileName.setChar('v', hiresFileName.size() - 3);
	hiresFileName.setChar('o', hiresFileName.size() - 2);
	hiresFileName.setChar('b', hiresFileName.size() - 1);

	if (_engine->getScriptManager()->getStateValue(StateKey_MPEGMovies) == 1 &&_engine->getSearchManager()->hasFile(hiresFileName)) {
		// TODO: Enable once AC3 support is implemented
		if (!_engine->getSearchManager()->hasFile(_fileName))	// Check for the regular video
			return true;
		warning("The hires videos of the DVD version of ZGI aren't supported yet, using lowres");
		//_fileName = hiresFileName;
		//switchToHires = true;
	} else if (!_engine->getSearchManager()->hasFile(_fileName))
		return true;
#else
	if (!_engine->getSearchManager()->hasFile(_fileName))
		return true;
#endif

	decoder = _engine->loadAnimation(_fileName);
	Subtitle *sub = (subtitleExists) ? new Subtitle(_engine, subname, switchToHires) : NULL;

	_engine->getCursorManager()->showMouse(false);

	if (switchToHires) {
		_engine->initHiresScreen();
		destRect = Common::Rect(40, -40, 760, 440);
		Common::Rect workingWindow = _engine->_workingWindow;
		workingWindow.translate(0, -40);
		_engine->getRenderManager()->initSubArea(HIRES_WINDOW_WIDTH, HIRES_WINDOW_HEIGHT, workingWindow);
	}

	_engine->playVideo(*decoder, destRect, _skippable, sub);

	if (switchToHires) {
		_engine->initScreen();
		_engine->getRenderManager()->initSubArea(WINDOW_WIDTH, WINDOW_HEIGHT, _engine->_workingWindow);
	}

	_engine->getCursorManager()->showMouse(true);

	delete decoder;
	delete sub;

	return true;
}
Example #27
0
bool Console::Cmd_DumpArchive(int argc, const char **argv) {
	if (argc != 2) {
		DebugPrintf("Extract all the files from a game archive.\n");
		DebugPrintf("The destination folder, named 'dump', must exist.\n");
		DebugPrintf("Usage :\n");
		DebugPrintf("dumpArchive [file name]\n");
		return true;
	}

	// Is the archive multi-room
	Common::String temp = Common::String(argv[1]);
	temp.toUppercase();

	bool multiRoom = !temp.hasSuffix(".M3A");
	if (!multiRoom) {
		temp = Common::String(argv[1], 4);
		temp.toUppercase();
	}

	Archive archive;
	if (!archive.open(argv[1], multiRoom ? 0 : temp.c_str())) {
		DebugPrintf("Can't open archive with name '%s'\n", argv[1]);
		return true;
	}

	archive.dumpToFiles();
	archive.close();

	return true;
}
Example #28
0
void Sound::playSMFSound(const char *baseSoundName) {
    Common::String soundName = baseSoundName;

    soundName += '.';

    switch (MidiDriver::getMusicType(_midiDevice)) {
    case MT_MT32:
        soundName += "ROL";
        break;
    case MT_PCSPK:
        return; // Not supported...
    default:
        soundName += "ADL";
        break;
    }

    debug(0, "Playing sound \'%s\'\n", soundName.c_str());
    Common::SeekableReadStream *soundStream = _vm->openFile(soundName.c_str());

    byte *soundData = (byte *)malloc(soundStream->size());
    soundStream->read(soundData, soundStream->size());
    _midiParser->loadMusic(soundData, soundStream->size());
    delete soundStream;

    _midiDriver->setTimerCallback(_midiParser, MidiParser::timerCallback);
}
Example #29
0
bool StarTrekEngine::saveGame(int slot, Common::String desc) {
	Common::String filename = getSavegameFilename(slot);
	Common::OutSaveFile *out;

	if (!(out = _saveFileMan->openForSaving(filename))) {
		warning("Can't create file '%s', game not saved", filename.c_str());
		return false;
	} else {
		debug(3, "Successfully opened %s for writing", filename.c_str());
	}

	SavegameMetadata meta;
	meta.version = CURRENT_SAVEGAME_VERSION;
	memset(meta.description, 0, sizeof(meta.description));
	strncpy(meta.description, desc.c_str(), SAVEGAME_DESCRIPTION_LEN);

	TimeDate curTime;
	_system->getTimeAndDate(curTime);
	meta.setSaveTimeAndDate(curTime);
	meta.playTime = g_engine->getTotalPlayTime();

	if (!saveOrLoadMetadata(nullptr, out, &meta)) {
		delete out;
		return false;
	}
	if (!saveOrLoadGameData(nullptr, out, &meta)) {
		delete out;
		return false;
	}

	out->finalize();
	delete out;
	return true;
}
Example #30
0
void PictureMetaEngine::removeSaveState(const char *target, int slot) const {
    // Slot 0 can't be deleted, it's for restarting the game(s)
    if (slot == 0)
        return;

    Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
    Common::String filename = Picture::PictureEngine::getSavegameFilename(target, slot);

    saveFileMan->removeSavefile(filename.c_str());

    Common::StringArray filenames;
    Common::String pattern = target;
    pattern += ".???";
    filenames = saveFileMan->listSavefiles(pattern.c_str());
    Common::sort(filenames.begin(), filenames.end());	// Sort (hopefully ensuring we are sorted numerically..)

    for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
        // Obtain the last 3 digits of the filename, since they correspond to the save slot
        int slotNum = atoi(file->c_str() + file->size() - 3);

        // Rename every slot greater than the deleted slot,
        // Also do not rename quicksaves.
        if (slotNum > slot && slotNum < 990) {
            // FIXME: Our savefile renaming done here is inconsitent with what we do in
            // GUI_v2::deleteMenu. While here we rename every slot with a greater equal
            // number of the deleted slot to deleted slot, deleted slot + 1 etc.,
            // we only rename the following slots in GUI_v2::deleteMenu until a slot
            // is missing.
            saveFileMan->renameSavefile(file->c_str(), filename.c_str());

            filename = Picture::PictureEngine::getSavegameFilename(target, ++slot);
        }
    }

}