让所有怪物头像,都可以拖动进入富文本

This commit is contained in:
枫谷剑仙 2025-05-12 21:00:48 +08:00
parent f4d8a048a1
commit 5a2e6dad91
3 changed files with 13 additions and 7 deletions

View File

@ -1227,6 +1227,11 @@ function copyString(input) {
}); });
//input.blur(); //取消焦点 //input.blur(); //取消焦点
} }
function cardAOnDragStart(event){
if (event.dataTransfer) {
event.dataTransfer.setData("card-id", this.dataset.cardid);
}
}
//产生一个怪物头像 //产生一个怪物头像
function createCardA(option) { function createCardA(option) {
const t = document.body.querySelector('#template-card-a'); const t = document.body.querySelector('#template-card-a');
@ -1234,6 +1239,7 @@ function createCardA(option) {
const monster = clone.querySelector(".monster"); const monster = clone.querySelector(".monster");
if (option?.noTreeCount) monster.querySelector(".count-in-box .evo-tree").remove(); if (option?.noTreeCount) monster.querySelector(".count-in-box .evo-tree").remove();
if (option?.noBoxCount) monster.querySelector(".count-in-box").remove(); if (option?.noBoxCount) monster.querySelector(".count-in-box").remove();
monster.ondragstart = cardAOnDragStart; //拖拽怪物头像时记录怪物id到拖拽
return monster; return monster;
} }
//返回文字说明内怪物Card的纯HTML //返回文字说明内怪物Card的纯HTML

View File

@ -3744,18 +3744,16 @@ function initialize() {
//设置为可以拖放已经编辑好的队伍 //设置为可以拖放已经编辑好的队伍
function richTextDropHandler(event) { function richTextDropHandler(event) {
//console.debug(event);
let isCopy = event.ctrlKey; //默认为按Ctrl是复制,不然是移动 let isCopy = event.ctrlKey; //默认为按Ctrl是复制,不然是移动
if (controlBox.querySelector("#change-swap-to-copy").checked) if (controlBox.querySelector("#change-swap-to-copy").checked)
isCopy = !isCopy; //勾选后逆向操作 isCopy = !isCopy; //勾选后逆向操作
event.dataTransfer.dropEffect = isCopy ? 'copy' : 'move'; event.dataTransfer.dropEffect = isCopy ? 'copy' : 'move';
let newIcon; let newIcon;
const formStr = event.dataTransfer.getData('from'); let dataFormStr, cardId;
if (formStr) { //从队伍里拖下来的,需要重新创建怪物头像,强制复制 if (dataFormStr = event.dataTransfer.getData('from')) { //从队伍里拖下来的,需要重新创建怪物头像,强制复制
event.preventDefault(); event.preventDefault();
const [teamNum, isAssist, indexInTeam] = JSON.parse(formStr); const [teamNum, isAssist, indexInTeam] = JSON.parse(dataFormStr);
const mon = formation.teams[teamNum][isAssist][indexInTeam]; const mon = formation.teams[teamNum][isAssist][indexInTeam];
newIcon = createIndexedIcon('card', mon.id); newIcon = createIndexedIcon('card', mon.id);
} else if (draggedNode) { } else if (draggedNode) {
@ -3771,6 +3769,8 @@ function initialize() {
const {type, index} = JSON.parse(indexed); const {type, index} = JSON.parse(indexed);
newIcon = createIndexedIcon(type, index); newIcon = createIndexedIcon(type, index);
} }
} else if (cardId = event.dataTransfer.getData('card-id')) {
newIcon = createIndexedIcon("card", parseInt(cardId, 10));
} }
// 重置引用 // 重置引用
draggedNode = null; draggedNode = null;

View File

@ -48283,11 +48283,11 @@ const cachesMap = new Map([
], ],
[ [
"script-universal_function.js", "script-universal_function.js",
"a1fb4b6badef8b98e89665bb74c1c0a5" "badccac0015ffb68514f04ac8caf6daf"
], ],
[ [
"script.js", "script.js",
"57f70ae19d087eaf6c75ab9fef44b30c" "059a9d5f7ef859e8475205e260996f66"
], ],
[ [
"solo.html", "solo.html",