fix game btns

This commit is contained in:
ntr 2019-10-18 15:51:45 +11:00
parent daa1b6214b
commit aa5b76551f
3 changed files with 24 additions and 4 deletions

View File

@ -10,6 +10,7 @@ const addState = connect(
chatShow, chatShow,
chatWheel, chatWheel,
instance, instance,
game,
} = state; } = state;
function sendInstanceChat(instance, i) { function sendInstanceChat(instance, i) {
@ -18,6 +19,7 @@ const addState = connect(
return { return {
instance, instance,
game,
chatShow, chatShow,
chatWheel, chatWheel,
@ -39,6 +41,7 @@ const addState = connect(
function Chat(args) { function Chat(args) {
const { const {
instance, instance,
game,
chatShow, chatShow,
chatWheel, chatWheel,
@ -47,7 +50,7 @@ function Chat(args) {
} = args; } = args;
function onClick(i) { function onClick(i) {
sendInstanceChat(instance.id, i); sendInstanceChat(instance ? instance.id : game && game.id, i);
setChatShow(false); setChatShow(false);
return true; return true;
} }

View File

@ -8,6 +8,8 @@ const addState = connect(
const { const {
ws, ws,
game, game,
account,
chatShow,
animating, animating,
} = state; } = state;
@ -30,6 +32,8 @@ const addState = connect(
return { return {
game, game,
account,
chatShow,
sendAbandon, sendAbandon,
sendGameSkillClear, sendGameSkillClear,
sendReady, sendReady,
@ -60,6 +64,8 @@ function GameCtrlBtns(args) {
const { const {
game, game,
animating, animating,
account,
chatShow,
getInstanceState, getInstanceState,
sendGameSkillClear, sendGameSkillClear,

View File

@ -4,6 +4,7 @@ const { connect } = require('preact-redux');
const actions = require('../actions'); const actions = require('../actions');
const PlayerBox = require('./player.box'); const PlayerBox = require('./player.box');
const Chat = require('./chat');
const GameCtrlButtons = require('./game.ctrl.btns'); const GameCtrlButtons = require('./game.ctrl.btns');
const GameCtrlTopButtons = require('./game.ctrl.btns.top'); const GameCtrlTopButtons = require('./game.ctrl.btns.top');
@ -13,12 +14,16 @@ const addState = connect(
animating, animating,
game, game,
account, account,
chatShow,
instanceChat,
} = state; } = state;
return { return {
animating, animating,
game, game,
account, account,
chatShow,
instanceChat,
}; };
}, },
); );
@ -28,6 +33,8 @@ function Controls(args) {
animating, animating,
account, account,
game, game,
chatShow,
instanceChat,
} = args; } = args;
if (!game) return false; if (!game) return false;
@ -61,13 +68,17 @@ function Controls(args) {
</div> </div>
); );
const bottom = chatShow
? <Chat />
: <PlayerBox player={player} isPlayer={true} chat={instanceChat && instanceChat[player.id]} />;
return ( return (
<aside> <aside>
{timer} {timer}
<div class="controls instance-ctrl"> <div class="controls instance-ctrl">
<GameCtrlTopButtons /> <GameCtrlTopButtons />
<PlayerBox player={opponent}/> <PlayerBox player={opponent} chat={instanceChat && instanceChat[opponent.id]}/>
<PlayerBox player={player} isPlayer={true} /> {bottom}
<GameCtrlButtons /> <GameCtrlButtons />
</div> </div>
</aside> </aside>