vbox actions
This commit is contained in:
parent
3bb0dcca3e
commit
16c83a529b
@ -20,8 +20,19 @@ const addState = connect(
|
|||||||
return dispatch(actions.setInfo(c));
|
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 {
|
return {
|
||||||
setInfo,
|
setInfo,
|
||||||
|
clearItems,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -30,6 +41,7 @@ function Instance(args) {
|
|||||||
const {
|
const {
|
||||||
instance,
|
instance,
|
||||||
setInfo,
|
setInfo,
|
||||||
|
clearItems,
|
||||||
|
|
||||||
nav,
|
nav,
|
||||||
} = args;
|
} = args;
|
||||||
@ -44,9 +56,14 @@ function Instance(args) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function instanceClick(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
clearItems();
|
||||||
|
}
|
||||||
|
|
||||||
const instanceClasses = `instance ${nav === 'constructs' ? 'constructs-visible' : ''}`;
|
const instanceClasses = `instance ${nav === 'constructs' ? 'constructs-visible' : ''}`;
|
||||||
return (
|
return (
|
||||||
<main class={instanceClasses} onMouseOver={() => setInfo(null)} >
|
<main class={instanceClasses} onClick={instanceClick} onMouseOver={() => setInfo(null)} >
|
||||||
<Vbox />
|
<Vbox />
|
||||||
<InfoContainer />
|
<InfoContainer />
|
||||||
<InstanceConstructsContainer />
|
<InstanceConstructsContainer />
|
||||||
|
|||||||
@ -107,7 +107,7 @@ function Construct(props) {
|
|||||||
|
|
||||||
function skillClick(e) {
|
function skillClick(e) {
|
||||||
if (!skill) return false;
|
if (!skill) return false;
|
||||||
setItemUnequip(skill.skill);
|
setItemUnequip([construct.id, skill.skill]);
|
||||||
setActiveConstruct(construct);
|
setActiveConstruct(construct);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
return true;
|
return true;
|
||||||
@ -117,7 +117,7 @@ function Construct(props) {
|
|||||||
if (!skill) return false;
|
if (!skill) return false;
|
||||||
sendUnequip(construct.id, skill.skill);
|
sendUnequip(construct.id, skill.skill);
|
||||||
setActiveConstruct(null);
|
setActiveConstruct(null);
|
||||||
setItemUnequip(null);
|
setItemUnequip([]);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
@ -156,14 +156,14 @@ function Construct(props) {
|
|||||||
|
|
||||||
function specClick(e) {
|
function specClick(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setItemUnequip(s);
|
setItemUnequip([construct.id, s]);
|
||||||
setActiveConstruct(construct);
|
setActiveConstruct(construct);
|
||||||
}
|
}
|
||||||
|
|
||||||
function specDblClick(e) {
|
function specDblClick(e) {
|
||||||
sendUnequip(construct.id, s);
|
sendUnequip(construct.id, s);
|
||||||
setActiveConstruct(null);
|
setActiveConstruct(null);
|
||||||
setItemUnequip(null);
|
setItemUnequip([]);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ function Equipment(props) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!itemUnequip) return false;
|
if (!itemUnequip) return false;
|
||||||
if (!activeConstruct) return false;
|
if (!activeConstruct) return false;
|
||||||
setItemUnequip(null);
|
setItemUnequip([]);
|
||||||
return sendUnequip(activeConstruct.id, itemUnequip);
|
return sendUnequip(activeConstruct.id, itemUnequip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ const addState = connect(
|
|||||||
dispatch(actions.setActiveConstruct(null));
|
dispatch(actions.setActiveConstruct(null));
|
||||||
dispatch(actions.setInfo(null));
|
dispatch(actions.setInfo(null));
|
||||||
dispatch(actions.setItemEquip(null));
|
dispatch(actions.setItemEquip(null));
|
||||||
dispatch(actions.setItemUnequip(null));
|
dispatch(actions.setItemUnequip([]));
|
||||||
dispatch(actions.setVboxHighlight([]));
|
dispatch(actions.setVboxHighlight([]));
|
||||||
|
|
||||||
return dispatch(actions.setNav(place));
|
return dispatch(actions.setNav(place));
|
||||||
|
|||||||
@ -17,6 +17,7 @@ const addState = connect(
|
|||||||
vboxHighlight,
|
vboxHighlight,
|
||||||
vboxSelected,
|
vboxSelected,
|
||||||
itemInfo,
|
itemInfo,
|
||||||
|
itemUnequip,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
function sendVboxDiscard() {
|
function sendVboxDiscard() {
|
||||||
@ -35,6 +36,10 @@ const addState = connect(
|
|||||||
return ws.sendVboxReclaim(instance.id, i);
|
return ws.sendVboxReclaim(instance.id, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendItemUnequip([constructId, item]) {
|
||||||
|
return ws.sendVboxUnequip(instance.id, constructId, item);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
combiner,
|
combiner,
|
||||||
instance,
|
instance,
|
||||||
@ -47,6 +52,8 @@ const addState = connect(
|
|||||||
vboxHighlight,
|
vboxHighlight,
|
||||||
vboxSelected,
|
vboxSelected,
|
||||||
itemInfo,
|
itemInfo,
|
||||||
|
itemUnequip,
|
||||||
|
sendItemUnequip
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -107,6 +114,8 @@ function Vbox(args) {
|
|||||||
setVboxSelected,
|
setVboxSelected,
|
||||||
|
|
||||||
setItemEquip,
|
setItemEquip,
|
||||||
|
itemUnequip,
|
||||||
|
sendItemUnequip,
|
||||||
|
|
||||||
setReclaiming,
|
setReclaiming,
|
||||||
setVboxHighlight,
|
setVboxHighlight,
|
||||||
@ -158,10 +167,14 @@ function Vbox(args) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearVboxSelected() {
|
||||||
|
setVboxSelected([]);
|
||||||
|
}
|
||||||
|
|
||||||
function vboxBuySelected() {
|
function vboxBuySelected() {
|
||||||
if (!vboxSelecting) return false;
|
if (!vboxSelecting) return false;
|
||||||
document.activeElement.blur();
|
document.activeElement.blur();
|
||||||
setVboxSelected([]);
|
clearVboxSelected();
|
||||||
sendVboxAccept(vboxSelected[0], vboxSelected[1]);
|
sendVboxAccept(vboxSelected[0], vboxSelected[1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -171,7 +184,8 @@ function Vbox(args) {
|
|||||||
|
|
||||||
const selected = vboxSelected[0] === group && vboxSelected[1] === index;
|
const selected = vboxSelected[0] === group && vboxSelected[1] === index;
|
||||||
|
|
||||||
function onClick() {
|
function onClick(e) {
|
||||||
|
e.stopPropagation();
|
||||||
// double clicked
|
// double clicked
|
||||||
if (selected) {
|
if (selected) {
|
||||||
return vboxBuySelected();
|
return vboxBuySelected();
|
||||||
@ -267,8 +281,10 @@ function Vbox(args) {
|
|||||||
const reclaimClass = `vbox-btn reclaim ${reclaiming ? 'reclaiming' : ''}`;
|
const reclaimClass = `vbox-btn reclaim ${reclaiming ? 'reclaiming' : ''}`;
|
||||||
|
|
||||||
function inventoryBtn(v, i) {
|
function inventoryBtn(v, i) {
|
||||||
|
const inventoryHighlight = vboxSelecting || itemUnequip.length;
|
||||||
|
|
||||||
if (!v && v !== 0) {
|
if (!v && v !== 0) {
|
||||||
return <button disabled={!vboxSelecting} class={vboxSelecting ? 'receiving' : 'empty'} > </button>;
|
return <button disabled={!inventoryHighlight} class={inventoryHighlight ? 'receiving' : 'empty'} > </button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick(e) {
|
function onClick(e) {
|
||||||
@ -334,15 +350,18 @@ function Vbox(args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function inventoryElement() {
|
function inventoryElement() {
|
||||||
function inventoryClick() {
|
function inventoryClick(e) {
|
||||||
|
e.stopPropagation();
|
||||||
setReclaiming(false);
|
setReclaiming(false);
|
||||||
if (vboxSelecting) vboxBuySelected();
|
if (vboxSelecting) return vboxBuySelected();
|
||||||
|
if (itemUnequip.length) return sendItemUnequip(itemUnequip);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class='vbox-section'
|
<div class='vbox-section'
|
||||||
onClick={inventoryClick}
|
onClick={inventoryClick}
|
||||||
|
style={vboxSelecting ? { cursor: 'pointer' } : null}
|
||||||
onMouseOver={e => hoverInfo(e, 'inventory')}>
|
onMouseOver={e => hoverInfo(e, 'inventory')}>
|
||||||
<div class="vbox-hdr">
|
<div class="vbox-hdr">
|
||||||
<h3 onTouchStart={e => e.target.scrollIntoView(true)}>INVENTORY</h3>
|
<h3 onTouchStart={e => e.target.scrollIntoView(true)}>INVENTORY</h3>
|
||||||
|
|||||||
@ -149,7 +149,7 @@ function registerEvents(store) {
|
|||||||
store.dispatch(actions.setActiveConstruct(null));
|
store.dispatch(actions.setActiveConstruct(null));
|
||||||
store.dispatch(actions.setInfo(null));
|
store.dispatch(actions.setInfo(null));
|
||||||
store.dispatch(actions.setItemEquip(null));
|
store.dispatch(actions.setItemEquip(null));
|
||||||
store.dispatch(actions.setItemUnequip(null));
|
store.dispatch(actions.setItemUnequip([]));
|
||||||
store.dispatch(actions.setVboxHighlight([]));
|
store.dispatch(actions.setVboxHighlight([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,9 @@ function setupKeys(store) {
|
|||||||
key('esc', () => store.dispatch(actions.setActiveConstruct(null)));
|
key('esc', () => store.dispatch(actions.setActiveConstruct(null)));
|
||||||
key('esc', () => store.dispatch(actions.setInfo(null)));
|
key('esc', () => store.dispatch(actions.setInfo(null)));
|
||||||
key('esc', () => store.dispatch(actions.setItemEquip(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.setVboxHighlight([])));
|
||||||
|
key('esc', () => store.dispatch(actions.setVboxSelected([])));
|
||||||
key('esc', () => store.dispatch(actions.setMtxActive(null)));
|
key('esc', () => store.dispatch(actions.setMtxActive(null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ module.exports = {
|
|||||||
instanceList: createReducer([], 'SET_INSTANCE_LIST'),
|
instanceList: createReducer([], 'SET_INSTANCE_LIST'),
|
||||||
itemEquip: createReducer(null, 'SET_ITEM_EQUIP'),
|
itemEquip: createReducer(null, 'SET_ITEM_EQUIP'),
|
||||||
itemInfo: createReducer({ combos: [], items: [] }, 'SET_ITEM_INFO'),
|
itemInfo: createReducer({ combos: [], items: [] }, 'SET_ITEM_INFO'),
|
||||||
itemUnequip: createReducer(null, 'SET_ITEM_UNEQUIP'),
|
itemUnequip: createReducer([], 'SET_ITEM_UNEQUIP'),
|
||||||
mtxActive: createReducer(null, 'SET_MTX_ACTIVE'),
|
mtxActive: createReducer(null, 'SET_MTX_ACTIVE'),
|
||||||
nav: createReducer('team', 'SET_NAV'),
|
nav: createReducer('team', 'SET_NAV'),
|
||||||
showNav: createReducer(null, 'SET_SHOW_NAV'),
|
showNav: createReducer(null, 'SET_SHOW_NAV'),
|
||||||
@ -45,8 +45,8 @@ module.exports = {
|
|||||||
skip: createReducer(false, 'SET_SKIP'),
|
skip: createReducer(false, 'SET_SKIP'),
|
||||||
shop: createReducer(false, 'SET_SHOP'),
|
shop: createReducer(false, 'SET_SHOP'),
|
||||||
team: createReducer([null, null, null], 'SET_SELECTED_CONSTRUCTS'),
|
team: createReducer([null, null, null], 'SET_SELECTED_CONSTRUCTS'),
|
||||||
vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'),
|
|
||||||
|
|
||||||
|
vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'),
|
||||||
vboxSelected: createReducer([], 'SET_VBOX_SELECTED'),
|
vboxSelected: createReducer([], 'SET_VBOX_SELECTED'),
|
||||||
|
|
||||||
ws: createReducer(null, 'SET_WS'),
|
ws: createReducer(null, 'SET_WS'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user