input_direction = NONE;
enter_level = false;
- name = "<no name>";
+ name = "<no file>";
music = "SALCON.MOD";
song = 0;
reader.read_string("name", &level.name);
reader.read_int("x", &level.x);
reader.read_int("y", &level.y);
+
+ get_level_title(&level); // get level's title
+
levels.push_back(level);
}
}
}
+void WorldMap::get_level_title(Levels::pointer level)
+{
+/** get level's title */
+level->title = "<no title>";
+
+FILE * fi;
+lisp_object_t* root_obj = 0;
+fi = fopen((datadir + "levels/" + level->name).c_str(), "r");
+if (fi == NULL)
+ {
+ perror((datadir + "levels/" + level->name).c_str());
+ return;
+ }
+
+lisp_stream_t stream;
+lisp_stream_init_file (&stream, fi);
+root_obj = lisp_read (&stream);
+
+if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR)
+ {
+ printf("World: Parse Error in file %s", level->name.c_str());
+ }
+
+if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0)
+ {
+ LispReader reader(lisp_cdr(root_obj));
+ reader.read_string("name", &level->title);
+ }
+
+fclose(fi);
+}
+
void
WorldMap::on_escape_press()
{
- std::cout << "on escape press" << std::endl;
-
+ // Show or hide the menu
if(!Menu::current())
Menu::set_current(worldmap_menu);
else
break;
case SDL_JOYAXISMOTION:
- switch(event.jaxis.axis)
+ if (event.jaxis.axis == joystick_keymap.x_axis)
{
- case JOY_X:
- if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ if (event.jaxis.value < -joystick_keymap.dead_zone)
input_direction = WEST;
- else if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ else if (event.jaxis.value > joystick_keymap.dead_zone)
input_direction = EAST;
- break;
- case JOY_Y:
- if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
+ }
+ else if (event.jaxis.axis == joystick_keymap.y_axis)
+ {
+ if (event.jaxis.value > joystick_keymap.dead_zone)
input_direction = SOUTH;
- else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
+ else if (event.jaxis.value < -joystick_keymap.dead_zone)
input_direction = NORTH;
- break;
}
break;
case SDL_JOYBUTTONDOWN:
- if (event.jbutton.button == JOY_B)
+ if (event.jbutton.button == joystick_keymap.b_button)
enter_level = true;
- else if (event.jbutton.button == JOY_START)
+ else if (event.jbutton.button == joystick_keymap.start_button)
on_escape_press();
break;
tux->update(0.33f);
}
- if(Menu::current())
+ Menu* menu = Menu::current();
+ if(menu)
{
- if(Menu::current() == worldmap_menu)
+ menu->action();
+
+ if(menu == worldmap_menu)
{
switch (worldmap_menu->check())
{
break;
}
}
+ else if(menu == options_menu)
+ {
+ process_options_menu();
+ }
}
}
if (i->x == tux->get_tile_pos().x &&
i->y == tux->get_tile_pos().y)
{
- white_text->draw_align(i->name.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM);
+ white_text->draw_align(i->title.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM);
break;
}
}
if(Menu::current())
{
- menu_process_current();
+ Menu::current()->draw();
mouse_cursor->draw();
}
flipscreen();