From 183a354ce48774d24a1c52cd9cdafa030685325c Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 12 Aug 2018 16:50:20 -0300 Subject: Don't make <=3-item menus render like spinners --- index.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index 6e339d3..f493585 100644 --- a/index.js +++ b/index.js @@ -293,15 +293,20 @@ class BaseBattleMenu { return } - const startIndex = this.currentOptionIndex - 1 - const endIndex = startIndex + 3 - - const len = this.options.length - this.drawY = 1 - for (let i = startIndex; i < endIndex; i++) { - const option = this.options[i === -1 ? len - 1 : i === len ? 0 : i] - this.drawOption(option, ctx) + + if (this.options.length > 3) { + const startIndex = this.currentOptionIndex - 1 + const endIndex = startIndex + 3 + const len = this.options.length + for (let i = startIndex; i < endIndex; i++) { + const option = this.options[i === -1 ? len - 1 : i === len ? 0 : i] + this.drawOption(option, ctx) + } + } else { + for (const option of this.options) { + this.drawOption(option, ctx) + } } } @@ -867,6 +872,10 @@ function drawLoop() { } canvas.addEventListener('keypress', evt => { + if (battle.gameState !== 'battle') { + return + } + const { targetTypeMenu, actionMenu, targetMenu, currentMenu } = battle const { atbBar } = battle.playerCharacter if (!battle.playerCharacter.isExecutingChain && battle.currentMenu) { -- cgit 1.3.0-6-gf8a5