Exemplo n.º 1
0
  // Set the buttons displayed in the panel
  // textFilePath - The path to the sound effect definition file
  // Returns 0 (an error occurred and a new project was opened), 1 (an error occurred), 2 (the
  // project opened normally)
  public int loadFile(String textFilePath) {
    clearBoard();

    // Get the sounds contained in the given project file
    ArrayList<SoundInfo> readSounds = soundManager.readFile(textFilePath);

    // Add buttons to the interface for each sound in the file
    for (int s = 0; s < readSounds.size(); s++) {
      SoundInfo curr = readSounds.get(s);
      if (checkValidKey(curr.getKeyName())) {
        addSound(readSounds.get(s));
      } else {
        soundManager.deleteSound(curr.getKeyCode());
      }
    }

    // Report if an error occurred while opening the project
    // Allow the user to close the project without proceeding
    if (soundManager.getProjectModified()) {
      int choice =
          JOptionPane.showConfirmDialog(
              frame,
              "One or more errors were encountered while reading the project file. "
                  + "The file may be missing, not well-formatted, or not a Cue Masher project file. Do you want to proceed?",
              "Keep Project Open?",
              JOptionPane.YES_NO_OPTION);
      if (choice == JOptionPane.NO_OPTION) {
        openNewProject();
        return 0;
      }
      return 1;
    }
    return 2;
  }
Exemplo n.º 2
0
  // Removes a sound from the interface and sound list
  // keyCode - The keyboard key code associated with the sound
  public void deleteSound(int keyCode) {
    soundManager.deleteSound(keyCode);

    // Search the sound buttons for the button to remove
    for (int s = 0; s < soundList.size(); s++) {
      BoardButton button = soundList.get(s);
      if (button.getKeyCode() == keyCode) {
        // Remove the button from the interface
        remove(button.getButton());
        soundList.remove(s);

        // Update the GUI
        frame.setProjectModified();
        refreshSoundBoard();

        break;
      }
    }
  }