[Super-tux-commit] supertux/src leveleditor.cpp,1.63,1.64 menu.cpp,1.54,1.55 menu.h,1.48,1.49 resour
Brought to you by:
wkendrick
From: Ingo R. <gr...@us...> - 2004-04-24 17:48:58
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15754 Modified Files: leveleditor.cpp menu.cpp menu.h resources.cpp setup.cpp sound.cpp sound.h Log Message: 'nother music patch by matzeb Index: menu.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- menu.cpp 24 Apr 2004 15:27:38 -0000 1.54 +++ menu.cpp 24 Apr 2004 17:48:49 -0000 1.55 @@ -154,7 +154,7 @@ /* 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"); @@ -602,6 +602,25 @@ } } +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) Index: setup.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/setup.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- setup.cpp 24 Apr 2004 15:08:21 -0000 1.54 +++ setup.cpp 24 Apr 2004 17:48:49 -0000 1.55 @@ -50,6 +50,7 @@ #include "scene.h" #include "worldmap.h" #include "resources.h" +#include "music_manager.h" #include "player.h" @@ -394,13 +395,13 @@ 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); @@ -517,31 +518,35 @@ { 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; } Index: menu.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/menu.h,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- menu.h 24 Apr 2004 15:27:38 -0000 1.48 +++ menu.h 24 Apr 2004 17:48:49 -0000 1.49 @@ -171,6 +171,9 @@ int check (); MenuItem& get_item(int index) { return item[index]; } + MenuItem& get_item_by_id(int id); + + bool isToggled(int id); void Menu::get_controlfield_key_into_input(MenuItem *item); @@ -183,6 +186,8 @@ int get_width() const; int get_height() const; + + bool is_toggled(int id) const; }; extern Surface* checkbox; Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- leveleditor.cpp 24 Apr 2004 09:32:31 -0000 1.63 +++ leveleditor.cpp 24 Apr 2004 17:48:49 -0000 1.64 @@ -41,6 +41,7 @@ #include "button.h" #include "tile.h" #include "resources.h" +#include "music_manager.h" /* definitions to aid development */ @@ -170,6 +171,8 @@ clearscreen(0, 0, 0); updatescreen(); + + music_manager->halt_music(); while (SDL_PollEvent(&event)) {} @@ -1221,6 +1224,8 @@ 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(); Index: sound.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sound.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- sound.cpp 24 Apr 2004 14:49:04 -0000 1.13 +++ sound.cpp 24 Apr 2004 17:48:49 -0000 1.14 @@ -27,7 +27,6 @@ bool use_sound = true; /* handle sound on/off menu and command-line option */ bool use_music = true; /* handle music on/off menu and command-line option */ bool audio_device = true; /* != 0: available and initialized */ -int current_music; char * soundfilenames[NUM_SOUNDS] = { "/sounds/jump.wav", Index: sound.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sound.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- sound.h 24 Apr 2004 14:49:04 -0000 1.26 +++ sound.h 24 Apr 2004 17:48:49 -0000 1.27 @@ -28,7 +28,7 @@ /*global variable*/ extern bool use_sound; /* handle sound on/off menu and command-line option */ -extern bool use_music; /* handle music on/off menu and command-line option */ +extern bool use_music; /* handle music on/off menu and command-line */ extern bool audio_device; /* != 0: available and initialized */ /* enum of different internal music types */ Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- resources.cpp 24 Apr 2004 14:49:04 -0000 1.21 +++ resources.cpp 24 Apr 2004 17:48:49 -0000 1.22 @@ -48,6 +48,7 @@ sprite_manager = new SpriteManager(datadir + "/supertux.strf"); music_manager = new MusicManager(); + music_manager->enable_music(use_music); /* Tuxes: */ smalltux_star = sprite_manager->load("smalltux-star"); |