GUI: fix intro carry-over in specific situations

issue #1149
This commit is contained in:
tildearrow 2023-06-12 02:18:50 -05:00
parent 54e7bd295d
commit 16adc1fb1b
3 changed files with 10 additions and 3 deletions

View file

@ -6953,6 +6953,7 @@ FurnaceGUI::FurnaceGUI():
mustClear(2), mustClear(2),
initialScreenWipe(1.0f), initialScreenWipe(1.0f),
introSkipDo(false), introSkipDo(false),
introStopped(false),
curTutorial(-1), curTutorial(-1),
curTutorialStep(0) { curTutorialStep(0) {
// value keys // value keys

View file

@ -2029,7 +2029,7 @@ class FurnaceGUI {
double monitorPos; double monitorPos;
int mustClear; int mustClear;
float initialScreenWipe; float initialScreenWipe;
bool introSkipDo; bool introSkipDo, introStopped;
ImVec2 introMin, introMax; ImVec2 introMin, introMax;
// tutorial // tutorial

View file

@ -19,6 +19,7 @@
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include "gui.h" #include "gui.h"
#include "../ta-log.h"
#include "imgui_internal.h" #include "imgui_internal.h"
#include <fmt/printf.h> #include <fmt/printf.h>
@ -73,6 +74,8 @@ void FurnaceGUI::drawImage(ImDrawList* dl, FurnaceGUIImages image, const ImVec2&
} }
void FurnaceGUI::endIntroTune() { void FurnaceGUI::endIntroTune() {
if (introStopped) return;
logV("ending intro");
stop(); stop();
if (curFileName.empty()) { if (curFileName.empty()) {
e->createNewFromDefaults(); e->createNewFromDefaults();
@ -96,6 +99,7 @@ void FurnaceGUI::endIntroTune() {
cursor=SelectionPoint(); cursor=SelectionPoint();
updateWindowTitle(); updateWindowTitle();
updateScroll(0); updateScroll(0);
introStopped=true;
} }
void FurnaceGUI::drawIntro(double introTime, bool monitor) { void FurnaceGUI::drawIntro(double introTime, bool monitor) {
@ -291,7 +295,7 @@ void FurnaceGUI::drawIntro(double introTime, bool monitor) {
if (introSkipDo) { if (introSkipDo) {
introSkip+=ImGui::GetIO().DeltaTime; introSkip+=ImGui::GetIO().DeltaTime;
if (introSkip>=0.5) { if (introSkip>=0.5) {
if (e->isPlaying()) endIntroTune(); if (!shortIntro) endIntroTune();
introPos=0.1; introPos=0.1;
if (introSkip>=0.75) introPos=12.0; if (introSkip>=0.75) introPos=12.0;
} }
@ -318,7 +322,7 @@ void FurnaceGUI::drawIntro(double introTime, bool monitor) {
e->setRepeatPattern(false); e->setRepeatPattern(false);
play(); play();
} }
if (e->isPlaying() && introPos>=10.0 && !shortIntro) endIntroTune(); if (introPos>=10.0 && !shortIntro) endIntroTune();
introPos+=ImGui::GetIO().DeltaTime; introPos+=ImGui::GetIO().DeltaTime;
if (introPos>=(shortIntro?1.0:11.0)) { if (introPos>=(shortIntro?1.0:11.0)) {
introPos=12.0; introPos=12.0;
@ -326,5 +330,7 @@ void FurnaceGUI::drawIntro(double introTime, bool monitor) {
commitTutorial(); commitTutorial();
} }
} }
} else if (!shortIntro) {
endIntroTune();
} }
} }