mirror of
https://github.com/Investigamer/cardconjurer.git
synced 2025-07-27 05:14:53 -05:00
Update creator-23.js
This commit is contained in:
@@ -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');
|
||||||
|
Reference in New Issue
Block a user