GUI: fix replace raw

This commit is contained in:
tildearrow 2023-07-17 16:31:55 -05:00
parent ec9a3180b2
commit 09d226a9aa
2 changed files with 22 additions and 4 deletions

View file

@ -4848,6 +4848,7 @@ bool FurnaceGUI::loop() {
case GUI_FILE_SAMPLE_OPEN_RAW:
case GUI_FILE_SAMPLE_OPEN_REPLACE_RAW:
pendingRawSample=copyOfName;
pendingRawSampleReplace=(curFileDialog==GUI_FILE_SAMPLE_OPEN_REPLACE_RAW);
displayPendingRawSample=true;
break;
case GUI_FILE_SAMPLE_SAVE:
@ -5715,10 +5716,26 @@ bool FurnaceGUI::loop() {
if (s==NULL) {
showError(e->getLastError());
} else {
if (e->addSamplePtr(s)==-1) {
showError(e->getLastError());
if (pendingRawSampleReplace) {
if (curSample>=0 && curSample<(int)e->song.sample.size()) {
e->lockEngine([this,s]() {
// if it crashes here please tell me...
DivSample* oldSample=e->song.sample[curSample];
e->song.sample[curSample]=s;
delete oldSample;
e->renderSamples();
MARK_MODIFIED;
});
} else {
showError("...but you haven't selected a sample!");
delete s;
}
} else {
MARK_MODIFIED;
if (e->addSamplePtr(s)==-1) {
showError(e->getLastError());
} else {
MARK_MODIFIED;
}
}
}
ImGui::CloseCurrentPopup();
@ -6756,6 +6773,7 @@ FurnaceGUI::FurnaceGUI():
pendingRawSampleUnsigned(false),
pendingRawSampleBigEndian(false),
pendingRawSampleSwapNibbles(false),
pendingRawSampleReplace(false),
globalWinFlags(0),
curFileDialog(GUI_FILE_OPEN),
warnAction(GUI_WARN_OPEN),

View file

@ -1335,7 +1335,7 @@ class FurnaceGUI {
String pendingRawSample;
int pendingRawSampleDepth, pendingRawSampleChannels;
bool pendingRawSampleUnsigned, pendingRawSampleBigEndian, pendingRawSampleSwapNibbles;
bool pendingRawSampleUnsigned, pendingRawSampleBigEndian, pendingRawSampleSwapNibbles, pendingRawSampleReplace;
ImGuiWindowFlags globalWinFlags;