// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
+
#include "globals.h"
#include "defines.h"
#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
-Font::draw(const std::string& text, const Vector& pos)
+Font::draw(const std::string& text, const Vector& pos, Uint32 drawing_effect)
{
if(shadowsize > 0)
- draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize));
+ draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize),
+ drawing_effect);
- draw_chars(chars, text, pos);
+ draw_chars(chars, text, pos, drawing_effect);
}
void
-Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos)
+Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos,
+ Uint32 drawing_effect)
{
SurfaceImpl* impl = pchars->impl;
int source_x = (index % 16) * w;
int source_y = (index / 16) * h;
- impl->draw_part(source_x, source_y, p.x, p.y, w, h, 255);
+ impl->draw_part(source_x, source_y, p.x, p.y, w, h, 255, drawing_effect);
p.x += w;
}
}
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);