calband/calchart

Inconsistent Use of Animation::GotoSheet(...)

Closed this issue · 1 comments

In an animation, stuntsheets are represented by AnimateSheet objects. Stuntsheets that are "not in the animation" (that is, stuntsheets with zero beats in them) are not represented in the animation, and thus do not have corresponding AnimateSheet objects in the Animation.

As a result, if there are 10 sheets, and 2 are not in the animation, there will be only 8 AnimateSheet objects.

Usually, when Animation::GotoSheet(index) is called, the index corresponds with the index of a sheet in the CC_show object (instead of the index of its corresponding AnimateSheet). However, sometimes, it corresponds with the index of the AnimateSheet.

Unfortunately, this can cause CalChart to exit with an unhandled exception. The AnimationView might call GotoSheet(10), for example, intending to jump to the sheet of the CC_show with an index of 10, but GotoSheet(...) will attempt to jump to the AnimateSheet having that index. Because the number of AnimateSheets can be less than the number of CC_sheets, the 10th index may be out of range, and an exception might be thrown.

Alternatively, when the slider of the animation frame is moved to position 10, we want to jump to the AnimateSheet with index 10.

Fixed in #95.