Skip to content

Commit

Permalink
GUI: mark modified when replacing instruments
Browse files Browse the repository at this point in the history
  • Loading branch information
tildearrow committed Nov 14, 2024
1 parent 725c463 commit 3ca9545
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5418,44 +5418,33 @@ bool FurnaceGUI::loop() {
}
break;
}
case GUI_FILE_SAMPLE_OPEN_REPLACE:
{
case GUI_FILE_SAMPLE_OPEN_REPLACE: {
std::vector<DivSample*> samples=e->sampleFromFile(copyOfName.c_str());
if (samples.empty())
{
if (samples.empty()) {
showError(e->getLastError());
}
else
{
if((int)samples.size() == 1)
{
if (curSample>=0 && curSample<(int)e->song.sample.size())
{
DivSample* s = samples[0];
e->lockEngine([this, s]()
{
} else {
if ((int)samples.size()==1) {
if (curSample>=0 && curSample<(int)e->song.sample.size()) {
DivSample* s=samples[0];
e->lockEngine([this,s]() {
// if it crashes here please tell me...
DivSample* oldSample=e->song.sample[curSample];
e->song.sample[curSample]= s;
e->song.sample[curSample]=s;
delete oldSample;
e->renderSamples();
MARK_MODIFIED;
});
updateSampleTex=true;
}
else
{
} else {
showError(_("...but you haven't selected a sample!"));
delete samples[0];
}
}
else
{
for (DivSample* s: samples) { //ask which samples to load!
} else {
for (DivSample* s: samples) { // ask which samples to load!
pendingSamples.push_back(std::make_pair(s,false));
}
displayPendingSamples=true;
replacePendingSample = true;
replacePendingSample=true;
}
}
break;
Expand Down Expand Up @@ -5540,6 +5529,7 @@ bool FurnaceGUI::loop() {
int instrumentCount=-1;
for (DivInstrument* i: instruments) {
instrumentCount=e->addInstrumentPtr(i);
MARK_MODIFIED;
}
if (instrumentCount>=0 && settings.selectAssetOnLoad) {
curIns=instrumentCount-1;
Expand Down Expand Up @@ -5567,6 +5557,7 @@ bool FurnaceGUI::loop() {
} else { // replace with the only instrument
if (curIns>=0 && curIns<(int)e->song.ins.size()) {
*e->song.ins[curIns]=*instruments[0];
MARK_MODIFIED;
} else {
showError(_("...but you haven't selected an instrument!"));
}
Expand Down

0 comments on commit 3ca9545

Please sign in to comment.