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

Method addTag

code/main/RenderArea.ts:207–240  ·  view source on GitHub ↗
(tag: RenderTag, y: number)

Source from the content-addressed store, hash-verified

205 }
206
207 public addTag(tag: RenderTag, y: number): boolean{
208 // BUGS
209 if(Bugs.getGraphicalBugLevel() >= 3)
210 y += Random.between(0, 10) - 5;
211
212 // Return false if y is out of bounds
213 if(y < 0 || y >= this.height)
214 return false;
215
216 // Return false if x is out of bounds
217 if(tag.getX() < 0 || tag.getX() > this.getWidth())
218 return false;
219
220 // If it's the first tag we add, we just add it
221 if(this.tags[y].length == 0){
222 this.tags[y].push(tag);
223 return true;
224 }
225 else{ // Else add the tag at the correct place in the array (tags must be sorted !!)
226 for(var i = 0; i < this.tags[y].length; i++){
227 // If this is the right place to add the tag, we add it and we break the loop
228 if(tag.getX() > this.tags[y][i].getX()){
229 this.tags[y].splice(i, 0, tag); // We add the tag just before the one we're iterating
230 return true;
231 }
232 }
233 }
234
235 // If we didn't add it yet, it means we have to add it at the end of the array : we do so
236 this.tags[y].push(tag);
237
238 // Return true
239 return true;
240 }
241
242 public addTextarea(x: number, y: number, width: number, height: number, otherClass: string, text: string = ""): boolean{
243 return this.addTag(new RenderTag(x, "<textarea class=\"textarea " + otherClass + "\" rows=\"" + height.toString() + "\" cols=\"" + width.toString() + "\">" + text + "</textarea>"), y);

Callers 12

addAsciiRealButtonMethod · 0.95
addCheckboxMethod · 0.95
addCommentMethod · 0.95
addEnigmaMethod · 0.95
addListMethod · 0.95
addSimpleInputMethod · 0.95
addTextareaMethod · 0.95
addTooltipMethod · 0.95
addTranslatedCommentMethod · 0.95
addTwoTagsMethod · 0.95
drawAreaMethod · 0.95
drawMethod · 0.80

Calls 2

getWidthMethod · 0.95
getXMethod · 0.80

Tested by

no test coverage detected