convert presets to new format, part 2

This commit is contained in:
tildearrow 2022-11-13 16:57:47 -05:00
parent d422372b7f
commit ea643c574c
5 changed files with 21 additions and 12 deletions

View File

@ -1390,10 +1390,14 @@ String DivEngine::decodeSysDesc(String desc) {
return newDesc.toBase64(); return newDesc.toBase64();
} }
void DivEngine::initSongWithDesc(const char* description) { void DivEngine::initSongWithDesc(const char* description, bool inBase64) {
int chanCount=0; int chanCount=0;
DivConfig c; DivConfig c;
c.loadFromBase64(description); if (inBase64) {
c.loadFromBase64(description);
} else {
c.loadFromMemory(description);
}
int index=0; int index=0;
for (; index<32; index++) { for (; index<32; index++) {
song.system[index]=systemFromFileFur(c.getInt(fmt::sprintf("id%d",index),0)); song.system[index]=systemFromFileFur(c.getInt(fmt::sprintf("id%d",index),0));
@ -1414,7 +1418,7 @@ void DivEngine::initSongWithDesc(const char* description) {
song.systemLen=index; song.systemLen=index;
} }
void DivEngine::createNew(const char* description, String sysName) { void DivEngine::createNew(const char* description, String sysName, bool inBase64) {
quitDispatch(); quitDispatch();
BUSY_BEGIN; BUSY_BEGIN;
saveLock.lock(); saveLock.lock();
@ -1422,7 +1426,7 @@ void DivEngine::createNew(const char* description, String sysName) {
song=DivSong(); song=DivSong();
changeSong(0); changeSong(0);
if (description!=NULL) { if (description!=NULL) {
initSongWithDesc(description); initSongWithDesc(description,inBase64);
} }
if (sysName=="") { if (sysName=="") {
song.systemName=getSongSystemLegacyName(song,!getConfInt("noMultiSystem",0)); song.systemName=getSongSystemLegacyName(song,!getConfInt("noMultiSystem",0));

View File

@ -467,7 +467,7 @@ class DivEngine {
bool deinitAudioBackend(bool dueToSwitchMaster=false); bool deinitAudioBackend(bool dueToSwitchMaster=false);
void registerSystems(); void registerSystems();
void initSongWithDesc(const char* description); void initSongWithDesc(const char* description, bool inBase64=true);
void exchangeIns(int one, int two); void exchangeIns(int one, int two);
void swapChannels(int src, int dest); void swapChannels(int src, int dest);
@ -501,7 +501,7 @@ class DivEngine {
// parse old system setup description // parse old system setup description
String decodeSysDesc(String desc); String decodeSysDesc(String desc);
// start fresh // start fresh
void createNew(const char* description, String sysName); void createNew(const char* description, String sysName, bool inBase64=true);
// load a file. // load a file.
bool load(unsigned char* f, size_t length); bool load(unsigned char* f, size_t length);
// save as .dmf. // save as .dmf.

View File

@ -4438,9 +4438,14 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup(); ImGui::EndPopup();
} }
ImGui::SetNextWindowSizeConstraints(ImVec2(400.0f*dpiScale,200.0f*dpiScale),ImVec2(canvasW,canvasH)); ImVec2 newSongMinSize=mobileUI?ImVec2(canvasW-(portrait?0:(60.0*dpiScale)),canvasH-60.0*dpiScale):ImVec2(400.0f*dpiScale,200.0f*dpiScale);
ImVec2 newSongMaxSize=ImVec2(canvasW-((mobileUI && !portrait)?(60.0*dpiScale):0),canvasH-(mobileUI?(60.0*dpiScale):0));
ImGui::SetNextWindowSizeConstraints(newSongMinSize,newSongMaxSize);
if (ImGui::BeginPopupModal("New Song",NULL,ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar)) { if (ImGui::BeginPopupModal("New Song",NULL,ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar)) {
ImGui::SetWindowPos(ImVec2(((canvasW)-ImGui::GetWindowSize().x)*0.5,((canvasH)-ImGui::GetWindowSize().y)*0.5)); ImGui::SetWindowPos(ImVec2(((canvasW)-ImGui::GetWindowSize().x)*0.5,((canvasH)-ImGui::GetWindowSize().y)*0.5));
if (ImGui::GetWindowSize().x<newSongMinSize.x || ImGui::GetWindowSize().y<newSongMinSize.y) {
ImGui::SetWindowSize(newSongMinSize,ImGuiCond_Always);
}
drawNewSong(); drawNewSong();
ImGui::EndPopup(); ImGui::EndPopup();
} }

View File

@ -143,7 +143,7 @@ void FurnaceGUI::drawNewSong() {
} }
if (accepted) { if (accepted) {
e->createNew(nextDesc.c_str(),nextDescName); e->createNew(nextDesc.c_str(),nextDescName,false);
undoHist.clear(); undoHist.clear();
redoHist.clear(); redoHist.clear();
curFileName=""; curFileName="";

View File

@ -2335,16 +2335,16 @@ FurnaceGUISysDef::FurnaceGUISysDef(const char* n, std::initializer_list<int> def
if (uncompiled[i]==0) break; if (uncompiled[i]==0) break;
DivConfig oldFlags; DivConfig oldFlags;
DivEngine::convertOldFlags(uncompiled[3],oldFlags,(DivSystem)uncompiled[0]); DivEngine::convertOldFlags(uncompiled[i+3],oldFlags,(DivSystem)uncompiled[i]);
definition+=fmt::sprintf( definition+=fmt::sprintf(
"id%d=%d\nvol%d=%d\npan%d=%d\nflags%d=%s\n", "id%d=%d\nvol%d=%d\npan%d=%d\nflags%d=%s\n",
index, index,
DivEngine::systemToFileFur((DivSystem)uncompiled[0]), DivEngine::systemToFileFur((DivSystem)uncompiled[i]),
index, index,
uncompiled[1], uncompiled[i+1],
index, index,
uncompiled[2], uncompiled[i+2],
index, index,
oldFlags.toBase64() oldFlags.toBase64()
); );