예제 #1
0
파일: main.cpp 프로젝트: Botje/residualvm
static void setupGraphics(OSystem &system) {

	system.beginGFXTransaction();
		// Set the user specified graphics mode (if any).
		system.setGraphicsMode(ConfMan.get("gfx_mode").c_str());

		system.initSize(320, 200);
		system.launcherInitSize(640, 480); //ResidualVM specific

		if (ConfMan.hasKey("aspect_ratio"))
			system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
		if (ConfMan.hasKey("fullscreen"))
			system.setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
		if (ConfMan.hasKey("filtering"))
			system.setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
	system.endGFXTransaction();

	// When starting up launcher for the first time, the user might have specified
	// a --gui-theme option, to allow that option to be working, we need to initialize
	// GUI here.
	// FIXME: Find a nicer way to allow --gui-theme to be working
	GUI::GuiManager::instance();

	// Set initial window caption
	system.setWindowCaption(gScummVMFullVersion);

	// Clear the main screen
	system.fillScreen(0);
}
예제 #2
0
파일: main.cpp 프로젝트: LasDesu/residualvm
static void setupKeymapper(OSystem &system) {
#ifdef ENABLE_KEYMAPPER
    using namespace Common;

    Keymapper *mapper = system.getEventManager()->getKeymapper();

    HardwareInputSet *inputSet = system.getHardwareInputSet();

    // Query backend for hardware keys and register them
    mapper->registerHardwareInputSet(inputSet);

    // Now create the global keymap
    Keymap *primaryGlobalKeymap = new Keymap(kGlobalKeymapName);
    Action *act;
    act = new Action(primaryGlobalKeymap, "MENU", _("Menu"));
    act->addEvent(EVENT_MAINMENU);

    act = new Action(primaryGlobalKeymap, "SKCT", _("Skip"));
    act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));

    act = new Action(primaryGlobalKeymap, "PAUS", _("Pause"));
    act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0));

    act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line"));
    act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0));

#ifdef ENABLE_VKEYBD
    act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard"));
    act->addEvent(EVENT_VIRTUAL_KEYBOARD);
#endif

    act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys"));
    act->addEvent(EVENT_KEYMAPPER_REMAP);

    act = new Action(primaryGlobalKeymap, "FULS", _("Toggle fullscreen"));
    act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));

    mapper->addGlobalKeymap(primaryGlobalKeymap);
    mapper->pushKeymap(kGlobalKeymapName, true);

    // Get the platform-specific global keymap (if it exists)
    Keymap *platformGlobalKeymap = system.getGlobalKeymap();
    if (platformGlobalKeymap) {
        String platformGlobalKeymapName = platformGlobalKeymap->getName();
        mapper->addGlobalKeymap(platformGlobalKeymap);
        mapper->pushKeymap(platformGlobalKeymapName, true);
    }
#endif

}
예제 #3
0
파일: main.cpp 프로젝트: rkmarvin/scummvm
static void setupKeymapper(OSystem &system) {

#ifdef ENABLE_KEYMAPPER
	using namespace Common;

	Keymapper *mapper = system.getEventManager()->getKeymapper();
	Keymap *globalMap = new Keymap(kGlobalKeymapName);
	Action *act;
	HardwareKeySet *keySet;

	keySet = system.getHardwareKeySet();

	// Query backend for hardware keys and register them
	mapper->registerHardwareKeySet(keySet);

	// Now create the global keymap
	act = new Action(globalMap, "MENU", _("Menu"), kGenericActionType, kSelectKeyType);
	act->addEvent(EVENT_MAINMENU);

	act = new Action(globalMap, "SKCT", _("Skip"), kGenericActionType, kActionKeyType);
	act->addKeyEvent(KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE, 0));

	act = new Action(globalMap, "PAUS", _("Pause"), kGenericActionType, kStartKeyType);
	act->addKeyEvent(KeyState(KEYCODE_SPACE, ' ', 0));

	act = new Action(globalMap, "SKLI", _("Skip line"), kGenericActionType, kActionKeyType);
	act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0));

	act = new Action(globalMap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
	act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));

	act = new Action(globalMap, "REMP", _("Remap keys"), kKeyRemapActionType);
	act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0));

	act = new Action(globalMap, "FULS", _("Toggle FullScreen"), kKeyRemapActionType);
	act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));

	mapper->addGlobalKeymap(globalMap);

	mapper->pushKeymap(kGlobalKeymapName, true);
#endif

}
예제 #4
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::kInvalidPathError;

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

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

		// TODO: An errorDialog for this and engine related errors is displayed already in the scummvm_main function
		// Is a separate dialog here still required?

		//GUI::displayErrorDialog("ScummVM could not find any game in the specified directory!");
		const char *errMsg = _(Common::errorToString(err));

		warning("%s failed to instantiate engine: %s (target '%s', path '%s')",
			plugin->getName(),
			errMsg,
			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
	SearchMan.addDirectory(dir.getPath(), dir, 0, 4);

	// 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.
	if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
		dir = Common::FSNode(ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain));
		SearchMan.addDirectory(dir.getPath(), dir);
	}

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

	// 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();

	// 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;
}
예제 #5
0
파일: main.cpp 프로젝트: LasDesu/residualvm
// 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;
}