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

Method drawLocalSave

code/main/Save.ts:182–237  ·  view source on GitHub ↗
(x: number, y: number)

Source from the content-addressed store, hash-verified

180 }
181
182 private drawLocalSave(x: number, y: number): number{
183 // The y we will return (will remain 0 if there's no translation to show)
184 var yAdd: number = 0;
185
186 // Title & why
187 this.drawTitle("saveLocalSaveTitle", y+yAdd);
188 this.drawPoint("saveLocalSaveWhy", x, y+yAdd+2);
189 if(Database.isTranslated()) yAdd += 1;
190
191 // If we support local saving
192 if(LocalSaving.supportsLocalSaving()){
193 // Choose a slot text
194 this.drawPoint("saveLocalSaveChooseSlot", x, y+yAdd+4);
195 // Slots list
196 this.renderArea.addList(x+5, x+45, y+yAdd+7, "saveLocalSaveSlotsList", new CallbackCollection(this.slotSelected.bind(this)), this.slotsArray);
197 // Autosave enabled ?
198 if(this.getGame().getLocalAutosaveEnabled()){
199 this.drawGreen(Database.getText("saveLocalSaveAutosaveEnabled"), x, y+yAdd+9);
200 if(Database.getTranslatedText("saveLocalSaveAutosaveEnabled") != "") this.drawGreen("(" + Database.getTranslatedText("saveLocalSaveAutosaveEnabled") + ")", x, y+yAdd+10, true);
201 this.drawGreen("Next save in " + Algo.pluralFormat(Math.ceil(this.getGame().getLocalAutosaveTime()/60), " minute", " minutes") + " on slot " + this.getGame().getLocalAutosaveSlot().substr(4, 1) + ".", x, y+yAdd+11);
202 }
203 // Separation lines
204 this.renderArea.drawVerticalLine("|", x+50, y+yAdd+5, y+yAdd+11);
205 this.renderArea.drawHorizontalLine("-", x, x+100, y+yAdd+3);
206 this.renderArea.drawHorizontalLine("-", x, x+100, y+yAdd+12);
207 // Choose what to do text
208 this.drawPoint("saveLocalSaveChooseWhatToDo", x+51, y+yAdd+4);
209 // Add save button
210 this.renderArea.addAsciiRealButton(Database.getText("saveLocalSaveSaveButton") + " on slot " + this.selectedSlot.substr(4, 1), x+51, y+yAdd+7, "saveLocalSaveSaveButton", Database.getTranslatedText("saveLocalSaveSaveButton"), true, -1, null, false);
211 this.renderArea.addLinkCall(".saveLocalSaveSaveButton", new CallbackCollection(this.clickedSave.bind(this)));
212 // If autosave is disabled or it's not enabled on the currently selected slot
213 if(this.getGame().getLocalAutosaveEnabled() == false){
214 // Add autosave button
215 this.renderArea.addAsciiRealButton(Database.getText("saveLocalSaveAutosaveButton") + " on slot " + this.selectedSlot.substr(4, 1), x+51, y+yAdd+10, "saveLocalSaveAutosaveButton", Database.getTranslatedText("saveLocalSaveAutosaveButton"), true, -1, null, false);
216 this.renderArea.addLinkCall(".saveLocalSaveAutosaveButton", new CallbackCollection(this.clickedAutosave.bind(this)));
217 }
218 // Else
219 else{
220 // Add disable autosave button
221 this.renderArea.addAsciiRealButton(Database.getText("saveLocalSaveDisableAutosaveButton"), x+51, y+yAdd+10, "saveLocalSaveDisableAutosaveButton", Database.getTranslatedText("saveLocalSaveDisableAutosaveButton"), true, -1, null, false);
222 this.renderArea.addLinkCall(".saveLocalSaveDisableAutosaveButton", new CallbackCollection(this.clickedDisableAutosave.bind(this)));
223 }
224 }
225 // If we don't
226 else{
227 // Warning messages
228 this.drawWarning(Database.getText("saveLocalSaveWarning0") + " (local storage and application cache)", x, y+yAdd+4);
229 this.drawWarning(Database.getText("saveLocalSaveWarning1"), x, y+yAdd+5);
230
231 this.drawWarning(Database.getTranslatedText("saveLocalSaveWarning0"), x, y+yAdd+7, true);
232 this.drawWarning(Database.getTranslatedText("saveLocalSaveWarning1"), x, y+yAdd+8, true);
233 }
234
235 // Return yAdd
236 return yAdd;
237 }
238
239 private drawFileLoad(x: number, y: number): number{

Callers 1

updateMethod · 0.95

Calls 15

drawTitleMethod · 0.95
drawPointMethod · 0.95
drawGreenMethod · 0.95
drawWarningMethod · 0.95
addListMethod · 0.80
bindMethod · 0.80
getLocalAutosaveTimeMethod · 0.80
getLocalAutosaveSlotMethod · 0.80
drawVerticalLineMethod · 0.80
drawHorizontalLineMethod · 0.80
addAsciiRealButtonMethod · 0.80

Tested by

no test coverage detected