diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index eab67020..21e090e7 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -20,8 +20,19 @@ const addState = connect( return dispatch(actions.setInfo(c)); } + function clearItems() { + dispatch(actions.setCombiner([])); + dispatch(actions.setReclaiming(false)); + dispatch(actions.setItemEquip(null)); + dispatch(actions.setItemUnequip([])); + dispatch(actions.setVboxHighlight([])); + dispatch(actions.setVboxSelected([])); + return true; + } + return { setInfo, + clearItems, }; } ); @@ -30,6 +41,7 @@ function Instance(args) { const { instance, setInfo, + clearItems, nav, } = args; @@ -44,9 +56,14 @@ function Instance(args) { ); } + function instanceClick(e) { + e.stopPropagation(); + clearItems(); + } + const instanceClasses = `instance ${nav === 'constructs' ? 'constructs-visible' : ''}`; return ( -
setInfo(null)} > +
setInfo(null)} > diff --git a/client/src/components/instance.constructs.jsx b/client/src/components/instance.constructs.jsx index 5a027298..9b386f44 100644 --- a/client/src/components/instance.constructs.jsx +++ b/client/src/components/instance.constructs.jsx @@ -107,7 +107,7 @@ function Construct(props) { function skillClick(e) { if (!skill) return false; - setItemUnequip(skill.skill); + setItemUnequip([construct.id, skill.skill]); setActiveConstruct(construct); e.stopPropagation(); return true; @@ -117,7 +117,7 @@ function Construct(props) { if (!skill) return false; sendUnequip(construct.id, skill.skill); setActiveConstruct(null); - setItemUnequip(null); + setItemUnequip([]); e.stopPropagation(); e.preventDefault(); return true; @@ -156,14 +156,14 @@ function Construct(props) { function specClick(e) { e.stopPropagation(); - setItemUnequip(s); + setItemUnequip([construct.id, s]); setActiveConstruct(construct); } function specDblClick(e) { sendUnequip(construct.id, s); setActiveConstruct(null); - setItemUnequip(null); + setItemUnequip([]); e.stopPropagation(); e.preventDefault(); return true; diff --git a/client/src/components/instance.equip.jsx b/client/src/components/instance.equip.jsx index 1ecc1866..ef4ac2e3 100644 --- a/client/src/components/instance.equip.jsx +++ b/client/src/components/instance.equip.jsx @@ -74,7 +74,7 @@ function Equipment(props) { e.stopPropagation(); if (!itemUnequip) return false; if (!activeConstruct) return false; - setItemUnequip(null); + setItemUnequip([]); return sendUnequip(activeConstruct.id, itemUnequip); } diff --git a/client/src/components/nav.jsx b/client/src/components/nav.jsx index b9a057c4..b0c8fd7e 100644 --- a/client/src/components/nav.jsx +++ b/client/src/components/nav.jsx @@ -52,7 +52,7 @@ const addState = connect( dispatch(actions.setActiveConstruct(null)); dispatch(actions.setInfo(null)); dispatch(actions.setItemEquip(null)); - dispatch(actions.setItemUnequip(null)); + dispatch(actions.setItemUnequip([])); dispatch(actions.setVboxHighlight([])); return dispatch(actions.setNav(place)); diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index fdaa13c5..6d588238 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -17,6 +17,7 @@ const addState = connect( vboxHighlight, vboxSelected, itemInfo, + itemUnequip, } = state; function sendVboxDiscard() { @@ -35,6 +36,10 @@ const addState = connect( return ws.sendVboxReclaim(instance.id, i); } + function sendItemUnequip([constructId, item]) { + return ws.sendVboxUnequip(instance.id, constructId, item); + } + return { combiner, instance, @@ -47,6 +52,8 @@ const addState = connect( vboxHighlight, vboxSelected, itemInfo, + itemUnequip, + sendItemUnequip }; }, @@ -107,6 +114,8 @@ function Vbox(args) { setVboxSelected, setItemEquip, + itemUnequip, + sendItemUnequip, setReclaiming, setVboxHighlight, @@ -158,10 +167,14 @@ function Vbox(args) { return true; } + function clearVboxSelected() { + setVboxSelected([]); + } + function vboxBuySelected() { if (!vboxSelecting) return false; document.activeElement.blur(); - setVboxSelected([]); + clearVboxSelected(); sendVboxAccept(vboxSelected[0], vboxSelected[1]); return true; } @@ -171,7 +184,8 @@ function Vbox(args) { const selected = vboxSelected[0] === group && vboxSelected[1] === index; - function onClick() { + function onClick(e) { + e.stopPropagation(); // double clicked if (selected) { return vboxBuySelected(); @@ -267,8 +281,10 @@ function Vbox(args) { const reclaimClass = `vbox-btn reclaim ${reclaiming ? 'reclaiming' : ''}`; function inventoryBtn(v, i) { + const inventoryHighlight = vboxSelecting || itemUnequip.length; + if (!v && v !== 0) { - return ; + return ; } function onClick(e) { @@ -334,15 +350,18 @@ function Vbox(args) { } function inventoryElement() { - function inventoryClick() { + function inventoryClick(e) { + e.stopPropagation(); setReclaiming(false); - if (vboxSelecting) vboxBuySelected(); + if (vboxSelecting) return vboxBuySelected(); + if (itemUnequip.length) return sendItemUnequip(itemUnequip); return true; } return (
hoverInfo(e, 'inventory')}>

e.target.scrollIntoView(true)}>INVENTORY

diff --git a/client/src/events.jsx b/client/src/events.jsx index 122b4187..fab4ee32 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -149,7 +149,7 @@ function registerEvents(store) { store.dispatch(actions.setActiveConstruct(null)); store.dispatch(actions.setInfo(null)); store.dispatch(actions.setItemEquip(null)); - store.dispatch(actions.setItemUnequip(null)); + store.dispatch(actions.setItemUnequip([])); store.dispatch(actions.setVboxHighlight([])); } diff --git a/client/src/keyboard.jsx b/client/src/keyboard.jsx index 7f651e6c..1646a358 100644 --- a/client/src/keyboard.jsx +++ b/client/src/keyboard.jsx @@ -12,8 +12,9 @@ function setupKeys(store) { key('esc', () => store.dispatch(actions.setActiveConstruct(null))); key('esc', () => store.dispatch(actions.setInfo(null))); key('esc', () => store.dispatch(actions.setItemEquip(null))); - key('esc', () => store.dispatch(actions.setItemUnequip(null))); + key('esc', () => store.dispatch(actions.setItemUnequip([]))); key('esc', () => store.dispatch(actions.setVboxHighlight([]))); + key('esc', () => store.dispatch(actions.setVboxSelected([]))); key('esc', () => store.dispatch(actions.setMtxActive(null))); } diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index b7521e6c..22c45295 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -34,7 +34,7 @@ module.exports = { instanceList: createReducer([], 'SET_INSTANCE_LIST'), itemEquip: createReducer(null, 'SET_ITEM_EQUIP'), itemInfo: createReducer({ combos: [], items: [] }, 'SET_ITEM_INFO'), - itemUnequip: createReducer(null, 'SET_ITEM_UNEQUIP'), + itemUnequip: createReducer([], 'SET_ITEM_UNEQUIP'), mtxActive: createReducer(null, 'SET_MTX_ACTIVE'), nav: createReducer('team', 'SET_NAV'), showNav: createReducer(null, 'SET_SHOW_NAV'), @@ -45,8 +45,8 @@ module.exports = { skip: createReducer(false, 'SET_SKIP'), shop: createReducer(false, 'SET_SHOP'), team: createReducer([null, null, null], 'SET_SELECTED_CONSTRUCTS'), - vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'), + vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'), vboxSelected: createReducer([], 'SET_VBOX_SELECTED'), ws: createReducer(null, 'SET_WS'),