MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / addAsciiRealButton

Method addAsciiRealButton

code/main/RenderArea.ts:26–55  ·  view source on GitHub ↗
(str: string, x: number, y: number, otherClass: string = "", comment: string = "", commentBelow: boolean = false, underlinedLetter: number = -1, color: Color = null, commentCentered: boolean = true, commentRightAligned: boolean = false)

Source from the content-addressed store, hash-verified

24 }
25
26 public addAsciiRealButton(str: string, x: number, y: number, otherClass: string = "", comment: string = "", commentBelow: boolean = false, underlinedLetter: number = -1, color: Color = null, commentCentered: boolean = true, commentRightAligned: boolean = false): boolean{
27 // Add the button
28 if(this.addTag(new RenderTag(x, "<span class=\"aroundRealButton\"><span class=\"asciiRealButton " + otherClass + "\"" + (color == null? "" : " style=\"background-color:" + color.getColorString() + ";\"") + ">" + Algo.makeUnderlinedLetter(str, underlinedLetter) + "</span></span>"), y) == false)
29 return false;
30
31 // Add the comment
32 if(comment != ""){
33 var commentX: number;
34 var commentY: number;
35
36 // If the comment should be on the right
37 if(commentBelow == false){
38 commentX = x+str.length+2;
39 commentY = y;
40 }
41 else{
42 if(commentCentered) commentX = Algo.correctIfUnderZero(x + str.length/2 - comment.length/2);
43 else if(commentRightAligned == false) commentX = x;
44 else commentX = x + (str.length - comment.length);
45 commentY = y+1;
46 }
47
48 if(this.drawString(comment, commentX, commentY) == false)
49 return false;
50 if(this.addTwoTags(commentX, commentX+comment.length, commentY, "<span class=\"translated\">", "</span>") == false)
51 return false;
52 }
53
54 return true;
55 }
56
57 public addBackgroundColor(x1: number, x2: number, y: number, color: Color): boolean{
58 return this.addTwoTags(x1, x2, y, "<span style=\"background-color:" + color.getColorString() + "\">", "</span>");

Callers 15

drawMethod · 0.80
drawBuyingButtonMethod · 0.80
addBackToButtonMethod · 0.80
updateMethod · 0.80
drawMethod · 0.80
updateMethod · 0.80
updateMethod · 0.80
addLighthouseButtonMethod · 0.80
addTheSeaButtonMethod · 0.80
drawCandiesStuffMethod · 0.80
drawLollipopsStuffMethod · 0.80

Calls 4

addTagMethod · 0.95
drawStringMethod · 0.95
addTwoTagsMethod · 0.95
getColorStringMethod · 0.80

Tested by

no test coverage detected