display_text_file() now reads the background image from the file.
authorRicardo Cruz <rick2@aeiou.pt>
Sat, 10 Jul 2004 14:07:04 +0000 (14:07 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Sat, 10 Jul 2004 14:07:04 +0000 (14:07 +0000)
SVN-Revision: 1563

src/intro.cpp
src/screen/font.cpp
src/screen/font.h
src/title.cpp
src/worldmap.cpp

index 587339e..e539279 100644 (file)
@@ -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);
 }
 
index 43e4165..2063286 100644 (file)
@@ -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<std::string> 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;
 }
 
index 68681f1..6ce4e10 100644 (file)
@@ -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
index 7ef9ff4..9d6388e 100644 (file)
@@ -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:
index 7237231..d69302f 100644 (file)
@@ -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;
                       }
                   }