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

Method drawBook

code/main/Cauldron.ts:210–247  ·  view source on GitHub ↗
(x: number, y: number)

Source from the content-addressed store, hash-verified

208 }
209
210 private drawBook(x: number, y: number): void{
211 // Draw the book
212 this.renderArea.drawArray(Database.getAscii("places/cauldron/book"), x, y);
213
214 // Draw the pages' content
215 this.renderArea.drawArray(Database.getAscii("places/cauldron/bookPage" + Saving.loadNumber("cauldronBookCurrentPage")), x+8, y+1);
216 this.renderArea.drawArray(Database.getAscii("places/cauldron/bookPage" + (Saving.loadNumber("cauldronBookCurrentPage")+1)), x+50, y+1);
217
218 // Add the previous page button if we're not already at the first page
219 if(Saving.loadNumber("cauldronBookCurrentPage") > 0){
220 this.renderArea.addAsciiRealButton(Database.getText("cauldronPreviousPageButton"), x, y+31, "cauldronPreviousPageButton", Database.getTranslatedText("cauldronPreviousPageButton"), true, -1, null, false);
221 this.renderArea.addLinkCall(".cauldronPreviousPageButton", new CallbackCollection(this.previousPage.bind(this)));
222 }
223
224 // Add the next page button if we're not already at the last page
225 if(Saving.loadNumber("cauldronBookCurrentPage") < this.maxPage){
226 this.renderArea.addAsciiRealButton(Database.getText("cauldronNextPageButton"), x+87, y+31, "cauldronNextPageButton", Database.getTranslatedText("cauldronNextPageButton"), true, -1, null, false, true);
227 this.renderArea.addLinkCall(".cauldronNextPageButton", new CallbackCollection(this.nextPage.bind(this)));
228 }
229
230 // Add the translation if there is one
231 if(Database.isTranslated()){
232 // Buttons on the left page
233 for(var i = 1; i < 28; i++){
234 this.renderArea.addAsciiNinjaButton(x+7, x+48, i, "cauldronLeftPageTranslationButton");
235 }
236 // Buttons on the right page
237 for(var i = 1; i < 28; i++){
238 this.renderArea.addAsciiNinjaButton(x+49, x+90, i, "cauldronRightPageTranslationButton");
239 }
240 // Tooltips
241 this.renderArea.addTooltip("cauldronLeftPageTranslationButtonTooltip", Database.getTranslatedText("cauldron.page" + Saving.loadNumber("cauldronBookCurrentPage")));
242 this.renderArea.addTooltip("cauldronRightPageTranslationButtonTooltip", Database.getTranslatedText("cauldron.page" + (Saving.loadNumber("cauldronBookCurrentPage")+1)));
243 // Links
244 this.renderArea.addLinkOnHoverShowTooltip(".cauldronLeftPageTranslationButton", ".cauldronLeftPageTranslationButtonTooltip");
245 this.renderArea.addLinkOnHoverShowTooltip(".cauldronRightPageTranslationButton", ".cauldronRightPageTranslationButtonTooltip");
246 }
247 }
248
249 private drawCauldron(x: number, y: number): void{
250 // Draw the cauldron

Callers 1

updateMethod · 0.95

Calls 9

drawArrayMethod · 0.80
getAsciiMethod · 0.80
addAsciiRealButtonMethod · 0.80
addLinkCallMethod · 0.80
bindMethod · 0.80
addAsciiNinjaButtonMethod · 0.80
addTooltipMethod · 0.80
getTextMethod · 0.45

Tested by

no test coverage detected