X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftracker%2FToggleIcon.js;h=98ae93240d0656087f0dd17719c9af89a9b80da1;hb=90922f8595a8d4fd7780a0b137eed66eaf7d6c49;hp=3966506d2b2b815868b5553bbdce64287af992ff;hpb=c56ab0725b926af522285d96a22f998f4f7c0c40;p=alttp.git diff --git a/resources/js/components/tracker/ToggleIcon.js b/resources/js/components/tracker/ToggleIcon.js index 3966506..98ae932 100644 --- a/resources/js/components/tracker/ToggleIcon.js +++ b/resources/js/components/tracker/ToggleIcon.js @@ -8,6 +8,7 @@ import { getDungeonBoss, getDungeonRemainingItems, getDungeonPrize, + getGTBoss, hasDungeonBoss, hasDungeonPrize, highestActive, @@ -18,7 +19,7 @@ import { } from '../../helpers/tracker'; import { useTracker } from '../../hooks/tracker'; -const ToggleIcon = ({ controller, className, icons }) => { +const ToggleIcon = ({ controller, className, icons, svg }) => { const { setManualState, state } = useTracker(); const activeController = controller || ToggleIcon.nullController; const active = activeController.getActive(state, icons); @@ -32,6 +33,23 @@ const ToggleIcon = ({ controller, className, icons }) => { if (className) { classNames.push(className); } + if (svg) { + return { + activeController.handlePrimary(state, setManualState, icons); + e.preventDefault(); + e.stopPropagation(); + }} + onContextMenu={(e) => { + activeController.handleSecondary(state, setManualState, icons); + e.preventDefault(); + e.stopPropagation(); + }} + > + + ; + } return { @@ -97,6 +115,27 @@ const previousString = property => (state, setState, icons) => { setState(s => ({ ...s, [property]: previous })); }; +ToggleIcon.bottleController = ctrl => ({ + getActive: (state, icons) => state[ctrl] ? icons[state[ctrl] - 1] : null, + getDefault: () => 'bottle', + handlePrimary: (state, setState, icons) => { + if (state[ctrl] === 0) { + // skip over mushroom + setState(s => ({ ...s, [ctrl]: 2 })); + } else { + setState(increment(ctrl, icons.length)); + } + }, + handleSecondary: (state, setState, icons) => { + if (state[ctrl] === 2) { + // skip over mushroom + setState(s => ({ ...s, [ctrl]: 0 })); + } else { + setState(decrement(ctrl, icons.length)); + } + }, +}); + ToggleIcon.countController = max => ({ getActive: highestActive, getDefault: firstIcon, @@ -163,6 +202,13 @@ ToggleIcon.dungeonPrizeController = (dungeon) => ({ handleSecondary: previousString(`${dungeon.id}-prize`), }); +ToggleIcon.gtBossController = (which) => ({ + getActive: (state) => getGTBoss(state, which), + getDefault: (state) => getGTBoss(state, which), + handlePrimary: nextString(`gt-${which}-boss`), + handleSecondary: previousString(`gt-${which}-boss`), +}); + ToggleIcon.medallionController = { getActive: highestActive, getDefault: firstIcon, @@ -248,6 +294,7 @@ ToggleIcon.propTypes = { handleSecondary: PropTypes.func, }), icons: PropTypes.arrayOf(PropTypes.string), + svg: PropTypes.bool, }; export default ToggleIcon;