当前位置: 首页>>代码示例>>C++>>正文


C++ OTMLNodePtr类代码示例

本文整理汇总了C++中OTMLNodePtr的典型用法代码示例。如果您正苦于以下问题:C++ OTMLNodePtr类的具体用法?C++ OTMLNodePtr怎么用?C++ OTMLNodePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OTMLNodePtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateStyle

void UIWidget::updateStyle()
{
    if(m_destroyed)
        return;

    if(m_loadingStyle && !m_updateStyleScheduled) {
        UIWidgetPtr self = static_self_cast<UIWidget>();
        g_dispatcher.addEvent([self] {
            self->m_updateStyleScheduled = false;
            self->updateStyle();
        });
        m_updateStyleScheduled = true;
        return;
    }

    if(!m_style)
        return;

    OTMLNodePtr newStateStyle = OTMLNode::create();

    // copy only the changed styles from default style
    if(m_stateStyle) {
        for(OTMLNodePtr node : m_stateStyle->children()) {
            if(OTMLNodePtr otherNode = m_style->get(node->tag()))
                newStateStyle->addChild(otherNode->clone());
        }
    }

    // checks for states combination
    for(const OTMLNodePtr& style : m_style->children()) {
        if(stdext::starts_with(style->tag(), "$")) {
            std::string statesStr = style->tag().substr(1);
            std::vector<std::string> statesSplit = stdext::split(statesStr, " ");

            bool match = true;
            for(std::string stateStr : statesSplit) {
                if(stateStr.length() == 0)
                    continue;

                bool notstate = (stateStr[0] == '!');
                if(notstate)
                    stateStr = stateStr.substr(1);

                bool stateOn = hasState(Fw::translateState(stateStr));
                if((!notstate && !stateOn) || (notstate && stateOn))
                    match = false;
            }

            // merge states styles
            if(match) {
                newStateStyle->merge(style);
            }
        }
    }

    //TODO: prevent setting already set proprieties

    applyStyle(newStateStyle);
    m_stateStyle = newStateStyle;
}
开发者ID:Pucker,项目名称:otclient,代码行数:60,代码来源:uiwidget.cpp

示例2: mergeNode

void Config::mergeNode(const std::string& key, const OTMLNodePtr& node)
{
    OTMLNodePtr clone = node->clone();
    node->setTag(key);
    node->setUnique(true);
    m_confsDoc->addChild(node);
}
开发者ID:JoseEduardo,项目名称:otclient,代码行数:7,代码来源:config.cpp

示例3: getStyle

std::string UIManager::getStyleClass(const std::string& styleName)
{
    OTMLNodePtr style = getStyle(styleName);
    if(style && style->get("__class"))
        return style->valueAt("__class");
    return "";
}
开发者ID:Xenioz,项目名称:otclient,代码行数:7,代码来源:uimanager.cpp

示例4: discoverModule

ModulePtr ModuleManager::discoverModule(const std::string& moduleFile)
{
    ModulePtr module;
    try {
        OTMLDocumentPtr doc = OTMLDocument::parse(moduleFile);
        OTMLNodePtr moduleNode = doc->at("Module");

        std::string name = moduleNode->valueAt("name");

        bool push = false;
        module = getModule(name);
        if(!module) {
            module = ModulePtr(new Module(name));
            push = true;
        }
        module->discover(moduleNode);

        // not loaded modules are always in back
        if(push)
            m_modules.push_back(module);
    } catch(stdext::exception& e) {
        g_logger.error(stdext::format("Unable to discover module from file '%s': %s", moduleFile, e.what()));
    }
    return module;
}
开发者ID:AdamSC1-ddg,项目名称:otclient,代码行数:25,代码来源:modulemanager.cpp

示例5: merge

void OTMLNode::merge(const OTMLNodePtr& node)
{
    for(const OTMLNodePtr& child : node->m_children)
        addChild(child->clone());
    setTag(node->tag());
    setSource(node->source());
}
开发者ID:AdamSC1-ddg,项目名称:otclient,代码行数:7,代码来源:otmlnode.cpp

示例6: getValue

std::string Config::getValue(const std::string& key)
{
    OTMLNodePtr child = m_confsDoc->get(key);
    if(child)
        return child->value();
    else
        return "";
}
开发者ID:JoseEduardo,项目名称:otclient,代码行数:8,代码来源:config.cpp

示例7: load

void ParticleEffectType::load(const OTMLNodePtr& node)
{
    m_node = node->clone();
    for(const OTMLNodePtr& childNode : node->children()) {
        if(childNode->tag() == "name")
            m_name = childNode->value();
        else if(childNode->tag() == "description")
            m_description = childNode->value();
    }
}
开发者ID:JoseEduardo,项目名称:otclient,代码行数:10,代码来源:particleeffect.cpp

示例8:

