mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 22:13:27 +02:00
add a new folder structure redesign organized by packages
This commit is contained in:
@@ -38,19 +38,19 @@ bool UIAnchorLayout::addAnchor(const UIElementPtr& anchoredElement, AnchorPoint
|
||||
UIElementPtr anchorLineElement = anchor.getAnchorLineElement();
|
||||
|
||||
if(!anchorLineElement) {
|
||||
error("ERROR: could not find the element to anchor on, wrong id?");
|
||||
logError("ERROR: could not find the element to anchor on, wrong id?");
|
||||
return false;
|
||||
}
|
||||
|
||||
// we can never anchor with itself
|
||||
if(anchoredElement == anchorLineElement) {
|
||||
error("ERROR: anchoring with itself is not possible");
|
||||
logError("ERROR: anchoring with itself is not possible");
|
||||
return false;
|
||||
}
|
||||
|
||||
// we must never anchor to an anchor child
|
||||
if(hasElementInAnchorTree(anchorLineElement, anchoredElement)) {
|
||||
error("ERROR: anchors is miss configurated, you must never make anchor chains in loops");
|
||||
logError("ERROR: anchors is miss configurated, you must never make anchor chains in loops");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -58,7 +58,7 @@ void UIElement::destroyCheck()
|
||||
UIElementPtr me = asUIElement();
|
||||
// check for leaks, the number of references must be always 2 here
|
||||
if(me.use_count() != 2 && me != UIContainer::getRoot()) {
|
||||
warning("destroyed element with id '",getId(),"', but it still have ",(me.use_count()-2)," references left");
|
||||
logWarning("destroyed element with id '",getId(),"', but it still have ",(me.use_count()-2)," references left");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ void UIElement::addAnchor(AnchorPoint anchoredEdge, AnchorLine anchorEdge)
|
||||
{
|
||||
UIElementPtr target = backwardsGetElementById(anchorEdge.getElementId());
|
||||
if(!target)
|
||||
warning("warning: element id '", anchorEdge.getElementId(), "' doesn't exist while anchoring element '", getId(), "'");
|
||||
logWarning("warning: element id '", anchorEdge.getElementId(), "' doesn't exist while anchoring element '", getId(), "'");
|
||||
|
||||
UIAnchorLayoutPtr layout = boost::dynamic_pointer_cast<UIAnchorLayout>(getLayout());
|
||||
if(layout)
|
||||
|
@@ -101,7 +101,6 @@ public:
|
||||
/// Get layout size, it always return the absolute position
|
||||
Rect getRect() const { return m_rect; }
|
||||
|
||||
// margins
|
||||
void setMargin(int top, int right, int bottom, int left) { m_marginLeft = left; m_marginRight = right; m_marginTop = top; m_marginBottom = bottom; getLayout()->recalculateElementLayout(asUIElement()); }
|
||||
void setMargin(int vertical, int horizontal) { m_marginLeft = m_marginRight = horizontal; m_marginTop = m_marginBottom = vertical; getLayout()->recalculateElementLayout(asUIElement()); }
|
||||
void setMargin(int margin) { m_marginLeft = m_marginRight = m_marginTop = m_marginBottom = margin; getLayout()->recalculateElementLayout(asUIElement()); }
|
||||
@@ -115,7 +114,6 @@ public:
|
||||
int getMarginTop() const { return m_marginTop; }
|
||||
int getMarginBottom() const { return m_marginBottom; }
|
||||
|
||||
// layout related
|
||||
void centerIn(const std::string& targetId);
|
||||
void addAnchor(AnchorPoint anchoredEdge, AnchorLine anchorEdge);
|
||||
|
||||
|
@@ -34,7 +34,7 @@ ImagePtr UIElementSkin::loadImage(OTMLNode* node)
|
||||
if(OTMLNode* cnode = node->at("bordered image")) {
|
||||
image = BorderedImage::loadFromOTMLNode(cnode, g_uiSkins.getDefaultTexture());
|
||||
if(!image)
|
||||
error(node->generateErrorMessage("failed to load bordered image"));
|
||||
logError(node->generateErrorMessage("failed to load bordered image"));
|
||||
} else if(OTMLNode* cnode = node->at("image")) {
|
||||
texture = g_textures.get(cnode->value());
|
||||
if(texture)
|
||||
@@ -43,7 +43,7 @@ ImagePtr UIElementSkin::loadImage(OTMLNode* node)
|
||||
m_defaultSize = texture->getSize();
|
||||
|
||||
if(!image)
|
||||
error(cnode->generateErrorMessage("failed to load image"));
|
||||
logError(cnode->generateErrorMessage("failed to load image"));
|
||||
}
|
||||
|
||||
if(texture) {
|
||||
|
@@ -67,7 +67,7 @@ UIElementPtr UILoader::loadFromFile(std::string filePath, const UIContainerPtr&
|
||||
// create element interpreting it's id
|
||||
element = createElementFromId(elementId);
|
||||
if(!element) {
|
||||
error(doc->front()->generateErrorMessage("invalid root element type"));
|
||||
logError(doc->front()->generateErrorMessage("invalid root element type"));
|
||||
return element;
|
||||
}
|
||||
parent->addChild(element);
|
||||
@@ -82,7 +82,7 @@ UIElementPtr UILoader::loadFromFile(std::string filePath, const UIContainerPtr&
|
||||
// report onLoad events
|
||||
element->onLoad();
|
||||
} catch(OTMLException e) {
|
||||
error("ERROR: Failed to load ui ",filePath,": ", e.what());
|
||||
logError("ERROR: Failed to load ui ",filePath,": ", e.what());
|
||||
}
|
||||
|
||||
return element;
|
||||
@@ -96,7 +96,7 @@ void UILoader::populateContainer(const UIContainerPtr& parent, OTMLNode* node)
|
||||
if(id[0] == '%') {
|
||||
UIElementPtr element = createElementFromId(id);
|
||||
if(!element) {
|
||||
error(cnode->generateErrorMessage("invalid element type"));
|
||||
logError(cnode->generateErrorMessage("invalid element type"));
|
||||
continue;
|
||||
}
|
||||
parent->addChild(element);
|
||||
@@ -184,20 +184,20 @@ void UILoader::loadElementAnchor(const UIElementPtr& anchoredElement, AnchorPoin
|
||||
|
||||
std::string anchorDescription = node->value();
|
||||
if(anchorDescription.empty()) {
|
||||
error(node->generateErrorMessage("anchor is empty, did you forget to fill it?"));
|
||||
logError(node->generateErrorMessage("anchor is empty, did you forget to fill it?"));
|
||||
return;
|
||||
}
|
||||
|
||||
UIAnchorLayoutPtr layout = boost::dynamic_pointer_cast<UIAnchorLayout>(anchoredElement->getLayout());
|
||||
if(!layout) {
|
||||
error(node->generateErrorMessage("could not add anchor, because this element does not participate of an anchor layout"));
|
||||
logError(node->generateErrorMessage("could not add anchor, because this element does not participate of an anchor layout"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> split;
|
||||
boost::split(split, anchorDescription, boost::is_any_of(std::string(".")));
|
||||
if(split.size() != 2) {
|
||||
error(node->generateErrorMessage("invalid anchor"));
|
||||
logError(node->generateErrorMessage("invalid anchor"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -205,12 +205,12 @@ void UILoader::loadElementAnchor(const UIElementPtr& anchoredElement, AnchorPoin
|
||||
AnchorPoint anchorLineEdge = UIAnchorLayout::parseAnchorPoint(split[1]);
|
||||
|
||||
if(anchorLineEdge == AnchorNone) {
|
||||
error(node->generateErrorMessage("invalid anchor type"));
|
||||
logError(node->generateErrorMessage("invalid anchor type"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!layout->addAnchor(anchoredElement, anchoredEdge, AnchorLine(anchorLineElementId, anchorLineEdge)))
|
||||
error(node->generateErrorMessage("anchoring failed"));
|
||||
logError(node->generateErrorMessage("anchoring failed"));
|
||||
}
|
||||
|
||||
void UILoader::loadElementScriptFunction(const UIElementPtr& element, OTMLNode* node)
|
||||
@@ -225,7 +225,7 @@ void UILoader::loadElementScriptFunction(const UIElementPtr& element, OTMLNode*
|
||||
if(g_lua.loadBufferAsFunction(node->value(), functionDesc))
|
||||
g_lua.setScriptObjectField(element, node->tag());
|
||||
else
|
||||
error(node->generateErrorMessage("failed to parse inline lua script"));
|
||||
logError(node->generateErrorMessage("failed to parse inline lua script"));
|
||||
}
|
||||
|
||||
void UILoader::loadButton(const UIButtonPtr& button, OTMLNode* node)
|
||||
|
@@ -42,7 +42,7 @@ void UISkins::load(const std::string& skinName)
|
||||
|
||||
std::stringstream fin;
|
||||
if(!g_resources.loadFile(skinName + ".otml", fin))
|
||||
fatal("FATAL ERROR: Could not load skin '",skinName,"'");
|
||||
logFatal("FATAL ERROR: Could not load skin '",skinName,"'");
|
||||
|
||||
try {
|
||||
OTMLParser parser(fin, skinName);
|
||||
@@ -50,7 +50,7 @@ void UISkins::load(const std::string& skinName)
|
||||
|
||||
m_defaultFont = g_fonts.get(doc->valueAt("default font"));
|
||||
if(!m_defaultFont)
|
||||
fatal("FATAL ERROR: Could not load skin default font");
|
||||
logFatal("FATAL ERROR: Could not load skin default font");
|
||||
|
||||
m_defaultFontColor = doc->readAt("default font color", Color::white);
|
||||
|
||||
@@ -81,7 +81,7 @@ void UISkins::load(const std::string& skinName)
|
||||
}
|
||||
}
|
||||
} catch(OTMLException e) {
|
||||
fatal("FATAL ERROR: Malformed skin file '",skinName,"':\n ",e.what());
|
||||
logFatal("FATAL ERROR: Malformed skin file '",skinName,"':\n ",e.what());
|
||||
}
|
||||
|
||||
g_resources.popCurrentPath();
|
||||
@@ -100,6 +100,6 @@ UIElementSkinPtr UISkins::getElementSkin(UI::ElementType elementType, const std:
|
||||
if(elementType == skin->getElementType() && name == skin->getName())
|
||||
return skin;
|
||||
}
|
||||
warning("Element skin '",name,"' not found");
|
||||
logWarning("Element skin '",name,"' not found");
|
||||
return UIElementSkinPtr();
|
||||
}
|
||||
|
Reference in New Issue
Block a user