X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fsetup.cpp;h=3826f3ff04096cfe9a0296b74e3f716f64d06890;hb=8a7ddfdc1401bd7889bb482afd4fda2d3f7ac1e8;hp=88afb06320530cdcd50903da103de40bef67a026;hpb=d56718daf62fa8168f91ce617f2e1356760e7f8e;p=supertux.git diff --git a/src/setup.cpp b/src/setup.cpp index 88afb0632..3826f3ff0 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -49,6 +49,9 @@ #include "configfile.h" #include "scene.h" #include "worldmap.h" +#include "resources.h" +#include "intro.h" +#include "music_manager.h" #include "player.h" @@ -343,10 +346,10 @@ void st_directory_setup(void) { std::string exedir = std::string(dirname(exe_file)) + "/"; - datadir = exedir + "../data/"; // SuperTux run from source dir + datadir = exedir + "../data"; // SuperTux run from source dir if (access(datadir.c_str(), F_OK) != 0) { - datadir = exedir + "../share/supertux/"; // SuperTux run from PATH + datadir = exedir + "../share/supertux"; // SuperTux run from PATH if (access(datadir.c_str(), F_OK) != 0) { // If all fails, fall back to compiled path datadir = DATA_PREFIX; @@ -376,32 +379,32 @@ void st_menu(void) worldmap_menu = new Menu(); main_menu->set_pos(screen->w/2, 335); - main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu); - main_menu->additem(MN_GOTO, "Contrib Levels",0,contrib_menu); - main_menu->additem(MN_GOTO, "Options",0,options_menu); - main_menu->additem(MN_ACTION,"Level editor",0,0); - main_menu->additem(MN_ACTION,"Credits",0,0); - main_menu->additem(MN_ACTION,"Quit",0,0); + main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu, MNID_STARTGAME); + main_menu->additem(MN_GOTO, "Contrib Levels",0,contrib_menu, MNID_CONTRIB); + main_menu->additem(MN_GOTO, "Options",0,options_menu, MNID_OPTIONMENU); + main_menu->additem(MN_ACTION,"Level editor",0,0, MNID_LEVELEDITOR); + main_menu->additem(MN_ACTION,"Credits",0,0, MNID_CREDITS); + main_menu->additem(MN_ACTION,"Quit",0,0, MNID_QUITMAINMENU); options_menu->additem(MN_LABEL,"Options",0,0); options_menu->additem(MN_HL,"",0,0); #ifndef NOOPENGL - options_menu->additem(MN_TOGGLE,"OpenGL",use_gl,0); + options_menu->additem(MN_TOGGLE,"OpenGL",use_gl,0, MNID_OPENGL); #else - options_menu->additem(MN_DEACTIVE,"OpenGL (not supported)",use_gl,0); + options_menu->additem(MN_DEACTIVE,"OpenGL (not supported)",use_gl,MNID_OPENGL); #endif - options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0); + options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0, MNID_FULLSCREEN); if(audio_device) { - options_menu->additem(MN_TOGGLE,"Sound ",use_sound,0); - options_menu->additem(MN_TOGGLE,"Music ",use_music,0); + 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); - options_menu->additem(MN_DEACTIVE,"Music ",use_music,0); + 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); + options_menu->additem(MN_TOGGLE,"Show FPS ",show_fps,0, MNID_SHOWFPS); options_menu->additem(MN_GOTO,"Key Setup",0,options_keys_menu); if(use_joystick) options_menu->additem(MN_GOTO,"Joystick Setup",0,options_joystick_menu); @@ -410,11 +413,11 @@ void st_menu(void) options_keys_menu->additem(MN_LABEL,"Key Setup",0,0); options_keys_menu->additem(MN_HL,"",0,0); - options_keys_menu->additem(MN_CONTROLFIELD,"Left move", 0,0, &keymap.left); - options_keys_menu->additem(MN_CONTROLFIELD,"Right move", 0,0, &keymap.right); - options_keys_menu->additem(MN_CONTROLFIELD,"Jump", 0,0, &keymap.jump); - options_keys_menu->additem(MN_CONTROLFIELD,"Duck", 0,0, &keymap.duck); - options_keys_menu->additem(MN_CONTROLFIELD,"Power", 0,0, &keymap.fire); + options_keys_menu->additem(MN_CONTROLFIELD,"Left move", 0,0, 0,&keymap.left); + options_keys_menu->additem(MN_CONTROLFIELD,"Right move", 0,0, 0,&keymap.right); + options_keys_menu->additem(MN_CONTROLFIELD,"Jump", 0,0, 0,&keymap.jump); + options_keys_menu->additem(MN_CONTROLFIELD,"Duck", 0,0, 0,&keymap.duck); + options_keys_menu->additem(MN_CONTROLFIELD,"Power", 0,0, 0,&keymap.fire); options_keys_menu->additem(MN_HL,"",0,0); options_keys_menu->additem(MN_BACK,"Back",0,0); @@ -422,50 +425,50 @@ void st_menu(void) { options_joystick_menu->additem(MN_LABEL,"Joystick Setup",0,0); options_joystick_menu->additem(MN_HL,"",0,0); - options_joystick_menu->additem(MN_CONTROLFIELD,"X axis", 0,0, &joystick_keymap.x_axis); - options_joystick_menu->additem(MN_CONTROLFIELD,"Y axis", 0,0, &joystick_keymap.y_axis); - options_joystick_menu->additem(MN_CONTROLFIELD,"A button", 0,0, &joystick_keymap.a_button); - options_joystick_menu->additem(MN_CONTROLFIELD,"B button", 0,0, &joystick_keymap.b_button); - options_joystick_menu->additem(MN_CONTROLFIELD,"Start", 0,0, &joystick_keymap.start_button); - options_joystick_menu->additem(MN_CONTROLFIELD,"DeadZone", 0,0, &joystick_keymap.dead_zone); + options_joystick_menu->additem(MN_CONTROLFIELD,"X axis", 0,0, 0,&joystick_keymap.x_axis); + options_joystick_menu->additem(MN_CONTROLFIELD,"Y axis", 0,0, 0,&joystick_keymap.y_axis); + options_joystick_menu->additem(MN_CONTROLFIELD,"A button", 0,0, 0,&joystick_keymap.a_button); + options_joystick_menu->additem(MN_CONTROLFIELD,"B button", 0,0, 0,&joystick_keymap.b_button); + options_joystick_menu->additem(MN_CONTROLFIELD,"Start", 0,0, 0,&joystick_keymap.start_button); + options_joystick_menu->additem(MN_CONTROLFIELD,"DeadZone", 0,0, 0,&joystick_keymap.dead_zone); options_joystick_menu->additem(MN_HL,"",0,0); options_joystick_menu->additem(MN_BACK,"Back",0,0); } load_game_menu->additem(MN_LABEL,"Start Game",0,0); load_game_menu->additem(MN_HL,"",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0); - load_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0); + load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); + load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); + load_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0, 3); + load_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0, 4); + load_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0, 5); load_game_menu->additem(MN_HL,"",0,0); load_game_menu->additem(MN_BACK,"Back",0,0); save_game_menu->additem(MN_LABEL,"Save Game",0,0); save_game_menu->additem(MN_HL,"",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0); - save_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0); + save_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); + save_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); + save_game_menu->additem(MN_DEACTIVE,"Slot 3",0,0, 3); + save_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0, 4); + save_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0, 5); save_game_menu->additem(MN_HL,"",0,0); save_game_menu->additem(MN_BACK,"Back",0,0); game_menu->additem(MN_LABEL,"Pause",0,0); game_menu->additem(MN_HL,"",0,0); - game_menu->additem(MN_ACTION,"Continue",0,0); + game_menu->additem(MN_ACTION,"Continue",0,0,MNID_CONTINUE); game_menu->additem(MN_GOTO,"Options",0,options_menu); game_menu->additem(MN_HL,"",0,0); - game_menu->additem(MN_ACTION,"Abort Level",0,0); + game_menu->additem(MN_ACTION,"Abort Level",0,0,MNID_ABORTLEVEL); worldmap_menu->additem(MN_LABEL,"Pause",0,0); worldmap_menu->additem(MN_HL,"",0,0); - worldmap_menu->additem(MN_ACTION,"Continue",0,0); - worldmap_menu->additem(MN_ACTION,"Save",0,0); + worldmap_menu->additem(MN_ACTION,"Continue",0,0,MNID_RETURNWORLDMAP); + worldmap_menu->additem(MN_ACTION,"Save",0,0,MNID_SAVEGAME); worldmap_menu->additem(MN_GOTO,"Options",0,options_menu); worldmap_menu->additem(MN_HL,"",0,0); - worldmap_menu->additem(MN_ACTION,"Quit Game",0,0); + worldmap_menu->additem(MN_ACTION,"Quit Game",0,0,MNID_QUITWORLDMAP); highscore_menu->additem(MN_TEXTFIELD,"Enter your name:",0,0); } @@ -486,12 +489,17 @@ bool process_load_game_menu() { int slot = load_game_menu->check(); - if(slot != -1 && load_game_menu->get_item(slot).kind == MN_ACTION) + if(slot != -1 && load_game_menu->get_item_by_id(slot).kind == MN_ACTION) { - WorldMapNS::WorldMap worldmap; - char slotfile[1024]; - snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot-1); + snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot); + + if (access(slotfile, F_OK) != 0) + { + display_text_file("intro.txt", "images/background/arctis2.jpg"); + } + + WorldMapNS::WorldMap worldmap; // Load the game or at least set the savegame_file variable worldmap.loadgame(slotfile); @@ -514,34 +522,37 @@ void process_options_menu(void) { switch (options_menu->check()) { - case 2: + case MNID_OPENGL: #ifndef NOOPENGL - if(use_gl != options_menu->item[2].toggled) + if(use_gl != options_menu->isToggled(MNID_OPENGL)) { use_gl = !use_gl; st_video_setup(); } +#else + options_menu->get_item_by_id(MNID_OPENGL).toggled = false; #endif break; - case 3: - if(use_fullscreen != options_menu->item[3].toggled) + case MNID_FULLSCREEN: + if(use_fullscreen != options_menu->isToggled(MNID_FULLSCREEN)) { use_fullscreen = !use_fullscreen; st_video_setup(); } break; - case 4: - if(use_sound != options_menu->item[4].toggled) + case MNID_SOUND: + if(use_sound != options_menu->isToggled(MNID_SOUND)) use_sound = !use_sound; break; - case 5: - if(use_music != options_menu->item[5].toggled) + case MNID_MUSIC: + if(use_music != options_menu->isToggled(MNID_MUSIC)) { - enable_music(options_menu->item[5].toggled); + use_music = !use_music; + music_manager->enable_music(use_music); } break; - case 6: - if(show_fps != options_menu->item[6].toggled) + case MNID_SHOWFPS: + if(show_fps != options_menu->isToggled(MNID_SHOWFPS)) show_fps = !show_fps; break; } @@ -867,7 +878,6 @@ void st_abort(const std::string& reason, const std::string& details) abort(); } - /* Set Icon (private) */ void seticon(void)