void LoadThemeGfxLogo(void) { LoadThemeGfx(GFX_LOGO, LOGO_TOP); #if defined LOGO_TEXT_X && defined LOGO_TEXT_Y u32 emunand_state = CheckEmuNand(); DrawStringF(LOGO_TEXT_X, LOGO_TEXT_Y - 0, LOGO_TOP, "SD card: %lluMB/%lluMB & %s", RemainingStorageSpace() / 1024 / 1024, TotalStorageSpace() / 1024 / 1024, (emunand_state == EMUNAND_READY) ? "EmuNAND ready" : (emunand_state == EMUNAND_GATEWAY) ? "GW EmuNAND" : (emunand_state == EMUNAND_REDNAND) ? "RedNAND" : (emunand_state > 3) ? "MultiNAND" : "no EmuNAND"); DrawStringF(LOGO_TEXT_X, LOGO_TEXT_Y - 10, LOGO_TOP, "Game directory: %s", (GetGameDir()) ? GetGameDir() : "(not available)"); DrawStringF(LOGO_TEXT_X, LOGO_TEXT_Y - 20, LOGO_TOP, "Work directory: %s", GetWorkDir()); #endif }
void SourceTASReader::CommonExecuteScript(bool search) { try { Reset(); #if OE const char* dir = y_spt_gamedir.GetString(); if (dir == NULL || dir[0] == '\0') Msg("WARNING: Trying to load a script file without setting the game directory with y_spt_gamedir in old engine!\n"); #endif std::string gameDir = GetGameDir(); scriptStream.open(gameDir + "\\" + fileName + SCRIPT_EXT); if (!scriptStream.is_open()) throw std::exception("File does not exist"); ParseProps(); if (search && searchType == SearchType::None) throw std::exception("In search mode but search property is not set"); else if (!search && searchType != SearchType::None) throw std::exception("Not in search mode but search property is set"); while (!scriptStream.eof()) { if (IsFramesLine()) ParseFrames(); else if (IsVarsLine()) ParseVariables(); else throw std::exception( "Unexpected section order in file. Expected order is props - variables - frames"); } Execute(); } catch (const std::exception& ex) { Msg("Error in line %i: %s!\n", currentLine, ex.what()); } catch (const SearchDoneException&) { Msg("Search done.\n"); variables.PrintBest(); } catch (...) { Msg("Unexpected exception on line %i\n", currentLine); } scriptStream.close(); }
int CMod::WriteToFile(FILE *fp) { fprintf( fp, "\t\t{\n" ); fprintf( fp, "\t\t\tgamedir \"%s\"\n", GetGameDir() ); fprintf( fp, "\t\t\t%i\n", MOD_STATCOUNT ); for ( int i = 0; i < MOD_STATCOUNT; i++ ) { fprintf( fp, "\t\t\t%i %i %i %i\n", stats[ i ].servers, stats[ i ].players, stats[ i ].bots, stats[ i ].bots_servers ); } fprintf( fp, "\t\t}\n" ); return 1; }
void DrawMenu(MenuInfo* currMenu, u32 index, bool fullDraw, bool subMenu) { u32 emunand_state = CheckEmuNand(); bool top_screen = true; u32 menublock_x0 = (((top_screen) ? SCREEN_WIDTH_TOP : SCREEN_WIDTH_BOT) - 30 * FONT_WIDTH_EXT) / 2; u32 menublock_x1 = menublock_x0 - FONT_WIDTH_EXT; u32 menublock_y0 = 40; u32 menublock_y1 = menublock_y0 + currMenu->n_entries * 10; if (fullDraw) { // draw full menu ClearScreenFull(true, !top_screen); DrawStringF(menublock_x0, menublock_y0 - 20, top_screen, "%s", currMenu->name); DrawStringF(menublock_x0, menublock_y0 - 10, top_screen, "=============================="); DrawStringF(menublock_x0, menublock_y1 + 0, top_screen, "=============================="); DrawStringF(menublock_x0, menublock_y1 + 10, top_screen, (subMenu) ? "A: Choose B: Return" : "A: Choose"); DrawStringF(menublock_x0, menublock_y1 + 20, top_screen, "SELECT: Unmount SD Card"); DrawStringF(menublock_x0, menublock_y1 + 30, top_screen, "START: Reboot / [+\x1B] Poweroff"); DrawStringF(menublock_x1, SCREEN_HEIGHT - 20, top_screen, "SD card: %lluMB/%lluMB & %s", RemainingStorageSpace() / 1024 / 1024, TotalStorageSpace() / 1024 / 1024, (emunand_state == EMUNAND_READY) ? "EmuNAND ready" : (emunand_state == EMUNAND_GATEWAY) ? "GW EmuNAND" : (emunand_state == EMUNAND_REDNAND) ? "RedNAND" : (emunand_state > 3) ? "MultiNAND" : "no EmuNAND"); DrawStringF(menublock_x1, SCREEN_HEIGHT - 30, top_screen, "Game directory: %s", (GetGameDir()) ? GetGameDir() : "(not available)"); DrawStringF(menublock_x1, SCREEN_HEIGHT - 40, top_screen, "Work directory: %s", GetWorkDir()); } if (!top_screen) DrawStringF(10, 10, true, "Selected: %-*.*s", 32, 32, currMenu->entries[index].name); for (u32 i = 0; i < currMenu->n_entries; i++) { // draw menu entries / selection [] char* name = currMenu->entries[i].name; DrawStringF(menublock_x0, menublock_y0 + (i*10), top_screen, (i == index) ? "[%s]" : " %s ", name); } }
void LoadBotModels(void) { char game_dir[256]; char path[MAX_PATH]; char search_path[MAX_PATH]; char dirname[MAX_PATH]; char filename[MAX_PATH]; int index; struct stat stat_str; #ifndef __linux__ HANDLE directory = NULL; #else DIR *directory = NULL; #endif for (index=0; index < MAX_SKINS; index++) bot_skins[index].skin_used = FALSE; number_skins = VALVE_MAX_SKINS; if(submod_id == SUBMOD_OP4) number_skins += GEARBOX_MAX_SKINS; for (index=0; index < number_skins; index++) { safe_strcopy(bot_skins[index].model_name, sizeof(bot_skins[index].model_name), default_bot_models[index]); safe_strcopy(bot_skins[index].bot_name, sizeof(bot_skins[index].bot_name), default_bot_names[index]); } // find the directory name of the currently running MOD... GetGameDir (game_dir); safevoid_snprintf(path, sizeof(path), "%s/models/player", game_dir); if (stat(path, &stat_str) != 0) { // use the valve/models/player directory if no MOD models/player strcpy(path, "valve/models/player"); } #ifndef __linux__ safevoid_snprintf(search_path, sizeof(search_path), "%s/*", path); #else strcpy(search_path, path); #endif while ((directory = FindDirectory(directory, dirname, sizeof(dirname), search_path)) != NULL) { if ((strcmp(dirname, ".") == 0) || (strcmp(dirname, "..") == 0)) continue; safevoid_snprintf(filename, sizeof(filename), "%s/%s/%s.mdl", path, dirname, dirname); if (stat(filename, &stat_str) == 0) { // add this model to the array of models... for (index=0; dirname[index]; index++) dirname[index] = tolower(dirname[index]); // check for duplicate... for (index=0; index < number_skins; index++) { if (strcmp(dirname, bot_skins[index].model_name) == 0) break; } if (index == number_skins) { // add this model to the bot_skins array... safe_strcopy(bot_skins[number_skins].model_name, sizeof(bot_skins[number_skins].model_name), dirname); dirname[0] = toupper(dirname[0]); safe_strcopy(bot_skins[number_skins].bot_name, sizeof(bot_skins[number_skins].bot_name), dirname); number_skins++; } } if (number_skins == MAX_SKINS) break; // break out if max models reached } }
u32 InitializeD9() { u32 errorlevel = 0; // 0 -> none, 1 -> autopause, 2 -> critical ClearScreenFull(true, true); DebugClear(); #ifndef BUILD_NAME Debug("-- Decrypt9 --"); #else Debug("-- %s --", BUILD_NAME); #endif // a little bit of information about the current menu if (sizeof(menu)) { u32 n_submenus = 0; u32 n_features = 0; for (u32 m = 0; menu[m].n_entries; m++) { n_submenus = m; for (u32 e = 0; e < menu[m].n_entries; e++) n_features += (menu[m].entries[e].function) ? 1 : 0; } Debug("Counting %u submenus and %u features", n_submenus, n_features); } Debug("Initializing, hold L+R to pause"); Debug(""); if (InitFS()) { Debug("Initializing SD card... success"); FileGetData("d9logo.bin", BOT_SCREEN0, 320 * 240 * 3, 0); memcpy(BOT_SCREEN1, BOT_SCREEN0, 320 * 240 * 3); Debug("Work directory: %s", GetWorkDir()); Debug("Game directory: %s", GetGameDir()); SetupSector0x96Key0x11(); // Sector0x96 key - no effect on error level if (SetupTwlKey0x03() != 0) // TWL KeyX / KeyY errorlevel = 2; if ((GetUnitPlatform() == PLATFORM_N3DS) && (SetupCtrNandKeyY0x05() != 0)) errorlevel = 2; // N3DS CTRNAND KeyY if (LoadKeyFromFile(0x25, 'X', NULL)) // NCCH 7x KeyX errorlevel = (errorlevel < 1) ? 1 : errorlevel; if (GetUnitKeysType() != KEYS_DEVKIT) { // don't even try 0x18 / 0x1B on devkits if (LoadKeyFromFile(0x18, 'X', NULL)) // NCCH Secure3 KeyX errorlevel = (errorlevel < 1) ? 1 : errorlevel; if (LoadKeyFromFile(0x1B, 'X', NULL)) // NCCH Secure4 KeyX errorlevel = (errorlevel < 1) ? 1 : errorlevel; } Debug("Finalizing Initialization..."); RemainingStorageSpace(); } else { Debug("Initializing SD card... failed"); errorlevel = 2; } Debug(""); Debug("Initialization: %s", (errorlevel == 0) ? "success!" : (errorlevel == 1) ? "partially failed" : "failed!"); if (((~HID_STATE & BUTTON_L1) && (~HID_STATE & BUTTON_R1)) || (errorlevel > 1)) { Debug("(A to %s)", (errorlevel > 1) ? "exit" : "continue"); while (!(InputWait() & BUTTON_A)); } return errorlevel; }
void Settings::load() { const char* settingsFile = "CONFIG:config.py"; try{ main = python::import("__main__"); python::object global = main.attr("__dict__"); local = python::dict(); if (ResMan::Instance()->exists(settingsFile)) { //TODO: Handle missing values python::object result = python::exec_file(ResMan::Instance()->getRealPath(settingsFile).c_str(), global, local); m_dataDir = python::extract<std::string>(local["config"]["data_dir"]); m_debug = python::extract<int>(local["config"]["debug"]); m_gameSpeed = python::extract<int>(local["config"]["game_speed"]); m_gameDir = python::extract<std::string>(local["config"]["game_dir"]); m_playIntro = python::extract<bool>(local["config"]["play_intro"]); m_resolution.x = python::extract<int>(local["config"]["graphics"]["width"]); m_resolution.y = python::extract<int>(local["config"]["graphics"]["height"]); m_fullscreen = python::extract<bool>(local["config"]["graphics"]["fullscreen"]); m_doubleBuffered = python::extract<bool>(local["config"]["graphics"]["double_buffered"]); m_soundOn = python::extract<bool>(local["config"]["sound"]["sound_on"]); m_sfxVolume = python::extract<int>(local["config"]["sound"]["sound_volume"]); m_responseVolume = python::extract<int>(local["config"]["sound"]["response_volume"]); m_voiceVolume = python::extract<int>(local["config"]["sound"]["voice_volume"]); m_musicOn = python::extract<bool>(local["config"]["sound"]["music_on"]); m_musicVolume = python::extract<int>(local["config"]["sound"]["music_volume"]); m_emuOpl = python::extract<int>(local["config"]["sound"]["opl_emulator"]); } else { python::exec("config = {'graphics' : dict(), 'sound' : dict()}", global, local); local["config"]["data_dir"] = m_dataDir = "DUNE2"; local["config"]["debug"] = m_debug = 8; local["config"]["game_speed"] = m_gameSpeed = 4; local["config"]["game_dir"] = m_gameDir = GAME_DIR; local["config"]["play_intro"] = m_playIntro = false; local["config"]["graphics"]["width"] = m_resolution.x = 640; local["config"]["graphics"]["height"] = m_resolution.y = 480; local["config"]["graphics"]["fullscreen"] = m_fullscreen = false; local["config"]["graphics"]["double_buffered"] = m_doubleBuffered = true; local["config"]["sound"]["sound_on"] = m_soundOn = true; local["config"]["sound"]["sound_volume"] = m_sfxVolume = MIX_MAX_VOLUME/2; local["config"]["sound"]["response_volume"] = m_responseVolume = 100; local["config"]["sound"]["voice_volume"] = m_voiceVolume = 128; local["config"]["sound"]["music_on"] = m_musicOn = true; local["config"]["sound"]["music_volume"] = m_musicVolume = MIX_MAX_VOLUME/2; local["config"]["sound"]["opl_emulator"] = m_emuOpl = (int)CT_EMUOPL; m_updated = true; } boost::filesystem::path pythonData(GetGameDir()); pythonData /= "python"; char *pyPath = Py_GetPath(); std::string pythonPath = pythonData.string() + #ifdef _WIN32 ";" #else ":" #endif + pyPath; PySys_SetPath((char*)pythonPath.c_str()); free(pyPath); save(); } catch(python::error_already_set const &) { PyErr_Print(); exit(EXIT_FAILURE); } #ifndef LOG_DISABLED Log::Instance()->setDefaultVerbosity(LogVerbosity(m_debug)); #endif /* if (configFile->exists("log_verbosity")) { Setting& node = configFile->lookup(".log_verbosity"); for (int j = 0; j < node.getLength(); j++) { std::string logSystem = node[j][0]; int logVerbosity = node[j][1]; Log::Instance()->setVerbosity(logSystem, (LogVerbosity)logVerbosity); } }*/ // Log::Instance()->setVerbosity("UnitClass", LV_MAX); // Log::Instance()->setVerbosity("ObjectClass", LV_MAX); // Log::Instance()->setVerbosity("TerrainClass", LV_MAX); // Log::Instance()->setVerbosity("MapClass", LV_MAX); /* root = configFile::loadFile((const char *)data); std::string config = ResMan::Instance()->readText("CONFIG:config.txt"); printf("%s\n", config.c_str()); config += "newline\n"; ResMan::Instance()->writeText("CONFIG:config.txt", config); */ }