This commit is contained in:
parent
87bc525f0b
commit
5baf58279b
|
@ -11,12 +11,10 @@ GraphicsBox {
|
||||||
title.text: ""
|
title.text: ""
|
||||||
|
|
||||||
// TODO: Adjust the UI design in case there are more than 7 cards
|
// 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
|
height: 64 + Math.min(cardView.contentHeight, 400) + 30
|
||||||
|
|
||||||
signal cardSelected(int cid)
|
|
||||||
signal cardsSelected(var ids)
|
signal cardsSelected(var ids)
|
||||||
property var selected_ids: []
|
|
||||||
property string Yuqi_type
|
property string Yuqi_type
|
||||||
property var card_data
|
property var card_data
|
||||||
property bool cancelable: true
|
property bool cancelable: true
|
||||||
|
@ -60,35 +58,11 @@ GraphicsBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GridLayout {
|
Rectangle {
|
||||||
columns: 7
|
id: cardsArea
|
||||||
Repeater {
|
color: "#1D1E19"
|
||||||
model: areaCards
|
width: 800
|
||||||
|
height: 130
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +79,7 @@ GraphicsBox {
|
||||||
text: luatr("OK")
|
text: luatr("OK")
|
||||||
enabled: lcall("YuqiFeasible", root.Yuqi_type, root.selected_ids,
|
enabled: lcall("YuqiFeasible", root.Yuqi_type, root.selected_ids,
|
||||||
root.card_data, root.extra_data);
|
root.card_data, root.extra_data);
|
||||||
onClicked: root.cardsSelected(root.selected_ids)
|
onClicked: root.cardsSelected(findAllModel())
|
||||||
}
|
}
|
||||||
|
|
||||||
MetroButton {
|
MetroButton {
|
||||||
|
@ -113,13 +87,28 @@ GraphicsBox {
|
||||||
height: 35
|
height: 35
|
||||||
text: luatr("Cancel")
|
text: luatr("Cancel")
|
||||||
visible: root.cancelable
|
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) {
|
function findAreaModel(name) {
|
||||||
let ret;
|
let ret;
|
||||||
|
@ -141,6 +130,14 @@ GraphicsBox {
|
||||||
return ret;
|
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) {
|
function addCustomCards(name, cards) {
|
||||||
let area = findAreaModel(name).areaCards;
|
let area = findAreaModel(name).areaCards;
|
||||||
|
@ -152,6 +149,9 @@ GraphicsBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arrangeCards() {
|
||||||
|
}
|
||||||
|
|
||||||
function refreshPrompt() {
|
function refreshPrompt() {
|
||||||
root.title.text = Util.processPrompt(lcall("YuqiPrompt", Yuqi_type, card_data, extra_data))
|
root.title.text = Util.processPrompt(lcall("YuqiPrompt", Yuqi_type, card_data, extra_data))
|
||||||
}
|
}
|
||||||
|
|
|
@ -788,16 +788,16 @@ function YuqiPrompt(yuqi_type, data, extra_data)
|
||||||
return yuqi.prompt(data, extra_data)
|
return yuqi.prompt(data, extra_data)
|
||||||
end
|
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]
|
local yuqi = Fk.yuqi_methods[yuqi_type]
|
||||||
if not yuqi then return "false" end
|
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
|
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]
|
local yuqi = Fk.yuqi_methods[yuqi_type]
|
||||||
if not yuqi then return "false" end
|
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
|
end
|
||||||
|
|
||||||
function YuqiFeasible(yuqi_type, current, origin, extra_data)
|
function YuqiFeasible(yuqi_type, current, origin, extra_data)
|
||||||
|
|
|
@ -636,6 +636,6 @@ end
|
||||||
---@class YuqiSpec
|
---@class YuqiSpec
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field feasible fun(current_data: any, old_data: any, extra_data: any): bool
|
---@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 entry_filter fun(card: int, from_pile: int, to_pile: int, data: any, extra_data: any): bool
|
||||||
---@field out_filter fun(card: 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
|
---@field prompt? string | fun(data: any, extra_data: any): string
|
||||||
|
|
Loading…
Reference in New Issue