Add support for drawing Text objects to Level.
authorMatt Mullins <mokomull@gmail.com>
Sat, 16 Jun 2012 04:51:42 +0000 (21:51 -0700)
committerMatt Mullins <mokomull@gmail.com>
Sat, 16 Jun 2012 05:05:10 +0000 (22:05 -0700)
Level.cpp
Level.h

index f6ed40b..52d820c 100644 (file)
--- a/Level.cpp
+++ b/Level.cpp
@@ -1,5 +1,6 @@
 #include "Level.h"
 #include "Game.h"
+#include "Text.h"
 #include "fns.h"
 #include <GL/gl.h>
 #include <algorithm>
@@ -62,6 +63,8 @@ void Level::drawScene()
        /** Draw Sprites*/
        DrawSprites();
 
+       DrawText();
+
        /** Draw Boundary Data */
        DrawCollisions();
 
@@ -76,6 +79,13 @@ void Level::DrawSprites()
        }
 }
 
+void Level::DrawText()
+{
+       for (vector<Text*>::iterator i = mText.begin(); i != mText.end(); ++i) {
+               (*i)->draw();
+       }
+}
+
 void Level::DrawCollisions()
 {
        if(Game::game()->ShowCollisions) {
@@ -290,3 +300,7 @@ void Level::closeFont( Font* f) {
                }
        }
 }
+
+void Level::addText(Text* t) {
+       mText.push_back(t);
+}
diff --git a/Level.h b/Level.h
index 2e16f34..ef42d4b 100644 (file)
--- a/Level.h
+++ b/Level.h
@@ -12,6 +12,8 @@
 using std::vector;
 using std::string;
 
+class Text;
+
 /**
 This is a stand alone Level that will have varying jobs
 
@@ -57,14 +59,19 @@ public:
        Sprite* findSpriteByName(string name);/**< returns the first Sprite with a given name \param name Name of the sprite to return \return Pointer to the requested sprite */
        bool Loaded;/**< Shows if the level has loaded or not (level changing) */
        void Unload();/**< What should be done when this level is left (not deleted) */
-       Font* getFont( int s, FontType t);/**< Grabs the font if it exists and creates it if it does not */
        void closeFont(Font *);/**< Closes the font if not more texts are using it. */
 
+       /**
+               Add a Text object to be drawn on the screen
+       */
+       void addText(Text*);
+
 protected://allow inheritance
        string mName;
        Background* mBackground;/**< Pointer to the current Background. */
        vector<WorldObject*> mWorldObjects;/**< Vector of all objects on the level.  \todo make a list ordered by Zorder (for drawing)*/
        vector<Sprite*> mSprites;/**< Vector of all sprites on the level */
+       vector<Text*> mText; /**< Text objects to be displayed */
        map<string,Actor> mActors;/**< This level's actors. */
        vector<Animation> mAnims;/**< This level's Animations */
        map<string, Texture> mTextures;/**< Textures that have been loaded by the level. */
@@ -77,6 +84,12 @@ protected://allow inheritance
        void DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2, int y2);/**< Draws an image at the specified location (x,y) that is blitted with width w and height h from the point (x2,y2) of the given image */
        void DrawSprites();/**< Draws all Sprites. */
        void DrawCollisions();/**< Draws all Collision data */
+
+       /**
+               Draws all Text elements on the screen.
+       */
+       void DrawText();
+
        Behavior mLoadBehavior;/**< will be used to define the Load action of the level */
        Behavior mUpdateBehavior;/**< will be used to define the update action of the level */
        Behavior mUnloadBehavior;/**< will be used to define the end action of the level as it closes*/