/* Create the options menu */ static struct Menu *make_options_menu(struct Menu *parent,struct MenuDrawingOptions *options) { struct MenuText save,back; struct Menu *opts; struct MenuItem *audiomenu; /* Create some special menu item labels */ save = menu_txt_label("Save settings"); save.color = font_color_red; back = menu_txt_label("Return"); back.color = font_color_green; /* Create menu */ opts = create_menu(0,parent,options,NULL,NULL,0); add_caption(opts,"Luola configuration"); add_submenu(opts,1,"Input settings", make_input_menu(opts)); add_submenu(opts,2,"Game settings", make_game_menu(opts)); add_submenu(opts,3,"Level settings", make_level_menu(opts)); audiomenu = add_submenu(opts,4,"Audio settings", make_audio_menu(opts)); add_submenu(opts,5,"Startup settings", make_startup_menu(opts)); add_menu_item(opts,MNU_ITEM_SEP,0,menu_txt_label("- - -"),MnuNullValue); add_menu_item(opts,MNU_ITEM_LABEL,0,save,MnuNullValue)->action = save_settings; add_menu_item(opts,MNU_ITEM_PARENT,0,back,MnuNullValue); if(SDL_WasInit(SDL_INIT_AUDIO)==0) audiomenu->sensitive = 0; return opts; }
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")); }
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")); }
/* Create the game settings menu */ static struct Menu *make_game_menu(struct Menu *parent) { struct Menu *m; struct MenuValue val = {NULL,0,2,1}; struct MenuItem *item; /* Create menu */ m = create_menu(0,parent,NULL,NULL,NULL,0); add_caption(m,"Game settings"); add_submenu(m,1,"Weapon settings",make_weapon_menu(m)); add_submenu(m,1,"Ship settings",make_ship_menu(m)); add_menu_item(m,0,MNU_ITEM_SEP,menu_txt_label("- - -"),MnuNullValue); val.value = (int*)&game_settings.jumplife; item = add_menu_item(m,MNU_ITEM_VALUE,1, menu_func_label(jumplife_label),val); val.value = &game_settings.onewayjp; item = add_menu_item(m,MNU_ITEM_TOGGLE,2, menu_txt_label("Jump points are %s-way"),val); item->text_enabled="one"; item->text_disabled="two"; val.value = &game_settings.enable_smoke; item = add_menu_item(m,MNU_ITEM_TOGGLE,3, menu_txt_label("Smoke is %s"),val); val.value = &game_settings.endmode; item = add_menu_item(m,MNU_ITEM_TOGGLE,4, menu_txt_label("Endmode: %s"),val); item->text_enabled="last player lands on a base"; item->text_disabled = "one player survives"; val.value = &game_settings.bigscreens; item = add_menu_item(m,MNU_ITEM_TOGGLE,5, menu_txt_label("Player screen size: %s"),val); item->text_enabled="maximum"; item->text_disabled = "quarter"; add_ok(m); return m; }
MainMenu::MainMenu() { set_center_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2 + 35); add_entry(MNID_STARTGAME, _("Start Game")); add_entry(MNID_ADDONS, _("Add-ons")); add_submenu(_("Options"), MenuStorage::OPTIONS_MENU); add_entry(MNID_CREDITS, _("Credits")); add_entry(MNID_QUITMAINMENU, _("Quit")); }
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")); }
MainMenu::MainMenu() { set_center_pos(static_cast<float>(SCREEN_WIDTH) / 2.0f, static_cast<float>(SCREEN_HEIGHT) / 2.0f + 35.0f); add_entry(MNID_STARTGAME, _("Start Game")); add_entry(MNID_ADDONS, _("Add-ons")); add_submenu(_("Options"), MenuStorage::OPTIONS_MENU); add_entry(MNID_LEVELEDITOR, _("Level Editor")); add_entry(MNID_CREDITS, _("Credits")); add_entry(MNID_QUITMAINMENU, _("Quit")); }
/* Create the level settings menu */ static struct Menu *make_level_menu(struct Menu *parent) { struct Menu *m; struct MenuValue val; struct MenuItem *item; /* Create menu */ m = create_menu(0,parent,NULL,NULL,NULL,0); add_caption(m,"Level settings"); add_submenu(m,1,"Critter settings",make_critter_menu(m)); add_menu_item(m,0,MNU_ITEM_SEP,menu_txt_label("- - -"),MnuNullValue); val.value = &game_settings.ls.indstr_base; item = add_menu_item(m,MNU_ITEM_TOGGLE,1, menu_txt_label("Bases are %s"),val); item->text_enabled = "indestructable"; item->text_disabled = "destructable"; val.value = &game_settings.base_regen; item = add_menu_item(m,MNU_ITEM_TOGGLE,1, menu_txt_label("Base regeneration is %s"),val); val.max = 5; val.min = 0; val.inc = 1; val.value = &game_settings.ls.jumpgates; item = add_menu_item(m,MNU_ITEM_VALUE,1, menu_txt_label("Jump gates: %d pairs"),val); val.max = 15; val.value = &game_settings.ls.turrets; item = add_menu_item(m,MNU_ITEM_VALUE,1, menu_txt_label("Turrets: %d"),val); val.value = &game_settings.ls.snowfall; item = add_menu_item(m,MNU_ITEM_TOGGLE,2, menu_txt_label("Snowfall is %s"),val); val.value = &game_settings.ls.stars; item = add_menu_item(m,MNU_ITEM_TOGGLE,2, menu_txt_label("Stars are %s"),val); add_ok(m); return m; }
/* Build the menu */ void build_menu(TilemEmulatorWindow* ewin) { GtkActionGroup *acts; GtkAccelGroup *ag; GtkWidget *menu, *submenu; ewin->actions = acts = gtk_action_group_new("Emulator"); gtk_action_group_set_translation_domain(acts, GETTEXT_PACKAGE); gtk_action_group_add_actions(ewin->actions, main_action_ents, G_N_ELEMENTS(main_action_ents), ewin); ag = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(ewin->window), ag); ewin->popup_menu = menu = gtk_menu_new(); add_item(menu, ag, acts, "send-file"); add_item(menu, ag, acts, "receive-file"); add_item(menu, ag, acts, "link-setup"); add_separator(menu); add_item(menu, ag, acts, "open-calc"); add_item(menu, ag, acts, "save-calc"); add_item(menu, ag, acts, "revert-calc"); add_item(menu, ag, acts, "reset-calc"); add_separator(menu); add_item(menu, ag, acts, "start-debugger"); submenu = add_submenu(menu, _("_Macro")); add_item(submenu, ag, acts, "begin-macro"); add_item(submenu, ag, acts, "end-macro"); add_item(submenu, ag, acts, "play-macro"); add_separator(submenu); add_item(submenu, ag, acts, "open-macro"); add_item(submenu, ag, acts, "save-macro"); add_item(menu, ag, acts, "screenshot"); add_item(menu, ag, acts, "quick-screenshot"); add_separator(menu); add_item(menu, ag, acts, "preferences"); add_separator(menu); add_item(menu, ag, acts, "about"); add_item(menu, ag, acts, "quit"); }
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")); }
MainMenu::MainMenu() : m_addon_menu(), m_contrib_menu(), m_main_world() { set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2 + 35); add_entry(MNID_STARTGAME, _("Start Game")); #ifdef DONATE_VERSION add_entry(MNID_LEVELS_CONTRIB, _("Contrib Levels")); add_entry(MNID_ADDONS, _("Add-ons")); #endif add_submenu(_("Options"), MenuStorage::get_options_menu()); add_entry(MNID_CREDITS, _("Credits")); add_entry(MNID_QUITMAINMENU, _("Quit")); }
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")); }
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")); }
GtkWidget * create_term_menu(ZvtTerm *term, gchar *command) { GtkWidget *menu_bar; GtkWidget *menu; GtkWidget *menu_item; GtkWidget *vide_menu; GtkWidget *tools_menu; GtkWidget *term_label; GdkColor color = TAB_COLOR; GtkStyle *defstyle; GtkStyle *style = gtk_style_new(); menu_bar = gtk_menu_bar_new(); defstyle = gtk_widget_get_default_style(); style = gtk_style_copy(defstyle); style->fg[0] = color; menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(menu_key_cb), NULL); gtk_object_set_data(GTK_OBJECT(term), "menu_bar", menu_bar); /* The terminal is running vi */ if(GPOINTER_TO_INT(gtk_object_get_user_data(GTK_OBJECT(term)))) { add_menu_item(menu, "Open File in Buffer", create_fileselector, GUINT_TO_POINTER(0)); if(strcmp(cfg.vi_clone, "vi")) add_menu_item (menu, "Split Buffer & Open File", create_fileselector, GUINT_TO_POINTER(1)); if(!strcmp(cfg.vi_clone, "vim")) add_menu_item (menu, "VSplit Buffer & Open File", create_fileselector, GUINT_TO_POINTER(2)); add_menu_separator (menu); } add_menu_item(menu, "Open File in New Term", create_fileselector, GUINT_TO_POINTER(3)); add_menu_separator (menu); add_menu_item(menu, "New Shell", split_zterm, NULL); add_menu_separator(menu); add_menu_item(menu, "List Pages", create_page_menu, NULL); add_menu_separator(menu); add_menu_item(menu, "Detach Term", detach_term, term); add_menu_separator(menu); add_menu_item (menu, "Cancel", NULL, NULL); vide_menu = add_submenu (menu_bar, "_Vide", menu); gtk_object_set_data(GTK_OBJECT(term), "vide_menu", vide_menu); menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(menu_key_cb), NULL); add_menu_item(menu, "Look up word", lookup_word, term); add_menu_separator(menu); /* add_menu_item(menu, "Compare file to..", compare_file, term); add_menu_separator(menu); */ /* I don't know how to visually select text in nvi and vile if((!strcmp("vim", cfg.vi_clone) | (!strcmp("elvis", cfg.vi_clone)))) { add_menu_item(menu, "Copy", copy_text, term); add_menu_separator(menu); add_menu_item(menu, "Paste", paste_text, term); add_menu_separator(menu); } */ add_menu_item(menu, "Cancel", NULL, NULL); tools_menu = add_submenu(menu_bar, "_Tools", menu); gtk_object_set_data(GTK_OBJECT(term), "tools_menu", tools_menu); /* label for filename on menubar */ menu = gtk_menu_new(); menu_item = gtk_menu_item_new(); term_label = gtk_widget_new(GTK_TYPE_LABEL, "GtkWidget::visible", TRUE, "GtkWidget::parent", menu_item, "GtkMisc::xalign", 0, 0, NULL); gtk_label_set_text(GTK_LABEL(term_label), command); gtk_widget_set_style(GTK_WIDGET(term_label), style); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu); gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), menu_item); gtk_menu_item_right_justify(GTK_MENU_ITEM(menu_item)); gtk_widget_show(menu_item); gtk_object_set_data(GTK_OBJECT(term), "term_label", term_label); return menu_bar; }
GtkWidget * create_main_menu_bar (void) { GtkWidget *main_menu_bar; GtkWidget *menu; GtkWidget *filter_menu; GtkWidget *menu_item; main_menu_bar = gtk_menu_bar_new (); menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(bookmark_key_cb), NULL); add_menu_item(menu, "Cancel ", NULL, NULL); add_menu_separator (menu); add_menu_item (menu, "Become Root", root_cb, NULL); add_menu_separator (menu); add_menu_item (menu, "Open Trash", open_trash_cb, NULL); add_menu_item (menu, "Empty Trash", empty_trash_cb, NULL); add_menu_separator (menu); add_menu_item (menu, "Quit Alt Q", quit_cb, NULL); app.vide_menu_item = add_submenu (main_menu_bar, "_Vide", menu); app.bookmark_menu = gtk_menu_new (); gtk_signal_connect (GTK_OBJECT (app.bookmark_menu), "key_press_event", GTK_SIGNAL_FUNC (bookmark_key_cb), NULL); add_menu_item (app.bookmark_menu, "Edit Bookmarks", edit_bookmarks_cb, NULL); add_menu_separator (app.bookmark_menu); app.bookmark_menu_item = add_submenu (main_menu_bar, "_Bookmarks", app.bookmark_menu); menu = gtk_menu_new (); gtk_signal_connect (GTK_OBJECT (menu), "key_press_event", GTK_SIGNAL_FUNC (bookmark_key_cb), NULL); add_menu_item(menu, "Show Dot Files", show_hidden_cb, NULL); add_menu_separator (menu); filter_menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(filter_menu), "key_press_event", GTK_SIGNAL_FUNC(bookmark_key_cb), NULL); add_menu_item(filter_menu, "File Name Filter", filename_cb, NULL); add_menu_separator(filter_menu); add_menu_item(filter_menu, "Date Filter", date_filter_cb, NULL); add_menu_separator(filter_menu); add_menu_item(filter_menu, "Size Filter", size_filter_cb, NULL); menu_item = add_menu_item(menu, "Set Filters", NULL, NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), filter_menu); add_menu_separator(menu); add_menu_item(menu, "Remove Filters", remove_filters_cb, NULL); add_menu_separator(menu); add_menu_item (menu, "Configure", create_config_dialog, NULL); add_menu_separator(menu); add_menu_item(menu, "Cancel ", NULL, NULL); app.options_menu_item = add_submenu (main_menu_bar, "_Options", menu); /* menu = gtk_menu_new(); gtk_signal_connect(GTK_OBJECT(menu), "key_press_event", GTK_SIGNAL_FUNC(bookmark_key_cb), NULL); add_menu_item(menu, "Open Project", NULL, NULL); add_menu_item(menu, "New Project", NULL, NULL); add_menu_item(menu, "Import Project", NULL, NULL); add_menu_separator(menu); add_menu_item(menu, "Close Project", NULL, NULL); app.tools_menu_item = add_submenu(main_menu_bar, "_Tools", menu); */ menu = gtk_menu_new (); gtk_signal_connect (GTK_OBJECT (menu), "key_press_event", GTK_SIGNAL_FUNC (bookmark_key_cb), NULL); add_menu_item(menu, "Using Vide :h", help_cb, NULL); add_menu_separator(menu); add_menu_item(menu, "Cancel ", NULL, NULL); app.help_menu_item = add_submenu (main_menu_bar, "_Help", menu); gtk_menu_item_right_justify (GTK_MENU_ITEM (app.help_menu_item)); return main_menu_bar; }
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); }