mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 19:58:13 +08:00
c6d883eccf
* huatuo * biyue * gender of player * let tablepile smaller * card emotions * remove getOtherPlayers * guicai * skill audio * card audio * death audio * bgm * damage sound * local bgm * add more skill audio * android: dont link to quickcontrol2 * android: fix ifndef * yield only when need * modify cpp according to clazy * reduce malloc times * revert yield * qingguo * fix back to lobby * use compact json in cpp * notifySkillInvoke animation * util: string2json * losehp; tablepile fix * judge result animation * add scrollbar for logedit * add lock on waitForReply * fix: virtual jink has no effect * tiandu * fix: duplicated cards when related to equiparea * ui: disable okcancel when replying * ui: disable invaild card when responding * game: skill & card use history * game: more judge on vsskill's canUse * luoyi * login page i18n * i18n for server error message * tuxi * expand equip area when needed * add footnote to cards from pile * ui: only filter CanUseCard when playing * expand equip when responding * prompt * prompt for askforchoice * guanxing * fix guanxing * tieqi * liuli * doc for trigger skill * xiaoji * lianying * fanjian * rende * add skill's subclass * TODO: add tmd skill functions for other cards * paoxiao * qicai * guose * yiji (WIP)
155 lines
3.5 KiB
QML
155 lines
3.5 KiB
QML
import QtQuick
|
|
|
|
Item {
|
|
property var discardedCards: []
|
|
property alias cards: area.cards
|
|
property bool toVanish: false
|
|
|
|
id: root
|
|
|
|
CardArea {
|
|
id: area
|
|
}
|
|
|
|
InvisibleCardArea {
|
|
id: invisibleArea
|
|
}
|
|
|
|
Timer {
|
|
id: vanishTimer
|
|
interval: 1500
|
|
repeat: true
|
|
running: true
|
|
triggeredOnStart: true
|
|
onTriggered: {
|
|
let i, card;
|
|
if (toVanish) {
|
|
for (i = 0; i < discardedCards.length; i++) {
|
|
card = discardedCards[i];
|
|
if (card.busy) {
|
|
discardedCards.splice(i, 1);
|
|
continue;
|
|
}
|
|
card.origOpacity = 0;
|
|
card.goBack(true);
|
|
card.destroyOnStop()
|
|
}
|
|
|
|
cards = cards.filter((c) => discardedCards.indexOf(c) === -1);
|
|
updateCardPosition(true);
|
|
|
|
discardedCards = [];
|
|
for (i = 0; i < cards.length; i++) {
|
|
if (cards[i].busy)
|
|
continue;
|
|
discardedCards.push(cards[i]);
|
|
}
|
|
toVanish = false;
|
|
} else {
|
|
for (i = 0; i < discardedCards.length; i++) {
|
|
discardedCards[i].selectable = false;
|
|
}
|
|
toVanish = true
|
|
}
|
|
}
|
|
}
|
|
|
|
function add(inputs)
|
|
{
|
|
area.add(inputs);
|
|
// if (!inputs instanceof Array)
|
|
for (let i = 0; i < inputs.length; i++) {
|
|
let c = inputs[i];
|
|
c.footnoteVisible = true;
|
|
c.selectable = true;
|
|
c.height = c.height * 0.8;
|
|
c.width = c.width * 0.8;
|
|
c.rotation = (Math.random() - 0.5) * 5;
|
|
}
|
|
}
|
|
|
|
function remove(outputs)
|
|
{
|
|
let i, j;
|
|
|
|
let result = area.remove(outputs);
|
|
for (let i = 0; i < result.length; i++) {
|
|
let c = result[i];
|
|
c.footnoteVisible = false;
|
|
c.selectable = false;
|
|
c.height = c.height / 0.8;
|
|
c.width = c.width / 0.8;
|
|
c.rotation = 0;
|
|
}
|
|
let vanished = [];
|
|
if (result.length < outputs.length) {
|
|
for (i = 0; i < outputs.length; i++) {
|
|
let exists = false;
|
|
for (j = 0; j < result.length; j++) {
|
|
if (result[j].cid === outputs[i]) {
|
|
exists = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!exists)
|
|
vanished.push(outputs[i]);
|
|
}
|
|
}
|
|
result = result.concat(invisibleArea.remove(vanished));
|
|
|
|
for (i = 0; i < result.length; i++) {
|
|
for (j = 0; j < discardedCards.length; j++) {
|
|
if (result[i].cid === discardedCards[j].cid) {
|
|
discardedCards.splice(j, 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
updateCardPosition(true);
|
|
return result;
|
|
}
|
|
|
|
function updateCardPosition(animated)
|
|
{
|
|
if (cards.length <= 0)
|
|
return;
|
|
|
|
let i, card;
|
|
|
|
let overflow = false;
|
|
for (i = 0; i < cards.length; i++) {
|
|
card = cards[i];
|
|
card.origX = i * card.width;
|
|
if (card.origX + card.width >= root.width) {
|
|
overflow = true;
|
|
break;
|
|
}
|
|
card.origY = 0;
|
|
}
|
|
|
|
if (overflow) {
|
|
//@to-do: Adjust cards in multiple lines if there are too many cards
|
|
let xLimit = root.width - card.width;
|
|
let spacing = xLimit / (cards.length - 1);
|
|
for (i = 0; i < cards.length; i++) {
|
|
card = cards[i];
|
|
card.origX = i * spacing;
|
|
card.origY = 0;
|
|
}
|
|
}
|
|
|
|
let offsetX = Math.max(0, (root.width - cards.length * card.width) / 2);
|
|
let parentPos = roomScene.mapFromItem(root, 0, 0);
|
|
for (i = 0; i < cards.length; i++) {
|
|
card = cards[i];
|
|
card.origX += parentPos.x + offsetX;
|
|
card.origY += parentPos.y;
|
|
}
|
|
|
|
if (animated) {
|
|
for (i = 0; i < cards.length; i++)
|
|
cards[i].goBack(true)
|
|
}
|
|
}
|
|
}
|