#include "main.hpp"
#include "spawn_point.hpp"
#include "file_system.hpp"
+#include "physfs/physfs_stream.hpp"
#include "tile_manager.hpp"
#include "tile_set.hpp"
#include "gui/menu.hpp"
const lisp::Lisp* sector = level->get_lisp("sector");
if(!sector)
- throw std::runtime_error("No sector sepcified in worldmap file.");
+ throw std::runtime_error("No sector specified in worldmap file.");
const lisp::Lisp* tilesets_lisp = level->get_lisp("tilesets");
if(tilesets_lisp != NULL) {
add_object(teleporter);
} else if(iter.item() == "ambient-light") {
std::vector<float> vColor;
- sector->get_vector( "ambient-light", vColor );
+ sector->get( "ambient-light", vColor );
if(vColor.size() < 3) {
log_warning << "(ambient-light) requires a color as argument" << std::endl;
} else {
int dirdata = available_directions_at(tux->get_tile_pos());
// first, test for crossroads
if (dirdata == Tile::WORLDMAP_CNSE ||
- dirdata == Tile::WORLDMAP_CNSW ||
- dirdata == Tile::WORLDMAP_CNEW ||
- dirdata == Tile::WORLDMAP_CSEW ||
- dirdata == Tile::WORLDMAP_CNSEW)
+ dirdata == Tile::WORLDMAP_CNSW ||
+ dirdata == Tile::WORLDMAP_CNEW ||
+ dirdata == Tile::WORLDMAP_CSEW ||
+ dirdata == Tile::WORLDMAP_CNSEW)
dir = D_NONE;
else if (dirdata & Tile::WORLDMAP_NORTH
&& tux->back_direction != D_NORTH)
if(!in_level) {
Menu* menu = Menu::current();
if(menu != NULL) {
- menu->update();
-
if(menu == worldmap_menu.get()) {
switch (worldmap_menu->check())
{
|| main_controller->pressed(Controller::MENU_SELECT)) {
/* some people define UP and JUMP on the same key... */
if(!main_controller->pressed(Controller::UP))
- enter_level = true;
- }
+ enter_level = true;
+ }
if(main_controller->pressed(Controller::PAUSE_MENU))
on_escape_press();
if (level->pos == tux->get_tile_pos()) {
try {
Vector shrinkpos = Vector(level->pos.x*32 + 16 - camera_offset.x,
- level->pos.y*32 + 16 - camera_offset.y);
+ level->pos.y*32 + 8 - camera_offset.y);
std::string levelfile = levels_path + level->get_name();
// update state and savegame
save_state();
main_loop->push_screen(new GameSession(levelfile, &level->statistics),
- new ShrinkFade(shrinkpos, 0.5));
+ new ShrinkFade(shrinkpos, 1.0f));
in_level = true;
} catch(std::exception& e) {
log_fatal << "Couldn't load level: " << e.what() << std::endl;
if(level->title == "")
get_level_title(*level);
- context.draw_text(white_text, level->title,
+ context.draw_text(normal_font, level->title,
Vector(SCREEN_WIDTH/2,
- SCREEN_HEIGHT - white_text->get_height() - 30),
- ALIGN_CENTER, LAYER_FOREGROUND1);
+ SCREEN_HEIGHT - normal_font->get_height() - 30),
+ ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::level_title_color);
// if level is solved, draw level picture behind stats
/*
if (special_tile->pos == tux->get_tile_pos()) {
/* Display an in-map message in the map, if any as been selected */
if(!special_tile->map_message.empty() && !special_tile->passive_message)
- context.draw_text(gold_text, special_tile->map_message,
+ context.draw_text(normal_font, special_tile->map_message,
Vector(SCREEN_WIDTH/2,
- SCREEN_HEIGHT - white_text->get_height() - 60),
- ALIGN_CENTER, LAYER_FOREGROUND1);
+ SCREEN_HEIGHT - normal_font->get_height() - 60),
+ ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::message_color);
break;
}
}
// display teleporter messages
Teleporter* teleporter = at_teleporter(tux->get_tile_pos());
if (teleporter && (teleporter->message != "")) {
- Vector pos = Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - white_text->get_height() - 30);
- context.draw_text(white_text, teleporter->message, pos, ALIGN_CENTER, LAYER_FOREGROUND1);
+ Vector pos = Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - normal_font->get_height() - 30);
+ context.draw_text(normal_font, teleporter->message, pos, ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::teleporter_message_color);
}
}
/* Display a passive message in the map, if needed */
if(passive_message_timer.started())
- context.draw_text(gold_text, passive_message,
- Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - white_text->get_height() - 60),
- ALIGN_CENTER, LAYER_FOREGROUND1);
+ context.draw_text(normal_font, passive_message,
+ Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - normal_font->get_height() - 60),
+ ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::message_color);
context.pop_transform();
}
throw SquirrelError(global_vm, "Couldn't set worldmap in roottable");
sq_pop(global_vm, 1);
+ //Run default.nut just before init script
+ try {
+ IFileStream in(levels_path + "/default.nut");
+ run_script(in, "WorldMap::default.nut");
+ } catch(std::exception& ) {
+ // doesn't exist or erroneous; do nothing
+ }
+
+
if(init_script != "") {
std::istringstream in(init_script);
run_script(in, "WorldMap::init");
for(LevelTiles::iterator i = levels.begin(); i != levels.end(); ++i) {
LevelTile* level = *i;
- sq_pushstring(vm, level->get_name().c_str(), -1);
- sq_newtable(vm);
+ sq_pushstring(vm, level->get_name().c_str(), -1);
+ sq_newtable(vm);
- store_bool(vm, "solved", level->solved);
- level->statistics.serialize_to_squirrel(vm);
+ store_bool(vm, "solved", level->solved);
+ level->statistics.serialize_to_squirrel(vm);
- sq_createslot(vm, -3);
+ sq_createslot(vm, -3);
}
sq_createslot(vm, -3);