Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @function drawCardName(card,grey);
- /// @param {index} card The card who's text to draw (objCardParent)
- /// @param {boolean} grey If the card being drawn should be in grayscale or not
- /// @param {real} opac opacity to draw the name scrolls, name and text at. Should only be used if the card being drawn fades in and out
- /// @param {struct} params If this struct is provided, it will use the details in it instead of the calling objects/_card's parameters {x,y,scaleX,scaleY,rot,name,text,cOwner,textPeek,strength}
- function drawCardName(_card,_grey = false,_opac = 1,_params = undefined)
- {
- if (live_call(_card,_grey,_opac,_params)) return live_result;
- var _x,_y,_strength,_scaleX,_scaleY,_rotation,_name,_text,_cOwner,_textPeek;
- var cardTextModified;
- if(_params != undefined)
- {
- _x = _params.x;
- _y = _params.y;
- _strength = _params.strength;
- _scaleX = _params.scaleX;
- _scaleY = _params.scaleY;
- _rotation = _params.rot;
- _name = _params.name;
- _text = _params.text;
- _cOwner = _params.cOwner;
- _textPeek = _params.textPeek;
- }
- else
- {
- _x = x;
- _y = y;
- _scaleX = image_xscale;
- _scaleY = image_yscale;
- _strength = _card.strength;
- _rotation = cardRot;
- _name = _card.name;
- _text = _card.text;
- _cOwner = _card.cardOwner;
- //if the card is a card selector, and that selector belongs to a card foil display that is locked, do not show the text even if the enable text visible option is enabled
- if(object_get_parent(_card.object_index) == objSelectorCardsParent)
- {
- if(_card.belongsToCardFoilDisplay != undefined)
- {
- if(_card.belongsToCardFoilDisplay.foilOption == cardFoilOptions.locked)
- _textPeek = 0;
- else
- {
- if(getListValue(global.optionsSettingsGameOptions,mainMenuListType.enable_text_visible))
- _textPeek = textPeekMax;
- else
- _textPeek = textPeek;
- }
- }
- else
- {
- if(getListValue(global.optionsSettingsGameOptions,mainMenuListType.enable_text_visible))
- _textPeek = textPeekMax;
- else
- _textPeek = textPeek;
- }
- }
- else
- {
- if(getListValue(global.optionsSettingsGameOptions,mainMenuListType.enable_text_visible))
- _textPeek = textPeekMax;
- else
- _textPeek = textPeek;
- }
- }
- //give the credits screen a bit more leeway when drawing cards
- if(global.gameMode == gameMode.credits)
- var extraDist = 1.5;
- else
- var extraDist = 1;
- if(!(_x >= 0-room_width*(extraDist-1) and _x <= room_width*extraDist and _y >= 0-room_height*(extraDist-1) and _y <= room_height*extraDist))
- {
- return;
- }
- var scaleRatio = sprite_get_height(sprCardFrontGeneric)/sprite_get_height(sprCardFrontGenericDisplay);
- //if card has left the board but is waiting to have it's on flip effect activate (it's drawing the grey sprite)
- //draw a second paper, scroll, and name at the old location
- if(_params == undefined)
- {
- if(object_get_parent(_card.object_index) == objCardParent)
- {
- if(_card.shadowActivateEffect == 1)
- {
- if(_card.nullZoneID != undefined or (_card.inDeck == true and _card.fightBoardID == undefined))
- {
- var rotatedGreyedRolledX = xStart + lengthdir_x(((sprite_get_height(sprCardFrontGeneric)-80)*normalScaleX*scaleRatio),0-90)
- var rotatedGreyedRolledY = yStart + lengthdir_y(((sprite_get_height(sprCardFrontGeneric)-80)*normalScaleY*scaleRatio),0-90)
- var rotatedGreyedPaperX = xStart + lengthdir_x(((sprite_get_height(sprCardFrontGeneric))*normalScaleX*scaleRatio),0-90) + lengthdir_x(246*scaleRatio*normalScaleX,0-180)
- var rotatedGreyedPaperY = yStart + lengthdir_y(((sprite_get_height(sprCardFrontGeneric))*normalScaleY*scaleRatio),0-90) + lengthdir_y(246*scaleRatio*normalScaleY,0-180)
- shader_set(sh_greyscale)
- //draw the name scroll and the text paper (based on _card.textPeek (if the options setting is set of course!))
- //draw the paper
- draw_sprite_general(sprCardFrontGenericScrollPaperDisplay,0,0,sprite_get_height(sprCardFrontGenericScrollPaperDisplay)-((sprite_get_height(sprCardFrontGenericScrollPaperDisplay)+80)*0.9),
- sprite_get_width(sprCardFrontGenericDisplay),(sprite_get_height(sprCardFrontGenericScrollPaperDisplay)+80)*(max(_textPeek+0.08,0.155)),
- rotatedGreyedPaperX,rotatedGreyedPaperY,
- scaleRatio*normalScaleX,-scaleRatio*normalScaleY,
- 0,c_white,c_white,c_white,c_white,0.5);
- //draw the scroll roll
- draw_sprite_ext(sprCardFrontGenericScrollRolledDisplay,0,rotatedGreyedRolledX,rotatedGreyedRolledY-(_textPeek * sprite_get_height(sprCardFrontGenericScrollPaperDisplay)*normalScaleY*scaleRatio),normalScaleX*scaleRatio,normalScaleY*scaleRatio,0,c_white,1)
- //draw the strength
- var _radOfSpace = 120, _spaceX = 90, _spaceY = 130;
- if(getListValue(global.optionsSettingsAccessibility,mainMenuListType.enable_dyslexic_font))
- var msdfFontScaleStrength = 2;
- else
- var msdfFontScaleStrength = 3;
- var rotatedGreyedStrengthX = xStart + lengthdir_x(((sprite_get_height(sprCardFrontGeneric))*normalScaleX*scaleRatio),0+90) + lengthdir_x(-(sprite_get_width(sprCardFrontGenericDisplay)/2-_spaceX)*normalScaleX*scaleRatio,0) + lengthdir_x((-_spaceY)*normalScaleX*scaleRatio,0+90);
- var rotatedGreyedStrengthY = yStart + lengthdir_y(((sprite_get_height(sprCardFrontGeneric))*normalScaleY*scaleRatio),0+90) + lengthdir_y(-(sprite_get_width(sprCardFrontGenericDisplay)/2-_spaceX)*normalScaleY*scaleRatio,0) + lengthdir_y((-_spaceY)*normalScaleY*scaleRatio,0+90);
- var scribStrength = scribble(global.optionsCurrentStrengthTextFont+"[c_white][fa_center][scaleStack,"+string(msdfFontScaleStrength)+"]"+string(_strength)).transform(1,1,0).scale_to_box(_radOfSpace*normalScaleX*scaleRatio,_radOfSpace*normalScaleY*scaleRatio,false)
- scribStrength.blend(c_white,0.5)
- scribStrength.origin(0,scribStrength.get_height()/2)
- scribStrength.msdf_border(c_black,1.4)
- scribStrength.draw(rotatedGreyedStrengthX,rotatedGreyedStrengthY)
- //draw the text, but only if the option is set to
- if(getListValue(global.optionsSettingsGameOptions,mainMenuListType.enable_text_visible))
- {
- //we're by default drawing it greyed out here, so alter it so
- //cardTextModified = string_replace_all(_text,"[/c]","[/c][c_black]")
- cardTextModified = string_replace_all(_text,"sprCardTextOnFlip,0","sprCardTextOnFlip,2")
- cardTextModified = string_replace_all(cardTextModified,"sprCardTextStrength,0","sprCardTextStrength,2")
- cardTextModified = string_replace_all(cardTextModified,"sprCardTextGameStart,0","sprCardTextGameStart,2")
- cardTextModified = string_replace_all(cardTextModified,"sprCardTextNullZone,0","sprCardTextNullZone,2")
- if(getListValue(global.optionsSettingsAccessibility,mainMenuListType.enable_dyslexic_font))
- {
- //remove the underline font (underlining is bad for dyslexia!)
- cardTextModified = string_replace_all(cardTextModified,"[/f][fntCardTextDisplayUnderlined]","");
- cardTextModified = string_replace_all(cardTextModified,"[/f][sprMSDFFontCardText]","");
- cardTextModified = string_replace_all(cardTextModified,"_"," ");
- cardTextModified = string_replace_all(cardTextModified,"c black","c_black");
- }
- var scrib = scribble(global.optionsCurrentCardTextFont+"[c_black][fa_left]"+cardTextModified).line_height(22*2,22*2).fit_to_box(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)-44,sprite_get_height(sprCardFrontGenericScrollPaperDisplay)-44)
- scrib.origin(0,scrib.get_height())
- scrib.transform(scaleRatio*normalScaleX,scaleRatio*normalScaleY,0)
- scrib.blend(c_white,map_value(_textPeek,textPeekStart,textPeekMax,-2,0.5))
- scrib.draw(rotatedGreyedRolledX-(scrib.get_width()*scaleRatio*normalScaleX)/2,rotatedGreyedRolledY+46*scaleRatio*normalScaleY)
- }
- //draw the name
- if(getListValue(global.optionsSettingsAccessibility,mainMenuListType.enable_dyslexic_font))
- var msdfFontScaleName = 1.5;
- else
- var msdfFontScaleName = 2;
- var scribNameGrey = scribble(global.optionsCurrentCardHeadingFont+"[c_white][fa_center][scaleStack,"+string(msdfFontScaleName)+"]"+_name).scale_to_box(210*normalScaleX,45*normalScaleY,false)
- scribNameGrey.origin(0,scribNameGrey.get_height()/2-6)
- scribNameGrey.blend(c_white,0.5)
- scribNameGrey.msdf_border(c_black,0.8)
- scribNameGrey.draw(
- rotatedGreyedRolledX + lengthdir_x((_textPeek * sprite_get_height(sprCardFrontGenericScrollPaperDisplay)*normalScaleX*scaleRatio),0+90) + lengthdir_x((1*normalScaleX*scaleRatio),0-90),
- rotatedGreyedRolledY + lengthdir_y((_textPeek * sprite_get_height(sprCardFrontGenericScrollPaperDisplay)*normalScaleY*scaleRatio),0+90) + lengthdir_y((1*normalScaleY*scaleRatio),0-90))
- shader_reset();
- }
- }
- }
- }
- //all of the following checks need to pass to draw the name and text
- var earlyEndCheck = false;
- if(_params == undefined)
- {
- if(object_get_parent(_card.object_index) == objCardParent)
- {
- earlyEndCheck = true;
- if(objSelectionController.objectFollowingMouse == _card)
- {
- earlyEndCheck = false;
- }
- //if the card is in a deck //during selection
- //if(!instance_exists(objFightController))
- //{
- if(_card.deckID != undefined)
- {
- if(_card.inDeck == true)
- {
- if(_card.faceDown == false)
- {
- var _numCardsToDraw = 1;
- if(ds_list_size(_card.deckID.cards) >= _numCardsToDraw)
- {
- if(objSelectionController.thisIsExpanded != _card.deckID)
- {
- if(ds_list_find_index(_card.deckID.cards,_card) < _numCardsToDraw)
- earlyEndCheck = false;
- //the last card in the deck will be drawn
- //if(_card.deckID.cards[| ds_list_size(_card.deckID.cards)-1] == _card)
- //{
- // earlyEndCheck = false;
- //}
- }
- else
- {
- earlyEndCheck = false;
- }
- }
- else
- {
- earlyEndCheck = false;
- }
- }
- else
- {
- earlyEndCheck = false;
- }
- if(_card.deckID.timesToShuffle > 0) //draw the name if the card is being shuffled (stops a graphical glitch)
- {
- earlyEndCheck = false;
- }
- }
- }
- //else
- //{
- // earlyEndCheck = false;
- //}
- //}
- //if the card is on a board
- if(_card.fightBoardID != undefined)
- {
- if(ds_list_size(_card.fightBoardID.cards) > 9)
- {
- if(objSelectionController.thisIsExpanded != _card.fightBoardID)
- {
- if(ds_list_find_index(_card.fightBoardID.cards,_card) >= ds_list_size(_card.fightBoardID.cards)-10)
- earlyEndCheck = false;
- }
- else
- {
- earlyEndCheck = false;
- }
- }
- else
- {
- earlyEndCheck = false;
- }
- }
- //if the card is in a null zone
- if(_card.nullZoneID != undefined)
- {
- if(objSelectionController.thisIsExpanded != _card.nullZoneID)
- {
- if(image_xscale <= 0.05)
- {
- earlyEndCheck = true;
- }
- else
- {
- earlyEndCheck = false;
- }
- }
- else
- {
- earlyEndCheck = false;
- }
- }
- }
- if(_card.dissolveDest == 0)
- {
- earlyEndCheck = true;
- }
- }
- if(earlyEndCheck == true)
- {
- return;
- }
- var rotatedRolledX = _x + lengthdir_x(((sprite_get_height(sprCardFrontGeneric)-80)*_scaleX*scaleRatio),_rotation-90)
- var rotatedRolledY = _y + lengthdir_y(((sprite_get_height(sprCardFrontGeneric)-80)*_scaleY*scaleRatio),_rotation-90)
- var rotatedPaperX = _x + lengthdir_x(((sprite_get_height(sprCardFrontGeneric))*_scaleX*scaleRatio),_rotation-90) + lengthdir_x(246*scaleRatio*_scaleX,_rotation-180)
- var rotatedPaperY = _y + lengthdir_y(((sprite_get_height(sprCardFrontGeneric))*_scaleY*scaleRatio),_rotation-90) + lengthdir_y(246*scaleRatio*_scaleY,_rotation-180)
- if(_grey == true)
- {
- shader_set(sh_greyscale)
- }
- //determine the colour to draw the scroll based on the card's owner
- if(_cOwner == owner.player)
- var ownerBlend = c_white;
- else
- var ownerBlend = make_color_rgb(252, 227, 225)
- //draw the name scroll and the text paper (based on _card.textPeek)
- //draw the paper
- draw_sprite_general(sprCardFrontGenericScrollPaperDisplay,0,0,sprite_get_height(sprCardFrontGenericScrollPaperDisplay)-((sprite_get_height(sprCardFrontGenericScrollPaperDisplay)+80)*(max(_textPeek,0.9))),
- sprite_get_width(sprCardFrontGenericDisplay),(sprite_get_height(sprCardFrontGenericScrollPaperDisplay)+80)*(max(_textPeek+0.056,0.155)),
- rotatedPaperX,rotatedPaperY,
- scaleRatio*_scaleX,-scaleRatio*_scaleY,
- _rotation,ownerBlend,ownerBlend,ownerBlend,ownerBlend,_opac);
- //draw the scroll roll
- draw_sprite_ext(sprCardFrontGenericScrollRolledDisplay,0,
- rotatedRolledX + lengthdir_x((_textPeek * sprite_get_height(sprCardFrontGenericScrollPaperDisplay)*_scaleX*scaleRatio),_rotation+90),
- rotatedRolledY + lengthdir_y((_textPeek * sprite_get_height(sprCardFrontGenericScrollPaperDisplay)*_scaleY*scaleRatio),_rotation+90),
- _scaleX*scaleRatio,_scaleY*scaleRatio,_rotation,ownerBlend,_opac)
- //draws the strength
- var _radOfSpace = 120, _spaceX = 90, _spaceY = 130;
- if(getListValue(global.optionsSettingsAccessibility,mainMenuListType.enable_dyslexic_font))
- var msdfFontScaleStrength = 2;
- else
- var msdfFontScaleStrength = 3;
- var rotatedStrengthX = _x + lengthdir_x(((sprite_get_height(sprCardFrontGeneric))*_scaleX*scaleRatio),_rotation+90) + lengthdir_x(-(sprite_get_width(sprCardFrontGenericDisplay)/2-_spaceX)*_scaleX*scaleRatio,_rotation) + lengthdir_x((-_spaceY)*_scaleX*scaleRatio,_rotation+90);
- var rotatedStrengthY = _y + lengthdir_y(((sprite_get_height(sprCardFrontGeneric))*_scaleY*scaleRatio),_rotation+90) + lengthdir_y(-(sprite_get_width(sprCardFrontGenericDisplay)/2-_spaceX)*_scaleY*scaleRatio,_rotation) + lengthdir_y((-_spaceY)*_scaleY*scaleRatio,_rotation+90);
- var scribStrengthColour;
- if(_params == undefined)
- {
- switch(sign(_strength-_card.printedStrength))
- {
- case -1:
- scribStrengthColour = "[c_red]"
- break;
- case 0:
- scribStrengthColour = "[c_white]"
- break;
- case 1:
- scribStrengthColour = "[c_brightgreen]"
- break;
- }
- }
- else
- {
- scribStrengthColour = "[c_white]"
- }
- var scribStrength = scribble(global.optionsCurrentStrengthTextFont+scribStrengthColour+"[fa_center]"+"[scaleStack,"+string(msdfFontScaleStrength*_scaleX*scaleRatio)+"]"+string(_strength)).transform(1,1,_rotation).scale_to_box(_radOfSpace*_scaleX*scaleRatio,_radOfSpace*_scaleY*scaleRatio,false)
- scribStrength.blend(c_white,_opac)
- scribStrength.origin(0,scribStrength.get_height()/2)
- scribStrength.msdf_border(c_black,1.4)
- scribStrength.draw(rotatedStrengthX,rotatedStrengthY)
- //draws the cards text
- if(_grey == true) //grey out the inline sprites if any
- {
- //cardTextModified = string_replace_all(_text,"[/c]","[/c][c_black]")
- cardTextModified = string_replace_all(_text,"sprCardTextOnFlip,0","sprCardTextOnFlip,2")
- cardTextModified = string_replace_all(cardTextModified,"sprCardTextStrength,0","sprCardTextStrength,2")
- cardTextModified = string_replace_all(cardTextModified,"sprCardTextGameStart,0","sprCardTextGameStart,2")
- cardTextModified = string_replace_all(cardTextModified,"sprCardTextNullZone,0","sprCardTextNullZone,2")
- }
- else
- {
- cardTextModified = _text;
- }
- if(getListValue(global.optionsSettingsAccessibility,mainMenuListType.enable_dyslexic_font))
- {
- //remove the italicised font (italics is bad for dyslexia!)
- cardTextModified = string_replace_all(cardTextModified,"[slant]","");
- cardTextModified = string_replace_all(cardTextModified,"[/slant]","");
- }
- if(_params == undefined)
- {
- if(hoveredOver or getListValue(global.optionsSettingsGameOptions,mainMenuListType.enable_text_visible) == true)
- {
- if(object_get_parent(_card.object_index) == objCardParent)
- {
- if(objSelectionController.thisIsExpanded == _card.deckID or objSelectionController.thisIsExpanded == _card.fightBoardID or objSelectionController.thisIsExpanded == _card.nullZoneID or getListValue(global.optionsSettingsGameOptions,mainMenuListType.enable_text_visible) == true)
- {
- var scrib = scribble(global.optionsCurrentCardTextFont+"[c_black][fa_left]"+cardTextModified).line_height(22*2,22*2).fit_to_box(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)-44,sprite_get_height(sprCardFrontGenericScrollPaperDisplay)-44)
- scrib.origin(scrib.get_width()/2,scrib.get_height())
- scrib.transform(scaleRatio*image_xscale,scaleRatio*image_yscale,cardRot)
- scrib.blend(c_white,map_value(_textPeek,textPeekStart,textPeekMax,-2,1))
- scrib.draw(rotatedPaperX + lengthdir_x(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)/2*scaleRatio*image_xscale,cardRot) + lengthdir_x(35*scaleRatio*image_xscale,cardRot+90),
- rotatedPaperY + lengthdir_y(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)/2*scaleRatio*image_yscale,cardRot) + lengthdir_y(35*scaleRatio*image_yscale,cardRot+90))
- }
- }
- if(object_get_parent(_card.object_index) == objSelectorCardsParent)
- {
- var scrib = scribble(global.optionsCurrentCardTextFont+"[c_black][fa_left]"+cardTextModified).line_height(22*2,22*2).fit_to_box(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)-44,sprite_get_height(sprCardFrontGenericScrollPaperDisplay)-44)
- scrib.origin(scrib.get_width()/2,scrib.get_height())
- scrib.transform(scaleRatio*image_xscale,scaleRatio*image_yscale,cardRot)
- scrib.blend(c_white,map_value(_textPeek,textPeekStart,textPeekMax,-2,1))
- scrib.draw(rotatedPaperX + lengthdir_x(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)/2*scaleRatio*image_xscale,cardRot) + lengthdir_x(35*scaleRatio*image_xscale,cardRot+90),
- rotatedPaperY + lengthdir_y(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)/2*scaleRatio*image_yscale,cardRot) + lengthdir_y(35*scaleRatio*image_yscale,cardRot+90))
- }
- }
- }
- else
- {
- var scrib = scribble(global.optionsCurrentCardTextFont+"[c_black][fa_left]"+cardTextModified).line_height(22*2,22*2).fit_to_box(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)-44,sprite_get_height(sprCardFrontGenericScrollPaperDisplay)-44)
- scrib.origin(scrib.get_width()/2,scrib.get_height())
- scrib.transform(scaleRatio*_scaleX,scaleRatio*_scaleY,_rotation)
- scrib.blend(c_white,_opac)
- scrib.draw(rotatedPaperX + lengthdir_x(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)/2*scaleRatio*_scaleX,_rotation) + lengthdir_x(35*scaleRatio*_scaleX,_rotation+90),
- rotatedPaperY + lengthdir_y(sprite_get_width(sprCardFrontGenericScrollPaperDisplay)/2*scaleRatio*_scaleY,_rotation) + lengthdir_y(35*scaleRatio*_scaleY,_rotation+90))
- }
- //draw the name
- if(getListValue(global.optionsSettingsAccessibility,mainMenuListType.enable_dyslexic_font))
- var msdfFontScaleName = 1.5;
- else
- var msdfFontScaleName = 2;
- if(_scaleX > 0 and _scaleY > 0)
- {
- var scribName = scribble(global.optionsCurrentCardHeadingFont+"[c_white][fa_center][fa_top]"+"[scaleStack,"+string(msdfFontScaleName)+"]"+_name).transform(1,1,_rotation).scale_to_box(210*_scaleX,45*_scaleY,false)
- scribName.origin(0,scribName.get_height()/2-6)
- scribName.blend(c_white,_opac)
- scribName.msdf_border(c_black,0.8)
- scribName.draw(rotatedRolledX + lengthdir_x((_textPeek * sprite_get_height(sprCardFrontGenericScrollPaperDisplay)*_scaleX*scaleRatio),_rotation+90) + lengthdir_x((1*_scaleX*scaleRatio),_rotation-90),
- rotatedRolledY + lengthdir_y((_textPeek * sprite_get_height(sprCardFrontGenericScrollPaperDisplay)*_scaleY*scaleRatio),_rotation+90) + lengthdir_y((1*_scaleY*scaleRatio),_rotation-90))
- }
- if(_grey == true)
- {
- shader_reset();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment