forked from GithubMirrors/cardconjurer
Etched auto frame, live auto frame updates
This commit is contained in:

committed by
Josh birnholz

parent
60e42a0359
commit
8caf5c74b5
@@ -634,8 +634,9 @@
|
|||||||
<div class='padding input-grid'>
|
<div class='padding input-grid'>
|
||||||
<select id="autoFrame" class="input" onchange="setAutoFrame()">
|
<select id="autoFrame" class="input" onchange="setAutoFrame()">
|
||||||
<option value="false">Disabled</option>
|
<option value="false">Disabled</option>
|
||||||
<option value="M15">Regular</option>
|
<option value="M15Regular-1">Regular</option>
|
||||||
<option value="UB">Universes Beyond</option>
|
<option value="UB">Universes Beyond</option>
|
||||||
|
<option value="Etched">Etched</option>
|
||||||
</select>
|
</select>
|
||||||
<!-- <button class='input' onclick='autoFrame("M15");'>M15</button>
|
<!-- <button class='input' onclick='autoFrame("M15");'>M15</button>
|
||||||
<button class='input' onclick='autoFrame("UB");'>Universes Beyond</button> -->
|
<button class='input' onclick='autoFrame("UB");'>Universes Beyond</button> -->
|
||||||
|
158
js/creator-23.js
158
js/creator-23.js
@@ -503,7 +503,7 @@ function doubleClick(event, maskOrFrame) {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
function cardFrameProperties(colors, manaCost, typeLine, power) {
|
function cardFrameProperties(colors, manaCost, typeLine, power, etched = false) {
|
||||||
var colors = colors.map(color => color.toUpperCase())
|
var colors = colors.map(color => color.toUpperCase())
|
||||||
if ([
|
if ([
|
||||||
['U', 'W'],
|
['U', 'W'],
|
||||||
@@ -528,7 +528,11 @@ function cardFrameProperties(colors, manaCost, typeLine, power) {
|
|||||||
|
|
||||||
var pinlineRules;
|
var pinlineRules;
|
||||||
if (colors.length > 2) {
|
if (colors.length > 2) {
|
||||||
|
if (etched && typeLine.includes('Artifact')) {
|
||||||
|
pinlineRules = 'A';
|
||||||
|
} else {
|
||||||
pinlineRules = 'M';
|
pinlineRules = 'M';
|
||||||
|
}
|
||||||
} else if (colors.length != 0) {
|
} else if (colors.length != 0) {
|
||||||
pinlineRules = colors[0];
|
pinlineRules = colors[0];
|
||||||
} else if (typeLine.includes('Land')) {
|
} else if (typeLine.includes('Land')) {
|
||||||
@@ -582,7 +586,7 @@ function cardFrameProperties(colors, manaCost, typeLine, power) {
|
|||||||
} else if (colors.length > 2) {
|
} else if (colors.length > 2) {
|
||||||
frame = 'M';
|
frame = 'M';
|
||||||
} else if (colors.length == 2) {
|
} else if (colors.length == 2) {
|
||||||
if (isHybrid) {
|
if (isHybrid || etched) {
|
||||||
frame = colors[0];
|
frame = colors[0];
|
||||||
} else {
|
} else {
|
||||||
frame = 'M';
|
frame = 'M';
|
||||||
@@ -594,11 +598,13 @@ function cardFrameProperties(colors, manaCost, typeLine, power) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var frameRight;
|
var frameRight;
|
||||||
|
if (!(typeLine.includes('Vehicle') || typeLine.includes('Artifact'))) {
|
||||||
if (typeLine.includes('Land')) {
|
if (typeLine.includes('Land')) {
|
||||||
frameRight = landRight;
|
frameRight = landRight;
|
||||||
} else if (colors.length == 2 && isHybrid) {
|
} else if (colors.length == 2 && (isHybrid || etched)) {
|
||||||
frameRight = colors[1];
|
frameRight = colors[1];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'land': land,
|
'land': land,
|
||||||
@@ -613,14 +619,21 @@ function cardFrameProperties(colors, manaCost, typeLine, power) {
|
|||||||
}
|
}
|
||||||
function autoFrame() {
|
function autoFrame() {
|
||||||
var frame = document.querySelector('#autoFrame').value;
|
var frame = document.querySelector('#autoFrame').value;
|
||||||
if (!frame) { return; }
|
if (frame == 'false') { return; }
|
||||||
|
|
||||||
var colors = [...new Set(card.text.mana.text.toUpperCase().split('').filter(char => ['W', 'U', 'B', 'R', 'G'].includes(char)))];
|
var colors = [...new Set(card.text.mana.text.toUpperCase().split('').filter(char => ['W', 'U', 'B', 'R', 'G'].includes(char)))];
|
||||||
|
|
||||||
if (frame == 'M15') {
|
if (frame == 'M15Regular-1') {
|
||||||
autoM15Frame(colors, card.text.mana.text, card.text.type.text, card.text.pt.text);
|
autoM15Frame(colors, card.text.mana.text, card.text.type.text, card.text.pt.text);
|
||||||
} else if (frame == 'UB') {
|
} else if (frame == 'UB') {
|
||||||
autoUBFrame(colors, card.text.mana.text, card.text.type.text, card.text.pt.text);
|
autoUBFrame(colors, card.text.mana.text, card.text.type.text, card.text.pt.text);
|
||||||
|
} else if (frame == 'Etched') {
|
||||||
|
autoEtchedFrame(colors, card.text.mana.text, card.text.type.text, card.text.pt.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.querySelector('#selectFramePack') != frame) {
|
||||||
|
document.querySelector('#selectFramePack').value = frame;
|
||||||
|
loadScript('/js/frames/pack' + frame + '.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function autoUBFrame(colors, mana_cost, type_line, power) {
|
async function autoUBFrame(colors, mana_cost, type_line, power) {
|
||||||
@@ -719,6 +732,44 @@ async function autoM15Frame(colors, mana_cost, type_line, power) {
|
|||||||
await card.frames.forEach(item => addFrame([], item));
|
await card.frames.forEach(item => addFrame([], item));
|
||||||
card.frames.reverse();
|
card.frames.reverse();
|
||||||
}
|
}
|
||||||
|
async function autoEtchedFrame(colors, mana_cost, type_line, power) {
|
||||||
|
var frames = card.frames.filter(frame => frame.name.includes('Extension'));
|
||||||
|
|
||||||
|
//clear the draggable frames
|
||||||
|
card.frames = [];
|
||||||
|
document.querySelector('#frame-list').innerHTML = null;
|
||||||
|
|
||||||
|
var properties = cardFrameProperties(colors, mana_cost, type_line, power, true);
|
||||||
|
|
||||||
|
// Set frames
|
||||||
|
|
||||||
|
if (type_line.includes('Legendary')) {
|
||||||
|
if (properties.frameRight) {
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.frameRight, 'Crown', true));
|
||||||
|
}
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.frame, "Crown", false));
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.frame, "Crown Border Cover", false));
|
||||||
|
}
|
||||||
|
if (properties.pt) {
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.pt, 'PT', false));
|
||||||
|
}
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.typeTitle, 'Type', false));
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.typeTitle, 'Title', false));
|
||||||
|
if (properties.pinlineRulesRight) {
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.pinlineRulesRight, 'Rules', true));
|
||||||
|
}
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.pinlineRules, 'Rules', false));
|
||||||
|
if (properties.frameRight) {
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.frameRight, 'Frame', true));
|
||||||
|
}
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.frame, 'Frame', false));
|
||||||
|
frames.push(makeEtchedFrameByLetter(properties.frame, 'Border', false));
|
||||||
|
|
||||||
|
card.frames = frames;
|
||||||
|
card.frames.reverse();
|
||||||
|
await card.frames.forEach(item => addFrame([], item));
|
||||||
|
card.frames.reverse();
|
||||||
|
}
|
||||||
function makeM15FrameByLetter(letter, mask = false, maskToRightHalf = false) {
|
function makeM15FrameByLetter(letter, mask = false, maskToRightHalf = false) {
|
||||||
letter = letter.toUpperCase();
|
letter = letter.toUpperCase();
|
||||||
var frameNames = {
|
var frameNames = {
|
||||||
@@ -925,6 +976,96 @@ function makeUBFrameByLetter(letter, mask = false, maskToRightHalf = false) {
|
|||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
function makeEtchedFrameByLetter(letter, mask = false, maskToRightHalf = false) {
|
||||||
|
if (letter == 'L') {
|
||||||
|
letter = 'C';
|
||||||
|
}
|
||||||
|
|
||||||
|
letter = letter.toUpperCase();
|
||||||
|
var frameNames = {
|
||||||
|
'W': 'White',
|
||||||
|
'U': 'Blue',
|
||||||
|
'B': 'Black',
|
||||||
|
'R': 'Red',
|
||||||
|
'G': 'Green',
|
||||||
|
'M': 'Multicolored',
|
||||||
|
'A': 'Artifact',
|
||||||
|
'L': 'Land',
|
||||||
|
'C': 'Colorless',
|
||||||
|
'V': 'Vehicle'
|
||||||
|
}
|
||||||
|
|
||||||
|
var frameName = frameNames[letter];
|
||||||
|
|
||||||
|
if (mask == "Crown Border Cover") {
|
||||||
|
return {
|
||||||
|
'name': 'Legend Crown Cover',
|
||||||
|
'src': '/img/frames/etched/regular/crowns/cover.svg',
|
||||||
|
'masks': [],
|
||||||
|
'bounds': { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask == "Crown") {
|
||||||
|
var frame = {
|
||||||
|
'name': frameName + ' Legend Crown',
|
||||||
|
'src': '/img/frames/etched/regular/crowns/' + letter + '.png',
|
||||||
|
'masks': [],
|
||||||
|
'bounds': {
|
||||||
|
'height': 0.092,
|
||||||
|
'width': 0.9387,
|
||||||
|
'x': 0.0307,
|
||||||
|
'y': 0.0191
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (maskToRightHalf) {
|
||||||
|
frame.masks.push({
|
||||||
|
'src': '/img/frames/maskRightHalf.png',
|
||||||
|
'name': 'Right Half'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask == 'PT') {
|
||||||
|
return {
|
||||||
|
'name': frameName + ' Power/Toughness',
|
||||||
|
'src': '/img/frames/etched/regular/pt/' + letter + '.png',
|
||||||
|
'masks': [],
|
||||||
|
'bounds': {
|
||||||
|
'height': 0.0733,
|
||||||
|
'width': 0.188,
|
||||||
|
'x': 0.7573,
|
||||||
|
'y': 0.8848
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var frame = {
|
||||||
|
'name': frameName + ' Frame',
|
||||||
|
'src': '/img/frames/etched/regular/' + letter + '.png',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask) {
|
||||||
|
frame.masks = [
|
||||||
|
{
|
||||||
|
'src': '/img/frames/etched/regular/' + mask + '.svg',
|
||||||
|
'name': mask
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
if (maskToRightHalf) {
|
||||||
|
frame.masks.push({
|
||||||
|
'src': '/img/frames/maskRightHalf.png',
|
||||||
|
'name': 'Right Half'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
frame.masks = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
async function addFrame(additionalMasks = [], loadingFrame = false) {
|
async function addFrame(additionalMasks = [], loadingFrame = false) {
|
||||||
var frameToAdd = JSON.parse(JSON.stringify(availableFrames[selectedFrameIndex]));
|
var frameToAdd = JSON.parse(JSON.stringify(availableFrames[selectedFrameIndex]));
|
||||||
var maskThumbnail = true;
|
var maskThumbnail = true;
|
||||||
@@ -1217,6 +1358,7 @@ function hslToRGB(h, s, l){
|
|||||||
}
|
}
|
||||||
//TEXT TAB
|
//TEXT TAB
|
||||||
var writingText;
|
var writingText;
|
||||||
|
var autoFrameTimer;
|
||||||
function loadTextOptions(textObject, replace=true) {
|
function loadTextOptions(textObject, replace=true) {
|
||||||
var oldCardText = card.text || {};
|
var oldCardText = card.text || {};
|
||||||
Object.entries(oldCardText).forEach(item => {
|
Object.entries(oldCardText).forEach(item => {
|
||||||
@@ -1267,6 +1409,7 @@ function textboxEditor() {
|
|||||||
function textEdited() {
|
function textEdited() {
|
||||||
card.text[Object.keys(card.text)[selectedTextIndex]].text = curlyQuotes(document.querySelector('#text-editor').value);
|
card.text[Object.keys(card.text)[selectedTextIndex]].text = curlyQuotes(document.querySelector('#text-editor').value);
|
||||||
drawTextBuffer();
|
drawTextBuffer();
|
||||||
|
autoFrameBuffer();
|
||||||
}
|
}
|
||||||
function fontSizedEdited() {
|
function fontSizedEdited() {
|
||||||
card.text[Object.keys(card.text)[selectedTextIndex]].fontSize = document.querySelector('#text-editor-font-size').value;
|
card.text[Object.keys(card.text)[selectedTextIndex]].fontSize = document.querySelector('#text-editor-font-size').value;
|
||||||
@@ -1276,6 +1419,10 @@ function drawTextBuffer() {
|
|||||||
clearTimeout(writingText);
|
clearTimeout(writingText);
|
||||||
writingText = setTimeout(drawText, 500);
|
writingText = setTimeout(drawText, 500);
|
||||||
}
|
}
|
||||||
|
function autoFrameBuffer() {
|
||||||
|
clearTimeout(autoFrameTimer);
|
||||||
|
autoFrameTimer = setTimeout(autoFrame, 500);
|
||||||
|
}
|
||||||
async function drawText() {
|
async function drawText() {
|
||||||
textContext.clearRect(0, 0, textCanvas.width, textCanvas.height);
|
textContext.clearRect(0, 0, textCanvas.width, textCanvas.height);
|
||||||
prePTContext.clearRect(0, 0, prePTCanvas.width, prePTCanvas.height);
|
prePTContext.clearRect(0, 0, prePTCanvas.width, prePTCanvas.height);
|
||||||
@@ -1292,7 +1439,6 @@ async function drawText() {
|
|||||||
} else {
|
} else {
|
||||||
drawCard();
|
drawCard();
|
||||||
}
|
}
|
||||||
autoFrame();
|
|
||||||
}
|
}
|
||||||
function writeText(textObject, targetContext) {
|
function writeText(textObject, targetContext) {
|
||||||
//Most bits of info about text loaded, with defaults when needed
|
//Most bits of info about text loaded, with defaults when needed
|
||||||
|
Reference in New Issue
Block a user