diff --git a/Fk/RoomElement/YuqiBox.qml b/Fk/RoomElement/YuqiBox.qml index 3d10e062..797b29d6 100644 --- a/Fk/RoomElement/YuqiBox.qml +++ b/Fk/RoomElement/YuqiBox.qml @@ -11,12 +11,10 @@ GraphicsBox { title.text: "" // TODO: Adjust the UI design in case there are more than 7 cards - width: 70 + 700 + width: 70 + 1000 height: 64 + Math.min(cardView.contentHeight, 400) + 30 - signal cardSelected(int cid) signal cardsSelected(var ids) - property var selected_ids: [] property string Yuqi_type property var card_data property bool cancelable: true @@ -60,35 +58,11 @@ GraphicsBox { } } - GridLayout { - columns: 7 - Repeater { - model: areaCards - - CardItem { - cid: model.cid - name: model.name || "" - suit: model.suit || "" - number: model.number || 0 - autoBack: false - known: model.cid !== -1 - selectable: chosenInBox || - lcall("YuqiFilter", root.Yuqi_type, model.cid, root.selected_ids, - root.card_data, root.extra_data); - - onSelectedChanged: { - if (selected) { - chosenInBox = true; - root.selected_ids.push(cid); - } else { - chosenInBox = false; - root.selected_ids.splice(root.selected_ids.indexOf(cid), 1); - } - root.selected_ids = root.selected_ids; - refreshPrompt(); - } - } - } + Rectangle { + id: cardsArea + color: "#1D1E19" + width: 800 + height: 130 } } } @@ -105,7 +79,7 @@ GraphicsBox { text: luatr("OK") enabled: lcall("YuqiFeasible", root.Yuqi_type, root.selected_ids, root.card_data, root.extra_data); - onClicked: root.cardsSelected(root.selected_ids) + onClicked: root.cardsSelected(findAllModel()) } MetroButton { @@ -113,13 +87,28 @@ GraphicsBox { height: 35 text: luatr("Cancel") visible: root.cancelable - onClicked: root.cardsSelected([]) + onClicked: root.cardsSelected(card_data) } } + Repeater { + id: citem + model: cards + + CardItem { + x: index + y: -1 + cid: modelData.cid + name: modelData.name + suit: modelData.suit + number: modelData.number + draggable: true + onReleased: updateCardReleased(this); + } + } + - onCardSelected: finished(); function findAreaModel(name) { let ret; @@ -141,6 +130,14 @@ GraphicsBox { return ret; } + function findAllModel() { + let ret = []; + for (let i = 0; i < cardModel.count; i++) { + let item = cardModel.get(i); + ret.push([item.areaName, item.areaCards]); + } + return ret; + } function addCustomCards(name, cards) { let area = findAreaModel(name).areaCards; @@ -152,6 +149,9 @@ GraphicsBox { } } + function arrangeCards() { + } + function refreshPrompt() { root.title.text = Util.processPrompt(lcall("YuqiPrompt", Yuqi_type, card_data, extra_data)) } diff --git a/lua/client/client_util.lua b/lua/client/client_util.lua index 071e2bc7..01128f82 100644 --- a/lua/client/client_util.lua +++ b/lua/client/client_util.lua @@ -788,16 +788,16 @@ function YuqiPrompt(yuqi_type, data, extra_data) return yuqi.prompt(data, extra_data) end -function YuqiEntryFilter(yuqi_type, to_select, position, to_pile, data, extra_data) +function YuqiEntryFilter(yuqi_type, to_select, from_pile, to_pile, data, extra_data) local yuqi = Fk.yuqi_methods[yuqi_type] if not yuqi then return "false" end - return json.encode(yuqi.entry_filter(to_select, position, to_pile, data, extra_data)) + return json.encode(yuqi.entry_filter(to_select, from_pile, to_pile, data, extra_data)) end -function YuqiOutFilter(yuqi_type, to_select, data, extra_data) +function YuqiOutFilter(yuqi_type, to_select, from_pile, data, extra_data) local yuqi = Fk.yuqi_methods[yuqi_type] if not yuqi then return "false" end - return json.encode(yuqi.out_filter(to_select, data, extra_data)) + return json.encode(yuqi.out_filter(to_select, from_pile, data, extra_data)) end function YuqiFeasible(yuqi_type, current, origin, extra_data) diff --git a/lua/fk_ex.lua b/lua/fk_ex.lua index 38d74e74..af483e3f 100644 --- a/lua/fk_ex.lua +++ b/lua/fk_ex.lua @@ -636,6 +636,6 @@ end ---@class YuqiSpec ---@field name string ---@field feasible fun(current_data: any, old_data: any, extra_data: any): bool ----@field entry_filter fun(card: int, pos: int, pile: int[], data: any, extra_data: any): bool ----@field out_filter fun(card: int, data: any, extra_data: any): bool +---@field entry_filter fun(card: int, from_pile: int, to_pile: int, data: any, extra_data: any): bool +---@field out_filter fun(card: int, from_pile: int, data: any, extra_data: any): bool ---@field prompt? string | fun(data: any, extra_data: any): string