2023-04-09 05:35:35 +00:00
|
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2023-04-04 16:49:54 +00:00
|
|
|
|
-- 主动技/视为技用。
|
|
|
|
|
-- 能创造一个简单的组件供UI使用。
|
|
|
|
|
|
|
|
|
|
-- 前端的应答/修改最终会被保存到xxx.data中。
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- 同时,这些应答也会被上传到服务器中。
|
2023-04-04 16:49:54 +00:00
|
|
|
|
|
|
|
|
|
local UI = {}
|
|
|
|
|
|
2023-04-12 12:51:09 +00:00
|
|
|
|
-- ComboBox: 一个按钮,点击后会显示类似askForChoice的框供选择
|
2023-04-04 16:49:54 +00:00
|
|
|
|
-- 可以赋值的属性有:
|
|
|
|
|
-- * choices: string[] 类型,保存着可选项,会被前端翻译
|
|
|
|
|
-- * default: string,默认的选项,默认为choices的第一个
|
2023-06-15 13:19:57 +00:00
|
|
|
|
-- * detailed: bool,为真的话送详细信息
|
2023-04-04 16:49:54 +00:00
|
|
|
|
UI.ComboBox = function(spec)
|
|
|
|
|
assert(type(spec.choices) == "table", "Choices is not a table")
|
|
|
|
|
assert(#spec.choices > 0, "Choices is empty")
|
|
|
|
|
spec.default = spec.default or spec.choices[1]
|
2023-06-15 13:19:57 +00:00
|
|
|
|
spec.detailed = spec.detailed
|
2023-04-04 16:49:54 +00:00
|
|
|
|
spec.type = "combo"
|
|
|
|
|
return spec
|
|
|
|
|
end
|
|
|
|
|
|
2023-04-29 16:52:39 +00:00
|
|
|
|
-- Spin: 一个能用两侧加减号调整某些数值的组件,见于奇谋等技能
|
|
|
|
|
-- 可以赋值的属性有:
|
|
|
|
|
-- * from: 最小值
|
|
|
|
|
-- * to: 最大值
|
|
|
|
|
-- * default: 默认值 默认为最小的
|
|
|
|
|
UI.Spin = function(spec)
|
|
|
|
|
assert(spec.from <= spec.to)
|
|
|
|
|
spec.type = "spin"
|
|
|
|
|
return spec
|
|
|
|
|
end
|
|
|
|
|
|
2023-04-04 16:49:54 +00:00
|
|
|
|
return UI
|