示例#1
0
void AdvancedMetaEngine::updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const {
	if (_singleId != NULL) {
		desc["preferredtarget"] = desc["gameid"];
		desc["gameid"] = _singleId;
	}

	if (!desc.contains("preferredtarget"))
		desc["preferredtarget"] = desc["gameid"];

	if (realDesc->flags & ADGF_AUTOGENTARGET) {
		if (*realDesc->extra)
			desc["preferredtarget"] = sanitizeName(realDesc->extra);
	}

	desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc);

	if (_flags & kADFlagUseExtraAsHint)
		desc["extra"] = realDesc->extra;

	desc.setGUIOptions(realDesc->guiOptions + _guiOptions);
	desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language));

	if (realDesc->flags & ADGF_ADDENGLISH)
		desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
}
示例#2
0
文件: util.cpp 项目: bluegr/scummvm
bool checkGameGUIOptionLanguage(Language lang, const String &str) {
	if (!str.contains("lang_")) // If no languages are specified
		return true;

	if (str.contains(getGameGUIOptionsDescriptionLanguage(lang)))
		return true;

	return false;
}
示例#3
0
static void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc, const ADParams &params) {
    if (params.singleid != NULL) {
        desc["preferredtarget"] = desc["gameid"];
        desc["gameid"] = params.singleid;
    }

    if (!(params.flags & kADFlagDontAugmentPreferredTarget)) {
        if (!desc.contains("preferredtarget"))
            desc["preferredtarget"] = desc["gameid"];

        desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc);
    }

    if (params.flags & kADFlagUseExtraAsHint)
        desc["extra"] = realDesc->extra;

    desc.setGUIOptions(realDesc->guioptions | params.guioptions);
    desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language));

    if (realDesc->flags & ADGF_ADDENGLISH)
        desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
}
示例#4
0
Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
    assert(engine);
    upgradeTargetIfNecessary(params);

    const ADGameDescription *agdDesc = 0;
    Common::Language language = Common::UNK_LANG;
    Common::Platform platform = Common::kPlatformUnknown;
    Common::String extra;

    if (ConfMan.hasKey("language"))
        language = Common::parseLanguage(ConfMan.get("language"));
    if (ConfMan.hasKey("platform"))
        platform = Common::parsePlatform(ConfMan.get("platform"));
    if (params.flags & kADFlagUseExtraAsHint)
        if (ConfMan.hasKey("extra"))
            extra = ConfMan.get("extra");

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

    Common::String path;
    if (ConfMan.hasKey("path")) {
        path = ConfMan.get("path");
    } else {
        path = ".";

        // This situation may happen only when game was
        // launched from a command line with wrong target and
        // no path was provided.
        //
        // A dummy entry will get created and will keep game path
        // We mark this entry, so it will not be added to the
        // config file.
        //
        // Fixes bug #1544799
        ConfMan.setBool("autoadded", true);

        warning("No path was provided. Assuming the data files are in the current directory");
    }
    Common::FSNode dir(path);
    Common::FSList files;
    if (!dir.isDirectory() || !dir.getChildren(files, Common::FSNode::kListAll)) {
        warning("Game data path does not exist or is not a directory (%s)", path.c_str());
        return Common::kNoGameDataFoundError;
    }

    ADGameDescList matches = detectGame(files, params, language, platform, extra);

    if (cleanupPirated(matches))
        return Common::kNoGameDataFoundError;

    if (params.singleid == NULL) {
        for (uint i = 0; i < matches.size(); i++) {
            if (matches[i]->gameid == gameid) {
                agdDesc = matches[i];
                break;
            }
        }
    } else if (matches.size() > 0) {
        agdDesc = matches[0];
    }

    if (agdDesc == 0) {
        // Use fallback detector if there were no matches by other means
        agdDesc = fallbackDetect(files);
        if (agdDesc != 0) {
            // Seems we found a fallback match. But first perform a basic
            // sanity check: the gameid must match.
            if (params.singleid == NULL && agdDesc->gameid != gameid)
                agdDesc = 0;
        }
    }

    if (agdDesc == 0)
        return Common::kNoGameDataFoundError;

    // If the GUI options were updated, we catch this here and update them in the users config
    // file transparently.
    Common::String lang = getGameGUIOptionsDescriptionLanguage(agdDesc->language);
    if (agdDesc->flags & ADGF_ADDENGLISH)
        lang += " " + getGameGUIOptionsDescriptionLanguage(Common::EN_ANY);

    Common::updateGameGUIOptions(agdDesc->guioptions | params.guioptions, lang);


    debug(2, "Running %s", toGameDescriptor(*agdDesc, params.list).description().c_str());
    if (!createInstance(syst, engine, agdDesc))
        return Common::kNoGameDataFoundError;
    else
        return Common::kNoError;
}
示例#5
0
Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
	assert(engine);

	const ADGameDescription *agdDesc = 0;
	Common::Language language = Common::UNK_LANG;
	Common::Platform platform = Common::kPlatformUnknown;
	Common::String extra;

	if (ConfMan.hasKey("language"))
		language = Common::parseLanguage(ConfMan.get("language"));
	if (ConfMan.hasKey("platform"))
		platform = Common::parsePlatform(ConfMan.get("platform"));
	if (_flags & kADFlagUseExtraAsHint) {
		if (ConfMan.hasKey("extra"))
			extra = ConfMan.get("extra");
	}

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

	Common::String path;
	if (ConfMan.hasKey("path")) {
		path = ConfMan.get("path");
	} else {
		path = ".";

		// This situation may happen only when game was
		// launched from a command line with wrong target and
		// no path was provided.
		//
		// A dummy entry will get created and will keep game path
		// We mark this entry, so it will not be added to the
		// config file.
		//
		// Fixes bug #1544799
		ConfMan.setBool("autoadded", true);

		warning("No path was provided. Assuming the data files are in the current directory");
	}
	Common::FSNode dir(path);
	Common::FSList files;
	if (!dir.isDirectory() || !dir.getChildren(files, Common::FSNode::kListAll, true)) {
		warning("Game data path does not exist or is not a directory (%s)", path.c_str());
		return Common::kNoGameDataFoundError;
	}

	if (files.empty())
		return Common::kNoGameDataFoundError;

	// Compose a hashmap of all files in fslist.
	FileMap allFiles;
	composeFileHashMap(allFiles, files, (_maxScanDepth == 0 ? 1 : _maxScanDepth));

	// Run the detector on this
	ADGameDescList matches = detectGame(files.begin()->getParent(), allFiles, language, platform, extra);

	if (cleanupPirated(matches))
		return Common::kNoGameDataFoundError;

	if (_singleId == NULL) {
		// Find the first match with correct gameid.
		for (uint i = 0; i < matches.size(); i++) {
			if (matches[i]->gameId == gameid) {
				agdDesc = matches[i];
				break;
			}
		}
	} else if (matches.size() > 0) {
		agdDesc = matches[0];
	}

	if (agdDesc == 0) {
		// Use fallback detector if there were no matches by other means
		agdDesc = fallbackDetect(allFiles, files);
		if (agdDesc != 0) {
			// Seems we found a fallback match. But first perform a basic
			// sanity check: the gameid must match.
			if (_singleId == NULL && agdDesc->gameId != gameid)
				agdDesc = 0;
		}
	}

	if (agdDesc == 0)
		return Common::kNoGameDataFoundError;

	// If the GUI options were updated, we catch this here and update them in the users config
	// file transparently.
	Common::String lang = getGameGUIOptionsDescriptionLanguage(agdDesc->language);
	if (agdDesc->flags & ADGF_ADDENGLISH)
		lang += " " + getGameGUIOptionsDescriptionLanguage(Common::EN_ANY);

	Common::updateGameGUIOptions(agdDesc->guiOptions + _guiOptions, lang);

	GameDescriptor gameDescriptor = toGameDescriptor(*agdDesc, _gameIds);

	bool showTestingWarning = false;

