better imports

This commit is contained in:
Kyle
2021-05-02 10:50:49 -07:00
parent 453beec2fb
commit 1470ef7821
21 changed files with 80 additions and 27 deletions

View File

@@ -220,11 +220,10 @@ include('../globalHTML/header-1.php');
<input type='url' placeholder='Via URL' class='input' onchange='imageURL(this.value, uploadArt, "autoFit");'>
</div>
</div>
<h5 class='margin-bottom padding input-description'>Or enter a card name (and index)</h5>
<div class='input-grid margin-bottom'>
<input id='art-name' type='text' placeholder='Enter Card Name' class='input' onchange='fetchScryfallData(this.value, artFromScryfall, true);'>
<input id='art-index' type='number' value=1 max=1 min=1 class='input' onchange='changeArtIndex();'>
</div>
<h5 class='margin-bottom padding input-description'>Or enter a card name</h5>
<input id='art-name' type='text' placeholder='Enter Card Name' class='input margin-bottom' onchange='fetchScryfallData(this.value, artFromScryfall, true);'>
<h5 class='padding margin-bottom input-description'>Select a specific card art to load</h5>
<select class='input margin-bottom' id='art-index' onchange='changeArtIndex();'></select>
<h5 class='margin-bottom padding input-description'>And credit the artist</h5>
<div class='input-grid'>
<input id='art-artist' type='text' class='input' oninput='artistEdited(this.value);' placeholder='Artist'>
@@ -387,11 +386,10 @@ include('../globalHTML/header-1.php');
</div>
<div id='creator-menu-import' class='hidden'>
<div class='readable-background margin-bottom padding'>
<h5 class='padding margin-bottom input-description'>Import a real card by name (and index)</h5>
<div class='input-grid margin-bottom'>
<input id='import-name' class='input' type='text' onchange='fetchScryfallData(this.value, importCard);' placeholder='Enter Card Name'>
<input id='import-index' class='input' type='number' onchange='changeCardIndex();' value=1 max=1 min=1>
</div>
<h5 class='padding margin-bottom input-description'>Import a real card by name</h5>
<input id='import-name' class='input margin-bottom' type='text' onchange='fetchScryfallData(this.value, importCard);' placeholder='Enter Card Name'>
<h5 class='padding margin-bottom input-description'>Select a specific card to import</h5>
<select class='input margin-bottom' id='import-index' onchange='changeCardIndex();'></select>
<h5 class='padding input-description'>Select a language for card imports (not all languages will always be available)</h5>
<select class='input' id='import-language' onchange='fetchScryfallData(document.querySelector("#import-name").value, importCard);'>
<option value="en">English</option>

