Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix local_art in Art tab and allow PNG downloads. #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions creator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -698,13 +698,13 @@ <h5 class='padding input-description'>Automatically update frame</h5>
<div class='readable-background padding'>
<h3 class='download padding' onclick='downloadCard();'>Download your card</h3>
<h5 onclick='downloadCard(false, true);' id='downloadJpg' href='' target='_blank' class='padding download input-description' style='text-align: left;'>Click here to download as JPEG</h5>
<h5 onclick='downloadCard(true);' id='downloadAlt' href='' target='_blank' class='padding download input-description' style='text-align: left;'>Click here for an alternative download</h5>
<h5 onclick='downloadCard(false, false);' id='downloadPng' href='' target='_blank' class='padding download input-description' style='text-align: left;'>Click here to download as PNG</h5>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes it functionally the same as line 699 here.

<!-- <label class='checkbox-container input margin-bottom'>800 DPI
<input id='high-res' type='checkbox' onchange='toggleHighRes();'>
<span class='checkmark'></span>
</label> -->
</div>

</div>
</div>
<!--
Expand Down
44 changes: 24 additions & 20 deletions js/creator-23.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async function resetCardIrregularities({canvas = [getStandardWidth(), getStandar
}
});
if (resetOthers) {
setBottomInfoStyle();
setBottomInfoStyle();
//onload
card.onload = null;
}
Expand Down Expand Up @@ -3808,7 +3808,11 @@ async function addTextbox(textboxType) {
}
//ART TAB
function uploadArt(imageSource, otherParams) {
art.src = imageSource;
if (!imageSource.includes('http')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real fix for this is to actually update /creator/index.html line 303 to use onchange='imageURL(this.value, uploadArt, "autoFit");' instead of the uploadArt function.

art.src = '/local_art/' + imageSource;
} else {
art.src = imageSource;
}
if (otherParams && otherParams == 'autoFit') {
art.onload = function() {
autoFitArt();
Expand Down Expand Up @@ -4289,8 +4293,8 @@ function drawCard() {
} else {
cardContext.drawImage(bottomInfoCanvas, 0, 0, cardCanvas.width, cardCanvas.height);
}


// cutout the corners
cardContext.globalCompositeOperation = 'destination-out';
if (!card.noCorners && (card.marginX == 0 && card.marginY == 0)) {
Expand Down Expand Up @@ -4376,34 +4380,34 @@ function scryfallCardFromText(text) {
}

lines = lines.map(item => item.trim()).filter(item => item != "");

var name = lines.shift();
var manaCost;
var manaCostStartIndex = name.indexOf("{");
if (manaCostStartIndex > 0) {
manaCost = name.substring(manaCostStartIndex).trim();
name = name.substring(0, manaCostStartIndex).trim();
}

var cardObject = {
"name": name,
"lang": "en"
};

if (manaCost !== undefined) {
cardObject.mana_cost = manaCost;
}

if (lines.count == 0) {
return cardObject;
}

cardObject.type_line = lines.shift().trim();

if (lines.count == 0) {
return cardObject;
}

var regex = /[0-9+\-*]+\/[0-9+*]+/
var match = lines[lines.length-1].match(regex);
if (match) {
Expand All @@ -4412,13 +4416,13 @@ function scryfallCardFromText(text) {
cardObject.toughness = pt[1];
lines.pop();
}

if (lines.count == 0) {
return cardObject;
}

cardObject.oracle_text = lines.join("\n");

return cardObject;
}

Expand All @@ -4441,7 +4445,7 @@ function changeCardIndex() {
});
rulesText = curlyQuotes(rulesText).replace(/{Q}/g, '{untap}').replace(/{\u221E}/g, "{inf}").replace(/• /g, '• {indent}');
rulesText = rulesText.replace('(If this card is your chosen companion, you may put it into your hand from outside the game for {3} any time you could cast a sorcery.)', '(If this card is your chosen companion, you may put it into your hand from outside the game for {3} as a sorcery.)')

if (card.version == 'pokemon') {
if (cardToImport.type_line.toLowerCase().includes('creature')) {
card.text.rules.text = langFontCode + rulesText;
Expand Down Expand Up @@ -4473,11 +4477,11 @@ function changeCardIndex() {
card.text.middleStatTitle.text = '';
card.text.rightStatTitle.text = '';
}

} else {
card.text.rules.text = langFontCode + rulesText;
}

if (cardToImport.flavor_text) {
var flavorText = cardToImport.flavor_text;
var flavorTextCounter = 1;
Expand Down Expand Up @@ -4508,7 +4512,7 @@ function changeCardIndex() {
}
card.text.rulesnoncreature.text += curlyQuotes(flavorText.replace('\n', '{lns}'));
}

} else {
if (!cardToImport.oracle_text || cardToImport.oracle_text == '') {
card.text.rules.text += '{i}';
Expand All @@ -4518,7 +4522,7 @@ function changeCardIndex() {
card.text.rules.text += curlyQuotes(flavorText.replace('\n', '{lns}'));
}


}
}

Expand Down Expand Up @@ -4613,7 +4617,7 @@ function changeCardIndex() {
document.querySelector('#info-number').value = number;
}


bottomInfoEdited();
}
}
Expand Down