Removed made public variables private in JoystickManager and KeyboardManager
[supertux.git] / src / supertux / menu / worldmap_cheat_menu.cpp
1 //  SuperTux
2 //  Copyright (C) 2014 Ingo Ruhnke <grumbel@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/worldmap_cheat_menu.hpp"
18
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"
26
27 WorldmapCheatMenu::WorldmapCheatMenu()
28 {
29   add_label(_("Cheats"));
30   add_hl();
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_SHRINK, _("Bonus: None"));
35   add_hl();
36   add_entry(MNID_FINISH_LEVEL, _("Finish Level"));
37   add_entry(MNID_RESET_LEVEL, _("Reset Level"));
38   add_hl();
39   add_entry(MNID_FINISH_WORLDMAP, _("Finish WorldMap"));
40   add_entry(MNID_RESET_WORLDMAP, _("Reset WorldMap"));
41   add_hl();
42   add_back(_("Back"));
43 }
44
45 void
46 WorldmapCheatMenu::menu_action(MenuItem* item)
47 {
48   worldmap::WorldMap* worldmap = worldmap::WorldMap::current();
49   if (!worldmap)
50   {
51     log_warning << "couldn't access WorldMap::current()" << std::endl;
52   }
53   else
54   {
55     PlayerStatus* status = worldmap->get_savegame().get_player_status();
56
57     switch(item->id)
58     {
59       case MNID_GROW:
60         status->bonus = GROWUP_BONUS;
61         break;
62
63       case MNID_FIRE:
64         status->bonus = FIRE_BONUS;
65         break;
66
67       case MNID_ICE:
68         status->bonus = ICE_BONUS;
69         break;
70
71       case MNID_SHRINK:
72         status->bonus = NO_BONUS;
73         break;
74
75       case MNID_FINISH_LEVEL:
76         {
77           worldmap::LevelTile* level_tile = worldmap->at_level();
78           if (level_tile)
79           {
80             level_tile->set_solved(true);
81             level_tile->set_perfect(false);
82           }
83         }
84         break;
85
86       case MNID_RESET_LEVEL:
87         {
88           worldmap::LevelTile* level_tile = worldmap->at_level();
89           if (level_tile)
90           {
91             level_tile->set_solved(false);
92             level_tile->set_perfect(false);
93           }
94         }
95         break;
96
97       case MNID_FINISH_WORLDMAP:
98         worldmap->set_levels_solved(true, false);
99         break;
100
101       case MNID_RESET_WORLDMAP:
102         worldmap->set_levels_solved(false, false);
103         break;
104     }
105   }
106
107   MenuManager::instance().clear_menu_stack();
108 }
109
110 /* EOF */