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/cheat_menu.hpp"
19 #include "gui/menu_item.hpp"
20 #include "gui/menu_manager.hpp"
21 #include "object/player.hpp"
22 #include "supertux/game_session.hpp"
23 #include "supertux/player_status.hpp"
24 #include "supertux/sector.hpp"
25 #include "util/gettext.hpp"
27 CheatMenu::CheatMenu()
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_STAR, _("Bonus: Star"));
37 add_entry(MNID_SHRINK, _("Shrink Tux"));
38 add_entry(MNID_KILL, _("Kill Tux"));
39 add_entry(MNID_FINISH, _("Finish Level"));
45 CheatMenu::menu_action(MenuItem* item)
47 if (Sector::current())
49 std::vector<Player*> players = Sector::current()->get_players();
50 Player* player = players.empty() ? nullptr : players[0];
57 player->set_bonus(GROWUP_BONUS);
64 player->set_bonus(FIRE_BONUS);
71 player->set_bonus(ICE_BONUS);
78 player->set_bonus(AIR_BONUS);
85 player->set_bonus(EARTH_BONUS);
92 player->make_invincible();
111 if (GameSession::current())
113 GameSession::current()->finish(true);
122 MenuManager::instance().clear_menu_stack();