mirror of
https://github.com/tildearrow/furnace.git
synced 2025-01-03 22:21:09 +00:00
add several warning dialogs
This commit is contained in:
parent
e9accf16db
commit
5dafd10fc7
4 changed files with 70 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "dataErrors.h"
|
#include "dataErrors.h"
|
||||||
|
#include "song.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
@ -755,8 +756,16 @@ const char* DivEngine::getEffectDesc(unsigned char effect, int chan) {
|
||||||
return "Invalid effect";
|
return "Invalid effect";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define addWarning(x) \
|
||||||
|
if (warnings.empty()) { \
|
||||||
|
warnings+=x; \
|
||||||
|
} else { \
|
||||||
|
warnings+=("\n" x); \
|
||||||
|
}
|
||||||
|
|
||||||
bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
SafeReader reader=SafeReader(file,len);
|
SafeReader reader=SafeReader(file,len);
|
||||||
|
warnings="";
|
||||||
try {
|
try {
|
||||||
DivSong ds;
|
DivSong ds;
|
||||||
|
|
||||||
|
@ -895,6 +904,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
}
|
}
|
||||||
ds.customTempo=true;
|
ds.customTempo=true;
|
||||||
ds.timeBase=0;
|
ds.timeBase=0;
|
||||||
|
addWarning("Yamaha YMU759 emulation is not currently possible!");
|
||||||
}
|
}
|
||||||
|
|
||||||
logI("reading pattern matrix (%d)...\n",ds.ordersLen);
|
logI("reading pattern matrix (%d)...\n",ds.ordersLen);
|
||||||
|
@ -1146,6 +1156,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
||||||
ins->gb.soundLen=ins->std.volMacroLen*2;
|
ins->gb.soundLen=ins->std.volMacroLen*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
addWarning("Game Boy volume macros converted to envelopes. may not be perfect!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,6 +1340,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
char magic[5];
|
char magic[5];
|
||||||
memset(magic,0,5);
|
memset(magic,0,5);
|
||||||
SafeReader reader=SafeReader(file,len);
|
SafeReader reader=SafeReader(file,len);
|
||||||
|
warnings="";
|
||||||
try {
|
try {
|
||||||
DivSong ds;
|
DivSong ds;
|
||||||
|
|
||||||
|
@ -1343,6 +1355,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
|
|
||||||
if (ds.version>DIV_ENGINE_VERSION) {
|
if (ds.version>DIV_ENGINE_VERSION) {
|
||||||
logW("this module was created with a more recent version of Furnace!\n");
|
logW("this module was created with a more recent version of Furnace!\n");
|
||||||
|
addWarning("this module was created with a more recent version of Furnace!");
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.readS(); // reserved
|
reader.readS(); // reserved
|
||||||
|
@ -1678,6 +1691,7 @@ SafeWriter* DivEngine::saveFur() {
|
||||||
int samplePtr[256];
|
int samplePtr[256];
|
||||||
std::vector<int> patPtr;
|
std::vector<int> patPtr;
|
||||||
size_t ptrSeek;
|
size_t ptrSeek;
|
||||||
|
warnings="";
|
||||||
|
|
||||||
SafeWriter* w=new SafeWriter;
|
SafeWriter* w=new SafeWriter;
|
||||||
w->init();
|
w->init();
|
||||||
|
@ -1891,6 +1905,7 @@ SafeWriter* DivEngine::saveDMF() {
|
||||||
lastError="this system is not possible on .dmf";
|
lastError="this system is not possible on .dmf";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
warnings="";
|
||||||
|
|
||||||
SafeWriter* w=new SafeWriter;
|
SafeWriter* w=new SafeWriter;
|
||||||
w->init();
|
w->init();
|
||||||
|
@ -1924,6 +1939,25 @@ SafeWriter* DivEngine::saveDMF() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (song.system[0]==DIV_SYSTEM_C64_6581 || song.system[0]==DIV_SYSTEM_C64_8580) {
|
||||||
|
addWarning("absolute duty/cutoff macro not available in .dmf!");
|
||||||
|
addWarning("duty precision will be lost");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DivInstrument* i: song.ins) {
|
||||||
|
if (i->type==DIV_INS_AMIGA) {
|
||||||
|
addWarning(".dmf format does not support arbitrary-pitch sample mode");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DivInstrument* i: song.ins) {
|
||||||
|
if (i->type==DIV_INS_FM) {
|
||||||
|
addWarning("no FM macros in .dmf format");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
w->writeC(song.ins.size());
|
w->writeC(song.ins.size());
|
||||||
for (DivInstrument* i: song.ins) {
|
for (DivInstrument* i: song.ins) {
|
||||||
w->writeString(i->name,true);
|
w->writeString(i->name,true);
|
||||||
|
@ -2051,6 +2085,10 @@ SafeWriter* DivEngine::saveDMF() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (song.sample.size()>0) {
|
||||||
|
addWarning("samples' rates will be rounded to nearest compatible value");
|
||||||
|
}
|
||||||
|
|
||||||
w->writeC(song.sample.size());
|
w->writeC(song.sample.size());
|
||||||
for (DivSample* i: song.sample) {
|
for (DivSample* i: song.sample) {
|
||||||
w->writeI(i->length);
|
w->writeI(i->length);
|
||||||
|
@ -3870,6 +3908,10 @@ String DivEngine::getLastError() {
|
||||||
return lastError;
|
return lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String DivEngine::getWarnings() {
|
||||||
|
return warnings;
|
||||||
|
}
|
||||||
|
|
||||||
DivInstrument* DivEngine::getIns(int index) {
|
DivInstrument* DivEngine::getIns(int index) {
|
||||||
if (index<0 || index>=song.insLen) return &song.nullIns;
|
if (index<0 || index>=song.insLen) return &song.nullIns;
|
||||||
return song.ins[index];
|
return song.ins[index];
|
||||||
|
@ -4254,6 +4296,7 @@ int DivEngine::addInstrument(int refChan) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivEngine::addInstrumentFromFile(const char *path) {
|
bool DivEngine::addInstrumentFromFile(const char *path) {
|
||||||
|
warnings="";
|
||||||
FILE* f=ps_fopen(path,"rb");
|
FILE* f=ps_fopen(path,"rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -4304,6 +4347,10 @@ bool DivEngine::addInstrumentFromFile(const char *path) {
|
||||||
short version=reader.readS();
|
short version=reader.readS();
|
||||||
reader.readS(); // reserved
|
reader.readS(); // reserved
|
||||||
|
|
||||||
|
if (version>DIV_ENGINE_VERSION) {
|
||||||
|
warnings="this instrument is made with a more recent version of Furnace!";
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int dataPtr=reader.readI();
|
unsigned int dataPtr=reader.readI();
|
||||||
reader.seek(dataPtr,SEEK_SET);
|
reader.seek(dataPtr,SEEK_SET);
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,7 @@ class DivEngine {
|
||||||
String configPath;
|
String configPath;
|
||||||
String configFile;
|
String configFile;
|
||||||
String lastError;
|
String lastError;
|
||||||
|
String warnings;
|
||||||
|
|
||||||
struct SamplePreview {
|
struct SamplePreview {
|
||||||
int sample;
|
int sample;
|
||||||
|
@ -495,6 +496,9 @@ class DivEngine {
|
||||||
|
|
||||||
// get last error
|
// get last error
|
||||||
String getLastError();
|
String getLastError();
|
||||||
|
|
||||||
|
// get warnings
|
||||||
|
String getWarnings();
|
||||||
|
|
||||||
// switch master
|
// switch master
|
||||||
void switchMaster();
|
void switchMaster();
|
||||||
|
|
|
@ -4170,6 +4170,9 @@ int FurnaceGUI::save(String path) {
|
||||||
w->finish();
|
w->finish();
|
||||||
curFileName=path;
|
curFileName=path;
|
||||||
modified=false;
|
modified=false;
|
||||||
|
if (!e->getWarnings().empty()) {
|
||||||
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4240,6 +4243,9 @@ int FurnaceGUI::load(String path) {
|
||||||
undoHist.clear();
|
undoHist.clear();
|
||||||
redoHist.clear();
|
redoHist.clear();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
|
if (!e->getWarnings().empty()) {
|
||||||
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4892,6 +4898,9 @@ bool FurnaceGUI::loop() {
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_INS_OPEN:
|
case GUI_FILE_INS_OPEN:
|
||||||
e->addInstrumentFromFile(copyOfName.c_str());
|
e->addInstrumentFromFile(copyOfName.c_str());
|
||||||
|
if (!e->getWarnings().empty()) {
|
||||||
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_WAVE_OPEN:
|
case GUI_FILE_WAVE_OPEN:
|
||||||
e->addWaveFromFile(copyOfName.c_str());
|
e->addWaveFromFile(copyOfName.c_str());
|
||||||
|
@ -4970,7 +4979,7 @@ bool FurnaceGUI::loop() {
|
||||||
|
|
||||||
if (ImGui::BeginPopupModal("Warning",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::BeginPopupModal("Warning",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("%s",warnString.c_str());
|
ImGui::Text("%s",warnString.c_str());
|
||||||
if (ImGui::Button("Yes")) {
|
if (ImGui::Button(warnAction==GUI_WARN_GENERIC?"OK":"Yes")) {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
switch (warnAction) {
|
switch (warnAction) {
|
||||||
case GUI_WARN_QUIT:
|
case GUI_WARN_QUIT:
|
||||||
|
@ -4993,11 +5002,15 @@ bool FurnaceGUI::loop() {
|
||||||
case GUI_WARN_OPEN:
|
case GUI_WARN_OPEN:
|
||||||
openFileDialog(GUI_FILE_OPEN);
|
openFileDialog(GUI_FILE_OPEN);
|
||||||
break;
|
break;
|
||||||
|
case GUI_WARN_GENERIC:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
if (warnAction==GUI_WARN_GENERIC) {
|
||||||
if (ImGui::Button("No")) {
|
ImGui::SameLine();
|
||||||
ImGui::CloseCurrentPopup();
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,8 @@ enum FurnaceGUIFileDialogs {
|
||||||
enum FurnaceGUIWarnings {
|
enum FurnaceGUIWarnings {
|
||||||
GUI_WARN_QUIT,
|
GUI_WARN_QUIT,
|
||||||
GUI_WARN_NEW,
|
GUI_WARN_NEW,
|
||||||
GUI_WARN_OPEN
|
GUI_WARN_OPEN,
|
||||||
|
GUI_WARN_GENERIC
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SelectionPoint {
|
struct SelectionPoint {
|
||||||
|
|
Loading…
Reference in a new issue