rename g_config

This commit is contained in:
Eduardo Bart
2011-04-06 17:53:00 -03:00
parent 5ab943ce13
commit b1ec45783e
6 changed files with 41 additions and 42 deletions

View File

@@ -27,7 +27,7 @@
#include <yaml-cpp/yaml.h>
Configs g_config;
Configs g_configs;
bool Configs::load(const std::string& fileName)
{
@@ -99,43 +99,43 @@ void Configs::setValue(const std::string &key, bool value)
setValue(key,"false");
}
const std::string &Configs::getString(const std::string &key)
const std::string &Configs::getString(const std::string &key) const
{
auto iter = m_confsMap.find(key);
if(iter == m_confsMap.end()) {
auto it = m_confsMap.find(key);
if(it == m_confsMap.end()) {
warning("Config value %s not found", key.c_str());
static std::string emptystr;
return emptystr;
}
return iter->second;
return it->second;
}
float Configs::getFloat(const std::string &key)
float Configs::getFloat(const std::string &key) const
{
auto iter = m_confsMap.find(key);
if(iter == m_confsMap.end()) {
auto it = m_confsMap.find(key);
if(it == m_confsMap.end()) {
warning("Config value %s not found", key.c_str());
return 0;
}
return convertType<float, std::string>(iter->second);
return convertType<float, std::string>(it->second);
}
bool Configs::getBoolean(const std::string &key)
bool Configs::getBoolean(const std::string &key) const
{
auto iter = m_confsMap.find(key);
if(iter == m_confsMap.end()) {
auto it = m_confsMap.find(key);
if(it == m_confsMap.end()) {
warning("Config value %s not found", key.c_str());
return 0;
}
return (iter->second == "true");
return (it->second == "true");
}
int Configs::getInteger(const std::string &key)
int Configs::getInteger(const std::string &key) const
{
auto iter = m_confsMap.find(key);
if(iter == m_confsMap.end()) {
auto it = m_confsMap.find(key);
if(it == m_confsMap.end()) {
warning("Config value %s not found", key.c_str());
return 0;
}
return convertType<int, std::string>(iter->second);
return convertType<int, std::string>(it->second);
}

View File

@@ -44,16 +44,16 @@ public:
void setValue(const std::string &key, bool value);
void setValue(const std::string &key, int value);
const std::string &getString(const std::string &key);
float getFloat(const std::string &key);
bool getBoolean(const std::string &key);
int getInteger(const std::string &key);
const std::string &getString(const std::string &key) const;
float getFloat(const std::string &key) const;
bool getBoolean(const std::string &key) const;
int getInteger(const std::string &key) const;
private:
std::string m_fileName;
std::map<std::string, std::string> m_confsMap;
};
extern Configs g_config;
extern Configs g_configs;
#endif // CONFIGS_H

View File

@@ -36,12 +36,10 @@ public:
/// Load font from file
bool load(const std::string &file);
std::string& getName() { return m_name; }
const std::string& getName() const { return m_name; }
private:
std::string m_name;
};
typedef std::shared_ptr<Font> FontPtr;
#endif // FONT_H

View File

@@ -62,7 +62,7 @@ FrameBuffer::FrameBuffer(int width, int height)
oglDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)Platform::getExtensionProcAddress("glDeleteFramebuffers");
oglCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)Platform::getExtensionProcAddress("glCheckFramebufferStatus");
}
// generate FBO
oglGenFramebuffers(1, &m_fbo);
oglBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo);

View File

@@ -40,6 +40,7 @@ public:
void init();
void terminate();
/// Check if a GL extension is supported
bool isExtensionSupported(const char *extension);
/// Called after every window resize