2 // Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
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.
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.
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/>.
17 #include "supertux/menu/worldmap_cheat_menu.hpp"
19 #include "gui/menu_item.hpp"
20 #include "gui/menu_manager.hpp"
21 #include "supertux/player_status.hpp"
22 #include "supertux/savegame.hpp"
23 #include "util/gettext.hpp"
24 #include "worldmap/level.hpp"
25 #include "worldmap/worldmap.hpp"
27 WorldmapCheatMenu::WorldmapCheatMenu()
29 add_label(_("Cheats"));
31 add_entry(MNID_GROW, _("Bonus: Grow"));
32 add_entry(MNID_FIRE, _("Bonus: Fire"));
33 add_entry(MNID_ICE, _("Bonus: Ice"));
34 add_entry(MNID_AIR, _("Bonus: Air"));
35 add_entry(MNID_EARTH, _("Bonus: Earth"));
36 add_entry(MNID_SHRINK, _("Bonus: None"));
38 add_entry(MNID_FINISH_LEVEL, _("Finish Level"));
39 add_entry(MNID_RESET_LEVEL, _("Reset Level"));
41 add_entry(MNID_FINISH_WORLDMAP, _("Finish WorldMap"));
42 add_entry(MNID_RESET_WORLDMAP, _("Reset WorldMap"));
48 WorldmapCheatMenu::menu_action(MenuItem* item)
50 worldmap::WorldMap* worldmap = worldmap::WorldMap::current();
53 log_warning << "couldn't access WorldMap::current()" << std::endl;
57 PlayerStatus* status = worldmap->get_savegame().get_player_status();
62 status->bonus = GROWUP_BONUS;
66 status->bonus = FIRE_BONUS;
70 status->bonus = ICE_BONUS;
74 status->bonus = AIR_BONUS;
78 status->bonus = EARTH_BONUS;
82 status->bonus = NO_BONUS;
85 case MNID_FINISH_LEVEL:
87 worldmap::LevelTile* level_tile = worldmap->at_level();
90 level_tile->set_solved(true);
91 level_tile->set_perfect(false);
96 case MNID_RESET_LEVEL:
98 worldmap::LevelTile* level_tile = worldmap->at_level();
101 level_tile->set_solved(false);
102 level_tile->set_perfect(false);
107 case MNID_FINISH_WORLDMAP:
108 worldmap->set_levels_solved(true, false);
111 case MNID_RESET_WORLDMAP:
112 worldmap->set_levels_solved(false, false);
117 MenuManager::instance().clear_menu_stack();