Common::Error Sword25Engine::appStart() { // Initialize the graphics mode to ARGB8888 Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24); initGraphics(800, 600, true, &format); if (format != g_system->getScreenFormat()) return Common::kUnsupportedColorMode; // Kernel initialization if (!Kernel::getInstance()->getInitSuccess()) { error("Kernel initialization failed."); return Common::kUnknownError; } // Load packages PackageManager *packageManagerPtr = Kernel::getInstance()->getPackage(); if (getGameFlags() & GF_EXTRACTED) { if (!packageManagerPtr->loadDirectoryAsPackage(ConfMan.get("path"), "/")) return Common::kUnknownError; } else { if (!loadPackages()) return Common::kUnknownError; } // Pass the command line to the script engine. ScriptEngine *scriptPtr = Kernel::getInstance()->getScript(); if (!scriptPtr) { error("Script intialization failed."); return Common::kUnknownError; } // Set the game target for use in savegames setGameTarget(_targetName.c_str()); Common::StringArray commandParameters; scriptPtr->setCommandLine(commandParameters); return Common::kNoError; }
QByteArray GameCFGWidget::getFullConfig() const { QList<QByteArray> bcfg; int mapgen = pMapContainer->get_mapgen(); if (Scripts->currentIndex() > 0) { bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString()).toUtf8(); } QString currentMap = pMapContainer->getCurrentMap(); if (currentMap.size() > 0) { bcfg << QString("emap " + currentMap).toUtf8(); // engine should figure it out on its own // if(pMapContainer->getCurrentIsMission()) // bcfg << QString("escript Maps/%1/map.lua").arg(currentMap).toUtf8(); } bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8(); bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8(); bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8(); bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8(); bcfg << QString("e$turntime %1").arg(schemeData(27).toInt() * 1000).toUtf8(); bcfg << QString("e$sd_turns %1").arg(schemeData(29).toInt()).toUtf8(); bcfg << QString("e$casefreq %1").arg(schemeData(30).toInt()).toUtf8(); bcfg << QString("e$minestime %1").arg(schemeData(31).toInt() * 1000).toUtf8(); bcfg << QString("e$minesnum %1").arg(schemeData(32).toInt()).toUtf8(); bcfg << QString("e$minedudpct %1").arg(schemeData(33).toInt()).toUtf8(); bcfg << QString("e$explosives %1").arg(schemeData(34).toInt()).toUtf8(); bcfg << QString("e$airmines %1").arg(schemeData(35).toInt()).toUtf8(); bcfg << QString("e$healthprob %1").arg(schemeData(36).toInt()).toUtf8(); bcfg << QString("e$hcaseamount %1").arg(schemeData(37).toInt()).toUtf8(); bcfg << QString("e$waterrise %1").arg(schemeData(38).toInt()).toUtf8(); bcfg << QString("e$healthdec %1").arg(schemeData(39).toInt()).toUtf8(); bcfg << QString("e$ropepct %1").arg(schemeData(40).toInt()).toUtf8(); bcfg << QString("e$getawaytime %1").arg(schemeData(41).toInt()).toUtf8(); bcfg << QString("e$worldedge %1").arg(schemeData(42).toInt()).toUtf8(); bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8(); bcfg << QString("e$feature_size %1").arg(pMapContainer->getFeatureSize()).toUtf8(); bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8(); if(!schemeData(43).isNull()) bcfg << QString("e$scriptparam %1").arg(schemeData(43).toString()).toUtf8(); switch (mapgen) { case MAPGEN_MAZE: case MAPGEN_PERLIN: bcfg << QString("e$maze_size %1").arg(pMapContainer->getMazeSize()).toUtf8(); break; case MAPGEN_DRAWN: { QByteArray data = pMapContainer->getDrawnMapData(); while(data.size() > 0) { QByteArray tmp = data; tmp.truncate(200); tmp.prepend("edraw "); bcfg << tmp; data.remove(0, 200); } break; } default: ; } QByteArray result; foreach(QByteArray ba, bcfg) HWProto::addByteArrayToBuffer(result, ba); return result; }
Common::Error GrimEngine::run() { // Try to see if we have the EMI Mac installer present // Currently, this requires the data fork to be standalone if (getGameType() == GType_MONKEY4) { if (SearchMan.hasFile("Monkey Island 4 Installer")) { StuffItArchive *archive = new StuffItArchive(); if (archive->open("Monkey Island 4 Installer")) SearchMan.add("Monkey Island 4 Installer", archive, 0, true); else delete archive; } if (SearchMan.hasFile("EFMI Installer")) { StuffItArchive *archive = new StuffItArchive(); if (archive->open("EFMI Installer")) SearchMan.add("EFMI Installer", archive, 0, true); else delete archive; } } ConfMan.registerDefault("check_gamedata", true); if (ConfMan.getBool("check_gamedata")) { MD5CheckDialog d; if (!d.runModal()) { Common::String confirmString = Common::String::format(_( "ResidualVM found some problems with your game data files.\n" "Running ResidualVM nevertheless may cause game bugs or even crashes.\n" "Do you still want to run %s?"), GType_MONKEY4 == getGameType() ? _("Escape From Monkey Island") : _("Grim Fandango") ); GUI::MessageDialog msg(confirmString, _("Yes"), _("No")); if (!msg.runModal()) { return Common::kUserCanceled; } } ConfMan.setBool("check_gamedata", false); ConfMan.flushToDisk(); } g_resourceloader = new ResourceLoader(); bool demo = getGameFlags() & ADGF_DEMO; if (getGameType() == GType_GRIM) g_movie = CreateSmushPlayer(demo); else if (getGameType() == GType_MONKEY4) { if (_gamePlatform == Common::kPlatformPS2) g_movie = CreateMpegPlayer(); else g_movie = CreateBinkPlayer(demo); } if (getGameType() == GType_GRIM) { g_imuse = new Imuse(20, demo); g_emiSound = nullptr; } else if (getGameType() == GType_MONKEY4) { g_emiSound = new EMISound(20); g_imuse = nullptr; } g_sound = new SoundPlayer(); bool fullscreen = ConfMan.getBool("fullscreen"); g_driver = createRenderer(640, 480, fullscreen); if (getGameType() == GType_MONKEY4 && SearchMan.hasFile("AMWI.m4b")) { // Play EMI Mac Aspyr logo playAspyrLogo(); } Bitmap *splash_bm = nullptr; if (!(_gameFlags & ADGF_DEMO) && getGameType() == GType_GRIM) splash_bm = Bitmap::create("splash.bm"); else if ((_gameFlags & ADGF_DEMO) && getGameType() == GType_MONKEY4) splash_bm = Bitmap::create("splash.til"); else if (getGamePlatform() == Common::kPlatformPS2 && getGameType() == GType_MONKEY4) splash_bm = Bitmap::create("load.tga"); g_driver->clearScreen(); if (splash_bm != nullptr) splash_bm->draw(); // This flipBuffer() may make the OpenGL renderer show garbage instead of the splash, // while the TinyGL renderer needs it. if (_softRenderer) g_driver->flipBuffer(); LuaBase *lua = createLua(); lua->registerOpcodes(); lua->registerLua(); // One version of the demo doesn't set the demo flag in scripts. if (getGameType() == GType_GRIM && _gameFlags & ADGF_DEMO) { lua->forceDemo(); } //Initialize Localizer first. In system-script are already localizeable Strings g_localizer = new Localizer(); lua->loadSystemScript(); lua->boot(); _savegameLoadRequest = false; _savegameSaveRequest = false; // Load game from specified slot, if any if (ConfMan.hasKey("save_slot")) { loadGameState(ConfMan.getInt("save_slot")); } g_grim->setMode(NormalMode); delete splash_bm; g_grim->mainLoop(); return Common::kNoError; }
const char *GrimEngine::getUpdateFilename() { if (!(getGameFlags() & ADGF_DEMO)) return "gfupd101.exe"; else return nullptr; }
Common::Error GrimEngine::run() { // Try to see if we have the EMI Mac installer present // Currently, this requires the data fork to be standalone if (getGameType() == GType_MONKEY4 && SearchMan.hasFile("Monkey Island 4 Installer")) { StuffItArchive *archive = new StuffItArchive(); if (archive->open("Monkey Island 4 Installer")) SearchMan.add("Monkey Island 4 Installer", archive, 0, true); else delete archive; } g_resourceloader = new ResourceLoader(); bool demo = getGameFlags() & ADGF_DEMO; if (getGameType() == GType_GRIM) g_movie = CreateSmushPlayer(demo); else if (getGameType() == GType_MONKEY4) { if (_gamePlatform == Common::kPlatformPS2) g_movie = CreateMpegPlayer(); else g_movie = CreateBinkPlayer(demo); } g_imuse = new Imuse(20, demo); g_sound = new SoundPlayer(); bool fullscreen = g_registry->getBool("fullscreen"); createRenderer(); g_driver->setupScreen(640, 480, fullscreen); if (getGameType() == GType_MONKEY4 && SearchMan.hasFile("AMWI.m4b")) { // TODO: Play EMI Mac Aspyr logo warning("TODO: Play Aspyr logo"); } Bitmap *splash_bm = NULL; if (!(_gameFlags & ADGF_DEMO) && getGameType() == GType_GRIM) splash_bm = Bitmap::create("splash.bm"); else if ((_gameFlags & ADGF_DEMO) && getGameType() == GType_MONKEY4) splash_bm = Bitmap::create("splash.til"); else if (getGamePlatform() == Common::kPlatformPS2 && getGameType() == GType_MONKEY4) splash_bm = Bitmap::create("load.tga"); g_driver->clearScreen(); if (splash_bm != NULL) splash_bm->draw(); // This flipBuffer() may make the OpenGL renderer show garbage instead of the splash, // while the TinyGL renderer needs it. if (_softRenderer) g_driver->flipBuffer(); LuaBase *lua = NULL; if (getGameType() == GType_GRIM) { lua = new Lua_V1(); } else { lua = new Lua_V2(); } lua->registerOpcodes(); lua->registerLua(); lua->loadSystemScript(); g_localizer = new Localizer(); lua->boot(); _savegameLoadRequest = false; _savegameSaveRequest = false; // Load game from specified slot, if any if (ConfMan.hasKey("save_slot")) { loadGameState(ConfMan.getInt("save_slot")); } g_grim->setMode(NormalMode); if (splash_bm) delete splash_bm; g_grim->mainLoop(); return Common::kNoError; }