| 866 | } |
| 867 | |
| 868 | void Snapshots::LoadState(FileStreamIn& in, int rev) |
| 869 | { |
| 870 | mLoadRev = rev; |
| 871 | |
| 872 | IDrawableModule::LoadState(in, rev); |
| 873 | |
| 874 | if (ModularSynth::sLoadingFileSaveStateRev < 423) |
| 875 | in >> rev; |
| 876 | LoadStateValidate(rev <= GetModuleSaveStateRev()); |
| 877 | |
| 878 | int collSize; |
| 879 | in >> collSize; |
| 880 | mSnapshotCollection.resize(collSize); |
| 881 | for (int i = 0; i < collSize; ++i) |
| 882 | { |
| 883 | int snapshotSize; |
| 884 | in >> snapshotSize; |
| 885 | mSnapshotCollection[i].mSnapshots.resize(snapshotSize); |
| 886 | for (auto& snapshotData : mSnapshotCollection[i].mSnapshots) |
| 887 | { |
| 888 | in >> snapshotData.mControlPath; |
| 889 | in >> snapshotData.mValue; |
| 890 | in >> snapshotData.mHasLFO; |
| 891 | snapshotData.mLFOSettings.LoadState(in); |
| 892 | in >> snapshotData.mGridCols; |
| 893 | in >> snapshotData.mGridRows; |
| 894 | if (rev < 3) |
| 895 | { |
| 896 | // Check if the loaded values are within an acceptable range. |
| 897 | // This is done because mGridCols and mGridRows could previously be saved with random values since they were not properly initialized. |
| 898 | if (snapshotData.mGridCols < 0 || snapshotData.mGridCols > 1000) |
| 899 | snapshotData.mGridCols = 0; |
| 900 | if (snapshotData.mGridRows < 0 || snapshotData.mGridRows > 1000) |
| 901 | snapshotData.mGridRows = 0; |
| 902 | } |
| 903 | snapshotData.mGridContents.resize(size_t(snapshotData.mGridCols) * snapshotData.mGridRows); |
| 904 | for (int k = 0; k < snapshotData.mGridCols * snapshotData.mGridRows; ++k) |
| 905 | in >> snapshotData.mGridContents[k]; |
| 906 | in >> snapshotData.mString; |
| 907 | } |
| 908 | in >> mSnapshotCollection[i].mLabel; |
| 909 | if (rev < 2 && mSnapshotCollection[i].mLabel.empty()) |
| 910 | mSnapshotCollection[i].mLabel = "snapshot" + ofToString(i); |
| 911 | mCurrentSnapshotSelector->SetLabel(mSnapshotCollection[i].mLabel, i); |
| 912 | } |
| 913 | |
| 914 | UpdateGridValues(); |
| 915 | |
| 916 | std::string path; |
| 917 | int size; |
| 918 | in >> size; |
| 919 | for (int i = 0; i < size; ++i) |
| 920 | { |
| 921 | in >> path; |
| 922 | if (path != "") |
| 923 | { |
| 924 | IDrawableModule* module = TheSynth->FindModule(path); |
| 925 | if (module) |
no test coverage detected