Merge branch 'master' of github.com:edubart/otclient

master
Eduardo Bart 13 years ago
commit 70a8338804

@ -93,12 +93,12 @@ void ConfigManager::setValue(const std::string &key, const char *value)
void ConfigManager::setValue(const std::string &key, int value)
{
setValue(key, boost::lexical_cast<std::string>(value));
setValue(key, convertType<std::string, int>(value));
}
void ConfigManager::setValue(const std::string &key, float value)
{
setValue(key, boost::lexical_cast<std::string>(value));
setValue(key, convertType<std::string, float>(value));
}
void ConfigManager::setValue(const std::string &key, bool value)
@ -127,7 +127,7 @@ float ConfigManager::getFloat(const std::string &key)
warning("Config value %s not found", key.c_str());
return 0;
}
return boost::lexical_cast<float>(iter->second);
return convertType<float, std::string>(iter->second);
}
bool ConfigManager::getBoolean(const std::string &key)
@ -147,5 +147,5 @@ int ConfigManager::getInteger(const std::string &key)
warning("Config value %s not found", key.c_str());
return 0;
}
return boost::lexical_cast<int>(iter->second);
return convertType<int, std::string>(iter->second);
}

@ -57,7 +57,7 @@ bool ResourceManager::setWriteDir(const std::string& path)
return ret;
}
bool ResourceManager::addToSearchPath(const std::string& path, bool insertInFront)
bool ResourceManager::addToSearchPath(const std::string& path, bool insertInFront /*= true*/)
{
if(!PHYSFS_addToSearchPath(path.c_str(), insertInFront ? 0 : 1)) {
error("Error while adding \"%s\" to resources search path: %s", path.c_str(), PHYSFS_getLastError());

@ -33,4 +33,21 @@ std::string vformat(const char *format, va_list args);
/// Formatting like printf for std::string
std::string format(const char *format, ...);
/// Convert any data type through boost::lexical_cast
//TODO: move declatation to util.cpp
template<class R, class T>
R convertType(T t)
{
R r = R();
try{
r = boost::lexical_cast<R>(t);
}
catch(boost::bad_lexical_cast bad){
//TODO: add an error message
}
return r;
}
#endif

@ -288,7 +288,7 @@ void Platform::showMouseCursor()
ShowCursor(true);
}
void Platform::setVsync(bool enable)
void Platform::setVsync(bool enable /*= true*/)
{
typedef GLint (*glSwapIntervalProc)(GLint);
glSwapIntervalProc glSwapInterval = NULL;

@ -108,7 +108,7 @@ int main(int argc, const char *argv[])
// state scope
{
std::unique_ptr<MenuState> menuState(new MenuState);
std::unique_ptr<MenuState> menuState(new MenuState());
g_engine.changeState(menuState.get());
Platform::showWindow();

@ -35,14 +35,14 @@ public:
MenuState();
virtual ~MenuState();
void onEnter();
void onLeave();
virtual void onEnter();
virtual void onLeave();
void onClose();
void onInputEvent(InputEvent *event);
virtual void onClose();
virtual void onInputEvent(InputEvent *event);
void render();
void update(int ticks, int elapsedTicks);
virtual void render();
virtual void update(int ticks, int elapsedTicks);
private:
TexturePtr m_background;

Loading…
Cancel
Save