std::vector<std::string> Config::getList(const std::string& key)
{
    std::vector<std::string> list;
    OTMLNodePtr child = m_confsDoc->get(key);
    if(child) {
        for(const OTMLNodePtr& subchild : child->children())
            list.push_back(subchild->value());
    }
    return list;
}
开发者ID:JoseEduardo,项目名称:otclient,代码行数:10,代码来源:config.cpp

示例9: setTag

void OTMLNode::copy(const OTMLNodePtr& node)
{
    setTag(node->tag());
    setValue(node->rawValue());
    setUnique(node->isUnique());
    setNull(node->isNull());
    setSource(node->source());
    clear();
    for(const OTMLNodePtr& child : node->m_children)
        addChild(child->clone());
}
开发者ID:AdamSC1-ddg,项目名称:otclient,代码行数:11,代码来源:otmlnode.cpp

示例10: setStyle

void UIWidget::setStyle(const std::string& styleName)
{
    OTMLNodePtr styleNode = g_ui.getStyle(styleName);
    if(!styleNode) {
        g_logger.traceError(stdext::format("unable to retrieve style '%s': not a defined style", styleName));
        return;
    }
    styleNode = styleNode->clone();
    applyStyle(styleNode);
    m_style = styleNode;
    updateStyle();
}
开发者ID:Pucker,项目名称:otclient,代码行数:12,代码来源:uiwidget.cpp

示例11: setStyle

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");
        return;
    }
    styleNode = styleNode->clone();
    applyStyle(styleNode);
    m_style = styleNode;
    updateStyle();
}
开发者ID:Cayan,项目名称:otclient,代码行数:12,代码来源:uiwidget.cpp

示例12: remove

void Config::setList(const std::string& key, const std::vector<std::string>& list)
{
    remove(key);

    if(list.size() == 0)
        return;

    OTMLNodePtr child = OTMLNode::create(key, true);
    for(const std::string& value : list)
        child->writeIn(value);
    m_confsDoc->addChild(child);
}
开发者ID:JoseEduardo,项目名称:otclient,代码行数:12,代码来源:config.cpp

示例13: load

bool ParticleAffector::load(const OTMLNodePtr& node)
{
    float minDelay = 0, maxDelay = 0;
    float minDuration = -1, maxDuration = -1;

    for(const OTMLNodePtr& childNode : node->children()) {
        if(childNode->tag() == "delay") {
            minDelay = childNode->value<float>();
            maxDelay = childNode->value<float>();
        }
        else if(childNode->tag() == "min-delay")
            minDelay = childNode->value<float>();
        else if(childNode->tag() == "max-delay")
            maxDelay = childNode->value<float>();

        if(childNode->tag() == "duration") {
            minDuration = childNode->value<float>();
            maxDuration = childNode->value<float>();
        }
        else if(childNode->tag() == "min-duration")
            minDuration = childNode->value<float>();
        else if(childNode->tag() == "max-duration")
            maxDuration = childNode->value<float>();
    }

    m_delay = Fw::randomRange(minDelay, maxDelay);
    m_duration = Fw::randomRange(minDuration, maxDuration);

    return true;
}
开发者ID:Cayan,项目名称:otclient,代码行数:30,代码来源:particleaffector.cpp

示例14: discover

void Module::discover(const OTMLNodePtr& moduleNode)
{
    const static std::string none = "none";
    m_description = moduleNode->valueAt("description", none);
    m_author = moduleNode->valueAt("author", none);
    m_website = moduleNode->valueAt("website", none);
    m_version = moduleNode->valueAt("version", none);
    m_autoLoad = moduleNode->valueAt<bool>("autoload", false);
    m_reloadable = moduleNode->valueAt<bool>("reloadable", true);
    m_autoLoadPriority = moduleNode->valueAt<int>("autoload-priority", 9999);

    if(OTMLNodePtr node = moduleNode->get("dependencies")) {
        for(const OTMLNodePtr& tmp : node->children())
            m_dependencies.push_back(tmp->value());
    }

    // set onLoad callback
    if(OTMLNodePtr node = moduleNode->get("@onLoad")) {
        g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
        g_lua.useValue();
        m_loadCallback = g_lua.polymorphicPop<std::function<void()>>();
    }

    // set onUnload callback
    if(OTMLNodePtr node = moduleNode->get("@onUnload")) {
        g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
        g_lua.useValue();
        m_unloadCallback = g_lua.polymorphicPop<std::function<void()>>();
    }

    if(OTMLNodePtr node = moduleNode->get("load-later")) {
        for(const OTMLNodePtr& tmp : node->children())
            m_loadLaterModules.push_back(tmp->value());
    }
}
开发者ID:LeandroPerrotta,项目名称:otclient,代码行数:35,代码来源:module.cpp

示例15: onStyleApply

void UIProgressRect::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
{
    UIWidget::onStyleApply(styleName, styleNode);

    for(const OTMLNodePtr& node : styleNode->children()) {
        if(node->tag() == "percent")
            setPercent(node->value<float>());
    }
}
开发者ID:JoseEduardo,项目名称:otclient,代码行数:9,代码来源:uiprogressrect.cpp


注:本文中的OTMLNodePtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。