#include "worldmap.hpp"
#include "resources.hpp"
#include "misc.hpp"
+#include "msg.hpp"
#include "player_status.hpp"
#include "textscroller.hpp"
#include "main.hpp"
#include "control/joystickkeyboardcontroller.hpp"
#include "object/background.hpp"
#include "object/tilemap.hpp"
-#include "scripting/script_interpreter.hpp"
-#include "exceptions.hpp"
Menu* worldmap_menu = 0;
tux_sprite->set_action(moving ? "small-walking" : "small-stop");
break;
default:
- msg_debug("Bonus type not handled in worldmap.");
+ msg_debug << "Bonus type not handled in worldmap." << std::endl;
tux_sprite->set_action("large-stop");
break;
}
if (dir == D_NONE)
{
// Should never be reached if tiledata is good
- msg_warning("Could not determine where to walk next");
+ msg_warning << "Could not determine where to walk next" << std::endl;
stop();
return;
}
}
else
{
- msg_warning("Tilemap data is buggy");
+ msg_warning << "Tilemap data is buggy" << std::endl;
stop();
}
}
parse_level_tile(iter.lisp());
} else if(iter.item() == "special-tile") {
parse_special_tile(iter.lisp());
+ } else if(iter.item() == "name") {
+ // skip
} else {
- msg_warning("Unknown token '" << iter.item() << "' in worldmap");
+ msg_warning << "Unknown token '" << iter.item() << "' in worldmap" << std::endl;
}
}
if(solids == 0)
// Do we want to bail out instead...? We might get messages from modders
// who can't make their levels run because they're too dumb to watch
// their terminals...
- msg_warning("level file '" << level.name
- << "' does not exist and will not be added to the worldmap");
+ msg_warning << "level file '" << level.name << "' does not exist and will not be added to the worldmap" << std::endl;
return;
}
level_lisp->get("name", level.title);
} catch(std::exception& e) {
- msg_warning("Problem when reading leveltitle: " << e.what());
+ msg_warning << "Problem when reading leveltitle: " << e.what() << std::endl;
return;
}
}
}
}
-void
-WorldMap::get_input()
-{
- main_controller->update();
-
- SDL_Event event;
- while (SDL_PollEvent(&event)) {
- if (Menu::current())
- Menu::current()->event(event);
- main_controller->process_event(event);
- if(event.type == SDL_QUIT)
- throw graceful_shutdown();
- }
-}
-
Vector
WorldMap::get_next_tile(Vector pos, Direction direction)
{
tux->set_direction(dir);
}
}
+
+ if (level->extro_script != "") {
+ /* TODO
+ try {
+ std::auto_ptr<ScriptInterpreter> interpreter
+ (new ScriptInterpreter(levels_path));
+ std::istringstream in(level->extro_script);
+ interpreter->run_script(in, "level-extro-script");
+ add_object(interpreter.release());
+ } catch(std::exception& e) {
+ msg_fatal << "Couldn't run level-extro-script:" << e.what() << std::endl;
+ }
+ */
+ }
+
+ if (!level->next_worldmap.empty()) {
+ // Load given worldmap
+ loadmap(level->next_worldmap);
+ }
+
+ if (level->quit_worldmap)
+ main_loop->exit_screen();
}
void
main_loop->exit_screen();
break;
}
- } else if(menu == options_menu) {
- process_options_menu();
}
return;
}
/* Check level action */
- bool level_finished = true;
Level* level = at_level();
if (!level) {
- msg_warning("No level to enter at: "
- << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y);
+ msg_warning << "No level to enter at: " << tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl;
return;
}
- if (level->pos == tux->get_tile_pos())
- {
- // do a shriking fade to the level
- shrink_fade(Vector((level->pos.x*32 + 16 + offset.x),
- (level->pos.y*32 + 16 + offset.y)), 500);
+ if (level->pos == tux->get_tile_pos()) {
+ // do a shriking fade to the level
+ shrink_fade(Vector((level->pos.x*32 + 16 + offset.x),
+ (level->pos.y*32 + 16 + offset.y)), 500);
+ try {
GameSession *session =
- new GameSession(levels_path + level->name,
- ST_GL_LOAD_LEVEL_FILE, &level->statistics);
+ new GameSession(levels_path + level->name,
+ ST_GL_LOAD_LEVEL_FILE, &level->statistics);
main_loop->push_screen(session);
+ } catch(std::exception& e) {
+ msg_fatal << "Couldn't load level: " << e.what() << std::endl;
}
- /* The porpose of the next checking is that if the player lost
- the level (in case there is one), don't show anything */
- if(level_finished) {
- if (level->extro_script != "") {
- try {
- std::auto_ptr<ScriptInterpreter> interpreter
- (new ScriptInterpreter(levels_path));
- std::istringstream in(level->extro_script);
- interpreter->run_script(in, "level-extro-script");
- add_object(interpreter.release());
- } catch(std::exception& e) {
- msg_warning("Couldn't run level-extro-script:" << e.what());
- }
- }
-
- if (!level->next_worldmap.empty())
- {
- // Load given worldmap
- loadmap(level->next_worldmap);
- }
- if (level->quit_worldmap)
- main_loop->exit_screen();
- }
+ }
}
else
{
void
WorldMap::loadgame(const std::string& filename)
{
- msg_debug("loadgame: " << filename);
+ msg_debug << "loadgame: " << filename << std::endl;
savegame_file = filename;
if (PHYSFS_exists(filename.c_str())) // savegame exists
}
}
} else {
- msg_warning("Unknown token '" << iter.item()
- << "' in levels block in worldmap");
+ msg_warning << "Unknown token '" << iter.item() << "' in levels block in worldmap" << std::endl;
}
}
}
} catch(std::exception& e) {
- msg_warning("Problem loading game '" << filename << "': " << e.what());
+ msg_warning << "Problem loading game '" << filename << "': " << e.what() << std::endl;
load_map();
player_status->reset();
}