KeyboardMenu::KeyboardMenu(InputManager& input_manager) : m_input_manager(input_manager) { add_label(_("Setup Keyboard")); add_hl(); add_controlfield(Controller::UP, _("Up")); add_controlfield(Controller::DOWN, _("Down")); add_controlfield(Controller::LEFT, _("Left")); add_controlfield(Controller::RIGHT, _("Right")); add_controlfield(Controller::JUMP, _("Jump")); add_controlfield(Controller::ACTION, _("Action")); add_controlfield(Controller::PEEK_LEFT, _("Peek Left")); add_controlfield(Controller::PEEK_RIGHT, _("Peek Right")); add_controlfield(Controller::PEEK_UP, _("Peek Up")); add_controlfield(Controller::PEEK_DOWN, _("Peek Down")); if (g_config->developer_mode) { add_controlfield(Controller::CONSOLE, _("Console")); } if (g_config->developer_mode) { add_controlfield(Controller::CHEAT_MENU, _("Cheat Menu")); } add_hl(); add_inactive(_("The following feature is deprecated.")); // l10n: Continuation of string "The following feature is deprecated." add_inactive(_("It will be removed from the next release")); // l10n: Continuation of string "It will be removed from the next release" add_inactive(_("of SuperTux.")); add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), &g_config->keyboard_config.jump_with_up_kbd); add_hl(); add_back(_("Back")); refresh(); }
EditorSectorMenu::EditorSectorMenu() : sector(Editor::current()->currentsector), sector_name_ptr(sector->get_name_ptr()), original_name(*sector_name_ptr), size(sector->get_editor_size()), new_size(size) { add_label(_("Sector") + " " + sector->get_name()); add_hl(); add_textfield(_("Name"), sector_name_ptr); add_script(_("Initialization script"), sector->get_init_script_ptr()); add_color(_("Ambient light"), sector->get_ambient_light_ptr()); add_numfield(_("Gravity"), §or->gravity); std::vector<std::string> music_formats; music_formats.push_back(".ogg"); music_formats.push_back(".music"); add_file(_("Music"), §or->music, music_formats); add_hl(); add_intfield(_("Width"), &(new_size.width)); add_intfield(_("Height"), &(new_size.height)); add_entry(MNID_RESIZESECTOR, _("Resize")); add_hl(); add_back(_("OK")); }
KeyboardMenu::KeyboardMenu(InputManager& input_manager) : m_input_manager(input_manager) { add_label(_("Setup Keyboard")); add_hl(); add_controlfield(Controller::UP, _("Up")); add_controlfield(Controller::DOWN, _("Down")); add_controlfield(Controller::LEFT, _("Left")); add_controlfield(Controller::RIGHT, _("Right")); add_controlfield(Controller::JUMP, _("Jump")); add_controlfield(Controller::ACTION, _("Action")); add_controlfield(Controller::PEEK_LEFT, _("Peek Left")); add_controlfield(Controller::PEEK_RIGHT, _("Peek Right")); add_controlfield(Controller::PEEK_UP, _("Peek Up")); add_controlfield(Controller::PEEK_DOWN, _("Peek Down")); if (g_config->developer_mode || g_config->console_enabled) { add_controlfield(Controller::CONSOLE, _("Console")); } if (g_config->developer_mode) { add_controlfield(Controller::CHEAT_MENU, _("Cheat Menu")); } add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), &g_config->keyboard_config.jump_with_up_kbd); add_hl(); add_back(_("Back")); refresh(); }
WorldmapMenu::WorldmapMenu() { add_label(_("Pause")); add_hl(); add_entry(MNID_RETURNWORLDMAP, _("Continue")); add_submenu(_("Options"), MenuStorage::INGAME_OPTIONS_MENU); add_hl(); add_entry(MNID_QUITWORLDMAP, _("Leave World")); }
EditorMenu::EditorMenu() { add_label(_("Level Editor")); add_hl(); add_entry(MNID_RETURNTOEDITOR, _("Return to editor")); add_entry(MNID_SAVELEVEL, _("Save current level")); add_entry(MNID_LEVELSEL, _("Edit another level")); add_entry(MNID_LEVELSETSEL, _("Choose another level subset")); add_hl(); add_entry(MNID_QUITEDITOR, _("Exit level editor")); }
void JoystickMenu::recreate_menu() { clear(); add_label(_("Setup Joystick")); add_hl(); add_toggle(MNID_AUTO_JOYSTICK_CFG, _("Manual Configuration"), &m_auto_joystick_cfg) .set_help(_("Use manual configuration instead of SDL2's automatic GameController support")); if (m_input_manager.use_game_controller()) { m_joysticks_available = false; } else { if (m_input_manager.joystick_manager->get_num_joysticks() > 0) { m_joysticks_available = true; add_controlfield(static_cast<int>(Control::UP), _("Up")); add_controlfield(static_cast<int>(Control::DOWN), _("Down")); add_controlfield(static_cast<int>(Control::LEFT), _("Left")); add_controlfield(static_cast<int>(Control::RIGHT), _("Right")); add_controlfield(static_cast<int>(Control::JUMP), _("Jump")); add_controlfield(static_cast<int>(Control::ACTION), _("Action")); add_controlfield(static_cast<int>(Control::START), _("Pause/Menu")); add_controlfield(static_cast<int>(Control::PEEK_LEFT), _("Peek Left")); add_controlfield(static_cast<int>(Control::PEEK_RIGHT), _("Peek Right")); add_controlfield(static_cast<int>(Control::PEEK_UP), _("Peek Up")); add_controlfield(static_cast<int>(Control::PEEK_DOWN), _("Peek Down")); if (g_config->developer_mode) { add_controlfield(static_cast<int>(Control::CONSOLE), _("Console")); } if (g_config->developer_mode) { add_controlfield(static_cast<int>(Control::CHEAT_MENU), _("Cheat Menu")); add_controlfield(static_cast<int>(Control::DEBUG_MENU), _("Debug Menu")); } add_toggle(MNID_JUMP_WITH_UP, _("Jump with Up"), &g_config->joystick_config.m_jump_with_up_joy); } else { m_joysticks_available = false; add_inactive(_("No Joysticks found")); add_entry(MNID_SCAN_JOYSTICKS, _("Scan for Joysticks")); } } add_hl(); add_back(_("Back")); refresh(); }
GameMenu::GameMenu() { Level* level = GameSession::current()->get_current_level(); add_label(level->name); add_hl(); add_entry(MNID_CONTINUE, _("Continue")); add_entry(MNID_RESETLEVEL, _("Restart Level")); add_submenu(_("Options"), MenuStorage::INGAME_OPTIONS_MENU); add_hl(); add_entry(MNID_ABORTLEVEL, _("Abort Level")); }
OptionsMenu::OptionsMenu() { add_label(_("Options")); add_hl(); add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen); add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled); add_toggle(MNID_MUSIC, _("Music"), config->music_enabled); add_submenu(_("Setup Keys"), main_controller->get_key_options_menu()); add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu()); add_hl(); add_back(_("Back")); }
void EditorLevelsetMenu::initialize() { levelset_type = world->m_is_levelset ? 1 : 0; add_label(_("Level subset properties")); add_hl(); add_textfield(_("Name"), &(world->m_title)); add_textfield(_("Description"), &(world->m_description)); add_string_select(1, _("Type"), &levelset_type, {_("Worldmap"), _("Levelset")}); add_hl(); add_back(_("OK")); }
EditorTilegroupMenu::EditorTilegroupMenu() { add_label(_("Tilegroups")); add_hl(); int id = 0; for(auto& tg : Editor::current()->tileset->tilegroups) { add_entry(id, tg.name); id++; } add_hl(); add_entry(-1,_("Cancel")); }
ColorMenu::ColorMenu(Color* color_) : color(color_) { add_label(_("Mix the colour")); add_hl(); add_colorchannel( &(color->red), Color(1.0f, 0.0f, 0.0f)); add_colorchannel( &(color->green), Color(0.0f, 1.0f, 0.0f)); add_colorchannel( &(color->blue), Color(0.0f, 0.0f, 1.0f)); add_colorchannel( &(color->alpha), Color(0.0f, 0.0f, 0.0f)); add_colordisplay(color); add_hl(); add_back(_("OK")); }
EditorTilegroupMenu::EditorTilegroupMenu() { add_label(_("Tilegroups")); add_hl(); int id = 0; for(auto i = Editor::current()->level->tileset->tilegroups.begin(); i != Editor::current()->level->tileset->tilegroups.end(); ++i) { Tilegroup* tg = &(*i); add_entry(id, tg->name); id++; } add_hl(); add_entry(-1,_("Abort")); }
void update_var(WINDOW *win, char *var, size_t off, size_t var_len, unsigned *hl, int color) { size_t li; size_t co; size_t start; size_t l_line; li = off / 16; co = off % 16; start = off; if (hl) add_hl(hl, off, var_len); off = 0; while (off < var_len) { /*l_line = (var_len - off + start) / 16 ? 16 : (var_len - off + start % 16); */ l_line = 1; co = (off + start) % 16; li = (off + start) / 16; axdump_dword(win, var + off, li, co, l_line, color); off += l_line; } prefresh(win, 0, 0, WIN_BORDER_LEN, WIN_BORDER_LEN, WIN_STACK_LI, WIN_STACK_CO); }
void EditorLevelsetMenu::initialize() { add_label(_("Level subset properties")); add_hl(); add_textfield(_("Name"), &(world->m_title)); add_textfield(_("Description"), &(world->m_description)); std::string worldmap_file = FileSystem::join(world->get_basedir(), "worldmap.stwm"); if (PHYSFS_exists(worldmap_file.c_str())) { add_toggle(-1, _("Do not use worldmap"), &(world->m_is_levelset)); add_entry(MNID_EDITWORLDMAP, _("Edit worldmap")); } else { add_entry(MNID_NEWWORLDMAP, _("Create worldmap")); } add_hl(); add_back(_("OK")); }
LanguageMenu::LanguageMenu() { add_label(_("Language")); add_hl(); add_entry(MNID_LANGUAGE_AUTO_DETECT, _("<auto-detect>")); add_entry(MNID_LANGUAGE_ENGLISH, "English"); int mnid = MNID_LANGUAGE_NEXT; std::set<tinygettext::Language> languages = dictionary_manager->get_languages(); for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++) { add_entry(mnid++, i->get_name()); } add_hl(); add_back(_("Back")); }
EditorSectorsMenu::EditorSectorsMenu() { add_label(_("Choose sector to edit:")); add_hl(); int id = 0; for (const auto& sector : Editor::current()->get_level()->m_sectors) { add_entry(id, sector->get_name()); id++; } add_hl(); add_submenu(_("Sector settings..."), MenuStorage::EDITOR_SECTOR_MENU); add_entry(-2,_("Create new sector")); add_entry(-3,_("Delete this sector")); add_entry(-4,_("Cancel")); }
EditorMenu::EditorMenu() { bool worldmap = Editor::current()->get_worldmap_mode(); bool is_world = Editor::current()->get_world(); std::vector<std::string> snap_grid_sizes; snap_grid_sizes.push_back(_("1/8 tile (4px)")); snap_grid_sizes.push_back(_("1/4 tile (8px)")); snap_grid_sizes.push_back(_("1/2 tile (16px)")); snap_grid_sizes.push_back(_("1 tile (32px)")); add_label(_("Level Editor")); add_hl(); add_entry(MNID_RETURNTOEDITOR, _("Return to editor")); add_entry(MNID_SAVELEVEL, worldmap ? _("Save current worldmap") : _("Save current level")); if (!worldmap) { add_entry(MNID_TESTLEVEL, _("Test the level")); } else { add_entry(MNID_TESTLEVEL, _("Test the worldmap")); } if (is_world) { add_entry(MNID_LEVELSEL, _("Edit another level")); } add_entry(MNID_LEVELSETSEL, _("Choose another level subset")); add_string_select(-1, _("Grid size"), &EditorInputCenter::selected_snap_grid_size, snap_grid_sizes); add_toggle(-1, _("Render lighting (F6)"), &DrawingContext::render_lighting); add_toggle(-1, _("Snap objects to grid (F7)"), &EditorInputCenter::snap_to_grid); add_toggle(-1, _("Show grid (F8)"), &EditorInputCenter::render_grid); add_toggle(-1, _("Render background"), &EditorInputCenter::render_background); add_toggle(-1, _("Show scroller (F9)"), &EditorScroller::rendered); add_submenu(worldmap ? _("Worldmap properties") : _("Level properties"), MenuStorage::EDITOR_LEVEL_MENU); add_hl(); add_entry(MNID_QUITEDITOR, _("Exit level editor")); }
void BadguySelectMenu::refresh_menu() { items.clear(); add_label(_("List of enemies")); add_hl(); add_string_select(-2, _("Enemy"), &selected, all_badguys); add_entry(-3, _("Add")); add_hl(); int i = 0; for (auto& badguy : *badguys) { add_entry(i, badguy); i++; } add_hl(); add_back(_("OK")); }
EditorLevelMenu::EditorLevelMenu() : old_tileset(Editor::current()->get_level()->m_tileset) { bool worldmap = Editor::current()->get_worldmap_mode(); auto level = Editor::current()->get_level(); add_label(worldmap ? _("Worldmap properties") :_("Level properties")); add_hl(); add_textfield(_("Name"), &(level->m_name)); add_textfield(_("Author"), &(level->m_author)); add_textfield(_("Contact"), &(level->m_contact)); add_textfield(_("License"), &(level->m_license)); add_file(_("Tileset"), &(level->m_tileset), std::vector<std::string>(1, ".strf")); if (!worldmap) { add_numfield(_("Target time"), &(level->m_target_time)); } add_hl(); add_back(_("OK")); }
CheatMenu::CheatMenu() { std::vector<Player*> players = Sector::get().get_players(); auto player = players.empty() ? nullptr : players[0]; add_label(_("Cheats")); add_hl(); add_entry(MNID_GROW, _("Bonus: Grow")); add_entry(MNID_FIRE, _("Bonus: Fire")); add_entry(MNID_ICE, _("Bonus: Ice")); add_entry(MNID_AIR, _("Bonus: Air")); add_entry(MNID_EARTH, _("Bonus: Earth")); add_entry(MNID_STAR, _("Bonus: Star")); add_entry(MNID_SHRINK, _("Shrink Tux")); add_entry(MNID_KILL, _("Kill Tux")); add_entry(MNID_FINISH, _("Finish Level")); add_entry(MNID_GHOST, (player != nullptr && player->get_ghost_mode()) ? _("Leave Ghost Mode") : _("Activate Ghost Mode")); add_hl(); add_back(_("Back")); }
void EditorLevelSelectMenu::initialize() { auto editor = Editor::current(); auto basedir = m_world->get_basedir(); editor->deactivate_request = true; m_levelset = std::unique_ptr<Levelset>(new Levelset(basedir)); add_label(m_world->get_title()); add_hl(); for (int i = 0; i < m_levelset->get_num_levels(); ++i) { std::string filename = m_levelset->get_level_filename(i); std::string full_filename = FileSystem::join(basedir, filename); std::string title = GameManager::current()->get_level_name(full_filename); add_entry(i, title); } add_hl(); add_entry(-1, _("Create Level")); add_entry(-3, _("Level subset properties")); add_back(_("Back"),-2); }
ContribLevelsetMenu::ContribLevelsetMenu(std::unique_ptr<World> world) : m_world(std::move(world)), m_levelset() { assert(m_world->is_levelset()); m_levelset = std::unique_ptr<Levelset>(new Levelset(m_world->get_basedir())); auto savegame = Savegame::from_file(m_world->get_savegame_filename()); LevelsetState state = savegame->get_levelset_state(m_world->get_basedir()); add_label(m_world->get_title()); add_hl(); for (int i = 0; i < m_levelset->get_num_levels(); ++i) { std::string filename = m_levelset->get_level_filename(i); std::string full_filename = FileSystem::join(m_world->get_basedir(), filename); std::string title = LevelParser::get_level_name(full_filename); LevelState level_state = state.get_level_state(filename); std::ostringstream out; if (level_state.solved) { out << title << " [*]"; } else { out << title << " [ ]"; } add_entry(i, out.str()); } add_hl(); add_back(_("Back")); }
OptionsMenu::OptionsMenu(bool complete) : next_magnification(0), next_aspect_ratio(0), next_resolution(0), magnifications(), aspect_ratios(), resolutions() { add_label(_("Options")); add_hl(); magnifications.clear(); // These values go from screen:640/projection:1600 to // screen:1600/projection:640 (i.e. 640, 800, 1024, 1280, 1600) magnifications.push_back(_("auto")); magnifications.push_back("40%"); magnifications.push_back("50%"); magnifications.push_back("62.5%"); magnifications.push_back("80%"); magnifications.push_back("100%"); magnifications.push_back("125%"); magnifications.push_back("160%"); magnifications.push_back("200%"); magnifications.push_back("250%"); // Gets the actual magnification: if (g_config->magnification != 0.0f) //auto { std::ostringstream out; out << (g_config->magnification*100) << "%"; std::string magn = out.str(); size_t count = 0; for (std::vector<std::string>::iterator i = magnifications.begin(); i != magnifications.end(); ++i) { if (*i == magn) { next_magnification = count; magn.clear(); break; } ++count; } if (!magn.empty()) //magnification not in our list but accept anyway { next_magnification = magnifications.size(); magnifications.push_back(magn); } } aspect_ratios.clear(); aspect_ratios.push_back(_("auto")); aspect_ratios.push_back("5:4"); aspect_ratios.push_back("4:3"); aspect_ratios.push_back("16:10"); aspect_ratios.push_back("16:9"); aspect_ratios.push_back("1368:768"); // Gets the actual aspect ratio: if (g_config->aspect_size != Size(0, 0)) //auto { std::ostringstream out; out << g_config->aspect_size.width << ":" << g_config->aspect_size.height; std::string aspect_ratio = out.str(); size_t cnt_ = 0; for(std::vector<std::string>::iterator i = aspect_ratios.begin(); i != aspect_ratios.end(); ++i) { if(*i == aspect_ratio) { aspect_ratio.clear(); next_aspect_ratio = cnt_; break; } ++cnt_; } if (!aspect_ratio.empty()) { next_aspect_ratio = aspect_ratios.size(); aspect_ratios.push_back(aspect_ratio); } } resolutions.clear(); int display_mode_count = SDL_GetNumDisplayModes(0); std::string last_display_mode; for(int i = 0; i < display_mode_count; ++i) { SDL_DisplayMode mode; int ret = SDL_GetDisplayMode(0, i, &mode); if (ret != 0) { log_warning << "failed to get display mode: " << SDL_GetError() << std::endl; } else { std::ostringstream out; out << mode.w << "x" << mode.h; if(mode.refresh_rate) out << "@" << mode.refresh_rate; if(last_display_mode == out.str()) continue; last_display_mode = out.str(); resolutions.insert(resolutions.begin(), out.str()); } } resolutions.push_back("Desktop"); std::string fullscreen_size_str = "Desktop"; { std::ostringstream out; if (g_config->fullscreen_size != Size(0, 0)) { out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height; if (g_config->fullscreen_refresh_rate) out << "@" << g_config->fullscreen_refresh_rate; fullscreen_size_str = out.str(); } } size_t cnt = 0; for (std::vector<std::string>::iterator i = resolutions.begin(); i != resolutions.end(); ++i) { if (*i == fullscreen_size_str) { fullscreen_size_str.clear(); next_resolution = cnt; break; } ++cnt; } if (!fullscreen_size_str.empty()) { next_resolution = resolutions.size(); resolutions.push_back(fullscreen_size_str); } if (complete) { // Language and profile changes are only be possible in the // main menu, since elsewhere it might not always work fully add_submenu(_("Select Language"), MenuStorage::LANGUAGE_MENU) ->set_help(_("Select a different language to display text in")); add_submenu(_("Select Profile"), MenuStorage::PROFILE_MENU) ->set_help(_("Select a profile to play with")); } add_toggle(MNID_FULLSCREEN,_("Fullscreen"), &g_config->use_fullscreen) ->set_help(_("Fill the entire screen")); MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution"), &next_resolution, resolutions); fullscreen_res->set_help(_("Determine the resolution used in fullscreen mode (you must toggle fullscreen to complete the change)")); MenuItem* magnification = add_string_select(MNID_MAGNIFICATION, _("Magnification"), &next_magnification, magnifications); magnification->set_help(_("Change the magnification of the game area")); MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"), &next_aspect_ratio, aspect_ratios); aspect->set_help(_("Adjust the aspect ratio")); if (SoundManager::current()->is_audio_enabled()) { add_toggle(MNID_SOUND, _("Sound"), &g_config->sound_enabled) ->set_help(_("Disable all sound effects")); add_toggle(MNID_MUSIC, _("Music"), &g_config->music_enabled) ->set_help(_("Disable all music")); } else { add_inactive( _("Sound (disabled)")); add_inactive( _("Music (disabled)")); } add_submenu(_("Setup Keyboard"), MenuStorage::KEYBOARD_MENU) ->set_help(_("Configure key-action mappings")); add_submenu(_("Setup Joystick"), MenuStorage::JOYSTICK_MENU) ->set_help(_("Configure joystick control-action mappings")); MenuItem* enable_transitions = add_toggle(MNID_TRANSITIONS, _("Enable transitions"), &g_config->transitions_enabled); enable_transitions->set_help(_("Enable screen transitions and smooth menu animation")); if (g_config->developer_mode) { add_toggle(MNID_DEVELOPER_MODE, _("Developer Mode"), &g_config->developer_mode); } if (g_config->is_christmas() || g_config->christmas_mode) { add_toggle(MNID_CHRISTMAS_MODE, _("Christmas Mode"), &g_config->christmas_mode); } add_hl(); add_back(_("Back")); }
void AddonMenu::refresh() { clear(); AddonManager& adm = AddonManager::get_instance(); // refresh list of addons m_addons = adm.get_addons(); // sort list std::sort(m_addons.begin(), m_addons.end(), generate_addons_menu_sorter); add_label(_("Add-ons")); add_hl(); // FIXME: don't use macro, use AddonManager::online_available() or so #ifdef HAVE_LIBCURL add_entry(0, std::string(_("Check Online"))); #else add_inactive(0, std::string(_("Check Online (disabled)"))); #endif //add_hl(); for (unsigned int i = 0; i < m_addons.size(); i++) { const Addon& addon = *m_addons[i]; std::string text = ""; if (!addon.kind.empty()) { std::string kind = addon.kind; if(addon.kind == "Levelset") { kind = _("Levelset"); } else if(addon.kind == "Worldmap") { kind = _("Worldmap"); } else if(addon.kind == "World") { kind = _("World"); } else if(addon.kind == "Level") { kind = _("Level"); } if(!addon.author.empty()) { text = str(boost::format(_("%s \"%s\" by \"%s\"")) % kind % addon.title % addon.author); } else { // Only addon type and name, no need for translation. text = str(boost::format("%s \"%s\"") % kind % addon.title); } } else { if (!addon.author.empty()) { text = str(boost::format(_("\"%s\" by \"%s\"")) % addon.title % addon.author); } else { // Only addon name, no need for translation. text = str(boost::format("\"%s\"") % addon.title); } } add_toggle(ADDON_LIST_START_ID + i, text, addon.loaded); } add_hl(); add_back(_("Back")); }
EditorLevelsetSelectMenu::EditorLevelsetSelectMenu() : m_contrib_worlds() { Editor::current()->deactivate_request = true; // Generating contrib levels list by making use of Level Subset std::vector<std::string> level_worlds; std::unique_ptr<char*, decltype(&PHYSFS_freeList)> files(PHYSFS_enumerateFiles("levels"), PHYSFS_freeList); for(const char* const* filename = files.get(); *filename != 0; ++filename) { std::string filepath = FileSystem::join("levels", *filename); PHYSFS_Stat statbuf; PHYSFS_stat(filepath.c_str(), &statbuf); if(statbuf.filetype == PHYSFS_FILETYPE_DIRECTORY) { level_worlds.push_back(filepath); } } add_label(_("Choose level subset")); add_hl(); int i = 0; for (std::vector<std::string>::const_iterator it = level_worlds.begin(); it != level_worlds.end(); ++it) { try { std::unique_ptr<World> world = World::load(*it); if (!world->hide_from_contribs()) { Savegame savegame(world->get_savegame_filename()); savegame.load(); if (world->is_levelset()) { int level_count = 0; const auto& state = savegame.get_levelset_state(world->get_basedir()); for(const auto& level_state : state.level_states) { if(level_state.filename == "") continue; level_count += 1; } std::ostringstream title; title << "[" << world->get_title() << "]"; if (level_count == 0) { title << " " << _("*NEW*"); } else { title << " (" << level_count << " " << _("levels") << ")"; } add_entry(i++, title.str()); m_contrib_worlds.push_back(std::move(world)); } else if (world->is_worldmap()) { int level_count = 0; const auto& state = savegame.get_worldmap_state(world->get_worldmap_filename()); for(const auto& level_state : state.level_states) { if(level_state.filename == "") continue; level_count += 1; } std::ostringstream title; title << world->get_title(); if (level_count == 0) { title << " " << _("*NEW*"); } else { title << " (" << level_count << " " << _("levels") << ")"; } add_entry(i++, title.str()); m_contrib_worlds.push_back(std::move(world)); } else { log_warning << "unknown World type" << std::endl; } } } catch(std::exception& e) { log_info << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl; } } add_hl(); add_submenu(_("New level subset"), MenuStorage::EDITOR_NEW_LEVELSET_MENU); add_back(_("Back"),-2); }
void FileSystemMenu::refresh_items() { items.clear(); directories.clear(); files.clear(); directory = FileSystem::normalize(directory); add_label(directory); add_hl(); int item_id = 0; // Do not allow leaving the data directory if (directory != "/") { directories.push_back(".."); } char** dir_files = PHYSFS_enumerateFiles(directory.c_str()); if (dir_files) { for(const char* const* file = dir_files; *file != nullptr; ++file) { std::string filepath = FileSystem::join(directory, *file); if(PhysFSFileSystem::is_directory(filepath)) { directories.push_back(*file); } else { if (AddonManager::current()->is_from_old_addon(filepath)) { continue; } if(has_right_suffix(*file)) { files.push_back(*file); } } } PHYSFS_freeList(dir_files); } for(const auto& item : directories) { add_entry(item_id, "[" + std::string(item) + "]"); item_id++; } for(const auto& item : files) { add_entry(item_id, item); item_id++; } add_hl(); add_back(_("Cancel")); active_item = 2; // Re-center menu on_window_resize(); }
void AddonMenu::rebuild_menu() { clear(); add_label(_("Add-ons")); add_hl(); if (m_installed_addons.empty()) { if (!m_repository_addons.empty()) { add_inactive(MNID_NOTHING_NEW, _("No Addons installed")); } else { add_inactive(MNID_NOTHING_NEW, _("No Addons found")); } } else { int idx = 0; for (const auto& addon_id : m_installed_addons) { const Addon& addon = m_addon_manager.get_installed_addon(addon_id); std::string text = generate_menu_item_text(addon); add_toggle(MAKE_INSTALLED_MENU_ID(idx), text, addon.is_enabled()); idx += 1; } } add_hl(); { bool have_new_stuff = false; int idx = 0; for (const auto& addon_id : m_repository_addons) { const Addon& addon = m_addon_manager.get_repository_addon(addon_id); try { // addon is already installed, so check if they are the same Addon& installed_addon = m_addon_manager.get_installed_addon(addon_id); if (installed_addon.get_md5() == addon.get_md5() || installed_addon.get_version() > addon.get_version()) { log_debug << "ignoring already installed addon " << installed_addon.get_id() << std::endl; } else { log_debug << installed_addon.get_id() << " is installed, but updated: '" << installed_addon.get_md5() << "' vs '" << addon.get_md5() << "' '" << installed_addon.get_version() << "' vs '" << addon.get_version() << "'" << std::endl; std::string text = generate_menu_item_text(addon); add_entry(MAKE_REPOSITORY_MENU_ID(idx), str(boost::format( _("Install %s *NEW*") ) % text)); have_new_stuff = true; } } catch(const std::exception& err) { // addon is not installed std::string text = generate_menu_item_text(addon); add_entry(MAKE_REPOSITORY_MENU_ID(idx), str(boost::format( _("Install %s") ) % text)); have_new_stuff = true; } idx += 1; } if (!have_new_stuff && m_addon_manager.has_been_updated()) { add_inactive(MNID_NOTHING_NEW, _("No new Addons found")); } } if (!m_addon_manager.has_online_support()) { add_inactive(MNID_CHECK_ONLINE, std::string(_("Check Online (disabled)"))); } else { add_entry(MNID_CHECK_ONLINE, std::string(_("Check Online"))); } add_hl(); add_back(_("Back")); }