diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 0d2053ea4..51a5bfa9c 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3437,6 +3437,14 @@ bool FurnaceGUI::loop() { continue; } + if (firstFrame) { + if (!tutorial.introPlayed || settings.alwaysPlayIntro==3 || (settings.alwaysPlayIntro==2 && curFileName.empty())) { + unsigned char* introTemp=new unsigned char[intro_fur_len]; + memcpy(introTemp,intro_fur,intro_fur_len); + e->load(introTemp,intro_fur_len); + } + } + layoutTimeBegin=SDL_GetPerformanceCounter(); ImGui_ImplSDLRenderer_NewFrame(); @@ -5666,12 +5674,6 @@ bool FurnaceGUI::init() { oldPat[i]=new DivPattern; } - if ((!tutorial.introPlayed || settings.alwaysPlayIntro>=2) && curFileName.empty()) { - unsigned char* introTemp=new unsigned char[intro_fur_len]; - memcpy(introTemp,intro_fur,intro_fur_len); - e->load(introTemp,intro_fur_len); - } - firstFrame=true; // TODO: MIDI mapping time! diff --git a/src/gui/intro.cpp b/src/gui/intro.cpp index 526e500df..8aa10d9c4 100644 --- a/src/gui/intro.cpp +++ b/src/gui/intro.cpp @@ -20,6 +20,7 @@ #define _USE_MATH_DEFINES #include "gui.h" #include "imgui_internal.h" +#include void FurnaceGUI::drawImage(ImDrawList* dl, FurnaceGUIImages image, const ImVec2& pos, const ImVec2& scale, double rotate, const ImVec2& uvMin, const ImVec2& uvMax, const ImVec4& imgColor) { FurnaceGUIImage* imgI=getImage(image); @@ -73,7 +74,27 @@ void FurnaceGUI::drawImage(ImDrawList* dl, FurnaceGUIImages image, const ImVec2& void FurnaceGUI::endIntroTune() { stop(); - e->createNewFromDefaults(); + if (curFileName.empty()) { + e->createNewFromDefaults(); + } else { // load pending song + if (load(curFileName)>0) { + showError(fmt::sprintf("Error while loading file! (%s)",lastError)); + curFileName=""; + e->createNewFromDefaults(); + } + } + undoHist.clear(); + redoHist.clear(); + modified=false; + curNibble=false; + orderNibble=false; + orderCursor=-1; + samplePos=0; + updateSampleTex=true; + selStart=SelectionPoint(); + selEnd=SelectionPoint(); + cursor=SelectionPoint(); + updateWindowTitle(); } void FurnaceGUI::drawIntro(double introTime, bool monitor) { @@ -89,7 +110,7 @@ void FurnaceGUI::drawIntro(double introTime, bool monitor) { nextWindow=GUI_WINDOW_NOTHING; ImGui::SetNextWindowPos(ImVec2(0,0)); ImGui::SetNextWindowSize(ImVec2(canvasW,canvasH)); - ImGui::SetNextWindowFocus(); + if (introPos<0.1) ImGui::SetNextWindowFocus(); } if (ImGui::Begin(monitor?"IntroMon X":"Intro",monitor?(&introMonOpen):NULL,monitor?globalWinFlags:(ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoDocking|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoBackground))) { if (monitor) { diff --git a/src/main.cpp b/src/main.cpp index 12dde1428..d8cc440b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -451,7 +451,7 @@ int main(int argc, char** argv) { e.preInit(); - if (!fileName.empty()) { + if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",false)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="")) { logI("loading module..."); FILE* f=ps_fopen(fileName.c_str(),"rb"); if (f==NULL) {