| 479 | } |
| 480 | |
| 481 | void Menu::Reload() noexcept |
| 482 | { |
| 483 | displayingFixedMenu = false; |
| 484 | |
| 485 | #if 0 // if all menus use the whole screen (no visual nesting) |
| 486 | currentMargin = rowOffset = 0; |
| 487 | lcd.ClearAll(); |
| 488 | #else |
| 489 | if (numNestedMenus == 1 || lcd.GetNumRows() < 160) // don't nest menus on a low-res display e.g. 12864 |
| 490 | { |
| 491 | currentMargin = rowOffset = 0; |
| 492 | lcd.ClearAll(); |
| 493 | } |
| 494 | else |
| 495 | { |
| 496 | const PixelNumber indentPerLevel = lcd.GetNumRows()/40 + 2; // 10 pixels on a 480x320 TFT |
| 497 | currentMargin = rowOffset = indentPerLevel * (numNestedMenus - 1); |
| 498 | const PixelNumber borderMargin = currentMargin - 2; |
| 499 | const PixelNumber right = lcd.GetNumCols() - borderMargin - 1; |
| 500 | const PixelNumber bottom = lcd.GetNumRows() - borderMargin - 1; |
| 501 | lcd.Clear(borderMargin, borderMargin, bottom, right); |
| 502 | |
| 503 | // Draw the outline |
| 504 | lcd.Line(borderMargin, borderMargin, bottom, borderMargin, true); |
| 505 | lcd.Line(borderMargin, borderMargin, borderMargin, right, true); |
| 506 | lcd.Line(bottom, borderMargin, bottom, right, true); |
| 507 | lcd.Line(borderMargin, right, bottom, right, true); |
| 508 | } |
| 509 | #endif |
| 510 | |
| 511 | ResetCache(); |
| 512 | displayingErrorMessage = false; |
| 513 | |
| 514 | lcd.SetRightMargin(lcd.GetNumCols() - currentMargin); |
| 515 | const char *_ecv_array const fname = filenames[numNestedMenus - 1].c_str(); |
| 516 | FileStore *_ecv_null const file = reprap.GetPlatform().OpenFile(MENU_DIR, fname, OpenMode::read); |
| 517 | if (file == nullptr) |
| 518 | { |
| 519 | LoadError("File not found", 0); |
| 520 | } |
| 521 | else |
| 522 | { |
| 523 | row = rowOffset; |
| 524 | column = currentMargin; |
| 525 | fontNumber = 0; |
| 526 | commandBufferIndex = 0; // Free the string buffer, which contains layout elements from an old menu |
| 527 | for (unsigned int line = 1; ; ++line) |
| 528 | { |
| 529 | char buffer[MaxMenuLineLength]; |
| 530 | if (file->ReadLine(buffer, sizeof(buffer)) < 0) |
| 531 | { |
| 532 | break; |
| 533 | } |
| 534 | char *_ecv_array const pcMenuLine = SkipWhitespace(buffer); |
| 535 | const char *_ecv_array _ecv_null const errMsg = ParseMenuLine(pcMenuLine); |
| 536 | if (errMsg != nullptr) |
| 537 | { |
| 538 | LoadError(errMsg, line); |