Skip to content

Fix mini textbox not closing when it's expanding and another textbox is triggered#389

Merged
0x0ade merged 1 commit into
EverestAPI:devfrom
WEGFan:fix/minitextbox
Oct 14, 2021
Merged

Fix mini textbox not closing when it's expanding and another textbox is triggered#389
0x0ade merged 1 commit into
EverestAPI:devfrom
WEGFan:fix/minitextbox

Conversation

@WEGFan
Copy link
Copy Markdown
Member

@WEGFan WEGFan commented Oct 13, 2021

Issue

When a mini textbox is expanding and the player triggers another textbox, the first one will stop expanding and stay on screen until retrying the level.

2021-10-13_22-06-46.mp4

Reason

Let's say we have mini textbox A and B, when A is expanding, the code is looping here in MiniTextbox.Routine():

while ((this.ease += Engine.DeltaTime * 4f) < 1f) {
    yield return null;
}

Then the player triggers B, the game checks and closes them if there are other textboxes in the level, also in MiniTextbox.Routine():

List<Entity> entities = this.Scene.Tracker.GetEntities<MiniTextbox>();
foreach (MiniTextbox miniTextbox in entities) {
    if (miniTextbox != this) {
        miniTextbox.Add(new Coroutine(miniTextbox.Close()));
    }
}

Then MiniTextbox.Close() routine is added to A, currently A has MiniTextbox.Close() and MiniTextbox.Routine() routines running, after the routine is added, the code will loop here in MiniTextbox.Close():

while ((this.ease -= Engine.DeltaTime * 4f) > 0f) {
    yield return null;
}

ease is increasing and decreasing by the same amount at the same time, causing A having a constant value of expanding progress, so it will stay on screen forever.

Solution

Since closing will be set to true in MiniTextbox.Close(), we can stop the display routine if the textbox is closing, so only MiniTextbox.Close() is running in A when B is triggered.

 while ((this.ease += Engine.DeltaTime * 4f) < 1f) {
+    if (this.closing) {
+        yield break;
+    }
     yield return null;
 }
2021-10-13_23-30-39.mp4

@0x0ade 0x0ade merged commit fa53631 into EverestAPI:dev Oct 14, 2021
@WEGFan WEGFan deleted the fix/minitextbox branch October 16, 2021 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants