Ejemplo n.º 1
0
void
GroupKnobSerialization::decode(const YAML::Node& node)
{
    _typeName = node["TypeName"].as<std::string>();
    _name = node["Name"].as<std::string>();
    if (node["Label"]) {
        _label = node["Label"].as<std::string>();
    } else {
        _label = _name;
    }

    if (node["Params"]) {
        YAML::Node paramsNode = node["Params"];
        for (std::size_t i = 0; i < paramsNode.size(); ++i) {

            std::string typeName;
            if (paramsNode[i]["TypeName"]) {
                typeName = paramsNode[i]["TypeName"].as<std::string>();
            }

            if (typeName == kKnobPageTypeName || typeName == kKnobGroupTypeName) {
                GroupKnobSerializationPtr s(new GroupKnobSerialization);
                s->decode(paramsNode[i]);
                _children.push_back(s);
            } else {
                KnobSerializationPtr s (new KnobSerialization);
                s->decode(paramsNode[i]);
                _children.push_back(s);
            }
        }
    }

    if (node["Props"]) {
        YAML::Node propsNode = node["Props"];
        for (std::size_t i = 0; i < propsNode.size(); ++i) {
            std::string prop = propsNode[i].as<std::string>();
            if (prop == "Opened") {
                _isOpened = true;
            } else if (prop == "Secret") {
                _secret = true;
            } else if (prop == "IsTab") {
                _isSetAsTab = true;
            }
        }
    }
} // GroupKnobSerialization::decode
Ejemplo n.º 2
0
void
SettingsSerialization::decode(const YAML::Node& node)
{

    if (node["Settings"]) {
        const YAML::Node& knobsNode = node["Settings"];
        for (std::size_t i = 0; i < knobsNode.size(); ++i) {
            KnobSerializationPtr n = boost::make_shared<KnobSerialization>();
            n->decode(knobsNode[i]);
            knobs.push_back(n);
        }
    }
    if (node["Plugins"]) {
        const YAML::Node& pluginNode = node["Plugins"];
        for (std::size_t i = 0; i < pluginNode.size(); ++i) {

            if (pluginNode[i].size() != 2) {
                throw YAML::InvalidNode();
            }

            PluginData data;
            PluginID id;

            const YAML::Node& idNode = pluginNode[0];
            id.identifier = idNode["ID"].as<std::string>();
            id.majorVersion = idNode["MajorVersion"].as<int>();
            id.minorVersion = idNode["MinorVersion"].as<int>();

            const YAML::Node& propsNode = pluginNode[1];

            for (std::size_t i = 0; i < propsNode.size(); ++i) {
                std::string prop = propsNode[i].as<std::string>();
                if (prop == "Disabled") {
                    data.enabled = false;
                } else if (prop == "RenderScale_Disabled") {
                    data.renderScaleEnabled = false;
                } else if (prop == "MultiThread_Disabled") {
                    data.multiThreadingEnabled = false;
                } else if (prop == "OpenGL_Disabled") {
                    data.openGLEnabled = false;
                }
            }

            pluginsData[id] = data;
        }
    }

    if (node["Shortcuts"]) {
        const YAML::Node& shortcutsNode = node["Shortcuts"];
        for (std::size_t i = 0; i < shortcutsNode.size(); ++i) {
            const YAML::Node& keybindNode = shortcutsNode[i];
            KeybindShortcutKey shortcutKey;
            KeybindShortcut shortcut;
            shortcutKey.grouping = keybindNode["Group"].as<std::string>();
            shortcutKey.actionID = keybindNode["Action"].as<std::string>();
            shortcut.symbol = keybindNode["Key"].as<std::string>();
            const YAML::Node& modifsNode = keybindNode["Modifiers"];
            for (std::size_t j = 0; j < modifsNode.size(); ++j) {
                shortcut.modifiers.push_back(modifsNode[j].as<std::string>());
            }

            shortcuts[shortcutKey] = shortcut;
        }
    }
} // decode