From bce822d92c4b0ea7f49f7e18a858e16e85d79b2c Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 9 Aug 2018 18:59:47 -0300 Subject: Wrap action menu options --- index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 8703cf9..ca401a5 100644 --- a/index.js +++ b/index.js @@ -106,14 +106,17 @@ class ActionMenu { const ctx = this.canvas.getContext('2d') ctx.clearRect(0, 0, this.canvas.width, this.canvas.height) - const startIndex = Math.max(0, this.currentOptionIndex - 1) - const endIndex = Math.min(this.options.length, startIndex + 3) + const startIndex = this.currentOptionIndex - 1 + const endIndex = startIndex + 3 + + const len = this.options.length let y = 1 for (let i = startIndex; i < endIndex; i++) { - const maxLevel = this.options[i].length + const option = this.options[i === -1 ? len - 1 : i === len ? 0 : i] + const maxLevel = option.length const effectiveLevel = Math.min(maxLevel, this.uiLevel) - const text = this.options[i][effectiveLevel - 1] + const text = option[effectiveLevel - 1] const rectW = this.getRectW(effectiveLevel) if (effectiveLevel < maxLevel) { const ghostRectW = this.getRectW(maxLevel) -- cgit 1.3.0-6-gf8a5