resource ls, init fonts
This commit is contained in:
parent
33a2b885b5
commit
884de984f3
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
#include "fonts.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
@ -47,6 +48,9 @@ void Engine::init()
|
||||||
// initialize graphics stuff
|
// initialize graphics stuff
|
||||||
g_graphics.init();
|
g_graphics.init();
|
||||||
|
|
||||||
|
// load fonts
|
||||||
|
g_fonts.load();
|
||||||
|
|
||||||
// finally show the window
|
// finally show the window
|
||||||
onResize(Platform::getWindowWidth(), Platform::getWindowHeight());
|
onResize(Platform::getWindowWidth(), Platform::getWindowHeight());
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include "fonts.h"
|
||||||
|
#include "resourcemanager.h"
|
||||||
|
|
||||||
|
Fonts g_fonts;
|
||||||
|
|
||||||
|
Fonts::Fonts()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Fonts::~Fonts()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Fonts::load()
|
||||||
|
{
|
||||||
|
std::list<std::string> files = g_resources.getDirectoryFiles("fonts");
|
||||||
|
for(std::list<std::string>::iterator it = files.begin(), end = files.end(); it != end; ++it) {
|
||||||
|
notice("File: %s", (*it).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef FONTS_H
|
||||||
|
#define FONTS_H
|
||||||
|
|
||||||
|
#include "prerequisites.h"
|
||||||
|
#include "rect.h"
|
||||||
|
|
||||||
|
struct Font
|
||||||
|
{
|
||||||
|
|
||||||
|
Rect textureArea[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
class Fonts
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Fonts();
|
||||||
|
~Fonts();
|
||||||
|
|
||||||
|
bool load();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<int, Font*> mFonts;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Fonts g_fonts;
|
||||||
|
|
||||||
|
#endif // FONTS_H
|
|
@ -117,3 +117,15 @@ bool ResourceManager::saveTextFile(const std::string &fileName, std::string text
|
||||||
{
|
{
|
||||||
return saveFile(fileName, (const unsigned char*)text.c_str(), text.size());
|
return saveFile(fileName, (const unsigned char*)text.c_str(), text.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::list<std::string> ResourceManager::getDirectoryFiles(const std::string& directory)
|
||||||
|
{
|
||||||
|
std::list<std::string> files;
|
||||||
|
char **rc = PHYSFS_enumerateFiles(directory.c_str());
|
||||||
|
|
||||||
|
for(char **i = rc; *i != NULL; i++)
|
||||||
|
files.push_back(*i);
|
||||||
|
|
||||||
|
PHYSFS_freeList(rc);
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
|
|
||||||
/// Save a text file into write directory
|
/// Save a text file into write directory
|
||||||
bool saveTextFile(const std::string &fileName, std::string text);
|
bool saveTextFile(const std::string &fileName, std::string text);
|
||||||
|
|
||||||
|
/// Get a list with all files in a directory
|
||||||
|
std::list<std::string> getDirectoryFiles(const std::string& directory);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ResourceManager g_resources;
|
extern ResourceManager g_resources;
|
||||||
|
|
Loading…
Reference in New Issue