From 2e4bab3917708e24e72da635e1d1b715989ff424 Mon Sep 17 00:00:00 2001 From: Matt Mullins Date: Fri, 15 Jun 2012 21:50:20 -0700 Subject: [PATCH] Finish support for creating Text objects. --- Text.cpp | 18 +++++++++++++++--- Text.h | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Text.cpp b/Text.cpp index 050a854..55e8d88 100644 --- a/Text.cpp +++ b/Text.cpp @@ -4,16 +4,28 @@ #include "Game.h" #include "fns.h" #include +#include +#include +#include +#include using namespace std; -Text::Text(string id, FontType t, int s, SDL_Color c, int w, int h) +Text::Text(string filename, string id, FontType t, int s, SDL_Color c, + int w, int h) : WorldObject(id), mFont(Game::game()->getFont(s, t)), color(c), width(w), height(h) { - + ifstream ifs(filename.c_str()); + YAML::Parser parser(ifs); + YAML::Node byLanguage; + parser.GetNextDocument(byLanguage); + + /** \todo un-hard-code this language */ + const YAML::Node& byId = byLanguage["en"]; + byId[id] >> text; } Text::Text(string name, string t, int s, SDL_Color c, int w, int h) @@ -24,7 +36,7 @@ Text::Text(string name, string t, int s, SDL_Color c, int w, int h) width(w), height(h) { - + throw new runtime_error("I haven't implemented this yet."); } Text::~Text() diff --git a/Text.h b/Text.h index 10e411b..b3b28dd 100644 --- a/Text.h +++ b/Text.h @@ -26,7 +26,7 @@ public: int width; int height; Text(string name, string t, int size = 24, SDL_Color c = WHITE, int w = 600, int h = 150); - Text(string id, FontType t, int size = 24, SDL_Color c = WHITE, int w = 600, int h = 150); + Text(string filename, string id, FontType t, int size = 24, SDL_Color c = WHITE, int w = 600, int h = 150); ~Text(); }; #endif -- 2.11.0