wallpaper_set_config

此功能将壁纸的配置发送到配套应用程序。它接受一个包含 选项/节 的“settings”数组,其中每个 选项/节 都是一个结构

设置数组

数组应具有以下格式: 

array = 
[
    {section_or_option},
    {section_or_option},
    {section_or_option}
];

此数组中的每个条目都是选项

节结构

节结构需要以下格式: 

{
    type: "section",
    name: "unique_identifier",
    label: "Label for this section in the companion app",
    children: [{section}, {option}, ...]
}

节结构中的children属性是数组。 此数组中的每个条目都是另一个节 结构体 或选项结构体。

选项结构

选项结构需要以下格式: 

{
    type: "type_of_return_value",
    name: "unique_identifier",
    label: "Label for this section in the companion app"
}

type属性允许使用以下类型:
“range”“boolean”“string”“string_multiline”“color” (或“colour”)、 “file”“folder”

根据类型的不同,必须为选项结构提供额外的属性: 

"range""range"

{
    type: "range",
    value: <a number, default value>,
    min: <a number, minimum range value>,
    max: <a number, maximum range value>,
    step: <a number, distance between possible values>
}

"boolean""boolean"

{
    type: "boolean",
    value: <true or false, default value>
}

"string""string"

{
    type: "string",
    value: <a string, default value>
}

"string_multiline""string_multiline"

{
    type: "string_multiline",
    value: <a string that can have newlines, e.g. "Line 1\nLine 2\nLine 3\nLine4">
}

"color" (or "colour")"color" (or "colour")

{
    type: "colour",
    value: <a colour, default value>
}

"file""file"

{
    type: "file",
    value: <a string containing file path, e.g. "C:\\Users\\MyUser\\Pictures\\MyPicture.png">
}

"folder""folder"

{
    type: "folder",
    value: <a string containing a folder path, e.g. "C:\\Users\\MyUser\\Pictures\\">
}

 

 

语法:

wallpaper_set_config(settings_array);

参数类型描述
settings_arrayArray包含节和选项结构的数组,如上文所述

 

返回:

N/A

 

例子:

var _config = 
[
    {
        type: "section",
        name: "animation",
        label: "Animation",
        children:
        [
            {
                type: "range",
                name: "speed",
                label: "Rotation speed",
                value: 50,
                min: 0,
                max: 200,
                step: 25
            },
            {
                type: "boolean",
                name: "clockwiseRotation",
                label: "Clockwise rotation",
                value: false
            },
            {
                type: "boolean",
                name: "pause",
                label: "Pause animation",
                value: true
            }
        ]
    },
    {
        type: "section",
        name: "colours",
        label: "Colours",
        children:
        [
           {
                type: "colour",
                name: "blendColor",
                label: "Blend colour",
                value: #FA1E4E
            },
            {
                type: "range",
                name: "blendAlpha",
                label: "Blend alpha",
                value: 100
            }
        ]
    }
];

wallpaper_set_config(_config);

上面的代码显示了 wallpaper_set_config函数的示例,其中包含两个部分。 第一部分包含三个选项(一个范围和两个布尔值),第二部分包含两个选项(一个颜色和一个范围)。

此示例首先在局部变量中初始化数组,然后将其传递到函数调用中。 如果你愿意,你可以跳过变量stuff,直接在函数参数中初始化数组。