(tag: RenderTag, y: number)
| 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); |
no test coverage detected