BIN
img/frames/invocation/a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
img/frames/invocation/b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
img/frames/invocation/g.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
img/frames/invocation/m.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/frames/invocation/r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
img/frames/invocation/u.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
img/frames/invocation/w.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -964,20 +964,24 @@ function autoFitArt() {
artEdited();
}
function artFromScryfall(scryfallResponse) {
// importedData = scryfallResponse.data;
// importedData.forEach(card => {
// });
// scryfallArt = scryfallResponse.data;
scryfallArt = scryfallResponse;
document.querySelector('#art-index').value = 1;
document.querySelector('#art-index').max = scryfallArt.length;
const artIndex = document.querySelector('#art-index');
artIndex.innerHTML = null;
var optionIndex = 0;
scryfallResponse.forEach(card => {
var option = document.createElement('option');
option.innerHTML = `${card.name} (${card.set_name})`;
option.value = optionIndex;
artIndex.appendChild(option);
optionIndex ++;
});
changeArtIndex();
}
function changeArtIndex() {
if (scryfallArt[document.querySelector('#art-index').value - 1].image_uris) {
uploadArt(scryfallArt[document.querySelector('#art-index').value - 1].image_uris.art_crop, "autoFit");
artistEdited(scryfallArt[document.querySelector('#art-index').value - 1].artist);
const artIndexValue = document.querySelector('#art-index').value;
if (scryfallArt[artIndexValue].image_uris) {
uploadArt(scryfallArt[artIndexValue].image_uris.art_crop, 'autoFit');
artistEdited(scryfallArt[artIndexValue].artist);
}
}
function initDraggableArt() {
@@ -1238,12 +1242,20 @@ async function downloadCard() {
//IMPORT/SAVE TAB
function importCard(cardObject) {
scryfallCard = cardObject;
document.querySelector('#import-index').value = 1;
document.querySelector('#import-index').max = scryfallCard.length;
const importIndex = document.querySelector('#import-index');
importIndex.innerHTML = null;
var optionIndex = 0;
cardObject.forEach(card => {
var option = document.createElement('option');
option.innerHTML = `${card.name} (${card.type_line})`;
option.value = optionIndex;
importIndex.appendChild(option);
optionIndex ++;
});
changeCardIndex();
}
function changeCardIndex() {
var cardToImport = scryfallCard[document.querySelector('#import-index').value - 1];
var cardToImport = scryfallCard[document.querySelector('#import-index').value];
//text
if (card.text.title) {card.text.title.text = curlyQuotes(cardToImport.name || '');}
if (card.text.nickname) {card.text.nickname.text = cardToImport.flavor_name || '';}
@@ -1567,16 +1579,17 @@ function fetchScryfallData(cardName, callback = console.log, searchUniqueArt = '
}
});
callback(responseCards);
} else if (this.readyState == 4 && this.status == 404) {
notify(`No cards found for "${cardName}" in "${cardLanguageSelect.options[cardLanguageSelect.selectedIndex].text}" language.`, 5);
} else if (this.readyState == 4 && this.status == 404 && !searchUniqueArt && cardName != '') {
notify(`No cards found for "${cardName}" in ${cardLanguageSelect.options[cardLanguageSelect.selectedIndex].text}.`, 5);
}
}
cardLanguageSelect = document.querySelector('#import-language');
var cardLanguage = `lang%3D${cardLanguageSelect.value}`;
var uniqueArt = '';
if (searchUniqueArt) {
uniqueArt = '&unique=art';
}
cardLanguageSelect = document.querySelector('#import-language');
xhttp.open('GET', `https://api.scryfall.com/cards/search?order=released&include_extras=true${uniqueArt}&q=lang%3D${cardLanguageSelect.value}%20name%3D${cardName.replace(/ /g, '_')}`, true);
xhttp.open('GET', `https://api.scryfall.com/cards/search?order=released&include_extras=true${uniqueArt}&q=name%3D${cardName.replace(/ /g, '_')}%20${cardLanguage}`, true);
try {
xhttp.send();
} catch {

View File

@@ -0,0 +1,42 @@
//Create objects for common properties across available frames
// var masks = [{src:'/img/frames/m15/regular/m15MaskPinline.png', name:'Pinline'}, {src:'/img/frames/m15/regular/m15MaskTitle.png', name:'Title'}, {src:'/img/frames/m15/regular/m15MaskType.png', name:'Type'}, {src:'/img/frames/m15/regular/m15MaskRules.png', name:'Rules'}, {src:'/img/frames/m15/regular/m15MaskFrame.png', name:'Frame'}, {src:'/img/frames/m15/regular/m15MaskBorder.png', name:'Border'}];
var bounds = {x:0.7573, y:0.8848, width:0.188, height:0.0733};
//defines available frames
availableFrames = [
{name:'White Frame', src:'/img/frames/invocation/W.png'},
{name:'Blue Frame', src:'/img/frames/invocation/U.png'},
{name:'Black Frame', src:'/img/frames/invocation/B.png'},
{name:'Red Frame', src:'/img/frames/invocation/R.png'},
{name:'Green Frame', src:'/img/frames/invocation/G.png'},
{name:'Multicolored Frame', src:'/img/frames/invocation/M.png'},
{name:'Artifact Frame', src:'/img/frames/invocation/A.png'},
{name:'Power/Toughness', src:'/img/frames/m15/regular/m15PTW.png', bounds:bounds},
];
//disables/enables the "Load Frame Version" button
document.querySelector('#loadFrameVersion').disabled = false;
//defines process for loading this version, if applicable
document.querySelector('#loadFrameVersion').onclick = async function() {
//resets things so that every frame doesn't have to
await resetCardIrregularities();
//sets card version
card.version = 'invocation';
//art bounds
card.artBounds = {x:0.0767, y:0.1129, width:0.8476, height:0.4429};
autoFitArt();
//set symbol bounds
card.setSymbolBounds = {x:0.9213, y:0.5910, width:0.12, height:0.0410, vertical:'center', horizontal: 'right'};
resetSetSymbol();
//watermark bounds
card.watermarkBounds = {x:0.5, y:0.7762, width:0.75, height:0.2305};
resetWatermark();
//text
loadTextOptions({
mana: {name:'Mana Cost', text:'', y:0.0613, width:0.9292, height:71/2100, oneLine:true, size:71/1638, align:'right', shadowX:-0.001, shadowY:0.0029, manaCost:true, manaSpacing:0},
title: {name:'Title', text:'', x:0.0854, y:0.0522, width:0.8292, height:0.0543, oneLine:true, font:'belerenb', size:0.0381},
type: {name:'Type', text:'', x:0.0854, y:0.5664, width:0.8292, height:0.0543, oneLine:true, font:'belerenb', size:0.0324},
rules: {name:'Rules Text', text:'', x:0.086, y:0.6303, width:0.828, height:0.2875, size:0.0362},
pt: {name:'Power/Toughness', text:'', x:0.7928, y:0.902, width:0.1367, height:0.0372, size:0.0372, font:'belerenbsc', oneLine:true, align:'center'}
});
}
//loads available frames
loadFramePack();