Update of /cvsroot/super-tux/supertux/src/screen
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28696/src/screen
Modified Files:
font.cpp font.h
Log Message:
display_text_file() now reads the background image from the file.
Index: font.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/screen/font.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- font.cpp 8 Jul 2004 10:11:07 -0000 1.8
+++ font.cpp 10 Jul 2004 14:07:03 -0000 1.9
@@ -130,14 +130,7 @@
#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 @@
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 @@
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 @@
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 @@
}
SDL_EnableKeyRepeat(0, 0); // disables key repeating
- Menu::set_current(main_menu);
+ delete background;
}
Index: font.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/screen/font.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- font.h 7 Jul 2004 22:47:06 -0000 1.6
+++ font.h 10 Jul 2004 14:07:03 -0000 1.7
@@ -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
|