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

Method drawActions

code/main/Cauldron.ts:123–208  ·  view source on GitHub ↗
(x: number, y: number, firstTimeWeUpdate: boolean, keepInputContent: boolean)

Source from the content-addressed store, hash-verified

121 }
122
123 private drawActions(x: number, y: number, firstTimeWeUpdate: boolean, keepInputContent: boolean): void{
124 // Variables
125 var candiesInputHasFocus: boolean = false;
126 var lollipopsInputHasFocus: boolean = false;
127
128 // If it's not the first time we update, we need to keep some stuff from the page (content of the inputs + focus on the inputs)
129 if(firstTimeWeUpdate == false){
130 // If if the candies / lollipops input has the focus (in order to restore the focus after the page updating)
131 candiesInputHasFocus = $(".cauldronCandiesInput").is(":focus");
132 lollipopsInputHasFocus = $(".cauldronLollipopsInput").is(":focus");
133
134 // Reset the content of candiesInput and lollipopsInput
135 this.candiesInput = "";
136 this.lollipopsInput = "";
137 }
138
139 // What you want to put in the cauldron
140 // Text
141 this.renderArea.drawString(Database.getText("cauldronWhatYouWantToPut"), x, y); // Normal
142 this.renderArea.addBold(x, x + Database.getText("cauldronWhatYouWantToPut").length, y); // Add bold on normal
143 this.renderArea.drawString(Database.getTranslatedText("cauldronWhatYouWantToPut"), x, y+1, true); // Translated
144 // Candies input
145 this.renderArea.addSimpleInput(x, x + 20, y+2, new CallbackCollection(this.changeCandiesInput.bind(this)), "cauldronCandiesInput", (keepInputContent? this.candiesInput: ""), candiesInputHasFocus);
146 this.renderArea.drawString("candies", x + 21, y+2);
147 if(this.candiesInputComment != null){
148 this.renderArea.drawString(this.candiesInputComment, x + 29, y+2);
149 this.renderArea.addBold(x + 29, x + 29 + this.candiesInputComment.length, y+2);
150 }
151 // Lollipops input
152 this.renderArea.addSimpleInput(x, x + 20, y+4, new CallbackCollection(this.changeLollipopsInput.bind(this)), "cauldronLollipopsInput", (keepInputContent? this.lollipopsInput: ""), lollipopsInputHasFocus);
153 this.renderArea.drawString("lollipops", x + 21, y+4);
154 if(this.lollipopsInputComment != null){
155 this.renderArea.drawString(this.lollipopsInputComment, x + 31, y+4);
156 this.renderArea.addBold(x + 31, x + 31 + this.lollipopsInputComment.length, y+4);
157 }
158 // Put all that in the cauldron
159 this.renderArea.addAsciiRealButton("Put all that in the cauldron", x, y+6, "cauldronPutAllThatInTheCauldronButton", "", false, 4);
160 this.renderArea.addLinkCall(".cauldronPutAllThatInTheCauldronButton", new CallbackCollection(this.putInCauldron.bind(this)));
161
162 // What is in the cauldron
163 // Text
164 this.renderArea.drawString(Database.getText("cauldronWhatIsIn"), x, y+9); // Normal
165 this.renderArea.addBold(x, x + Database.getText("cauldronWhatIsIn").length, y+9); // Add bold on normal
166 this.renderArea.drawString(Database.getTranslatedText("cauldronWhatIsIn"), x, y+10, true); // Translated
167 // Candies
168 this.renderArea.drawString("Candies :", x+2, y+11);
169 this.renderArea.drawString(Algo.numberToStringButNicely(this.getGame().getCandiesInCauldron().getCurrent()), x + 14, y + 11);
170 // Lollipops
171 this.renderArea.drawString("Lollipops :", x+2, y+12);
172 this.renderArea.drawString(Algo.numberToStringButNicely(this.getGame().getLollipopsInCauldron().getCurrent()), x + 14, y + 12);
173
174 // What you can do with it
175 // Text
176 this.renderArea.drawString(Database.getText("cauldronWhatYouCanDo"), x, y+14); // Normal
177 this.renderArea.addBold(x, x + Database.getText("cauldronWhatYouCanDo").length, y+14); // Add bold on normal
178 this.renderArea.drawString(Database.getTranslatedText("cauldronWhatYouCanDo"), x, y+15, true); // Translated
179 // Mix button
180 this.renderArea.addAsciiRealButton("Mix", x, y+16, "cauldronMixButton", "", false, 0);

Callers 1

updateMethod · 0.95

Calls 15

getSpecialMixingTextMethod · 0.95
getSpecialBoilingTextMethod · 0.95
$Function · 0.85
isMethod · 0.80
drawStringMethod · 0.80
addBoldMethod · 0.80
addSimpleInputMethod · 0.80
bindMethod · 0.80
addAsciiRealButtonMethod · 0.80
addLinkCallMethod · 0.80
getCurrentMethod · 0.80
getCandiesInCauldronMethod · 0.80

Tested by

no test coverage detected