diff --git a/Source/CartManager.cpp b/Source/CartManager.cpp index 779026e7..2a120f17 100644 --- a/Source/CartManager.cpp +++ b/Source/CartManager.cpp @@ -256,6 +256,36 @@ void CartManager::programSelected(ProgramListBox *source, int pos) { } } +void CartManager::programAutoCopied(ProgramListBox *source, int pos) { + + ProgramListBox *otherListBox; + + if ( source == activeCart.get() ) { + otherListBox = browserCart.get(); + } else { + otherListBox = activeCart.get(); + } + + int i; + int foundIndex = -1; + + for ( i = 0; i < otherListBox->programNames.size(); i++ ) { + if ( otherListBox->programNames[i] == "- " || otherListBox->programNames[i] == " " ) { + foundIndex = i; + break; + } + } + + if ( foundIndex < 0 ){ + AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Auto Copy", "No free program slot found!"); + return; + } + + char *sourceSysExPointer = source->getCurrentCart().getRawVoice() + (pos*128); + + programDragged(otherListBox, foundIndex, sourceSysExPointer); +} + void CartManager::buttonClicked(juce::Button *buttonThatWasClicked) { if ( buttonThatWasClicked == closeButton.get() ) { hideCartridgeManager(); @@ -306,6 +336,11 @@ void CartManager::buttonClicked(juce::Button *buttonThatWasClicked) { void CartManager::fileDoubleClicked(const File& file) { if ( file.isDirectory() ) return; + int rc = AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon, "Load Cartridge", + "This will replace the current cartridge. " + "Are you sure?"); + if ( rc == 0 ) + return; mainWindow->loadCart(file); activeCart->setCartridge(mainWindow->processor->currentCart); updateCartFilename(); diff --git a/Source/CartManager.h b/Source/CartManager.h index f90b5728..caf909a0 100644 --- a/Source/CartManager.h +++ b/Source/CartManager.h @@ -106,6 +106,7 @@ class CartManager : public Component, public Button::Listener, public DragAndDr virtual void programSelected(ProgramListBox *source, int pos) override; virtual void programRightClicked(ProgramListBox *source, int pos) override; virtual void programDragged(ProgramListBox *destListBox, int dest, char *packedPgm) override; + virtual void programAutoCopied(ProgramListBox *source, int pos) override; virtual bool keyPressed(const KeyPress& key, Component* originatingComponent) override; void initialFocus(); diff --git a/Source/ProgramListBox.cpp b/Source/ProgramListBox.cpp index fb196c04..e7968957 100644 --- a/Source/ProgramListBox.cpp +++ b/Source/ProgramListBox.cpp @@ -81,7 +81,7 @@ bool ProgramListBox::keyPressed(const KeyPress &key, Component *originatingCompo if ( key.isKeyCode(KeyPress::returnKey) ) { activePgm = programLabel->idx; if ( activePgm != -1 ) { - listener->programSelected(this, activePgm); + listener->programAutoCopied(this, activePgm); } return true; } @@ -108,6 +108,11 @@ bool ProgramListBox::keyPressed(const KeyPress &key, Component *originatingCompo return false; } + activePgm = currentIdx; + if ( activePgm != -1 ) { + listener->programSelected(this, activePgm); + } + labels[currentIdx]->grabKeyboardFocus(); repaint(); diff --git a/Source/ProgramListBox.h b/Source/ProgramListBox.h index 274da137..056bca24 100644 --- a/Source/ProgramListBox.h +++ b/Source/ProgramListBox.h @@ -32,6 +32,7 @@ class ProgramListBoxListener { virtual void programSelected(ProgramListBox *source, int pos) = 0; virtual void programRightClicked(ProgramListBox *source, int pos) = 0; virtual void programDragged(ProgramListBox *destListBox, int dest, char *packedPgm) = 0; + virtual void programAutoCopied(ProgramListBox *source, int pos) = 0; }; class ProgramLabel;