Changeset 169 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures


Ignore:
Timestamp:
12/18/2019 02:12:23 PM (6 years ago)
Author:
sdanthin
Message:

SimulationScript?.java modified to use correct names for both imported and created I_AudioEvents

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/structures/SimulationScript.java

    r158 r169  
    8585     
    8686    public boolean saved; 
    87  
     87     
    8888    //TODO: Pretty much everything in this constructor is dummy data. 
    8989    //Replace all of it. 
     
    273273        saved = true; 
    274274    } 
     275     
     276    /** 
     277     * Creates the proper audio directory using the I_AudioEvent types. 
     278     * @param path of audio directory root 
     279     */ 
    275280    private void createAudioDirectory(Path path){ 
    276281        File f = new File(path.toString()+"/audio"); 
     
    278283        { 
    279284            f.mkdir(); 
    280             //scan through to see what is already there and then make changes accordingly. 
     285            //scan through to see what is already there and if there is no existing audio directory, create it. 
    281286        } 
    282287        for(ScriptIncident i : incidents) 
     
    286291                String name = ((Integer) i.number).toString(); 
    287292                File incidentFolder = new File(path.toString()+"/audio/"+name); 
    288                 if(incidentFolder.exists()) 
     293                if(!incidentFolder.exists()) 
    289294                { 
    290                     //check to see if there are already files for the given incidents 
    291                     //not sure how the ordering of the files should be. 
    292                     //check to see if folder needs filling 
    293                 }else 
    294                 { 
    295  
    296295                    //create an incidentfolder since one does not already exist 
    297296                    incidentFolder.mkdir(); 
    298                     int fileCount = 1; 
    299                     for(TimeSlice slice : i.getSlices()) 
     297                } 
     298 
     299                 
     300                for(TimeSlice slice : i.getSlices()) 
     301                { 
     302                    for(I_ScriptEvent event : slice.events) 
    300303                    { 
    301                         for(I_ScriptEvent event : slice.events) 
     304                        if(event instanceof I_AudioEvent) 
    302305                        { 
    303                             if(event.getScriptEventType().equals(ScriptEvent.ScriptEventType.CHP_RADIO_EVENT)) 
     306                            //if the event is a chp radio event 
     307                            //then add the dummy file to the subdirectory created 
     308                            //CURRENTLY this ONLY is implemented for CHPRadioEvent, so it will need to be changed later. 
     309                            CHPRadioEvent radioEvent = (CHPRadioEvent) event; 
     310 
     311                            String output = radioEvent.toScriptFile(); 
     312                            //optimally, this line should use the ID, but to account for files being read in, it needs to be the radiofile name 
     313                            File newAudioScript = new File(path.toString()+"/audio/"+name+"/"+radioEvent.radioFile.replaceAll(".mp3","")+".txt"); 
     314                             
     315                            try 
    304316                            { 
    305                                 //if the event is a chp radio event 
    306                                 //then add the dummy file to the subdirectory created 
    307                                 CHPRadioEvent radioEvent = (CHPRadioEvent) event; 
    308                                  
    309                                 String output = radioEvent.toScriptFile(); 
    310                                  
    311                                 File newAudioScript = new File(path.toString()+"/audio/"+name+"/"+name+fileCount+".txt"); 
    312                                  
    313                                 fileCount++; 
    314                                 try 
    315                                 { 
    316                                     newAudioScript.createNewFile(); 
    317                                     BufferedWriter bw = new BufferedWriter(new FileWriter(newAudioScript)); 
    318                                     bw.write(output); 
    319                                     bw.flush(); 
    320                                     bw.close(); 
    321                                 }catch(Exception e) 
    322                                 { 
    323                                     System.err.println("there was a problem creating your text files"); 
    324                                 } 
    325  
     317                                newAudioScript.createNewFile(); 
     318                                BufferedWriter bw = new BufferedWriter(new FileWriter(newAudioScript)); 
     319                                bw.write(output); 
     320                                bw.flush(); 
     321                                bw.close(); 
     322                            }catch(Exception e) 
     323                            { 
     324                                System.err.println("there was a problem creating your text files"); 
    326325                            } 
     326 
    327327                        } 
    328328                    } 
    329  
    330329                } 
     330 
     331                 
    331332            } 
    332333 
Note: See TracChangeset for help on using the changeset viewer.