[Super-tux-commit] supertux/src/screen font.cpp,1.6,1.7 font.h,1.5,1.6
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-07-07 22:47:16
|
Update of /cvsroot/super-tux/supertux/src/screen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29974/src/screen Modified Files: font.cpp font.h Log Message: Fixed the translating of the shown text files. Index: font.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/screen/font.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- font.cpp 7 Jul 2004 19:19:18 -0000 1.6 +++ font.cpp 7 Jul 2004 22:47:06 -0000 1.7 @@ -141,33 +141,39 @@ { std::string text; std::vector<std::string> names; - - lisp_object_t* root_obj = lisp_read_from_file(datadir + file); - lisp_object_t* cur = lisp_car(root_obj); - if (lisp_symbol_p(cur) && strcmp(lisp_symbol(cur), "text") == 0) - { - LispReader reader(lisp_cdr(root_obj)); - reader.read_string("text", text); - } - else + LispReader* reader = LispReader::load(datadir + "/" + file, "supertux-text"); + + if(!reader) { - std::cerr << "Error: Could not open text. Ignoring...\n"; - return; + std::cerr << "Error: Could not open text. Ignoring...\n"; + return; } - unsigned int l, i; - l = 0; + + reader->read_string("text", text); + delete reader; + + names.clear(); + unsigned int i, l; + i = 0; while(true) { - i = l; l = text.find("\n", i); - if(l != std::string::npos) + + if(l == std::string::npos) + { + char temp[1024]; + temp[text.copy(temp, text.size() - i, i)] = '\0'; + names.push_back(temp); break; + } - char* temp = 0; - text.copy(temp, l, i); + char temp[1024]; + temp[text.copy(temp, l-i, i)] = '\0'; names.push_back(temp); + + i = l+1; } int done = 0; Index: font.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/screen/font.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- font.h 29 Jun 2004 13:00:40 -0000 1.5 +++ font.h 7 Jul 2004 22:47:06 -0000 1.6 @@ -26,6 +26,8 @@ #include "surface.h" #include "vector.h" +/** 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); |