1 // SuperTux 2 // Copyright (C) 2015 Hume2 <teratux.mail@gmail.com> 3 // 4 // This program is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 #include "supertux/menu/editor_objectgroup_menu.hpp" 18 19 #include "editor/editor.hpp" 20 #include "editor/object_group.hpp" 21 #include "gui/menu_item.hpp" 22 #include "gui/menu_manager.hpp" 23 #include "supertux/level.hpp" 24 #include "util/gettext.hpp" 25 EditorObjectgroupMenu()26EditorObjectgroupMenu::EditorObjectgroupMenu() 27 { 28 bool worldmap = Editor::current()->get_level()->is_worldmap(); 29 30 add_label(_("Objects")); 31 add_hl(); 32 33 int id = 0; 34 for (auto& og : Editor::current()->get_objectgroups()) { 35 if (worldmap == og.is_worldmap()) { 36 add_entry(id, og.get_name()); 37 } 38 id++; 39 } 40 41 add_hl(); 42 add_entry(-1,_("Cancel")); 43 } 44 ~EditorObjectgroupMenu()45EditorObjectgroupMenu::~EditorObjectgroupMenu() 46 { 47 auto editor = Editor::current(); 48 if (editor == nullptr) { 49 return; 50 } 51 editor->m_reactivate_request = true; 52 } 53 54 void menu_action(MenuItem & item)55EditorObjectgroupMenu::menu_action(MenuItem& item) 56 { 57 if (item.get_id() >= 0) 58 { 59 Editor::current()->select_objectgroup(item.get_id()); 60 } 61 MenuManager::instance().clear_menu_stack(); 62 } 63 64 /* EOF */ 65