Exemplo n.º 1
0
ResourceLoader::ResourceLoader() {
	_cacheDirty = false;
	_cacheMemorySize = 0;

	Lab *l;
	Common::ArchiveMemberList files, updFiles;

	if (g_grim->getGameType() == GType_GRIM) {
		if (g_grim->getGameFlags() & ADGF_DEMO) {
			SearchMan.listMatchingMembers(files, "gfdemo01.lab");
			SearchMan.listMatchingMembers(files, "grimdemo.mus");
			SearchMan.listMatchingMembers(files, "sound001.lab");
			SearchMan.listMatchingMembers(files, "voice001.lab");
		} else {
			//Load the update from the executable
			Common::File *updStream = new Common::File();
			if (updStream && updStream->open("gfupd101.exe")) {
				Common::Archive *update = loadUpdateArchive(updStream);
				if (update)
					SearchMan.add("update", update, 1);
			} else
				delete updStream;

			if (!SearchMan.hasFile("residualvm-grim-patch.lab"))
				error("residualvm-grim-patch.lab not found");

			SearchMan.listMatchingMembers(files, "residualvm-grim-patch.lab");
			SearchMan.listMatchingMembers(files, "data???.lab");
			SearchMan.listMatchingMembers(files, "movie??.lab");
			SearchMan.listMatchingMembers(files, "vox????.lab");
			SearchMan.listMatchingMembers(files, "year?mus.lab");
			SearchMan.listMatchingMembers(files, "local.lab");
			SearchMan.listMatchingMembers(files, "credits.lab");

			//Sort the archives in order to ensure that they are loaded with the correct order
			Common::sort(files.begin(), files.end(), LabListComperator());

			//Check the presence of datausr.lab and ask the user if he wants to load it.
			//In this case put it in the top of the list
			Common::ArchiveMemberList::iterator datausr_it = Common::find_if(files.begin(), files.end(), LabListComperator("datausr.lab"));
			if (datausr_it != files.end()) {
				Grim::InputDialog d("User-patch detected, the ResidualVM-team\n provides no support for using such patches.\n Click OK to load, or Cancel\n to skip the patch.", "OK", false);
				int res = d.runModal();
				if (res == GUI::kMessageOK)
					files.push_front(*datausr_it);
				files.erase(datausr_it);
			}
		}
	} else if (g_grim->getGameType() == GType_MONKEY4) {
		if (g_grim->getGameFlags() == ADGF_DEMO) {
			SearchMan.listMatchingMembers(files, "i9n.lab");
			SearchMan.listMatchingMembers(files, "lip.lab");
			SearchMan.listMatchingMembers(files, "MagDemo.lab");
			SearchMan.listMatchingMembers(files, "tile.lab");
			SearchMan.listMatchingMembers(files, "voice.lab");
		} else {
			if (g_grim->getGamePlatform() == Common::kPlatformWindows) {
				//Load the update from the executable
				SearchMan.listMatchingMembers(updFiles, "MonkeyUpdate.exe");
				SearchMan.listMatchingMembers(updFiles, "MonkeyUpdate_???.exe");
				for (Common::ArchiveMemberList::const_iterator x = updFiles.begin(); x != updFiles.end(); ++x) {
					Common::SeekableReadStream *updStream;
					updStream = (*x)->createReadStream();

					Common::Archive *update = loadUpdateArchive(updStream);
					if (update)
						SearchMan.add("update", update, 1);
				}
			}

			SearchMan.listMatchingMembers(files, "patch.m4b");
			SearchMan.listMatchingMembers(files, "i9n.m4b");
			SearchMan.listMatchingMembers(files, "art???.m4b");
			SearchMan.listMatchingMembers(files, "lip.m4b");
			SearchMan.listMatchingMembers(files, "local.m4b");
			SearchMan.listMatchingMembers(files, "sfx.m4b");
			SearchMan.listMatchingMembers(files, "voice???.m4b");
			SearchMan.listMatchingMembers(files, "music?.m4b");
		}
	}

	if (files.empty())
		error("Cannot find game data - check configuration file");

	//load labs
	int priority = files.size();
	for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
		Common::String filename = (*x)->getName();
		filename.toLowercase();

		//Avoid duplicates
		if (_files.hasArchive(filename))
			continue;

		l = new Lab();
		if (l->open(filename))
			_files.add(filename, l, priority--, true);
		else
			delete l;
	}

	files.clear();
}
Exemplo n.º 2
0
ResourceLoader::ResourceLoader() {
    _cacheDirty = false;
    _cacheMemorySize = 0;

    Lab *l;
    Common::ArchiveMemberList files, updFiles;

    if (g_grim->getGameType() == GType_GRIM) {
        if (g_grim->getGameFlags() & ADGF_DEMO) {
            SearchMan.listMatchingMembers(files, "gfdemo01.lab");
            SearchMan.listMatchingMembers(files, "grimdemo.mus");
            SearchMan.listMatchingMembers(files, "sound001.lab");
            SearchMan.listMatchingMembers(files, "voice001.lab");
        } else {
            //Load the update from the executable
            Common::File *updStream = new Common::File();
            if (updStream && updStream->open("gfupd101.exe")) {
                Common::Archive *update = loadUpdateArchive(updStream);
                if (update)
                    SearchMan.add("update", update, 1);
            } else
                delete updStream;

            if (!SearchMan.hasFile("residualvm-grim-patch.lab"))
                error("residualvm-grim-patch.lab not found");

            SearchMan.listMatchingMembers(files, "residualvm-grim-patch.lab");
            SearchMan.listMatchingMembers(files, "data005.lab");
            SearchMan.listMatchingMembers(files, "data004.lab");
            SearchMan.listMatchingMembers(files, "data003.lab");
            SearchMan.listMatchingMembers(files, "data002.lab");
            SearchMan.listMatchingMembers(files, "data001.lab");
            SearchMan.listMatchingMembers(files, "data000.lab");
            SearchMan.listMatchingMembers(files, "movie??.lab");
            SearchMan.listMatchingMembers(files, "vox????.lab");
            SearchMan.listMatchingMembers(files, "year?mus.lab");
            SearchMan.listMatchingMembers(files, "local.lab");
            SearchMan.listMatchingMembers(files, "credits.lab");

            //Sort the archives in order to ensure that they are loaded with the correct order
            Common::sort(files.begin(), files.end(), LabListComperator());

            //Check the presence of datausr.lab and if the user wants to load it.
            //In this case put it in the top of the list
            const char *datausr_name = "datausr.lab";
            if (SearchMan.hasFile(datausr_name) && ConfMan.getBool("datausr_load")) {
                warning("Loading datausr.lab. Please note that the ResidualVM-team doesn't provide support for using such patches");
                files.push_front(SearchMan.getMember(datausr_name));
            }
        }
    } else if (g_grim->getGameType() == GType_MONKEY4) {
        if (g_grim->getGameFlags() & ADGF_DEMO) {
            SearchMan.listMatchingMembers(files, "i9n.lab");
            SearchMan.listMatchingMembers(files, "lip.lab");
            SearchMan.listMatchingMembers(files, "MagDemo.lab");
            SearchMan.listMatchingMembers(files, "tile.lab");
            SearchMan.listMatchingMembers(files, "voice.lab");
        } else {
            if (g_grim->getGamePlatform() == Common::kPlatformWindows) {
                //Load the update from the executable
                SearchMan.listMatchingMembers(updFiles, "MonkeyUpdate.exe");
                SearchMan.listMatchingMembers(updFiles, "MonkeyUpdate_???.exe");
                for (Common::ArchiveMemberList::const_iterator x = updFiles.begin(); x != updFiles.end(); ++x) {
                    Common::SeekableReadStream *updStream;
                    updStream = (*x)->createReadStream();

                    Common::Archive *update = loadUpdateArchive(updStream);
                    if (update)
                        SearchMan.add("update", update, 1);
                }
            }

            SearchMan.listMatchingMembers(files, "patch.m4b");
            SearchMan.listMatchingMembers(files, "i9n.m4b");
            SearchMan.listMatchingMembers(files, "art???.m4b");
            SearchMan.listMatchingMembers(files, "lip.m4b");
            SearchMan.listMatchingMembers(files, "local.m4b");
            SearchMan.listMatchingMembers(files, "sfx.m4b");
            SearchMan.listMatchingMembers(files, "voice???.m4b");
            SearchMan.listMatchingMembers(files, "music?.m4b");

            if (g_grim->getGamePlatform() == Common::kPlatformPS2) {
                SearchMan.listMatchingMembers(files, "???.m4b");
            }

            //Check the presence of datausr.m4b and if the user wants to load it.
            //In this case put it in the top of the list
            const char *datausr_name = "datausr.m4b";
            if (SearchMan.hasFile(datausr_name) && ConfMan.getBool("datausr_load")) {
                warning("Loading datausr.m4b. Please note that the ResidualVM-team doesn't provide support for using such patches");
                files.push_front(SearchMan.getMember(datausr_name));
            }
        }
    }

    // Check if the update has correctly loaded
    if (!(g_grim->getGameFlags() & ADGF_DEMO || SearchMan.hasArchive("update"))) {
        const char *errorMessage = 0;
        if (g_grim->getGameType() == GType_GRIM) {
            errorMessage =  "Unsupported version of Grim Fandango.\n"
                            "Please download the original patch from\n"
                            "http://www.residualvm.org/downloads/\n"
                            "and put it in the game data files directory";
            GUI::displayErrorDialog(errorMessage);
            error("gfupd101.exe not found");
        }

        //Don't force the update for MI4 for now
        /*else if (g_grim->getGameType() == GType_MONKEY4)
            errorMessage =  "Unsupported version of Escape from Monkey Island.\n"
                            "Please download the original patch from\n"
                            "http://www.residualvm.org/downloads/\n"
                            "and put it in the game data files directory.\n"
                            "Pay attention to download the correct version according to the game's language";
        */
    }

    if (files.empty())
        error("Cannot find game data - check configuration file");

    //load labs
    int priority = files.size();
    for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
        Common::String filename = (*x)->getName();
        filename.toLowercase();

        //Avoid duplicates
        if (SearchMan.hasArchive(filename))
            continue;

        l = new Lab();
        if (l->open(filename))
            SearchMan.add(filename, l, priority--, true);
        else
            delete l;
    }

    files.clear();
}