Example #1
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 #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
ObjectVerb Object::parseObjectVerb(const Common::String &verb) {
	for (int i = 0; i < kObjectVerbNone; i++)
		if (verb.equalsIgnoreCase(objectVerb[i]))
			return (ObjectVerb) i;

	return kObjectVerbNone;
}
Example #4
0
ThemeEngine::GraphicsMode ThemeEngine::findMode(const Common::String &cfg) {
	for (uint i = 0; i < _rendererModesSize; ++i) {
		if (cfg.equalsIgnoreCase(_rendererModes[i].cfg))
			return _rendererModes[i].mode;
	}

	return kGfxDisabled;
}
Example #5
0
reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) {
	// Hide the cursor if it's showing and then show it again if it was
	// previously visible.
	bool reshowCursor = g_sci->_gfxCursor->isVisible();
	if (reshowCursor)
		g_sci->_gfxCursor->kernelHide();

	uint16 screenWidth = g_system->getWidth();
	uint16 screenHeight = g_system->getHeight();

	Video::VideoDecoder *videoDecoder = 0;

	if (argv[0].getSegment() != 0) {
		Common::String filename = s->_segMan->getString(argv[0]);

		if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
			// Mac QuickTime
			// The only argument is the string for the video

			// HACK: Switch to 16bpp graphics for Cinepak.
			initGraphics(screenWidth, screenHeight, screenWidth > 320, NULL);

			if (g_system->getScreenFormat().bytesPerPixel == 1) {
				warning("This video requires >8bpp color to be displayed, but could not switch to RGB color mode");
				return NULL_REG;
			}

			videoDecoder = new Video::QuickTimeDecoder();
			if (!videoDecoder->loadFile(filename))
				error("Could not open '%s'", filename.c_str());
		} else {
			// DOS SEQ
			// SEQ's are called with no subops, just the string and delay
			// Time is specified as ticks
			videoDecoder = new SEQDecoder(argv[1].toUint16());

			if (!videoDecoder->loadFile(filename)) {
				warning("Failed to open movie file %s", filename.c_str());
				delete videoDecoder;
				videoDecoder = 0;
			}
		}
	} else {
		// Windows AVI
		// TODO: This appears to be some sort of subop. case 0 contains the string
		// for the video, so we'll just play it from there for now.

#ifdef ENABLE_SCI32
		if (getSciVersion() >= SCI_VERSION_2_1) {
			// SCI2.1 always has argv[0] as 1, the rest of the arguments seem to
			// follow SCI1.1/2.
			if (argv[0].toUint16() != 1)
				error("SCI2.1 kShowMovie argv[0] not 1");
			argv++;
			argc--;
		}
#endif
		switch (argv[0].toUint16()) {
		case 0: {
			Common::String filename = s->_segMan->getString(argv[1]);
			videoDecoder = new Video::AVIDecoder();

			if (filename.equalsIgnoreCase("gk2a.avi")) {
				// HACK: Switch to 16bpp graphics for Indeo3.
				// The only known movie to do use this codec is the GK2 demo trailer
				// If another video turns up that uses Indeo, we may have to add a better
				// check.
				initGraphics(screenWidth, screenHeight, screenWidth > 320, NULL);

				if (g_system->getScreenFormat().bytesPerPixel == 1) {
					warning("This video requires >8bpp color to be displayed, but could not switch to RGB color mode");
					return NULL_REG;
				}
			}

			if (!videoDecoder->loadFile(filename.c_str())) {
				warning("Failed to open movie file %s", filename.c_str());
				delete videoDecoder;
				videoDecoder = 0;
			} else {
				s->_videoState.fileName = filename;
			}
			break;
		}
		default:
			warning("Unhandled SCI kShowMovie subop %d", argv[0].toUint16());
		}
	}

	if (videoDecoder) {
		playVideo(videoDecoder, s->_videoState);

		// HACK: Switch back to 8bpp if we played a true color video.
		// We also won't be copying the screen to the SCI screen...
		if (g_system->getScreenFormat().bytesPerPixel != 1)
			initGraphics(screenWidth, screenHeight, screenWidth > 320);
		else {
			g_sci->_gfxScreen->kernelSyncWithFramebuffer();
			g_sci->_gfxPalette->kernelSyncScreenPalette();
		}
	}

	if (reshowCursor)
		g_sci->_gfxCursor->kernelShow();

	return s->r_acc;
}
Example #6
0
// TODO: specify the possible return values here
static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const Common::String &edebuglevels) {
    // Determine the game data path, for validation and error messages
    Common::FSNode dir(ConfMan.get("path"));
    Common::Error err = Common::kNoError;
    Engine *engine = 0;

    // Verify that the game path refers to an actual directory
    if (!(dir.exists() && dir.isDirectory()))
        err = Common::kPathNotDirectory;

    // Create the game engine
    if (err.getCode() == Common::kNoError)
        err = (*plugin)->createInstance(&system, &engine);

    // Check for errors
    if (!engine || err.getCode() != Common::kNoError) {

        // Print a warning; note that scummvm_main will also
        // display an error dialog, so we don't have to do this here.
        warning("%s failed to instantiate engine: %s (target '%s', path '%s')",
                plugin->getName(),
                err.getDesc().c_str(),
                ConfMan.getActiveDomainName().c_str(),
                dir.getPath().c_str()
               );

        // Autoadded is set only when no path was provided and
        // the game is run from command line.
        //
        // Thus, we remove this garbage entry
        //
        // Fixes bug #1544799
        if (ConfMan.hasKey("autoadded")) {
            ConfMan.removeGameDomain(ConfMan.getActiveDomainName().c_str());
        }

        return err;
    }

    // Set the window caption to the game name
    Common::String caption(ConfMan.get("description"));

    if (caption.empty()) {
        caption = EngineMan.findGame(ConfMan.get("gameid")).description();
    }
    if (caption.empty())
        caption = ConfMan.getActiveDomainName();	// Use the domain (=target) name
    if (!caption.empty())	{
        system.setWindowCaption(caption.c_str());
    }

    //
    // Setup various paths in the SearchManager
    //

    // Add the game path to the directory search list
    engine->initializePath(dir);

    // Add extrapath (if any) to the directory search list
    if (ConfMan.hasKey("extrapath")) {
        dir = Common::FSNode(ConfMan.get("extrapath"));
        SearchMan.addDirectory(dir.getPath(), dir);
    }

    // If a second extrapath is specified on the app domain level, add that as well.
    // However, since the default hasKey() and get() check the app domain level,
    // verify that it's not already there before adding it. The search manager will
    // check for that too, so this check is mostly to avoid a warning message.
    if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
        Common::String extraPath = ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain);
        if (!SearchMan.hasArchive(extraPath)) {
            dir = Common::FSNode(extraPath);
            SearchMan.addDirectory(dir.getPath(), dir);
        }
    }

    // On creation the engine should have set up all debug levels so we can use
    // the command line arguments here
    Common::StringTokenizer tokenizer(edebuglevels, " ,");
    while (!tokenizer.empty()) {
        Common::String token = tokenizer.nextToken();
        if (token.equalsIgnoreCase("all"))
            DebugMan.enableAllDebugChannels();
        else if (!DebugMan.enableDebugChannel(token))
            warning(_("Engine does not support debug level '%s'"), token.c_str());
    }

    // Initialize any game-specific keymaps
    engine->initKeymap();

    // Set default values for all of the custom engine options
    const ExtraGuiOptions engineOptions = (*plugin)->getExtraGuiOptions(Common::String());
    for (uint i = 0; i < engineOptions.size(); i++) {
        ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
    }

    // Inform backend that the engine is about to be run
    system.engineInit();

    // Run the engine
    Common::Error result = engine->run();

    // Inform backend that the engine finished
    system.engineDone();

    // Clean up any game-specific keymaps
    engine->deinitKeymap();

    // Free up memory
    delete engine;

    // We clear all debug levels again even though the engine should do it
    DebugMan.clearAllDebugChannels();

    // Reset the file/directory mappings
    SearchMan.clear();

    // Return result (== 0 means no error)
    return result;
}