Click item -> click cryp for equip

This commit is contained in:
Mashy 2019-05-14 00:15:35 +10:00
parent 20fd2376e8
commit 76a3ddc08e
3 changed files with 36 additions and 26 deletions

View File

@ -321,6 +321,18 @@
justify-content: center; justify-content: center;
} }
.instance-equip .items {
display: flex;
justify-content: center;
}
.instance-equip .label {
display: flex;
justify-content: center;
font-size: 20pt;
padding: 15px;
}
.instance-equip .skills { .instance-equip .skills {
display: flex; display: flex;
min-height: 100px; min-height: 100px;
@ -341,26 +353,12 @@
} }
.instance-equip .specs { .instance-equip .specs {
display: flex; display: flex;
padding-left: 50px; padding-left: 50px;
flex-direction: column; flex-direction: column;
} }
.instance-equip .items {
display: flex;
justify-content: center;
}
.instance-equip .label {
display: flex;
justify-content: center;
font-size: 20pt;
padding: 15px;
}
.instance-equip .specs figure { .instance-equip .specs figure {
flex: 1; flex: 1;
border: 0; border: 0;

View File

@ -8,7 +8,7 @@ const actions = require('../actions');
const addState = connect( const addState = connect(
function receiveState(state) { function receiveState(state) {
const { ws, instance, player, account, vboxHidden, vboxInfo } = state; const { ws, instance, player, account, vboxHidden, vboxInfo, activeVar } = state;
function sendInstanceReady() { function sendInstanceReady() {
return ws.sendInstanceReady(instance.id); return ws.sendInstanceReady(instance.id);
@ -18,7 +18,7 @@ const addState = connect(
return ws.sendVboxApply(instance.id, crypId, i); return ws.sendVboxApply(instance.id, crypId, i);
} }
return { instance, player, account, sendInstanceReady, sendVboxApply, vboxHidden, vboxInfo }; return { instance, player, account, sendInstanceReady, sendVboxApply, vboxHidden, vboxInfo, activeVar };
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
@ -49,11 +49,13 @@ const addState = connect(
function Cryp(props) { function Cryp(props) {
const { const {
activeVar,
cryp, cryp,
sendVboxApply,
setInfo, setInfo,
setActiveCryp, setActiveCryp,
vboxInfo,
setVboxHighlight, setVboxHighlight,
vboxInfo,
} = props; } = props;
function setHighlight(type) { function setHighlight(type) {
@ -69,6 +71,7 @@ function Cryp(props) {
: (<span>&nbsp;</span>); : (<span>&nbsp;</span>);
function skillClick(e) { function skillClick(e) {
if (!skill && activeVar !== null) return sendVboxApply(cryp.id, activeVar);
if (!skill) setHighlight('skill'); if (!skill) setHighlight('skill');
else setInfo('skill', { skill: skill.skill, cryp }); else setInfo('skill', { skill: skill.skill, cryp });
e.stopPropagation(); e.stopPropagation();
@ -84,6 +87,7 @@ function Cryp(props) {
function onClick(e) { function onClick(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
if (activeVar !== null) return sendVboxApply(cryp.id, activeVar);
return setActiveCryp(cryp); return setActiveCryp(cryp);
} }
@ -92,8 +96,9 @@ function Cryp(props) {
function blankSpecClick(e) { function blankSpecClick(e) {
e.stopPropagation(); e.stopPropagation();
setActiveCryp(cryp); if (activeVar !== null) return sendVboxApply(cryp.id, activeVar);
setHighlight('spec'); setHighlight('spec');
return setActiveCryp(cryp);
} }
if (!s) { if (!s) {
@ -193,9 +198,9 @@ function Cryp(props) {
function InstanceCryps(props) { function InstanceCryps(props) {
const { const {
activeVar,
player, player,
instance, instance,
// clearInfo, // clearInfo,
setInfo, setInfo,
setActiveCryp, setActiveCryp,
@ -210,7 +215,7 @@ function InstanceCryps(props) {
if (instance.phase === 'Lobby') return false; if (instance.phase === 'Lobby') return false;
const cryps = player.cryps.map((c, i) => Cryp({ const cryps = player.cryps.map((c, i) => Cryp({
cryp: c, sendVboxApply, setInfo, setActiveCryp, vboxInfo, setVboxHighlight, activeVar, cryp: c, sendVboxApply, setInfo, setActiveCryp, vboxInfo, setVboxHighlight,
})); }));
const classes = `instance-cryp-list ${vboxHidden ? '' : 'hidden'}`; const classes = `instance-cryp-list ${vboxHidden ? '' : 'hidden'}`;

View File

@ -21,7 +21,11 @@ const addState = connect(
return dispatch(actions.setInfo([])); return dispatch(actions.setInfo([]));
} }
return { setInfo, clearInfo }; function setActiveVar(v) {
return dispatch(actions.setActiveVar(v));
}
return { setInfo, setActiveVar, clearInfo };
} }
); );
@ -29,8 +33,9 @@ const addState = connect(
function Equipment(props) { function Equipment(props) {
const { const {
player, player,
setInfo,
vboxInfo, vboxInfo,
setInfo,
setActiveVar,
} = props; } = props;
const { vbox } = player; const { vbox } = player;
@ -38,7 +43,7 @@ function Equipment(props) {
function boundClick(e, i) { function boundClick(e, i) {
const value = vbox.bound[i]; const value = vbox.bound[i];
setInfo('item', value); setInfo('item', value);
setActiveVar(i);
return false; return false;
} }
@ -68,13 +73,15 @@ function Equipment(props) {
); );
} return false; } return false;
}); });
// const specLabel = specs.every(i => i === false) ? '' : 'Specs';
const skillLabel = skills.every(i => i === false) ? '' : 'Skills';
const specLabel = specs.every(i => i === false) ? '' : 'Specs';
return ( return (
<div className="instance-equip" > <div className="instance-equip" >
<div className="skills"> <div className="skills">
<div className="label"> <div className="label">
Skills {skillLabel}
</div> </div>
<div className ="items"> <div className ="items">
{skills} {skills}
@ -82,7 +89,7 @@ function Equipment(props) {
</div> </div>
<div className="specs"> <div className="specs">
<div className="label"> <div className="label">
Specs {specLabel}
</div> </div>
<div className ="items"> <div className ="items">
{specs} {specs}