FreeKill/lua/ui-util.lua
YoumuKon 3aef53d16c bypassDistancesCheck + bugfix (#204)
- 重命名isUnlimited/unlimited,因为未正式上线所以无关紧要(?)
- 新增bypassDistancesCheck/bypass_distances,实现真正的无距离限制
- 修复早退导致的报错bug

---------

Co-authored-by: notify <notify-ctrl@qq.com>
2023-06-20 14:17:20 +08:00

38 lines
1.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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