ee4822971f786327f28a8e92cc8dc80ce8cac1c3
[supertux.git] / src / misc.cpp
1 //  SuperTux
2 //  Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
3 //
4 //  This program is free software; you can redistribute it and/or
5 //  modify it under the terms of the GNU General Public License
6 //  as published by the Free Software Foundation; either version 2
7 //  of the License, or (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, write to the Free Software
16 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 #include <config.h>
18
19 #include "misc.h"
20 #include "main.h"
21 #include "gameconfig.h"
22 #include "app/globals.h"
23 #include "game_session.h"
24 #include "control/joystickkeyboardcontroller.h"
25
26 Menu* main_menu      = 0;
27 Menu* game_menu      = 0;
28 Menu* options_menu   = 0;
29 Menu* options_keys_menu     = 0;
30 Menu* options_joystick_menu = 0;
31 Menu* highscore_menu = 0;
32 Menu* load_game_menu = 0;
33 Menu* save_game_menu = 0;
34 Menu* contrib_menu   = 0;
35 Menu* contrib_subset_menu   = 0;
36
37 void process_options_menu()
38 {
39   switch (options_menu->check()) {
40     case MNID_FULLSCREEN:
41       if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
42         config->use_fullscreen = !config->use_fullscreen;
43         init_video();
44       }
45       break;
46     case MNID_SOUND:
47       if(config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) {
48         config->sound_enabled = !config->sound_enabled;
49         sound_manager->enable_sound(config->sound_enabled);
50       }
51       break;
52     case MNID_MUSIC:
53       if(config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) {
54         config->music_enabled = !config->music_enabled;
55         sound_manager->enable_music(config->music_enabled);
56       }
57       break;
58     default:
59       break;
60   }
61 }
62
63 void setup_menu()
64 {
65   main_menu      = new Menu();
66   options_menu   = new Menu();
67   load_game_menu = new Menu();
68   game_menu      = new Menu();
69   contrib_menu   = new Menu();
70   contrib_subset_menu   = new Menu();
71   worldmap_menu  = new Menu();
72
73   main_menu->set_pos(SCREEN_WIDTH/2, 335);
74   main_menu->add_submenu(_("Start Game"), load_game_menu, MNID_STARTGAME);
75   main_menu->add_submenu(_("Contrib Levels"), contrib_menu, MNID_LEVELS_CONTRIB);
76   main_menu->add_submenu(_("Options"), options_menu);
77   main_menu->add_entry(MNID_LEVELEDITOR, _("Level Editor"));
78   main_menu->add_entry(MNID_CREDITS, _("Credits"));
79   main_menu->add_entry(MNID_QUITMAINMENU, _("Quit"));
80   
81   options_menu->add_label(_("Options"));
82   options_menu->add_hl();
83   options_menu->add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
84   options_menu->add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
85   options_menu->add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
86   options_menu->add_submenu(_("Setup Keys"),
87                             main_controller->get_key_options_menu());
88   options_menu->add_submenu(_("Setup Joystick"),
89                             main_controller->get_joystick_options_menu());
90   options_menu->add_hl();
91   options_menu->add_back(_("Back"));
92   
93   load_game_menu->add_label(_("Start Game"));
94   load_game_menu->add_hl();
95   load_game_menu->add_deactive(1, "Slot 1");
96   load_game_menu->add_deactive(2, "Slot 2");
97   load_game_menu->add_deactive(3, "Slot 3");
98   load_game_menu->add_deactive(4, "Slot 4");
99   load_game_menu->add_deactive(5, "Slot 5");
100   load_game_menu->add_hl();
101   load_game_menu->add_back(_("Back"));
102   
103   game_menu->add_label(_("Pause"));
104   game_menu->add_hl();
105   game_menu->add_entry(MNID_CONTINUE, _("Continue"));
106   game_menu->add_submenu(_("Options"), options_menu);
107   game_menu->add_hl();
108   game_menu->add_entry(MNID_ABORTLEVEL, _("Abort Level"));
109
110   worldmap_menu->add_label(_("Pause"));
111   worldmap_menu->add_hl();
112   worldmap_menu->add_entry(WorldMapNS::MNID_RETURNWORLDMAP, _("Continue"));
113   worldmap_menu->add_submenu(_("Options"), options_menu);
114   worldmap_menu->add_hl();
115   worldmap_menu->add_entry(WorldMapNS::MNID_QUITWORLDMAP, _("Quit Game"));
116 }
117
118 void free_menu()
119 {
120   delete worldmap_menu;
121   delete main_menu;
122   delete game_menu;
123   delete options_menu;
124   delete contrib_menu;
125   delete contrib_subset_menu;
126   delete load_game_menu;
127 }
128