rework log function and protocol

* remove some protocol ifdefs, replace with game features system
This commit is contained in:
Eduardo Bart
2012-05-28 19:04:44 -03:00
parent 4c80d783d6
commit c01b32b032
51 changed files with 391 additions and 280 deletions

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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();

View File

@@ -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)