From: Ricardo Cruz Date: Sat, 10 Jul 2004 14:07:04 +0000 (+0000) Subject: display_text_file() now reads the background image from the file. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f93fe31d61df5bdee12a35f6991ed75ea1259719;p=supertux.git display_text_file() now reads the background image from the file. SVN-Revision: 1563 --- diff --git a/src/intro.cpp b/src/intro.cpp index 587339e3a..e53927959 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -25,6 +25,6 @@ void draw_intro() { - display_text_file("intro.txt", "/images/background/arctis.jpg", SCROLL_SPEED_MESSAGE); + display_text_file("intro.txt", SCROLL_SPEED_MESSAGE); } diff --git a/src/screen/font.cpp b/src/screen/font.cpp index 43e416527..2063286a9 100644 --- a/src/screen/font.cpp +++ b/src/screen/font.cpp @@ -130,14 +130,7 @@ Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos, #define SCROLL 60 #define ITEMS_SPACE 4 -void display_text_file(const std::string& file, const std::string& surface, float scroll_speed) -{ - Surface* sur = new Surface(datadir + surface, IGNORE_ALPHA); - display_text_file(file, sur, scroll_speed); - delete sur; -} - -void display_text_file(const std::string& file, Surface* surface, float scroll_speed) +void display_text_file(const std::string& file, float scroll_speed) { std::string text; std::vector names; @@ -150,10 +143,12 @@ void display_text_file(const std::string& file, Surface* surface, float scroll_s return; } - reader->read_string("text", text, true); + std::string background_file; + reader->read_string("background", background_file, true); delete reader; + // Split text string lines into a vector names.clear(); unsigned int i, l; i = 0; @@ -176,6 +171,9 @@ void display_text_file(const std::string& file, Surface* surface, float scroll_s i = l+1; } + // load background image + Surface* background = new Surface(datadir + "/images/background/" + background_file, IGNORE_ALPHA); + int done = 0; float scroll = 0; float speed = scroll_speed / 50; @@ -225,7 +223,7 @@ void display_text_file(const std::string& file, Surface* surface, float scroll_s speed = -MAX_VEL; /* draw the credits */ - context.draw_surface(surface, Vector(0,0), 0); + context.draw_surface(background, Vector(0,0), 0); float y = 0; for(size_t i = 0; i < names.size(); i++) { @@ -265,6 +263,6 @@ void display_text_file(const std::string& file, Surface* surface, float scroll_s } SDL_EnableKeyRepeat(0, 0); // disables key repeating - Menu::set_current(main_menu); + delete background; } diff --git a/src/screen/font.h b/src/screen/font.h index 68681f18c..6ce4e1040 100644 --- a/src/screen/font.h +++ b/src/screen/font.h @@ -28,8 +28,7 @@ /** Reads a text file (using LispReader, so it as to be in its formatting) and displays it in a StarTrek fashion */ -void display_text_file(const std::string& file, const std::string& surface, float scroll_speed); -void display_text_file(const std::string& file, Surface* surface, float scroll_speed); +void display_text_file(const std::string& file, float scroll_speed); /* Text type */ class Font diff --git a/src/title.cpp b/src/title.cpp index 7ef9ff4c3..9d6388e81 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -345,7 +345,7 @@ void title(void) update_time = st_get_ticks(); break; case MNID_CREDITS: - display_text_file("CREDITS", bkg_title, SCROLL_SPEED_CREDITS); + display_text_file("CREDITS", SCROLL_SPEED_CREDITS); Menu::set_current(main_menu); break; case MNID_QUITMAINMENU: diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 72372314a..d69302f28 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -381,8 +381,6 @@ WorldMap::~WorldMap() void WorldMap::load_map() { - std::cout << "Loading map: " << datadir + "/levels/worldmap/" + map_filename << std::endl; - lisp_object_t* root_obj = lisp_read_from_file(datadir + "/levels/worldmap/" + map_filename); if (!root_obj) st_abort("Couldn't load file", datadir + "/levels/worldmap/" + map_filename); @@ -702,10 +700,8 @@ WorldMap::update(float delta) sound_manager->load_music(datadir + "/music/theme.mod"); sound_manager->play_music(theme); // Display final credits and go back to the main menu - display_text_file(level->extro_filename, - "/images/background/extro.jpg", SCROLL_SPEED_MESSAGE); - display_text_file("CREDITS", - "/images/background/oiltux.jpg", SCROLL_SPEED_CREDITS); + display_text_file(level->extro_filename, SCROLL_SPEED_MESSAGE); + display_text_file("CREDITS", SCROLL_SPEED_CREDITS); quit = true; } }