MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / LoadState

Method LoadState

Source/Snapshots.cpp:868–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866}
867
868void 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)

Callers 1

SetSnapshotMethod · 0.45

Calls 9

LoadStateValidateFunction · 0.85
ofToStringFunction · 0.85
resizeMethod · 0.80
emptyMethod · 0.80
AddPatchCableMethod · 0.80
SetEnumMethod · 0.80
SetLabelMethod · 0.45
FindModuleMethod · 0.45
FindUIControlMethod · 0.45

Tested by

no test coverage detected