#ifdef RELEASE_BUILD
	showTestingWarning = true;
#endif

	if (((gameDescriptor.getSupportLevel() == kUnstableGame
			|| (gameDescriptor.getSupportLevel() == kTestingGame
					&& showTestingWarning)))
			&& !Engine::warnUserAboutUnsupportedGame())
		return Common::kUserCanceled;

	debug(2, "Running %s", gameDescriptor.description().c_str());
	initSubSystems(agdDesc);
	if (!createInstance(syst, engine, agdDesc))
		return Common::kNoGameDataFoundError;
	else
		return Common::kNoError;
}
示例#6
0
DetectedGames SwordMetaEngine::detectGames(const Common::FSList &fslist) const {
	int i, j;
	DetectedGames detectedGames;
	bool filesFound[NUM_FILES_TO_CHECK];
	for (i = 0; i < NUM_FILES_TO_CHECK; i++)
		filesFound[i] = false;

	Sword1CheckDirectory(fslist, filesFound);
	bool mainFilesFound = true;
	bool pcFilesFound = true;
	bool macFilesFound = true;
	bool demoFilesFound = true;
	bool macDemoFilesFound = true;
	bool psxFilesFound = true;
	bool psxDemoFilesFound = true;
	for (i = 0; i < NUM_COMMON_FILES_TO_CHECK; i++)
		if (!filesFound[i])
			mainFilesFound = false;
	for (j = 0; j < NUM_PC_FILES_TO_CHECK; i++, j++)
		if (!filesFound[i])
			pcFilesFound = false;
	for (j = 0; j < NUM_MAC_FILES_TO_CHECK; i++, j++)
		if (!filesFound[i])
			macFilesFound = false;
	for (j = 0; j < NUM_DEMO_FILES_TO_CHECK; i++, j++)
		if (!filesFound[i])
			demoFilesFound = false;
	for (j = 0; j < NUM_DEMO_FILES_TO_CHECK; i++, j++)
		if (!filesFound[i])
			macDemoFilesFound = false;
	for (j = 0; j < NUM_PSX_FILES_TO_CHECK; i++, j++)
		if (!filesFound[i])
			psxFilesFound = false;
	for (j = 0; j < NUM_PSX_DEMO_FILES_TO_CHECK; i++, j++)
		if (!filesFound[i] || psxFilesFound)
			psxDemoFilesFound = false;

	DetectedGame game;
	if (mainFilesFound && pcFilesFound && demoFilesFound)
		game = DetectedGame(sword1DemoSettings);
	else if (mainFilesFound && pcFilesFound && psxFilesFound)
		game = DetectedGame(sword1PSXSettings);
	else if (mainFilesFound && pcFilesFound && psxDemoFilesFound)
		game = DetectedGame(sword1PSXDemoSettings);
	else if (mainFilesFound && pcFilesFound && !psxFilesFound)
		game = DetectedGame(sword1FullSettings);
	else if (mainFilesFound && macFilesFound)
		game = DetectedGame(sword1MacFullSettings);
	else if (mainFilesFound && macDemoFilesFound)
		game = DetectedGame(sword1MacDemoSettings);
	else
		return detectedGames;

	game.setGUIOptions(GUIO2(GUIO_NOMIDI, GUIO_NOASPECT));

	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::DE_DEU));
	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::FR_FRA));
	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::IT_ITA));
	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::ES_ESP));
	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::PT_BRA));
	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::CZ_CZE));

	detectedGames.push_back(game);

	return detectedGames;
}