bool
LispReader::read_string (const char* name, std::string& str)
{
- lisp_object_t* obj = search_for (name);
+ char str_[1204];
+ sprintf(str_, "%s-%s", name, getenv("LANG"));
+ lisp_object_t* obj = search_for (str_);
+
+ if(!obj)
+ obj = search_for (name);
+
if (!obj)
return false;
#include "screen.h"
#include "font.h"
#include "drawing_context.h"
+#include "../lispreader.h"
Font::Font(const std::string& file, FontType ntype, int nw, int nh,
int nshadowsize)
void display_text_file(const std::string& file, Surface* surface, float scroll_speed)
{
- int done;
- float scroll;
- float speed;
- FILE* fi;
- char temp[1024];
+ std::string text;
std::vector<std::string> names;
- char filename[1024];
- sprintf(filename,"%s/%s", datadir.c_str(), file.c_str());
- if((fi = fopen(filename,"r")) != NULL)
+ 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)
{
- while(fgets(temp, sizeof(temp), fi) != NULL)
- {
- temp[strlen(temp)-1]='\0';
- names.push_back(temp);
- }
- fclose(fi);
+ LispReader reader(lisp_cdr(root_obj));
+ reader.read_string("text", text);
}
else
{
- names.push_back("File was not found!");
- names.push_back(filename);
- names.push_back("Shame on the guy, who");
- names.push_back("forgot to include it");
- names.push_back("in your SuperTux distribution.");
+ std::cerr << "Error: Could not open text. Ignoring...\n";
+ return;
+ }
+
+ unsigned int l, i;
+ l = 0;
+ while(true)
+ {
+ i = l;
+ l = text.find("\n", i);
+ if(l != std::string::npos)
+ break;
+
+ char* temp = 0;
+ text.copy(temp, l, i);
+ names.push_back(temp);
}
- scroll = 0;
- speed = scroll_speed / 50;
- done = 0;
+ int done = 0;
+ float scroll = 0;
+ float speed = scroll_speed / 50;
DrawingContext context;
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);