| 550 | } |
| 551 | |
| 552 | String EditorExportPreset::get_version(const StringName &p_preset_string, bool p_windows_version) const { |
| 553 | String result = get(p_preset_string); |
| 554 | if (result.is_empty()) { |
| 555 | result = GLOBAL_GET("application/config/version"); |
| 556 | |
| 557 | // Split and validate version number components. |
| 558 | const PackedStringArray result_split = result.split(".", false); |
| 559 | bool valid_version = !result_split.is_empty(); |
| 560 | for (const String &E : result_split) { |
| 561 | if (!_check_digits(E)) { |
| 562 | valid_version = false; |
| 563 | break; |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | if (valid_version) { |
| 568 | if (p_windows_version) { |
| 569 | // Modify version number to match Windows constraints (version numbers must have 4 components). |
| 570 | if (result_split.size() == 1) { |
| 571 | result = result + ".0.0.0"; |
| 572 | } else if (result_split.size() == 2) { |
| 573 | result = result + ".0.0"; |
| 574 | } else if (result_split.size() == 3) { |
| 575 | result = result + ".0"; |
| 576 | } else { |
| 577 | result = vformat("%s.%s.%s.%s", result_split[0], result_split[1], result_split[2], result_split[3]); |
| 578 | } |
| 579 | } else { |
| 580 | result = String(".").join(result_split); |
| 581 | } |
| 582 | } else { |
| 583 | if (!result.is_empty()) { |
| 584 | WARN_PRINT(vformat("Invalid version number \"%s\". The version number can only contain numeric characters (0-9) and non-consecutive periods (.).", result)); |
| 585 | } |
| 586 | if (p_windows_version) { |
| 587 | result = "1.0.0.0"; |
| 588 | } else { |
| 589 | result = "1.0.0"; |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | return result; |
| 595 | } |
no test coverage detected