图像库是其他插件可以用来存储和管理图像以在 UI 中使用的工具。它本身没有真正的目的。
控制台命令
refreshallimages – 检索并存储所有项目图标 URL(包括车间图像)。如果配置选项“图像 – 仅在需要时下载图像”设置为 true,则还会将每个图标下载到文件存储中
cancelstorage – 这将取消任何待处理的文件下载
配置
ImageLibrary
config
{
"Avatars - Store player avatars": true,
"Steam API key (get one here https://steamcommunity.com/dev/apikey)": "",
"Progress - Show download progress in console": true,
"Progress - Time between update notifications": 20,
"User Images - Manually define images to be loaded": {},
"Version": {
"Major": 2,
"Minor": 0,
"Patch": 47
}
}
配置选项
“头像 – 商店玩家头像”:下载玩家的头像图像(某些插件可能需要此)
“进度 – 在控制台中显示下载进度”:此选项将在控制台
中显示加载顺序的进度“进度 – 更新通知之间的时间”:进度更新
之间的时间量“用户图像 – 手动定义要加载的图像”:用户指定要下载的图像(某些插件可能需要此)
“Steam API 密钥(https://steamcommunity.com/dev/apikey 在这里获取一个)”:这是从创意工坊下载皮肤图像所必需的
设置已批准和研讨会皮肤支持
要使 ImageLibrary 能够访问已批准的 Steam 创意工坊皮肤图标,您必须提供有效的 API 密钥。这些密钥已注册到您的 Steam 帐户,每天限制为 100,000 次 API 调用。
要获取您的 Steam API 密钥,请访问 -> https://steamcommunity.com/dev/apikey
获得 Steam API 密钥后,将其复制并粘贴到配置中的“Steam API 密钥”条目中
开发者 API
(bool) AddImage(string url, string imageName, ulong imageId, Action callback = null)
// Used to download an individual image using a URL (Does not create a load order)
(bool)AddImageData(string imageName, byte[]array, ulong imageId, Action callback = null)
// Adds the image to file storage using raw image data in a byte[] (Does not create a load order)
(void) ForceFullDownload(string title)
// Can be called to force download every available image (Not recommended)
(string) GetImage(string imageName, ulong imageId = 0, bool returnUrl = false)
// Used to retrieve the ID of a stored image.
// By passing "returnUrl" as true the plugin will return the image's URL if the image has not been stored.
// Useful if you want to display a image from a URL whilst it is being downloaded to storage
(List<ulong>) GetImageList(string name)
// Returns a List of available skin Id's for the requested item
(Dictionary<string, object>) GetSkinInfo(string name, ulong id)
// Returns the skin data for workshop items
(bool) HasImage(string imageName, ulong imageId)
// Returns true if the specified image has been downloaded to storage
(bool) IsReady()
// Returns true if there are no pending load orders
(void) ImportImageList(string title, Dictionary<string, string> imageList, ulong imageId = 0, bool replace = false, Action callback = null)
// Used to create a new load order and download a list of images.
// You can pass a dictionary containing names and URL's, IL will then check which of those images have no yet been stored and will store any that are missing.
// Set your plugin title as the title parameter, imageId can be used to prevent plugins from overwriting your images with the same name, and replace is used to force overwrite existing images with the same name.
(void) ImportImageData(string title, Dictionary<string, byte[]> imageList, ulong imageId = 0, bool replace = false, Action callback = null)
// Same as above but used to mass import raw image data in a byte[] (See LustyMap for example usage)
(void) LoadImageList(string title, List<KeyValuePair<string, ulong>> imageList, Action callback = null)
// Used to load any item icons that are missing from the list you specify. (See ServerRewards for example usage)
注意:图像导入/加载方法有一个可选的回调参数,该参数将在加载完成时调用函数
从插件导入创意工坊皮肤
可以通过调用“LoadImageList”方法从工坊导入皮肤。
此方法专门用于查找和下载插件的项目图标。LoadImageList 将对您提供的物品皮肤 ID 列表进行排序,游戏尚未实现的任何物品都将传递给 Steams API 以尝试查找该图标。
应该在指定回调的情况下调用此方法,并且在调用该回调之前不应启用您的插件!
有关使用此方法的示例,请参阅 ServerRewards
WTF 是负载订单?
加载顺序是插件请求下载的一组图像。例如,在 ServerRewards 中,当生成 UI 时,它会创建一个加载顺序,要求下载商店中的每个项目的图标。任何尚未存储的项目图标都将排队等待按该加载顺序进行处理。然后,用户将能够通过 RCon 在控制台中查看该加载顺序的进度。这会将庞大的项目队列列表分解为更小的类别,以便更好地优化,并防止图像下载加倍
暂无评论内容