#include "button.h"
#include "tile.h"
#include "resources.h"
+#include "music_manager.h"
/* definitions to aid development */
clearscreen(0, 0, 0);
updatescreen();
+
+ music_manager->halt_music();
while (SDL_PollEvent(&event))
{}
GameSession session("test",le_level, ST_GL_TEST);
session.run();
+ music_manager->halt_music();
+
Menu::set_current(leveleditor_menu);
le_world.arrays_free();
le_current_level->load_gfx();
/* Set ControlField a key */
void Menu::get_controlfield_key_into_input(MenuItem *item)
{
-switch(*item->int_p)
+ switch(*item->int_p)
{
case SDLK_UP:
strcpy(item->input, "Up cursor");
}
}
+MenuItem&
+Menu::get_item_by_id(int id)
+{
+ for(std::vector<MenuItem>::iterator i = item.begin(); i != item.end(); ++i) {
+ if(i->id == id)
+ return *i;
+ }
+
+ assert(false);
+ static MenuItem dummyitem;
+ return dummyitem;
+}
+
+bool
+Menu::isToggled(int id)
+{
+ return get_item_by_id(id).toggled;
+}
+
/* Check for menu event */
void
Menu::event(SDL_Event& event)
#include "scene.h"
#include "worldmap.h"
#include "resources.h"
+#include "music_manager.h"
#include "player.h"
options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0, MNID_FULLSCREEN);
if(audio_device)
{
- options_menu->additem(MN_TOGGLE,"Sound ",use_sound,0, MNID_SOUND);
- options_menu->additem(MN_TOGGLE,"Music ",use_music,0, MNID_MUSIC);
+ options_menu->additem(MN_TOGGLE,"Sound ", use_sound,0, MNID_SOUND);
+ options_menu->additem(MN_TOGGLE,"Music ", use_music,0, MNID_MUSIC);
}
else
{
- options_menu->additem(MN_DEACTIVE,"Sound ",use_sound,0, MNID_SOUND);
- options_menu->additem(MN_DEACTIVE,"Music ",use_music,0, MNID_MUSIC);
+ options_menu->additem(MN_DEACTIVE,"Sound ", false,0, MNID_SOUND);
+ options_menu->additem(MN_DEACTIVE,"Music ", false,0, MNID_MUSIC);
}
options_menu->additem(MN_TOGGLE,"Show FPS ",show_fps,0, MNID_SHOWFPS);
options_menu->additem(MN_GOTO,"Key Setup",0,options_keys_menu);
{
case MNID_OPENGL:
#ifndef NOOPENGL
- if(use_gl != options_menu->item[MNID_OPENGL].toggled)
+ if(use_gl != options_menu->isToggled(MNID_OPENGL))
{
use_gl = !use_gl;
st_video_setup();
}
#else
- options_menu->item[MNID_OPENGL].toggled = false;
+ options_menu->get_item_by_id(MNID_OPENGL).toggled = false;
#endif
break;
case MNID_FULLSCREEN:
- if(use_fullscreen != options_menu->item[MNID_FULLSCREEN].toggled)
+ if(use_fullscreen != options_menu->isToggled(MNID_FULLSCREEN))
{
use_fullscreen = !use_fullscreen;
st_video_setup();
}
break;
case MNID_SOUND:
- if(use_sound != options_menu->item[MNID_SOUND].toggled)
+ if(use_sound != options_menu->isToggled(MNID_SOUND))
use_sound = !use_sound;
break;
case MNID_MUSIC:
- music_manager->enable_music(options_menu->item[MNID_MUSIC].toggled);
+ if(use_music != options_menu->isToggled(MNID_MUSIC))
+ {
+ use_music = !use_music;
+ music_manager->enable_music(use_music);
+ }
break;
case MNID_SHOWFPS:
- if(show_fps != options_menu->item[MNID_SHOWFPS].toggled)
+ if(show_fps != options_menu->isToggled(MNID_SHOWFPS))
show_fps = !show_fps;
break;
}