// $Id$
-//
+//
// SuperTux
-// Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
// Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "title.hpp"
#include "mainloop.hpp"
-#include "video/screen.hpp"
#include "video/drawing_context.hpp"
#include "video/surface.hpp"
#include "audio/sound_manager.hpp"
#include "level.hpp"
#include "world.hpp"
#include "game_session.hpp"
-#include "worldmap.hpp"
+#include "worldmap/worldmap.hpp"
#include "player_status.hpp"
#include "tile.hpp"
#include "sector.hpp"
#include "object/player.hpp"
#include "resources.hpp"
#include "gettext.hpp"
-#include "misc.hpp"
#include "textscroller.hpp"
+#include "fadeout.hpp"
#include "file_system.hpp"
#include "control/joystickkeyboardcontroller.hpp"
#include "control/codecontroller.hpp"
#include "main.hpp"
-#include "msg.hpp"
+#include "log.hpp"
+#include "options_menu.hpp"
#include "console.hpp"
+#include "random_generator.hpp"
+
+enum MainMenuIDs {
+ MNID_STARTGAME,
+ MNID_LEVELS_CONTRIB,
+ MNID_OPTIONMENU,
+ MNID_LEVELEDITOR,
+ MNID_CREDITS,
+ MNID_QUITMAINMENU
+};
void
TitleScreen::update_load_game_menu()
contrib_worlds.push_back(world.release());
} catch(std::exception& e) {
#ifdef DEBUG
- msg_warning << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl;
+ log_warning << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl;
#endif
}
}
level->get("name", name);
return name;
} catch(std::exception& e) {
- msg_warning << "Problem getting name of '" << filename << "'." << std::endl;
+ log_warning << "Problem getting name of '" << filename << "'." << std::endl;
return "";
}
}
if (contrib_world_menu->get_item_by_id(index).kind == MN_ACTION) {
sound_manager->stop_music();
GameSession* session =
- new GameSession(
- current_world->get_level_filename(index), ST_GL_PLAY);
+ new GameSession(current_world->get_level_filename(index));
main_loop->push_screen(session);
}
}
if(pathBlocked)
jumpDuration = 0.5;
else
- jumpDuration = float(rand() % 500 + 300) / 1000.0;
+ jumpDuration = systemRandom.randf(0.3, 0.8);
jumpPushTimer.start(jumpDuration);
- randomWaitTimer.start(float(rand() % 3000 + 3000) / 1000.0);
+ randomWaitTimer.start(systemRandom.randf(3.0, 6.0));
}
// Keep jump button pressed
TitleScreen::TitleScreen()
{
controller.reset(new CodeController());
- titlesession.reset(new GameSession("levels/misc/menu.stl", ST_GL_DEMO_GAME));
+ titlesession.reset(new GameSession("levels/misc/menu.stl"));
Player* player = titlesession->get_current_sector()->player;
player->set_controller(controller.get());
+
+ main_menu.reset(new Menu());
+ main_menu->set_pos(SCREEN_WIDTH/2, 335);
+ main_menu->add_entry(MNID_STARTGAME, _("Start Game"));
+ main_menu->add_entry(MNID_LEVELS_CONTRIB, _("Contrib Levels"));
+ main_menu->add_submenu(_("Options"), get_options_menu());
+ main_menu->add_entry(MNID_CREDITS, _("Credits"));
+ main_menu->add_entry(MNID_QUITMAINMENU, _("Quit"));
}
TitleScreen::~TitleScreen()
sector->activate(sector->player->get_pos());
}
- Menu::set_current(main_menu);
+ Menu::set_current(main_menu.get());
}
void
{
Sector* sector = titlesession->get_current_sector();
sector->deactivate();
+ Menu::set_current(NULL);
}
void
Sector* sector = titlesession->get_current_sector();
sector->draw(context);
- /*
- if (Menu::current() == main_menu)
- context.draw_surface(logo, Vector(SCREEN_WIDTH/2 - logo->get_width()/2, 30),
- LAYER_FOREGROUND1+1);
- */
-
context.draw_text(white_small_text, " SuperTux " PACKAGE_VERSION "\n",
Vector(0, SCREEN_HEIGHT - 50), LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(white_small_text,
if(menu) {
menu->update();
- if(menu == main_menu) {
+ if(menu == main_menu.get()) {
switch (main_menu->check()) {
case MNID_STARTGAME:
// Start Game, ie. goto the slots menu
Menu::push_current(contrib_menu.get());
break;
case MNID_CREDITS:
- fadeout(500);
- main_loop->push_screen(new TextScroller("credits.txt"));
+ main_loop->push_screen(new TextScroller("credits.txt"),
+ new FadeOut(0.5));
break;
case MNID_QUITMAINMENU:
- main_loop->quit();
+ main_loop->quit(new FadeOut(0.25));
break;
}
} else if(menu == load_game_menu.get()) {
if(confirm_dialog(bkg_title, str.c_str())) {
str = "save/slot" + stream.str() + ".stsg";
- msg_debug << "Removing: " << str << std::endl;
+ log_debug << "Removing: " << str << std::endl;
PHYSFS_delete(str.c_str());
}
update_load_save_game_menu(load_game_menu);
- Menu::set_current(main_menu);
+ Menu::set_current(main_menu.get());
}*/
process_load_game_menu();
} else if(menu == contrib_menu.get()) {
// reopen menu of user closed it (so that the app doesn't close when user
// accidently hit ESC)
if(Menu::current() == 0) {
- Menu::set_current(main_menu);
+ Menu::set_current(main_menu.get());
}
}
stream << "save/" << worlddirname << "_" << slot << ".stsg";
std::string slotfile = stream.str();
- fadeout(256);
-
try {
current_world->set_savegame_filename(slotfile);
current_world->run();
} catch(std::exception& e) {
- msg_fatal << "Couldn't start world: " << e.what() << std::endl;
+ log_fatal << "Couldn't start world: " << e.what() << std::endl;
}
return true;