Modify combo box (#140)

Co-authored-by: notify <notify-ctrl@qq.com>
This commit is contained in:
Ho-spair 2023-04-30 00:52:39 +08:00 committed by GitHub
parent 696b4d0073
commit 29fdfca9bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 3 deletions

View File

@ -20,4 +20,15 @@ UI.ComboBox = function(spec)
return spec
end
-- Spin: 一个能用两侧加减号调整某些数值的组件,见于奇谋等技能
-- 可以赋值的属性有:
-- * from: 最小值
-- * to: 最大值
-- * default: 默认值 默认为最小的
UI.Spin = function(spec)
assert(spec.from <= spec.to)
spec.type = "spin"
return spec
end
return UI

View File

@ -71,14 +71,14 @@ local test_active = fk.CreateActiveSkill{
end,
card_num = 2,
target_filter = function() return true end,
interaction = function()return UI.ComboBox {
choices = Fk.package_names,
interaction = function()return UI.Spin {
--choices = Fk.package_names,
from=2,to=8,
-- default = "guanyu",
}end,
on_use = function(self, room, effect)
--room:doSuperLightBox("packages/test/qml/Test.qml")
local from = room:getPlayerById(effect.from)
--print(self.interaction.data)
local to = room:getPlayerById(effect.tos[1])
-- room:swapSeat(from, to)
from:control(to)

View File

@ -489,6 +489,13 @@ Item {
skillInteraction.item.skill = skill_name;
skillInteraction.item.default_choice = data["default"];
skillInteraction.item.choices = data.choices;
skillInteraction.item.clicked();
break;
case "spin":
skillInteraction.source = "RoomElement/SkillInteraction/SkillSpin.qml";
skillInteraction.item.skill = skill_name;
skillInteraction.item.from = data.from;
skillInteraction.item.to = data.to;
break;
default:
skillInteraction.source = "";

View File

@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
SpinBox {
background: Rectangle { color: "#88EEEEEE" }
property int answer: value
property string skill
// from, to
onValueChanged: {
Backend.callLuaFunction(
"SetInteractionDataOfSkill",
[skill, JSON.stringify(answer)]
);
roomScene.dashboard.startPending(skill);
}
}