AskForArrangeCards

This commit is contained in:
YoumuKon 2024-05-15 03:47:57 +08:00
parent 4e66b1c940
commit 3f80ea5008
2 changed files with 43 additions and 5 deletions

View File

@ -996,6 +996,29 @@ callbacks["AskForSkillInvoke"] = (data) => {
roomScene.cancelButton.enabled = true; roomScene.cancelButton.enabled = true;
} }
callbacks["AskForArrangeCards"] = (data) => {
roomScene.state = "replying";
roomScene.popupBox.sourceComponent =
Qt.createComponent("../RoomElement/ArrangeCardsBox.qml");
const box = roomScene.popupBox.item;
const cards = data.cards;
box.cards = cards.reduce((newArray, elem) => {
return newArray.concat(elem.map(cid => lcall("GetCardData", cid)));
}, []);
box.org_cards = cards;
box.prompt = data.prompt;
box.size = data.size;
box.areaCapacities = data.capacities;
box.areaLimits = data.limits;
box.free_arrange = data.is_free;
box.areaNames = data.names;
box.pattern = data.pattern;
box.poxi_type = data.poxi_type;
box.cancelable = data.cancelable;
box.initializeCards();
}
callbacks["AskForGuanxing"] = (data) => { callbacks["AskForGuanxing"] = (data) => {
const cards = []; const cards = [];
const min_top_cards = data.min_top_cards; const min_top_cards = data.min_top_cards;

View File

@ -2007,11 +2007,25 @@ function Room:askForArrangeCards(player, skillname, cardMap, prompt, free_arrang
end end
pattern = pattern or "." pattern = pattern or "."
poxi_type = poxi_type or "" poxi_type = poxi_type or ""
local result = player.room:askForCustomDialog(player, skillname, local command = "AskForArrangeCards"
"packages/utility/qml/ArrangeCardsBox.qml", { local data = {
cardMap, prompt, box_size, max_limit, min_limit, free_arrange or false, areaNames, cards = cardMap,
pattern or ".", poxi_type or "", ((pattern ~= "." or poxi_type ~= "") and (default_choice == nil)) names = areaNames,
}) prompt = prompt,
size = box_size,
capacities = max_limit,
limits = min_limit,
is_free = free_arrange or false,
pattern = pattern or ".",
poxi_type = poxi_type or "",
cancelable = ((pattern ~= "." or poxi_type ~= "") and (default_choice == nil))
}
local result = self:doRequest(player, command, json.encode(data))
-- local result = player.room:askForCustomDialog(player, skillname,
-- "RoomElement/ArrangeCardsBox.qml", {
-- cardMap, prompt, box_size, max_limit, min_limit, free_arrange or false, areaNames,
-- pattern or ".", poxi_type or "", ((pattern ~= "." or poxi_type ~= "") and (default_choice == nil))
-- })
if result == "" then if result == "" then
if default_choice then return default_choice end if default_choice then return default_choice end
for j = 1, #min_limit, 1 do for j = 1, #min_limit, 1 do
@ -2493,6 +2507,7 @@ end
-- Show a qml dialog and return qml's ClientInstance.replyToServer -- Show a qml dialog and return qml's ClientInstance.replyToServer
-- Do anything you like through this function -- Do anything you like through this function
-- 调用一个自定义对话框须自备loadData方法
---@param player ServerPlayer ---@param player ServerPlayer
---@param focustxt string ---@param focustxt string
---@param qmlPath string ---@param qmlPath string