diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-09 18:59:47 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-09 18:59:47 -0300 |
commit | bce822d92c4b0ea7f49f7e18a858e16e85d79b2c (patch) | |
tree | 9d9654d058d3bb5ad5f6376e81eb10c9de04ca8c | |
parent | 1aa951fc2b4970674510a18c2e0f1e92378dc446 (diff) |
Wrap action menu options
-rw-r--r-- | index.js | 11 |
1 files 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) |