mirror of
https://github.com/edubart/otclient.git
synced 2025-12-01 15:36:50 +01:00
rework log function and protocol
* remove some protocol ifdefs, replace with game features system
This commit is contained in:
@@ -52,8 +52,8 @@ void exitSignalHandler(int sig)
|
||||
break;
|
||||
}
|
||||
}
|
||||
Application::Application(const std::string& appName)
|
||||
|
||||
Application::Application(const std::string& appName)
|
||||
{
|
||||
g_app = this;
|
||||
m_appName = appName;
|
||||
|
||||
@@ -45,7 +45,7 @@ bool ConfigManager::load(const std::string& file)
|
||||
m_confsDoc = confsDoc;
|
||||
return true;
|
||||
} catch(stdext::exception& e) {
|
||||
logError("could not load configurations: ", e.what());
|
||||
logError("Unable to load configuration file: %s", e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void FileStream::cache()
|
||||
m_cacheBuffer.resize(size);
|
||||
int res = PHYSFS_read(m_fileHandle, &m_cacheBuffer[0], size, 1);
|
||||
if(res == -1)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
|
||||
PHYSFS_close(m_fileHandle);
|
||||
m_fileHandle = nullptr;
|
||||
@@ -58,7 +58,7 @@ bool FileStream::close()
|
||||
{
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_isInit() && PHYSFS_close(m_fileHandle) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
|
||||
m_fileHandle = nullptr;
|
||||
return true;
|
||||
@@ -75,7 +75,7 @@ bool FileStream::flush()
|
||||
return false;
|
||||
|
||||
if(PHYSFS_flush(m_fileHandle) == 0) {
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -86,7 +86,7 @@ int FileStream::read(void *buffer, int size, int nmemb)
|
||||
if(m_fileHandle) {
|
||||
int res = PHYSFS_read(m_fileHandle, buffer, size, nmemb);
|
||||
if(res == -1) {
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
return 0;
|
||||
}
|
||||
return res;
|
||||
@@ -111,7 +111,7 @@ bool FileStream::write(void *buffer, int count)
|
||||
return false;
|
||||
|
||||
if(PHYSFS_write(m_fileHandle, buffer, 1, count) != count) {
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,12 +122,12 @@ bool FileStream::seek(int pos)
|
||||
{
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_seek(m_fileHandle, pos) == 0) {
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if(pos > (int)m_cacheBuffer.size() || pos < 0) {
|
||||
logTraceError("operation failed on '", m_name, "': seek pos cannot be greater than file length");
|
||||
logTraceError("operation failed on '%s': seek pos cannot be greater than file length", m_name);
|
||||
return false;
|
||||
}
|
||||
m_cacheReadPos = pos;
|
||||
@@ -156,10 +156,10 @@ uint8 FileStream::getU8()
|
||||
uint8 v = 0;
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_read(m_fileHandle, &v, 1, 1) != 1)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
} else {
|
||||
if(m_cacheReadPos+1 > m_cacheBuffer.size()) {
|
||||
logTraceError("operation failed on '", m_name, "': reached file eof");
|
||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -174,10 +174,10 @@ uint16 FileStream::getU16()
|
||||
uint16 v = 0;
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_readULE16(m_fileHandle, &v) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
} else {
|
||||
if(m_cacheReadPos+2 > m_cacheBuffer.size()) {
|
||||
logTraceError("operation failed on '", m_name, "': reached file eof");
|
||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -192,10 +192,10 @@ uint32 FileStream::getU32()
|
||||
uint32 v = 0;
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_readULE32(m_fileHandle, &v) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
} else {
|
||||
if(m_cacheReadPos+4 > m_cacheBuffer.size()) {
|
||||
logTraceError("operation failed on '", m_name, "': reached file eof");
|
||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -210,10 +210,10 @@ uint64 FileStream::getU64()
|
||||
uint64 v = 0;
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_readULE64(m_fileHandle, (PHYSFS_uint64*)&v) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
} else {
|
||||
if(m_cacheReadPos+8 > m_cacheBuffer.size()) {
|
||||
logTraceError("operation failed on '", m_name, "': reached file eof");
|
||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -231,12 +231,12 @@ std::string FileStream::getString()
|
||||
char buffer[8192];
|
||||
if(m_fileHandle) {
|
||||
if(PHYSFS_read(m_fileHandle, buffer, 1, len) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
else
|
||||
str = std::string(buffer, len);
|
||||
} else {
|
||||
if(m_cacheReadPos+len > m_cacheBuffer.size()) {
|
||||
logTraceError("operation failed on '", m_name, "': reached file eof");
|
||||
logTraceError("operation failed on '%s': reached file eof", m_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ std::string FileStream::getString()
|
||||
m_cacheReadPos += len;
|
||||
}
|
||||
} else {
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@@ -252,23 +252,23 @@ std::string FileStream::getString()
|
||||
void FileStream::addU8(uint8 v)
|
||||
{
|
||||
if(PHYSFS_write(m_fileHandle, &v, 1, 1) != 1)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
}
|
||||
|
||||
void FileStream::addU16(uint8 v)
|
||||
{
|
||||
if(PHYSFS_writeULE16(m_fileHandle, v) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
}
|
||||
|
||||
void FileStream::addU32(uint8 v)
|
||||
{
|
||||
if(PHYSFS_writeULE32(m_fileHandle, v) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
}
|
||||
|
||||
void FileStream::addU64(uint8 v)
|
||||
{
|
||||
if(PHYSFS_writeULE64(m_fileHandle, v) == 0)
|
||||
logTraceError("operation failed on '", m_name, "': ", PHYSFS_getLastError());
|
||||
logTraceError("operation failed on '%s': %s", m_name, PHYSFS_getLastError());
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ void Logger::setLogFile(const std::string& file)
|
||||
{
|
||||
m_outFile.open(file.c_str(), std::ios::out | std::ios::app);
|
||||
if(!m_outFile.is_open() || !m_outFile.good()) {
|
||||
logError("Unable to save log to '", file, "'");
|
||||
logError("Unable to save log to '%s'", file);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,17 +57,17 @@ private:
|
||||
extern Logger g_logger;
|
||||
|
||||
// specialized logging
|
||||
#define logDebug(...) g_logger.log(Fw::LogDebug, stdext::mkstr(__VA_ARGS__))
|
||||
#define logInfo(...) g_logger.log(Fw::LogInfo, stdext::mkstr(__VA_ARGS__))
|
||||
#define logWarning(...) g_logger.log(Fw::LogWarning, stdext::mkstr(__VA_ARGS__))
|
||||
#define logError(...) g_logger.log(Fw::LogError, stdext::mkstr(__VA_ARGS__))
|
||||
#define logFatal(...) g_logger.log(Fw::LogFatal, stdext::mkstr(__VA_ARGS__))
|
||||
#define logDebug(...) g_logger.log(Fw::LogDebug, stdext::format(__VA_ARGS__))
|
||||
#define logInfo(...) g_logger.log(Fw::LogInfo, stdext::format(__VA_ARGS__))
|
||||
#define logWarning(...) g_logger.log(Fw::LogWarning, stdext::format(__VA_ARGS__))
|
||||
#define logError(...) g_logger.log(Fw::LogError, stdext::format(__VA_ARGS__))
|
||||
#define logFatal(...) g_logger.log(Fw::LogFatal, stdext::format(__VA_ARGS__))
|
||||
|
||||
#define logTrace() g_logger.logFunc(Fw::LogDebug, "", __PRETTY_FUNCTION__)
|
||||
#define logTraceDebug(...) g_logger.logFunc(Fw::LogDebug, stdext::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceInfo(...) g_logger.logFunc(Fw::LogInfo, stdext::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceWarning(...) g_logger.logFunc(Fw::LogWarning, stdext::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceError(...) g_logger.logFunc(Fw::LogError, stdext::mkstr(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceDebug(...) g_logger.logFunc(Fw::LogDebug, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceInfo(...) g_logger.logFunc(Fw::LogInfo, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceWarning(...) g_logger.logFunc(Fw::LogWarning, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
#define logTraceError(...) g_logger.logFunc(Fw::LogError, stdext::format(__VA_ARGS__), __PRETTY_FUNCTION__)
|
||||
|
||||
#define logTraceCounter() { \
|
||||
static int __count = 0; \
|
||||
|
||||
@@ -39,12 +39,12 @@ bool Module::load()
|
||||
for(const std::string& depName : m_dependencies) {
|
||||
ModulePtr dep = g_modules.getModule(depName);
|
||||
if(!dep) {
|
||||
logError("Unable to load module '", m_name, "' because dependency '", depName, "' was not found");
|
||||
logError("Unable to load module '%s' because dependency '%s' was not found", m_name, depName);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!dep->isLoaded() && !dep->load()) {
|
||||
logError("Unable to load module '", m_name, "' because dependency '", depName, "' has failed to laod");
|
||||
logError("Unable to load module '%s' because dependency '%s' has failed to load", m_name, depName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,13 @@ bool Module::load()
|
||||
m_loadCallback();
|
||||
|
||||
m_loaded = true;
|
||||
logInfo("Loaded module '", m_name, "'");
|
||||
logInfo("Loaded module '%s'", m_name);
|
||||
g_modules.updateModuleLoadOrder(asModule());
|
||||
|
||||
for(const std::string& modName : m_loadLaterModules) {
|
||||
ModulePtr dep = g_modules.getModule(modName);
|
||||
if(!dep)
|
||||
logError("Unable to find module '", modName, "' required by '", m_name, "'");
|
||||
logError("Unable to find module '%s' required by '%s'", modName, m_name);
|
||||
else if(!dep->isLoaded())
|
||||
dep->load();
|
||||
}
|
||||
@@ -73,7 +73,7 @@ void Module::unload()
|
||||
if(m_unloadCallback)
|
||||
m_unloadCallback();
|
||||
m_loaded = false;
|
||||
logInfo("Unloaded module '", m_name, "'");
|
||||
logInfo("Unloaded module '%s'", m_name);
|
||||
g_modules.updateModuleLoadOrder(asModule());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void ModuleManager::discoverModulesPath()
|
||||
for(const std::string& dir : possibleModulesDirs) {
|
||||
// try to add module directory
|
||||
if(g_resources.addToSearchPath(dir, false)) {
|
||||
logInfo("Using modules directory '", dir.c_str(), "'");
|
||||
logInfo("Using modules directory '%s'", dir.c_str());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ void ModuleManager::discoverModulesPath()
|
||||
for(const std::string& dir : possibleAddonsDirs) {
|
||||
// try to add module directory
|
||||
if(g_resources.addToSearchPath(dir, true)) {
|
||||
logInfo("Using addons directory '", dir.c_str(), "'");
|
||||
logInfo("Using addons directory '%s'", dir.c_str());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -103,8 +103,6 @@ ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
|
||||
OTMLNodePtr moduleNode = doc->at("Module");
|
||||
|
||||
std::string name = moduleNode->valueAt("name");
|
||||
//if(getModule(name))
|
||||
// stdext::throw_exception("module '", name, "' already exists, cannot have duplicate module names");
|
||||
|
||||
bool push = false;
|
||||
module = getModule(name);
|
||||
@@ -118,7 +116,7 @@ ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
|
||||
if(push)
|
||||
m_modules.push_back(module);
|
||||
} catch(stdext::exception& e) {
|
||||
logError("Unable to discover module from file '", moduleFile, "': ", e.what());
|
||||
logError("Unable to discover module from file '%s': %s", moduleFile, e.what());
|
||||
}
|
||||
return module;
|
||||
}
|
||||
@@ -127,7 +125,7 @@ void ModuleManager::ensureModuleLoaded(const std::string& moduleName)
|
||||
{
|
||||
ModulePtr module = g_modules.getModule(moduleName);
|
||||
if(!module || !module->load())
|
||||
logFatal("Unable to load '", moduleName, "' module");
|
||||
logFatal("Unable to load '%s' module", moduleName);
|
||||
}
|
||||
|
||||
void ModuleManager::unloadModules()
|
||||
|
||||
@@ -43,7 +43,7 @@ void ResourceManager::terminate()
|
||||
bool ResourceManager::setupWriteDir(const std::string& appWriteDirName)
|
||||
{
|
||||
std::string userDir = PHYSFS_getUserDir();
|
||||
std::string dirName = stdext::mkstr(".", appWriteDirName);
|
||||
std::string dirName = stdext::format(".%s", appWriteDirName);
|
||||
std::string writeDir = userDir + dirName;
|
||||
if(!PHYSFS_setWriteDir(writeDir.c_str())) {
|
||||
if(!PHYSFS_setWriteDir(userDir.c_str()))
|
||||
@@ -150,7 +150,7 @@ FileStreamPtr ResourceManager::openFile(const std::string& fileName)
|
||||
std::string fullPath = resolvePath(fileName);
|
||||
PHYSFS_File* file = PHYSFS_openRead(fullPath.c_str());
|
||||
if(!file) {
|
||||
logTraceError("unable to open file '", fullPath, "': ", PHYSFS_getLastError());
|
||||
logTraceError("unable to open file '%s': %s", fullPath, PHYSFS_getLastError());
|
||||
return nullptr;
|
||||
}
|
||||
return FileStreamPtr(new FileStream(fullPath, file));
|
||||
@@ -160,7 +160,7 @@ FileStreamPtr ResourceManager::appendFile(const std::string& fileName)
|
||||
{
|
||||
PHYSFS_File* file = PHYSFS_openAppend(fileName.c_str());
|
||||
if(!file) {
|
||||
logTraceError("failed to append file '", fileName, "': ", PHYSFS_getLastError());
|
||||
logTraceError("failed to append file '%s': %s", fileName, PHYSFS_getLastError());
|
||||
return nullptr;
|
||||
}
|
||||
return FileStreamPtr(new FileStream(fileName, file));
|
||||
@@ -170,7 +170,7 @@ FileStreamPtr ResourceManager::createFile(const std::string& fileName)
|
||||
{
|
||||
PHYSFS_File* file = PHYSFS_openWrite(fileName.c_str());
|
||||
if(!file) {
|
||||
logTraceError("failed to create file '", fileName, "': ", PHYSFS_getLastError());
|
||||
logTraceError("failed to create file '%s': %s", fileName, PHYSFS_getLastError());
|
||||
return nullptr;
|
||||
}
|
||||
return FileStreamPtr(new FileStream(fileName, file));
|
||||
@@ -211,7 +211,7 @@ std::string ResourceManager::resolvePath(const std::string& path)
|
||||
fullPath += path;
|
||||
}
|
||||
if(!(boost::starts_with(fullPath, "/")))
|
||||
logTraceWarning("the following file path is not fully resolved: ", path);
|
||||
logTraceWarning("the following file path is not fully resolved: %s", path);
|
||||
boost::replace_all(fullPath, "//", "/");
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@ bool FontManager::importFont(std::string fontFile)
|
||||
OTMLNodePtr fontNode = doc->at("Font");
|
||||
|
||||
std::string name = fontNode->valueAt("name");
|
||||
//if(fontExists(name))
|
||||
// stdext::throw_exception("font '", name, "' already exists, cannot have duplicate font names");
|
||||
|
||||
// remove any font with the same name
|
||||
for(auto it = m_fonts.begin(); it != m_fonts.end(); ++it) {
|
||||
@@ -69,7 +67,7 @@ bool FontManager::importFont(std::string fontFile)
|
||||
|
||||
return true;
|
||||
} catch(stdext::exception& e) {
|
||||
logError("Unable to load font from file '", fontFile, "': ", e.what());
|
||||
logError("Unable to load font from file '%s': %s", fontFile, e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -92,7 +90,7 @@ FontPtr FontManager::getFont(const std::string& fontName)
|
||||
}
|
||||
|
||||
// when not found, fallback to default font
|
||||
logError("font '", fontName, "' not found");
|
||||
logError("font '%s' not found", fontName);
|
||||
return getDefaultFont();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ Graphics::Graphics()
|
||||
|
||||
void Graphics::init()
|
||||
{
|
||||
logInfo("GPU ", glGetString(GL_RENDERER));
|
||||
logInfo("OpenGL ", glGetString(GL_VERSION));
|
||||
logInfo("GPU %s", glGetString(GL_RENDERER));
|
||||
logInfo("OpenGL %s", glGetString(GL_VERSION));
|
||||
|
||||
#if OPENGL_ES==2
|
||||
g_painterOGL2 = new PainterOGL2;
|
||||
@@ -56,7 +56,7 @@ void Graphics::init()
|
||||
// init GL extensions
|
||||
GLenum err = glewInit();
|
||||
if(err != GLEW_OK)
|
||||
logFatal("Unable to init GLEW: ", glewGetErrorString(err));
|
||||
logFatal("Unable to init GLEW: %s", glewGetErrorString(err));
|
||||
|
||||
// overwrite framebuffer API if needed
|
||||
if(GLEW_EXT_framebuffer_object && !GLEW_ARB_framebuffer_object) {
|
||||
|
||||
@@ -46,7 +46,7 @@ ImagePtr Image::load(const std::string& file)
|
||||
// load image file data
|
||||
image = loadPNG(file);
|
||||
} catch(stdext::exception& e) {
|
||||
logError("unable to load image '", file, "': ", e.what());
|
||||
logError("unable to load image '%s': %s", file, e.what());
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ bool ParticleManager::load(const std::string& filename)
|
||||
}
|
||||
return true;
|
||||
} catch(stdext::exception& e) {
|
||||
logError("could not load particles: ", e.what());
|
||||
logError("could not load particles: %s", e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ bool ShaderProgram::addShader(const ShaderPtr& shader) {
|
||||
bool ShaderProgram::addShaderFromSourceCode(Shader::ShaderType shaderType, const std::string& sourceCode) {
|
||||
ShaderPtr shader(new Shader(shaderType));
|
||||
if(!shader->compileSourceCode(sourceCode)) {
|
||||
logError("failed to compile shader: ", shader->log());
|
||||
logError("failed to compile shader: %s", shader->log());
|
||||
return false;
|
||||
}
|
||||
return addShader(shader);
|
||||
@@ -57,7 +57,7 @@ bool ShaderProgram::addShaderFromSourceCode(Shader::ShaderType shaderType, const
|
||||
bool ShaderProgram::addShaderFromSourceFile(Shader::ShaderType shaderType, const std::string& sourceFile) {
|
||||
ShaderPtr shader(new Shader(shaderType));
|
||||
if(!shader->compileSourceFile(sourceFile)) {
|
||||
logError("failed to compile shader: ", shader->log());
|
||||
logError("failed to compile shader: %s", shader->log());
|
||||
return false;
|
||||
}
|
||||
return addShader(shader);
|
||||
|
||||
@@ -82,9 +82,10 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
|
||||
|
||||
// checks texture max size
|
||||
if(std::max(glSize.width(), glSize.height()) > g_graphics.getMaxTextureSize()) {
|
||||
logError("loading texture with size ", width, "x", height, " failed, "
|
||||
"the maximum size allowed by the graphics card is ", g_graphics.getMaxTextureSize(), "x", g_graphics.getMaxTextureSize(), ",",
|
||||
"to prevent crashes the texture will be displayed as a blank texture");
|
||||
logError("loading texture with size %dx%d failed, "
|
||||
"the maximum size allowed by the graphics card is %dx%d,"
|
||||
"to prevent crashes the texture will be displayed as a blank texture",
|
||||
width, height, g_graphics.getMaxTextureSize(), g_graphics.getMaxTextureSize());
|
||||
//TODO: make a workaround, could be bilinear scaling the texture
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ TexturePtr TextureManager::getTexture(const std::string& fileName)
|
||||
g_resources.loadFile(filePath, fin);
|
||||
texture = loadPNG(fin);
|
||||
} catch(stdext::exception& e) {
|
||||
logError("unable to load texture '", fileName, "': ", e.what());
|
||||
logError("unable to load texture '%s': %s", fileName, e.what());
|
||||
texture = g_graphics.getEmptyTexture();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,21 +33,21 @@ void LuaException::generateLuaErrorMessage(const std::string& error, int traceLe
|
||||
{
|
||||
// append trace level to error message
|
||||
if(traceLevel >= 0)
|
||||
m_what = stdext::mkstr("LUA ERROR: ", g_lua.traceback(error, traceLevel));
|
||||
m_what = stdext::format("LUA ERROR: %s", g_lua.traceback(error, traceLevel));
|
||||
else
|
||||
m_what = stdext::mkstr("LUA ERROR: ", error);
|
||||
m_what = stdext::format("LUA ERROR: %s", error);
|
||||
}
|
||||
|
||||
LuaBadNumberOfArgumentsException::LuaBadNumberOfArgumentsException(int expected, int got)
|
||||
{
|
||||
std::string error = "attempt to call a function with wrong number of arguments";
|
||||
if(expected >= 0 && got >= 0)
|
||||
error = stdext::mkstr(error, " (expected ", expected, ", but got ", got, ")");
|
||||
error = stdext::format("%s (expected %d, but got %d)", error, expected, got);
|
||||
generateLuaErrorMessage(error, 1);
|
||||
}
|
||||
|
||||
LuaBadValueCastException::LuaBadValueCastException(const std::string& luaTypeName, const std::string& cppTypeName)
|
||||
{
|
||||
std::string error = stdext::mkstr("attempt to cast a '", luaTypeName, "' lua value to '", cppTypeName, "'");
|
||||
std::string error = stdext::format("attempt to cast a '%s' lua value to '%s'", luaTypeName, cppTypeName);
|
||||
generateLuaErrorMessage(error, 0);
|
||||
}
|
||||
|
||||
@@ -163,12 +163,12 @@ void LuaInterface::registerClassMemberField(const std::string& className,
|
||||
|
||||
if(getFunction) {
|
||||
pushCppFunction(getFunction);
|
||||
setField(stdext::mkstr("get_", field));
|
||||
setField(stdext::format("get_%s", field));
|
||||
}
|
||||
|
||||
if(setFunction) {
|
||||
pushCppFunction(setFunction);
|
||||
setField(stdext::mkstr("set_", field));
|
||||
setField(stdext::format("set_%s", field));
|
||||
}
|
||||
|
||||
pop();
|
||||
@@ -324,9 +324,9 @@ void LuaInterface::loadFunction(const std::string& buffer, const std::string& so
|
||||
|
||||
std::string buf;
|
||||
if(boost::starts_with(buffer, "function"))
|
||||
buf = stdext::mkstr("__func = ", buffer);
|
||||
buf = stdext::format("__func = %s", buffer);
|
||||
else
|
||||
buf = stdext::mkstr("__func = function(self)\n", buffer,"\nend");
|
||||
buf = stdext::format("__func = function(self)\n%s\nend", buffer);
|
||||
|
||||
loadBuffer(buf, source);
|
||||
safeCall();
|
||||
@@ -343,7 +343,7 @@ void LuaInterface::evaluateExpression(const std::string& expression, const std::
|
||||
{
|
||||
// evaluates the expression
|
||||
if(!expression.empty()) {
|
||||
std::string buffer = stdext::mkstr("__exp = (", expression, ")");
|
||||
std::string buffer = stdext::format("__exp = (%s)", expression);
|
||||
loadBuffer(buffer, source);
|
||||
safeCall();
|
||||
|
||||
@@ -480,7 +480,7 @@ int LuaInterface::protectedCall(int numArgs, int requestedResults)
|
||||
throw LuaException("attempt to call a non function value", 0);
|
||||
}
|
||||
} catch(LuaException &e) {
|
||||
logError("protected lua call failed: ", e.what());
|
||||
logError("protected lua call failed: %s", e.what());
|
||||
}
|
||||
|
||||
// pushes nil values if needed
|
||||
@@ -515,7 +515,7 @@ int LuaInterface::luaScriptLoader(lua_State* L)
|
||||
g_lua.loadScript(fileName);
|
||||
return 1;
|
||||
} catch(LuaException& e) {
|
||||
logError("failed to load script file '", fileName, "' :'", e.what());
|
||||
logError("failed to load script file '%s': %s", fileName, e.what());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ int LuaInterface::luaScriptRunner(lua_State* L)
|
||||
g_lua.call(0, LUA_MULTRET);
|
||||
return g_lua.stackSize();
|
||||
} catch(LuaException& e) {
|
||||
logError("failed to load script file '", fileName, "' :'", e.what());
|
||||
logError("failed to load script file '%s': %s", fileName, e.what());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -548,7 +548,7 @@ int LuaInterface::luaScriptsRunner(lua_State* L)
|
||||
g_lua.loadScript(directory + "/" + fileName);
|
||||
g_lua.call(0, 0);
|
||||
} catch(LuaException& e) {
|
||||
logError("failed to load script file '", fileName, "' :'", e.what());
|
||||
logError("failed to load script file '%s': %s", fileName, e.what());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -583,7 +583,7 @@ int LuaInterface::luaCppFunctionCallback(lua_State* L)
|
||||
g_lua.m_cppCallbackDepth--;
|
||||
assert(numRets == g_lua.stackSize());
|
||||
} catch(LuaException &e) {
|
||||
logError("lua cpp callback failed: ", e.what());
|
||||
logError("lua cpp callback failed: %s", e.what());
|
||||
}
|
||||
|
||||
return numRets;
|
||||
@@ -1019,7 +1019,7 @@ void LuaInterface::pushObject(const LuaObjectPtr& obj)
|
||||
new(newUserdata(sizeof(LuaObjectPtr))) LuaObjectPtr(obj);
|
||||
|
||||
// set the userdata metatable
|
||||
getGlobal(stdext::mkstr(obj->getClassName(), "_mt"));
|
||||
getGlobal(stdext::format("%s_mt", obj->getClassName()));
|
||||
assert(!isNil());
|
||||
setMetatable();
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ bool luavalue_cast(int index, std::function<void(Args...)>& func) {
|
||||
"did you forget to hold a reference for that function?", 0);
|
||||
}
|
||||
} catch(LuaException& e) {
|
||||
logError("lua function callback failed: ", e.what());
|
||||
logError("lua function callback failed: %s", e.what());
|
||||
}
|
||||
};
|
||||
return true;
|
||||
@@ -239,7 +239,7 @@ luavalue_cast(int index, std::function<Ret(Args...)>& func) {
|
||||
"did you forget to hold a reference for that function?", 0);
|
||||
}
|
||||
} catch(LuaException& e) {
|
||||
logError("lua function callback failed: ", e.what());
|
||||
logError("lua function callback failed: %s", e.what());
|
||||
}
|
||||
return Ret();
|
||||
};
|
||||
|
||||
@@ -86,6 +86,7 @@ std::string InputMessage::getString()
|
||||
|
||||
void InputMessage::decryptRSA(int size, const std::string& p, const std::string& q, const std::string& d)
|
||||
{
|
||||
checkRead(size);
|
||||
RSA::decrypt((char*)m_buffer + m_readPos, size, p.c_str(), q.c_str(), d.c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ OTMLNodePtr OTMLNode::at(const std::string& childTag)
|
||||
}
|
||||
}
|
||||
if(!res)
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("child node with tag '", childTag, "' not found"));
|
||||
throw OTMLException(shared_from_this(), stdext::format("child node with tag '%s' not found", childTag));
|
||||
return res;
|
||||
}
|
||||
|
||||
OTMLNodePtr OTMLNode::atIndex(int childIndex)
|
||||
{
|
||||
if(childIndex >= size() || childIndex < 0)
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("child node with index '", childIndex, "' not found"));
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("child node with index '%d' not found", childIndex));
|
||||
return m_children[childIndex];
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ template<typename T>
|
||||
T OTMLNode::value() {
|
||||
T ret;
|
||||
if(!stdext::cast(m_value, ret))
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("failed to cast node value to type '", stdext::demangle_type<T>(), "'"));
|
||||
throw OTMLException(shared_from_this(), stdext::mkstr("failed to cast node value to type '%s'", stdext::demangle_type<T>()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <bitset>
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
#include <stack>
|
||||
|
||||
@@ -109,7 +109,7 @@ void crashHandler(int signum, siginfo_t* info, void* secret)
|
||||
fout << ss.str();
|
||||
fout << "\n";
|
||||
fout.close();
|
||||
logInfo("Crash report saved to file ", fileName.c_str());
|
||||
logInfo("Crash report saved to file %s", fileName.c_str());
|
||||
} else
|
||||
logError("Failed to save crash report!");
|
||||
|
||||
|
||||
@@ -134,14 +134,15 @@ LONG CALLBACK ExceptionHandler(LPEXCEPTION_POINTERS e)
|
||||
if(fout.is_open() && fout.good()) {
|
||||
fout << ss.str();
|
||||
fout.close();
|
||||
logInfo("Crash report saved to file ", fileName);
|
||||
logInfo("Crash report saved to file %s", fileName);
|
||||
} else
|
||||
logError("Failed to save crash report!");
|
||||
|
||||
// inform the user
|
||||
std::string msg = stdext::format("The application has crashed.\n\n"
|
||||
"A crash report has been written to:\n"
|
||||
"%s", fileName.c_str());
|
||||
std::string msg = stdext::format(
|
||||
"The application has crashed.\n\n"
|
||||
"A crash report has been written to:\n"
|
||||
"%s", fileName.c_str());
|
||||
MessageBox(NULL, msg.c_str(), "Application crashed", 0);
|
||||
|
||||
// this seems to silently close the application
|
||||
|
||||
@@ -680,7 +680,7 @@ void WIN32Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||
|
||||
apng_data apng;
|
||||
if(load_apng(fin, &apng) != 0) {
|
||||
logTraceError("unable to load png file ", file);
|
||||
logTraceError("unable to load png file %s", file);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -416,7 +416,7 @@ void X11Window::internalCreateGLContext()
|
||||
|
||||
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, attrList);
|
||||
if(m_eglContext == EGL_NO_CONTEXT )
|
||||
logFatal("Unable to create EGL context: ", eglGetError());
|
||||
logFatal("Unable to create EGL context: %s", eglGetError());
|
||||
#else
|
||||
m_glxContext = glXCreateContext(m_display, m_visual, NULL, True);
|
||||
|
||||
@@ -457,7 +457,7 @@ void X11Window::internalConnectGLContext()
|
||||
#ifdef OPENGL_ES
|
||||
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_window, NULL);
|
||||
if(m_eglSurface == EGL_NO_SURFACE)
|
||||
logFatal("Unable to create EGL surface: ", eglGetError());
|
||||
logFatal("Unable to create EGL surface: %s", eglGetError());
|
||||
if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
|
||||
logFatal("Unable to connect EGL context into X11 window");
|
||||
#else
|
||||
@@ -841,7 +841,7 @@ void X11Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||
|
||||
apng_data apng;
|
||||
if(load_apng(fin, &apng) != 0) {
|
||||
logTraceError("unable to load png file ", file);
|
||||
logTraceError("unable to load png file %s", file);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ bool OggSoundFile::prepareOgg()
|
||||
|
||||
vorbis_info* vi = ov_info(&m_vorbisFile, -1);
|
||||
if(!vi) {
|
||||
logError("ogg file not supported: ", m_file->name());
|
||||
logError("ogg file not supported: %s", m_file->name());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ bool SoundBuffer::fillBuffer(const SoundFilePtr& soundFile)
|
||||
{
|
||||
ALenum format = soundFile->getSampleFormat();
|
||||
if(format == AL_UNDETERMINED) {
|
||||
logError("unable to determine sample format for '", soundFile->getName(), "'");
|
||||
logError("unable to determine sample format for '%s'", soundFile->getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
DataBuffer<char> samples(soundFile->getSize());
|
||||
int read = soundFile->read(&samples[0], soundFile->getSize());
|
||||
if(read <= 0) {
|
||||
logError("unable to fill audio buffer data for '", soundFile->getName(), "'");
|
||||
logError("unable to fill audio buffer data for '%s'", soundFile->getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ bool SoundBuffer::fillBuffer(ALenum sampleFormat, const DataBuffer<char>& data,
|
||||
alBufferData(m_bufferId, sampleFormat, &data[0], size, rate);
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR) {
|
||||
logError("unable to fill audio buffer data: ", alGetString(err));
|
||||
logError("unable to fill audio buffer data: %s", alGetString(err));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -33,7 +33,7 @@ SoundFilePtr SoundFile::loadSoundFile(const std::string& filename)
|
||||
{
|
||||
FileStreamPtr file = g_resources.openFile(filename);
|
||||
if(!file) {
|
||||
logTraceError("unable to open ", filename);
|
||||
logTraceError("unable to open %s", filename);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ SoundFilePtr SoundFile::loadSoundFile(const std::string& filename)
|
||||
if(oggSoundFile->prepareOgg())
|
||||
soundFile = oggSoundFile;
|
||||
} else
|
||||
logError("unknown sound file format ", filename);
|
||||
logError("unknown sound file format %s", filename);
|
||||
|
||||
return soundFile;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void SoundManager::init()
|
||||
|
||||
m_context = alcCreateContext(m_device, NULL);
|
||||
if(!m_context) {
|
||||
logError("unable to create audio context: ", alcGetString(m_device, alcGetError(m_device)));
|
||||
logError("unable to create audio context: %s", alcGetString(m_device, alcGetError(m_device)));
|
||||
return;
|
||||
}
|
||||
alcMakeContextCurrent(m_context);
|
||||
@@ -136,7 +136,7 @@ void SoundManager::play(const std::string& filename)
|
||||
|
||||
SoundSourcePtr soundSource = createSoundSource(filename);
|
||||
if(!soundSource) {
|
||||
logError("unable to play '", filename, "'");
|
||||
logError("unable to play '%s'", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ void SoundManager::playMusic(const std::string& filename, float fadetime)
|
||||
|
||||
m_musicSource = createSoundSource(filename);
|
||||
if(!m_musicSource) {
|
||||
logError("unable to play '", filename, "'");
|
||||
logError("unable to play '%s'", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ SoundSourcePtr SoundManager::createSoundSource(const std::string& filename)
|
||||
buffer->fillBuffer(soundFile);
|
||||
source->setBuffer(buffer);
|
||||
m_buffers[filename] = buffer;
|
||||
logWarning("uncached sound '", filename, "' requested to be played");
|
||||
logWarning("uncached sound '%s' requested to be played", filename);
|
||||
} else {
|
||||
StreamSoundSourcePtr streamSource(new StreamSoundSource);
|
||||
streamSource->setSoundFile(soundFile);
|
||||
|
||||
@@ -143,12 +143,12 @@ bool StreamSoundSource::fillBufferAndQueue(ALuint buffer)
|
||||
alBufferData(buffer, format, &bufferData[0], bytesRead, m_soundFile->getRate());
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
logError("unable to refill audio buffer for '", m_soundFile->getName(), "': ", alGetString(err));
|
||||
logError("unable to refill audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err));
|
||||
|
||||
alSourceQueueBuffers(m_sourceId, 1, &buffer);
|
||||
err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
logError("unable to queue audio buffer for '", m_soundFile->getName(), "': ", alGetString(err));
|
||||
logError("unable to queue audio buffer for '%s': %s", m_soundFile->getName(), alGetString(err));
|
||||
}
|
||||
|
||||
// return false if there aren't more buffers to fill
|
||||
|
||||
@@ -54,4 +54,6 @@ const static dumper::dumper_util dump;
|
||||
|
||||
}
|
||||
|
||||
using stdext::dump;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,10 @@ T from_string(const std::string& str, T def = T()) { return unsafe_cast<T, std::
|
||||
|
||||
/// Cast non-class types like int, char, float, double and pointers
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value || std::is_pointer<T>::value || std::is_floating_point<T>::value, T>::type sprintf_cast(const T& t) { return t; }
|
||||
typename std::enable_if<std::is_integral<T>::value ||
|
||||
std::is_pointer<T>::value ||
|
||||
std::is_floating_point<T>::value ||
|
||||
std::is_enum<T>::value, T>::type sprintf_cast(const T& t) { return t; }
|
||||
|
||||
/// Cast any class or struct convertible to std::string
|
||||
inline const char *sprintf_cast(const std::string& s) { return s.c_str(); }
|
||||
|
||||
@@ -93,7 +93,7 @@ bool UIAnchorLayout::updateWidget(const UIWidgetPtr& widget, UIAnchorGroup& anch
|
||||
return false;
|
||||
|
||||
if(first == widget) {
|
||||
logError("child '", widget->getId(), "' of parent widget '", parentWidget->getId(), "' is recursively anchored to itself, please fix this");
|
||||
logError("child '%s' of parent widget '%s' is recursively anchored to itself, please fix this", widget->getId(), parentWidget->getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ void UIManager::onWidgetDestroy(const UIWidgetPtr& widget)
|
||||
g_lua.collectGarbage();
|
||||
for(const UIWidgetPtr& widget : backupList) {
|
||||
if(widget->getUseCount() != 1)
|
||||
logWarning("widget '", widget->getId(), "' destroyed but still have ", widget->getUseCount()-1, " reference(s) left");
|
||||
logWarning("widget '%s' destroyed but still have %d reference(s) left", widget->getId(), widget->getUseCount()-1);
|
||||
}
|
||||
}, 1);
|
||||
}, 1000);
|
||||
@@ -301,7 +301,7 @@ bool UIManager::importStyle(const std::string& file)
|
||||
importStyleFromOTML(styleNode);
|
||||
return true;
|
||||
} catch(stdext::exception& e) {
|
||||
logError("Failed to import UI styles from '", file, "': ", e.what());
|
||||
logError("Failed to import UI styles from '%s': %s", file, e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ void UIManager::importStyleFromOTML(const OTMLNodePtr& styleNode)
|
||||
/*
|
||||
auto it = m_styles.find(name);
|
||||
if(it != m_styles.end())
|
||||
logWarning("style '", name, "' is being redefined");
|
||||
logWarning("style '%s' is being redefined", name);
|
||||
*/
|
||||
|
||||
OTMLNodePtr originalStyle = getStyle(base);
|
||||
@@ -382,7 +382,7 @@ UIWidgetPtr UIManager::loadUI(const std::string& file, const UIWidgetPtr& parent
|
||||
|
||||
return widget;
|
||||
} catch(stdext::exception& e) {
|
||||
logError("failed to load UI from '", file, "': ", e.what());
|
||||
logError("failed to load UI from '%s': %s", file, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -393,7 +393,7 @@ UIWidgetPtr UIManager::createWidgetFromStyle(const std::string& styleName, const
|
||||
try {
|
||||
return createWidgetFromOTML(node, parent);
|
||||
} catch(stdext::exception& e) {
|
||||
logError("failed to create widget from style '", styleName, "': ", e.what());
|
||||
logError("failed to create widget from style '%s': %s", styleName, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ UIWidget::~UIWidget()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if(!m_destroyed)
|
||||
logWarning("widget '", m_id, "' was not explicitly destroyed");
|
||||
logWarning("widget '%s' was not explicitly destroyed", m_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ void UIWidget::applyStyle(const OTMLNodePtr& styleNode)
|
||||
}
|
||||
m_firstOnStyle = false;
|
||||
} catch(stdext::exception& e) {
|
||||
logError("Failed to apply style to widget '", m_id, "' style: ", e.what());
|
||||
logError("failed to apply style to widget '%s': %s", m_id, e.what());
|
||||
}
|
||||
m_loadingStyle = false;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ void UIWidget::addAnchor(Fw::AnchorEdge anchoredEdge, const std::string& hookedW
|
||||
if(UIAnchorLayoutPtr anchorLayout = getAnchoredLayout())
|
||||
anchorLayout->addAnchor(asUIWidget(), anchoredEdge, hookedWidgetId, hookedEdge);
|
||||
else
|
||||
logError("cannot add anchors to widget ", m_id, ": the parent doesn't use anchors layout");
|
||||
logError("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id);
|
||||
}
|
||||
|
||||
void UIWidget::removeAnchor(Fw::AnchorEdge anchoredEdge)
|
||||
@@ -530,7 +530,7 @@ void UIWidget::centerIn(const std::string& hookedWidgetId)
|
||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorHorizontalCenter, hookedWidgetId, Fw::AnchorHorizontalCenter);
|
||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorVerticalCenter, hookedWidgetId, Fw::AnchorVerticalCenter);
|
||||
} else
|
||||
logError("cannot add anchors to widget ", m_id, ": the parent doesn't use anchors layout");
|
||||
logError("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id);
|
||||
}
|
||||
|
||||
void UIWidget::fill(const std::string& hookedWidgetId)
|
||||
@@ -544,7 +544,7 @@ void UIWidget::fill(const std::string& hookedWidgetId)
|
||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorTop, hookedWidgetId, Fw::AnchorTop);
|
||||
anchorLayout->addAnchor(asUIWidget(), Fw::AnchorBottom, hookedWidgetId, Fw::AnchorBottom);
|
||||
} else
|
||||
logError("cannot add anchors to widget ", m_id, ": the parent doesn't use anchors layout");
|
||||
logError("cannot add anchors to widget '%s': the parent doesn't use anchors layout", m_id);
|
||||
}
|
||||
|
||||
void UIWidget::breakAnchors()
|
||||
@@ -710,7 +710,7 @@ void UIWidget::internalDestroy()
|
||||
void UIWidget::destroy()
|
||||
{
|
||||
if(m_destroyed)
|
||||
logWarning("attempt to destroy widget '", m_id, "' two times");
|
||||
logWarning("attempt to destroy widget '%s' two times", m_id);
|
||||
|
||||
// hold itself reference
|
||||
UIWidgetPtr self = asUIWidget();
|
||||
@@ -799,7 +799,7 @@ void UIWidget::setLayout(const UILayoutPtr& layout)
|
||||
bool UIWidget::setRect(const Rect& rect)
|
||||
{
|
||||
if(rect.width() > 8192 || rect.height() > 8192) {
|
||||
logError("attempt to set huge rect size (", rect,") for ", m_id);
|
||||
logError("attempt to set huge rect size (%s) for %s", stdext::to_string(rect), m_id);
|
||||
return false;
|
||||
}
|
||||
// only update if the rect really changed
|
||||
@@ -830,7 +830,7 @@ void UIWidget::setStyle(const std::string& styleName)
|
||||
{
|
||||
OTMLNodePtr styleNode = g_ui.getStyle(styleName);
|
||||
if(!styleNode) {
|
||||
logTraceError("unable to retrive style '", styleName, "': not a defined style");
|
||||
logTraceError("unable to retrieve style '%s': not a defined style", styleName);
|
||||
return;
|
||||
}
|
||||
styleNode = styleNode->clone();
|
||||
|
||||
@@ -41,7 +41,7 @@ void UIWidget::initBaseStyle()
|
||||
|
||||
// generate an unique id, this is need because anchored layouts find widgets by id
|
||||
static unsigned long id = 1;
|
||||
m_id = stdext::mkstr("widget", id++);
|
||||
m_id = stdext::format("widget %d", id++);
|
||||
}
|
||||
|
||||
void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||
|
||||
Reference in New Issue
Block a user