此功能将壁纸的配置发送到配套应用程序。它接受一个包含 选项/节 的“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”。
根据类型的不同,必须为选项结构提供额外的属性:
{
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>
}
{
type: "boolean",
value: <true or false, default value>
}
{
type: "string",
value: <a string, default value>
}
{
type: "string_multiline",
value: <a string that can have newlines, e.g. "Line 1\nLine 2\nLine 3\nLine4">
}
{
type: "colour",
value: <a colour, default value>
}
{
type: "file",
value: <a string containing file path, e.g. "C:\\Users\\MyUser\\Pictures\\MyPicture.png">
}
{
type: "folder",
value: <a string containing a folder path, e.g. "C:\\Users\\MyUser\\Pictures\\">
}
wallpaper_set_config(settings_array);
参数 | 类型 | 描述 |
---|---|---|
settings_array | Array | 包含节和选项结构的数组,如上文所述 |
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,直接在函数参数中初始化数组。