OPM import: Fix reset read procedural flow
This commit is contained in:
		
							parent
							
								
									f716ac262d
								
							
						
					
					
						commit
						3550ad512a
					
				| 
						 | 
				
			
			@ -830,11 +830,14 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, St
 | 
			
		|||
       m2Read = false,
 | 
			
		||||
       c2Read = false;
 | 
			
		||||
 | 
			
		||||
  DivInstrument* newPatch = nullptr;
 | 
			
		||||
  
 | 
			
		||||
  auto completePatchRead = [&]() {
 | 
			
		||||
    return patchNameRead && lfoRead && characteristicRead && m1Read && c1Read && m2Read && c2Read;
 | 
			
		||||
  };
 | 
			
		||||
  auto resetPatchRead = [&]() {
 | 
			
		||||
    patchNameRead = lfoRead = characteristicRead = m1Read = c1Read = m2Read = c2Read = false;
 | 
			
		||||
    newPatch = nullptr;
 | 
			
		||||
  };
 | 
			
		||||
  auto readOpmOperator = [](SafeReader& reader, DivInstrumentFM::Operator& op) {
 | 
			
		||||
    op.ar = atoi(reader.readString_Token().c_str());
 | 
			
		||||
| 
						 | 
				
			
			@ -850,8 +853,6 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, St
 | 
			
		|||
    op.ssgEnv = atoi(reader.readString_Token().c_str());
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  DivInstrument* newPatch = nullptr;
 | 
			
		||||
 | 
			
		||||
  try {
 | 
			
		||||
    reader.seek(0, SEEK_SET);
 | 
			
		||||
    while (!reader.isEOF()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -922,7 +923,7 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, St
 | 
			
		|||
 | 
			
		||||
      if (completePatchRead()) {
 | 
			
		||||
        insList.push_back(newPatch);
 | 
			
		||||
        newPatch = nullptr;
 | 
			
		||||
        resetPatchRead();
 | 
			
		||||
        ++readCount;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1290,9 +1290,9 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
 | 
			
		|||
      if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
 | 
			
		||||
      hasOpened=fileDialog->openLoad(
 | 
			
		||||
        "Load Instrument",
 | 
			
		||||
        {"compatible files", "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.bnk *.ff",
 | 
			
		||||
        {"compatible files", "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.bnk *.ff *.opm",
 | 
			
		||||
         "all files", ".*"},
 | 
			
		||||
        "compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.bnk,.ff},.*",
 | 
			
		||||
        "compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.bnk,.ff,.opm},.*",
 | 
			
		||||
        workingDirIns,
 | 
			
		||||
        dpiScale
 | 
			
		||||
      );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2489,6 +2489,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
 | 
			
		|||
  ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".fti",uiColors[GUI_COLOR_FILE_INSTR],ICON_FA_FILE);
 | 
			
		||||
  ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".bti",uiColors[GUI_COLOR_FILE_INSTR],ICON_FA_FILE);
 | 
			
		||||
  ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".ff",uiColors[GUI_COLOR_FILE_INSTR],ICON_FA_FILE);
 | 
			
		||||
  ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByExtension,".opm",uiColors[GUI_COLOR_FILE_INSTR],ICON_FA_FILE);
 | 
			
		||||
 | 
			
		||||
  if (updateFonts) {
 | 
			
		||||
    if (fileDialog!=NULL) delete fileDialog;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue