From 4d28d2fbfda355d8d2dca433bf25cb80ce737865 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 19 Feb 2015 15:15:39 -0500 Subject: [PATCH] Added battle fight menu Doesn't do anything except read in from from moves and show that list. --- modules/BattleMovr/BattleMovr.js | 80 +++++++++++++++++++++----------- modules/MenuGraphr/MenuGraphr.js | 2 +- settings/battles.js | 17 +++---- settings/menus.js | 17 ++++++- 4 files changed, 75 insertions(+), 41 deletions(-) diff --git a/modules/BattleMovr/BattleMovr.js b/modules/BattleMovr/BattleMovr.js index e82eddc0..a23eb164 100644 --- a/modules/BattleMovr/BattleMovr.js +++ b/modules/BattleMovr/BattleMovr.js @@ -5,7 +5,14 @@ FSP.BattleMover.startBattle({ }, "playerActors": [ { - "title": "Mew" + "title": "Squirtle", + "moves": [{ + "title": "TACKLE" + }, { + "title": "TAIL WHIP" + }, { + "title": "BUBBLE" + }] } ] }); @@ -31,7 +38,7 @@ function BattleMovr(settings) { battleMenuName, - battleMenuOptions, + battleOptionNames, battleInfo, @@ -57,9 +64,9 @@ function BattleMovr(settings) { throw new Error("No battleMenuName given to BattleMovr."); } - battleMenuOptions = settings.battleMenuOptions; - if (typeof battleMenuOptions === "undefined") { - throw new Error("No battleMenuOptions given to BattleMovr."); + battleOptionNames = settings.battleOptionNames; + if (typeof battleOptionNames === "undefined") { + throw new Error("No battleOptionNames given to BattleMovr."); } animations = settings.animations; @@ -176,33 +183,20 @@ function BattleMovr(settings) { function showPlayerMenu() { EightBitter.MenuGrapher.createMenu("BattleOptions"); EightBitter.MenuGrapher.addMenuList("BattleOptions", { - "options": battleMenuOptions + "options": [{ + "text": battleOptionNames["moves"], + "callback": self.openMovesMenu + }, { + "text": battleOptionNames["items"] + }, { + "text": battleOptionNames["actors"] + }, { + "text": battleOptionNames["exit"] + }] }); EightBitter.MenuGrapher.setActiveMenu("BattleOptions"); } - ///** - // * - // */ - //self.showBattleMenu = function () { - // EightBitter.MenuGrapher.createMenu("GeneralText"); - - // EightBitter.MenuGrapher.createMenu("BattleDisplayOpponent"); - // EightBitter.MenuGrapher.addMenuDialog( - // "BattleDisplayOpponent", - // actors.opponent.displayTitle - // ); - - // EightBitter.MenuGrapher.createMenu("BattleOptions"); - // EightBitter.MenuGrapher.addMenuList("BattleOptions", { - // "options": battleMenuOptions - // }); - // EightBitter.MenuGrapher.setActiveMenu("BattleOptions"); - - // // Used by MenuGrapher.addMenuDialog - // return false; - //}; - /** * */ @@ -230,6 +224,36 @@ function BattleMovr(settings) { ); }; + /** + * + */ + self.openMovesMenu = function () { + var actorMoves = battleInfo.playerActors[0].moves, + moveOptions = [], + move, i; + + for (i = 0; i < actorMoves.length; i += 1) { + move = actorMoves[i]; + moveOptions[i] = { + "text": move.title, + "remaining": move.remaining, + "callback": console.log.bind(console, "Hi!") + }; + } + + for (i = actorMoves.length; i < 4; i += 1) { + moveOptions[i] = { + "text": "-" + }; + } + + EightBitter.MenuGrapher.createMenu("BattleFightList"); + EightBitter.MenuGrapher.addMenuList("BattleFightList", { + "options": moveOptions + }); + EightBitter.MenuGrapher.setActiveMenu("BattleFightList"); + }; + self.reset(settings || {}); } \ No newline at end of file diff --git a/modules/MenuGraphr/MenuGraphr.js b/modules/MenuGraphr/MenuGraphr.js index 17ec36e2..705db60d 100644 --- a/modules/MenuGraphr/MenuGraphr.js +++ b/modules/MenuGraphr/MenuGraphr.js @@ -543,7 +543,7 @@ function MenuGraphr(settings) { top = menu.top + menu.textYOffset * EightBitter.unitsize, textProperties = EightBitter.ObjectMaker.getPropertiesOf("Text"), textWidth = (menu.textWidth || textProperties.width) * EightBitter.unitsize, - textHeight = (menu.textWidth || textProperties.height) * EightBitter.unitsize, + textHeight = (menu.textHeight || textProperties.height) * EightBitter.unitsize, textPaddingY = (menu.textPaddingY || textProperties.paddingY) * EightBitter.unitsize, arrowXOffset = (menu.arrowXOffset || 0) * EightBitter.unitsize, arrowYOffset = (menu.arrowYOffset || 0) * EightBitter.unitsize, diff --git a/settings/battles.js b/settings/battles.js index 5a02f369..8d1170bf 100644 --- a/settings/battles.js +++ b/settings/battles.js @@ -1,16 +1,11 @@ FullScreenPokemon.prototype.settings.battles = { "battleMenuName": "Battle", - "battleMenuOptions": [ - { - "text": "FIGHT", - }, { - "text": "ITEM", - }, { - "text": ["Poke", "Mon"] - }, { - "text": "RUN", - } - ], + "battleOptionNames": { + "moves": "FIGHT", + "items": "ITEM", + "actors": ["Poke", "Mon"], + "exit": "RUN" + }, "defaults": { "textStart": ["A wild ", " appeared!"], "textEntry": ["Go! ", "!"] diff --git a/settings/menus.js b/settings/menus.js index 3173f0ee..a0c9cc4f 100644 --- a/settings/menus.js +++ b/settings/menus.js @@ -656,6 +656,21 @@ FullScreenPokemon.prototype.settings.menus = { "textSpeed": 0, "textXOffset": 1, "textYOffset": -.5 - } + }, + "BattleFightList": { + "size": { + "width": 64, + }, + "position": { + "horizontal": "right", + "vertical": "stretch" + }, + "container": "GeneralText", + "backMenu": "BattleOptions", + "textXOffset": 8, + "textYOffset": 3.5, + "textPaddingY": 4, + "arrowXOffset": 1 + }, } }; \ No newline at end of file