Browse Source

resource ls, init fonts

Henrique Santiago 10 years ago
parent
commit
884de984f3

+ 4
- 0
src/framework/engine.cpp View File

@@ -23,6 +23,7 @@
23 23
 
24 24
 
25 25
 #include "engine.h"
26
+#include "fonts.h"
26 27
 #include "platform.h"
27 28
 #include "graphics.h"
28 29
 #include "input.h"
@@ -47,6 +48,9 @@ void Engine::init()
47 48
     // initialize graphics stuff
48 49
     g_graphics.init();
49 50
 
51
+    // load fonts
52
+    g_fonts.load();
53
+
50 54
     // finally show the window
51 55
     onResize(Platform::getWindowWidth(), Platform::getWindowHeight());
52 56
 }

+ 22
- 0
src/framework/fonts.cpp View File

@@ -0,0 +1,22 @@
1
+#include "fonts.h"
2
+#include "resourcemanager.h"
3
+
4
+Fonts g_fonts;
5
+
6
+Fonts::Fonts()
7
+{
8
+}
9
+
10
+Fonts::~Fonts()
11
+{
12
+}
13
+
14
+bool Fonts::load()
15
+{
16
+    std::list<std::string> files = g_resources.getDirectoryFiles("fonts");
17
+    for(std::list<std::string>::iterator it = files.begin(), end = files.end(); it != end; ++it) {
18
+        notice("File: %s", (*it).c_str());
19
+    }
20
+
21
+    return true;
22
+}

+ 27
- 0
src/framework/fonts.h View File

@@ -0,0 +1,27 @@
1
+#ifndef FONTS_H
2
+#define FONTS_H
3
+
4
+#include "prerequisites.h"
5
+#include "rect.h"
6
+
7
+struct Font
8
+{
9
+
10
+    Rect textureArea[256];
11
+};
12
+
13
+class Fonts
14
+{
15
+public:
16
+    Fonts();
17
+    ~Fonts();
18
+
19
+    bool load();
20
+
21
+private:
22
+    std::map<int, Font*> mFonts;
23
+};
24
+
25
+extern Fonts g_fonts;
26
+
27
+#endif // FONTS_H

+ 12
- 0
src/framework/resourcemanager.cpp View File

@@ -117,3 +117,15 @@ bool ResourceManager::saveTextFile(const std::string &fileName, std::string text
117 117
 {
118 118
     return saveFile(fileName, (const unsigned char*)text.c_str(), text.size());
119 119
 }
120
+
121
+std::list<std::string> ResourceManager::getDirectoryFiles(const std::string& directory)
122
+{
123
+    std::list<std::string> files;
124
+    char **rc = PHYSFS_enumerateFiles(directory.c_str());
125
+
126
+    for(char **i = rc; *i != NULL; i++)
127
+        files.push_back(*i);
128
+
129
+    PHYSFS_freeList(rc);
130
+    return files;
131
+}

+ 3
- 0
src/framework/resourcemanager.h View File

@@ -63,6 +63,9 @@ public:
63 63
 
64 64
     /// Save a text file into write directory
65 65
     bool saveTextFile(const std::string &fileName, std::string text);
66
+
67
+    /// Get a list with all files in a directory
68
+    std::list<std::string> getDirectoryFiles(const std::string& directory);
66 69
 };
67 70
 
68 71
 extern ResourceManager g_resources;

Loading…
Cancel
Save