From 2e76fac275d7211f89d92246e9f6546fb049a48a Mon Sep 17 00:00:00 2001 From: Kyle <41976328+ImKyle4815@users.noreply.github.com> Date: Fri, 19 Apr 2019 09:43:44 -0700 Subject: [PATCH] fix --- data/borders/fullArtLandM15/border.js | 6 +-- data/borders/fullArtLandUnstable/border.js | 6 +-- data/borders/m15/border.js | 6 +-- data/borders/miniPlane/border.js | 8 ++- data/borders/plane/border.js | 9 ++-- data/borders/planeswalker/border.js | 6 +-- data/borders/tokenTall/border.js | 6 +-- data/borders/tokenText/border.js | 6 +-- data/borders/tokenTextless/border.js | 6 +-- data/borders/tokenTextless/old.js | 57 ---------------------- data/main.js | 39 +++++++++------ 11 files changed, 43 insertions(+), 112 deletions(-) delete mode 100644 data/borders/tokenTextless/old.js diff --git a/data/borders/fullArtLandM15/border.js b/data/borders/fullArtLandM15/border.js index eb135f58..b694d82a 100644 --- a/data/borders/fullArtLandM15/border.js +++ b/data/borders/fullArtLandM15/border.js @@ -24,7 +24,5 @@ imgTitleMask.load("data/borders/fullArtLandM15/imgTitleMask.png") imgTypeMask.load("data/borders/fullArtLandM15/imgTypeMask.png") //Loads the Colors loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,colorless-Colorless") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() \ No newline at end of file +//Finishes loading the border style +finishChangingBorder() \ No newline at end of file diff --git a/data/borders/fullArtLandUnstable/border.js b/data/borders/fullArtLandUnstable/border.js index 6c96a6d9..17d72c85 100644 --- a/data/borders/fullArtLandUnstable/border.js +++ b/data/borders/fullArtLandUnstable/border.js @@ -30,7 +30,5 @@ imgFrameMask.load("data/borders/fullArtLandUnstable/imgFrameMask.png") imgPinlineMask.load("data/borders/fullArtLandUnstable/imgPinlineMask.png") //Loads the Colors loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,colorless-Colorless") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() \ No newline at end of file +//Finishes loading the border style +finishChangingBorder() \ No newline at end of file diff --git a/data/borders/m15/border.js b/data/borders/m15/border.js index 463fafd0..bf52f299 100644 --- a/data/borders/m15/border.js +++ b/data/borders/m15/border.js @@ -3,7 +3,5 @@ //============================================// //Loads the colors loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,artifact-Artifact,colorless-Colorless,vehicle-Vehicle,clear-Clear,whiteLand-White Land,blueLand-Blue Land,blackLand-Black Land,redLand-Red Land,greenLand-Green Land,goldLand-Gold Land,colorlessLand-Colorless Land") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() +//Finishes loading the border style +finishChangingBorder() diff --git a/data/borders/miniPlane/border.js b/data/borders/miniPlane/border.js index cc8cf53e..4e933972 100644 --- a/data/borders/miniPlane/border.js +++ b/data/borders/miniPlane/border.js @@ -39,11 +39,9 @@ imgArtMask.load("data/borders/miniPlane/imgArtMask.png") imgFrameMask.load("data/borders/miniPlane/imgFrameMask.png") imgBorderMask.load("data/borders/miniPlane/imgBorderMask.png") //Loads the Colors -loadColors("white-White") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() +loadColors("white-Regular") +//Finishes loading the border style +finishChangingBorder() function bottomInfoPlanechase() { var infoNumber = document.getElementById("inputInfoNumber").value diff --git a/data/borders/plane/border.js b/data/borders/plane/border.js index c1094ba3..ae49f96d 100644 --- a/data/borders/plane/border.js +++ b/data/borders/plane/border.js @@ -9,9 +9,8 @@ cardData.miracle = false cardData.nyx = false cardData.legendary = false cardData.creature = false -cardData.rulesBox = false -cardData.titleTypeBoxes = false cardData.rareStamp = false +cardData.pinline = false //Specific Values cardData.manaSymbolDirection = "none" cardData.titleAlignment = "center" @@ -47,10 +46,8 @@ imgTypeMask.load("data/borders/plane/imgTypeMask.png") imgTitleMask.load("data/borders/plane/imgTitleMask.png") //Loads the Colors loadColors("white-Regular,high-High,mid-Middle,low-Low,none-Single") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() +//Finishes loading the border style +finishChangingBorder() function bottomInfoPlanechase() { var infoNumber = document.getElementById("inputInfoNumber").value diff --git a/data/borders/planeswalker/border.js b/data/borders/planeswalker/border.js index d76592bd..b0d898f5 100644 --- a/data/borders/planeswalker/border.js +++ b/data/borders/planeswalker/border.js @@ -45,10 +45,8 @@ loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,arti document.getElementById("inputCreatureColor").value = "#ffffff" cardData.specialImageA = true cardData.specialImageB = true -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() +//Finishes loading the border style +finishChangingBorder() var abilityLineThickness = cheight(6) var abilityLines = [] diff --git a/data/borders/tokenTall/border.js b/data/borders/tokenTall/border.js index 30c3ba51..b9876c2f 100644 --- a/data/borders/tokenTall/border.js +++ b/data/borders/tokenTall/border.js @@ -24,7 +24,5 @@ imgLegendary.load("none", cwidth(26), cheight(20), cwidth(697), cheight(112)) imgLegendaryRight.load("none", cwidth(26), cheight(20), cwidth(697), cheight(112)) //Loads the Colors loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,artifact-Artifact,colorless-Colorless") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() \ No newline at end of file +//Finishes loading the border style +finishChangingBorder() \ No newline at end of file diff --git a/data/borders/tokenText/border.js b/data/borders/tokenText/border.js index 11a0002e..12e75ea4 100644 --- a/data/borders/tokenText/border.js +++ b/data/borders/tokenText/border.js @@ -27,7 +27,5 @@ imgLegendary.load("none", cwidth(26), cheight(20), cwidth(697), cheight(112)) imgLegendaryRight.load("none", cwidth(26), cheight(20), cwidth(697), cheight(112)) //Loads the Colors loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,artifact-Artifact,colorless-Colorless") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() \ No newline at end of file +//Finishes loading the border style +finishChangingBorder() \ No newline at end of file diff --git a/data/borders/tokenTextless/border.js b/data/borders/tokenTextless/border.js index 545f469e..43e91aab 100644 --- a/data/borders/tokenTextless/border.js +++ b/data/borders/tokenTextless/border.js @@ -27,7 +27,5 @@ imgLegendary.load("none", cwidth(26), cheight(20), cwidth(697), cheight(112)) imgLegendaryRight.load("none", cwidth(26), cheight(20), cwidth(697), cheight(112)) //Loads the Colors loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,artifact-Artifact,colorless-Colorless") -//Runs the things! -sectionTextFunction() -sectionFrameFunction() -sectionOtherFunction() \ No newline at end of file +//Finishes loading the border style +finishChangingBorder() \ No newline at end of file diff --git a/data/borders/tokenTextless/old.js b/data/borders/tokenTextless/old.js deleted file mode 100644 index f5c31110..00000000 --- a/data/borders/tokenTextless/old.js +++ /dev/null @@ -1,57 +0,0 @@ -//M15 Border -//Anything to do with... -//Loading Images -var artX = 56 -var artY = 125 -imgMultiMask.src = borderPath + "multiMask.png" -imgFrameMask.src = borderPath + "frameMask.png" -imgLegendFrameMask.src = borderPath + "legendFrameMask.png" -imgBorderMask.src = borderPath + "borderMask.png" -//Card Title -document.getElementById("inputTitleColor").value = "#ffe886" -var titleFont = "40px belerenbsc" //40 -var titleFontSpacing = "0.15px" //0.15 -var titleX = 374.5 //62 -var titleY = 59 //59 -var titleAlign = "center" -//Mana Cost -var manaCostRadius = 17.5 //17.5 -var manaCostX = 657 //657 -var manaCostY = 59 //59 -//Card Type -var typeFont = "33.5px belerenb" //33.5 -var typeFontSpacing = "0.05px" //0.05 -var typeX = 60 //60 -var typeY = 868 //868 -// Rules/Flavor Text -var textFont = "px mplantin" -var textFontSpacing = 0.7 //0.7 -var textX = 66 //66 -var textY = 266 //656 -var textWidth = 682 //682 -//Power Toughness -var ptFont = "39px belerenb" //39 -var ptFontSpacing = "0.3px" //0.3 -var ptTextX = 645 //645 -var ptTextY = 939 //939 -imgBorderCreature.imgValues(571, 926, 137, 75) -//Bottom Info -var infoY = 999 //999 -//Set Symbol -var setSymbolY = 883 //616 -var setSymbolRight = 693 //693 -var setSymbolWidth = 84 //77 -var setSymbolHeight = 44 //44 -//Color Options -loadColors("white-White,blue-Blue,black-Black,red-Red,green-Green,gold-Gold,colorless-Colorless,artifact-Artifact") -document.getElementById("secondColorSelection").innerHTML = document.getElementById("colorSelection").innerHTML -document.getElementById("thirdColorSelection").innerHTML = document.getElementById("colorSelection").innerHTML -//Things The Card Can Do -legendaryBorder = true -imgBorderLegendary.imgValues(26, 20, 697, 112, "imgSecondBorderLegendary") -nyxBorder = true -imgBorderNyx.imgValues(30, 30, 689, 643, "imgSecondBorderNyx") -//With all the new values in place, the program will update it's border images -finishTemplate() -//Any special functions go at the bottom -var uniqueFunctionName = "bottomInfoM15" \ No newline at end of file diff --git a/data/main.js b/data/main.js index fe296283..ff27b86a 100644 --- a/data/main.js +++ b/data/main.js @@ -29,7 +29,7 @@ function scrollFunction() { } function textAreaKeyPressed() { - if (event.key == "Enter" || event.key == "Return") { + if (event.key == "Enter" || event.key == "Return" || event.keyCode == 13) { setTimeout(function() { cursorIndex = document.getElementById("inputText").selectionStart document.getElementById("inputText").value = document.getElementById("inputText").value.slice(0, cursorIndex) + "{line}" + document.getElementById("inputText").value.slice(cursorIndex, 0) @@ -75,9 +75,13 @@ var cardData = {} Object.assign(cardData, defaultCardData) //Function that restores image values for various things :) function backToDefault(version) { + //Fixes canvas size if (cardWidth != 750 || cardHeight != 1050) { changeCanvasSize(750, 1050) } + //Default card data, correct card version + Object.assign(cardData, defaultCardData) + cardData.version = version //Default image values imgLegendary.load("none", cwidth(20), cheight(20), cwidth(714), cheight(186)) imgLegendaryRight.load("none", cwidth(20), cheight(20), cwidth(714), cheight(186)) @@ -88,16 +92,13 @@ function backToDefault(version) { imgNyxRight.load("none", cwidth(30), cheight(30), cwidth(690), cheight(586)) imgMiracle.load("none", cwidth(30), cheight(30), cwidth(689), cheight(511)) imgMiracleRight.load("none", cwidth(30), cheight(30), cwidth(689), cheight(511)) - //Default card data, correct card version - Object.assign(cardData, defaultCardData) - cardData.version = version //Default masks for (var i = 0; i < frameMaskList.length; i++) { if (window[frameMaskList[i]].src.includes("data/borders/m15/" + frameMaskList[i] + ".png") == false) { window[frameMaskList[i]].load("data/borders/m15/" + frameMaskList[i] + ".png") } } - //Loads correct frame images + //Loads default frame images for (var i = 0; i < frameImageList.length; i++) { window[frameImageList[i]].load("data/borders/" + cardData.version + "/white/frame.png") } @@ -108,6 +109,17 @@ function backToDefault(version) { //Runs the finishing script loadScript('data/borders/' + version + '/border.js') } +function finishChangingBorder() { + loadLegendaryImages() + loadRareStampImages() + loadMiracleImages() + loadNyxImages() + changePowerToughnessColor() + //Runs the three main drawing functions + sectionTextFunction() + sectionFrameFunction() + sectionOtherFunction() +} //Set up canvases var canvas = document.getElementById("canvas") @@ -157,10 +169,8 @@ CanvasRenderingContext2D.prototype.mask = function(image, masks, color, maskOpac maskContext.globalCompositeOperation = "source-in" } maskContext.globalAlpha = maskOpacity - if (image != "none") { - maskContext.drawImage(image, image.xVal, image.yVal, image.wVal, image.hVal) - // console.log(image.yVal) + maskContext.drawImage(image, image.xVal || 0, image.yVal || 0, image.wVal || cardWidth, image.hVal || cardHeight) } //If a color is provided, fill that in too. if (color != undefined && color != "none") { @@ -450,10 +460,6 @@ function whiteToTransparent(targetImage) { function createImage(name, section) { //Create the image and give it default values window[name] = new Image() - window[name].xVal = 0 - window[name].yVal = 0 - window[name].wVal = cardWidth - window[name].hVal = cardHeight window[name].name = name if (section != undefined) { window[name].cardSection = section @@ -492,10 +498,11 @@ Image.prototype.load = function(source, x, y, w, h) { this.loadingStatus = true this.src = source } - if (x != undefined) {this.xVal = x} else /*if (this.xVal == undefined)*/ {this.xVal = 0} - if (y != undefined) {this.yVal = y} else /*if (this.yVal == undefined)*/ {this.yVal = 0} - if (w != undefined) {this.wVal = w} else /*if (this.wVal == undefined)*/ {this.wVal = cardWidth} - if (h != undefined) {this.hVal = h} else /*if (this.hVal == undefined)*/ {this.hVal = cardHeight} + + if (x != undefined) {this.xVal = x} + if (y != undefined) {this.yVal = y} + if (w != undefined) {this.wVal = w} + if (h != undefined) {this.hVal = h} } //Loads images via URL