From 3213c82ad2dd75e313d15423e25653596c7ce278 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sun, 24 Mar 2024 13:23:37 +0100 Subject: [PATCH] tracker medallion controler --- resources/js/components/tracker/Items.js | 18 ++++++++++ resources/js/components/tracker/ToggleIcon.js | 33 ++++++++++++++++++- resources/js/helpers/tracker.js | 8 +++++ resources/sass/tracker.scss | 11 +++++-- 4 files changed, 67 insertions(+), 3 deletions(-) diff --git a/resources/js/components/tracker/Items.js b/resources/js/components/tracker/Items.js index 712ee6c..2e83565 100644 --- a/resources/js/components/tracker/Items.js +++ b/resources/js/components/tracker/Items.js @@ -49,12 +49,30 @@ const Items = () => {
+ {state['mm-medallion'] === 'bombos' ? + MM + : null} + {state['tr-medallion'] === 'bombos' ? + TR + : null}
+ {state['mm-medallion'] === 'ether' ? + MM + : null} + {state['tr-medallion'] === 'ether' ? + TR + : null}
+ {state['mm-medallion'] === 'quake' ? + MM + : null} + {state['tr-medallion'] === 'quake' ? + TR + : null}
diff --git a/resources/js/components/tracker/ToggleIcon.js b/resources/js/components/tracker/ToggleIcon.js index 49375ef..3f6af96 100644 --- a/resources/js/components/tracker/ToggleIcon.js +++ b/resources/js/components/tracker/ToggleIcon.js @@ -163,7 +163,38 @@ ToggleIcon.medallionController = { getActive: highestActive, getDefault: firstIcon, handlePrimary: nextIcon, - handleSecondary: doNothing, + handleSecondary: (state, setState, icons) => { + const mm = state['mm-medallion']; + const tr = state['tr-medallion']; + const isMM = mm === icons[0]; + const isTR = tr === icons[0]; + console.log({ mm, isMM, tr, isTR }); + if (!isMM && !isTR) { + // empty: set as MM if mire is unset, else set as TR if TR is unset + if (!mm) { + setState(s => ({ ...s, 'mm-medallion': icons[0] })); + } else if (!tr) { + setState(s => ({ ...s, 'tr-medallion': icons[0] })); + } + } else if (isMM && !isTR) { + // MM: if TR is free, switch to TR, otherwise remove MM + if (!tr) { + setState(s => ({ ...s, 'mm-medallion': null, 'tr-medallion': icons[0] })); + } else { + setState(s => ({ ...s, 'mm-medallion': null })); + } + } else if (!isMM && isTR) { + // TR: if MM is free, switch to both, otherwise remove TR + if (!mm) { + setState(s => ({ ...s, 'mm-medallion': icons[0] })); + } else { + setState(s => ({ ...s, 'tr-medallion': null })); + } + } else { + // both: remove both + setState(s => ({ ...s, 'mm-medallion': null, 'tr-medallion': null })); + } + }, }; ToggleIcon.modulusController = ctrl => ({ diff --git a/resources/js/helpers/tracker.js b/resources/js/helpers/tracker.js index 707e3f7..f2be243 100644 --- a/resources/js/helpers/tracker.js +++ b/resources/js/helpers/tracker.js @@ -1620,6 +1620,14 @@ export const makeEmptyState = () => { state[`${dungeon.id}-prize-acquired`] = false; } }); + OVERWORLD_LOCATIONS.forEach(location => { + state[location.id] = false; + }); + UNDERWORLD_LOCATIONS.forEach(location => { + state[location.id] = false; + }); + state['mm-medallion'] = null; + state['tr-medallion'] = null; return state; }; diff --git a/resources/sass/tracker.scss b/resources/sass/tracker.scss index 06f1577..2e75301 100644 --- a/resources/sass/tracker.scss +++ b/resources/sass/tracker.scss @@ -1,5 +1,6 @@ .tracker { - .count-display { + .count-display, + .med-display { background: black; font-weight: bold; text-align: center; @@ -104,12 +105,18 @@ .right { right: 0; } - .count-display { + .count-display, + .med-display { pointer-events: none; &.is-zero { display: none; } } + .med-display { + height: 30%; + font-size: 80%; + line-height: 1; + } } .toggle-icon { &.inactive { -- 2.39.2