Update creator-23.js

This commit is contained in:
Kyle
2021-10-04 17:44:22 -07:00
parent a01b1ced0d
commit bae89a965f

View File

@@ -157,11 +157,14 @@ function getElementIndex(element) {
return Array.prototype.indexOf.call(element.parentElement.children, element); return Array.prototype.indexOf.call(element.parentElement.children, element);
} }
function getCardName() { function getCardName() {
if (card.text == undefined) {
return 'unnamed';
}
var imageName = card.text.title.text || 'unnamed'; var imageName = card.text.title.text || 'unnamed';
if (card.text.nickname) { if (card.text.nickname) {
imageName += ' (' + card.text.nickname.text + ')'; imageName += ' (' + card.text.nickname.text + ')';
} }
return imageName.replace(/\{[^}]+\}/g, '') + '.png'; return imageName.replace(/\{[^}]+\}/g, '');
} }
//UI //UI
function toggleCreatorTabs(event, target) { function toggleCreatorTabs(event, target) {
@@ -727,6 +730,9 @@ function writeText(textObject, targetContext) {
if (params.get('copyright') != null && (textObject.name == 'wizards' || textObject.name == 'copyright') && card.margins) { if (params.get('copyright') != null && (textObject.name == 'wizards' || textObject.name == 'copyright') && card.margins) {
rawText = params.get('copyright'); //so people using CC for custom card games without WotC's IP can customize their copyright info rawText = params.get('copyright'); //so people using CC for custom card games without WotC's IP can customize their copyright info
} }
if (rawText.toLowerCase().includes('{cardname}')) {
rawText = rawText.replace(/{cardname}/ig, getCardName());
}
var splitText = rawText.replace(/\n/g, '{line}').replace(/{flavor}/g, '{lns}{bar}{lns}{fixtextalign}{i}').replace(/{/g, splitString + '{').replace(/}/g, '}' + splitString).replace(/ /g, splitString + ' ' + splitString).split(splitString); var splitText = rawText.replace(/\n/g, '{line}').replace(/{flavor}/g, '{lns}{bar}{lns}{fixtextalign}{i}').replace(/{/g, splitString + '{').replace(/}/g, '}' + splitString).replace(/ /g, splitString + ' ' + splitString).split(splitString);
splitText = splitText.filter(item => item); splitText = splitText.filter(item => item);
if (textObject.vertical) { if (textObject.vertical) {
@@ -1582,7 +1588,7 @@ function downloadCard(alt = false) {
} else { } else {
// Prep file information // Prep file information
const imageDataURL = cardCanvas.toDataURL('image/png'); const imageDataURL = cardCanvas.toDataURL('image/png');
var imageName = getCardName(); var imageName = getCardName() + '.png';
// Download image // Download image
if (alt) { if (alt) {
const newWindow = window.open('about:blank'); const newWindow = window.open('about:blank');