Finish support for creating Text objects.
authorMatt Mullins <mokomull@gmail.com>
Sat, 16 Jun 2012 04:50:20 +0000 (21:50 -0700)
committerMatt Mullins <mokomull@gmail.com>
Sat, 16 Jun 2012 05:04:20 +0000 (22:04 -0700)
Text.cpp
Text.h

index 050a854..55e8d88 100644 (file)
--- a/Text.cpp
+++ b/Text.cpp
@@ -4,16 +4,28 @@
 #include "Game.h"
 #include "fns.h"
 #include <GL/gl.h>
+#include <stdexcept>
+#include <map>
+#include <fstream>
+#include <yaml-cpp/yaml.h>
 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 (file)
--- 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