Skip to content

Commit 9289091

Browse files
committed
[bugfix] Block shortcuts when buttons are disabled
1 parent 237e179 commit 9289091

File tree

2 files changed

+72
-25
lines changed

2 files changed

+72
-25
lines changed

src/components/control/ControlGeneral.vue

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<span v-b-tooltip.hover
44
:title="'Immediately stop all robots (' + Object.keys(keymapHalt)[0] + ')'">
55
<b-button v-hotkey="keymapHalt"
6+
ref="btnHalt"
67
v-on:click="send('halt')"
78
v-bind:disabled="halted">
89
Halt
@@ -11,6 +12,7 @@
1112
<span v-b-tooltip.hover
1213
:title="'Robots have to keep distance to the ball (' + Object.keys(keymapStop)[0] + ')'">
1314
<b-button v-hotkey="keymapStop"
15+
ref="btnStop"
1416
v-on:click="send('stop')"
1517
v-bind:disabled="stopped || !stopAllowed">
1618
Stop
@@ -19,6 +21,7 @@
1921
<span v-b-tooltip.hover
2022
:title="'Restart the game in draw situations (' + Object.keys(keymapForceStart)[0] + ')'">
2123
<b-button v-hotkey="keymapForceStart"
24+
ref="btnForceStart"
2225
v-on:click="send('forceStart')"
2326
v-bind:disabled="!stopped || !forceStartAllowed">
2427
Force Start
@@ -27,6 +30,7 @@
2730
<span v-b-tooltip.hover
2831
:title="'Continue game after a prepare state (' + Object.keys(keymapNormalStart)[0] + ')'">
2932
<b-button v-hotkey="keymapNormalStart"
33+
ref="btnNormalStart"
3034
v-on:click="send('normalStart')"
3135
v-bind:disabled="!prepareSth || !normalStartAllowed">
3236
Normal Start
@@ -35,6 +39,7 @@
3539
<span v-b-tooltip.hover
3640
:title="'Continue based on last game event (' + Object.keys(keymapContinue)[0] + ')'">
3741
<b-button v-hotkey="keymapContinue"
42+
ref="btnContinue"
3843
v-on:click="triggerContinue"
3944
v-bind:disabled="!gameEventPresent">
4045
Continue
@@ -58,19 +63,49 @@
5863
},
5964
computed: {
6065
keymapHalt() {
61-
return {'numpad .': () => this.send('halt')}
66+
return {
67+
'esc': () => {
68+
if (!this.$refs.btnHalt.disabled) {
69+
this.send('halt')
70+
}
71+
}
72+
}
6273
},
6374
keymapStop() {
64-
return {'numpad 0': () => this.send('stop')}
75+
return {
76+
'numpad 0': () => {
77+
if (!this.$refs.btnStop.disabled) {
78+
this.send('stop')
79+
}
80+
}
81+
}
6582
},
6683
keymapForceStart() {
67-
return {'numpad 5': () => this.send('forceStart')}
84+
return {
85+
'numpad 5': () => {
86+
if (!this.$refs.btnForceStart.disabled) {
87+
this.send('forceStart')
88+
}
89+
}
90+
}
6891
},
6992
keymapNormalStart() {
70-
return {'numpad -': () => this.send('normalStart')}
93+
return {
94+
'numpad -': () => {
95+
if (!this.$refs.btnNormalStart.disabled) {
96+
this.send('normalStart')
97+
}
98+
}
99+
}
71100
},
72101
keymapContinue() {
73-
return {'numpad +': () => this.triggerContinue()}
102+
return {
103+
'numpad +': () => {
104+
if (!this.$refs.btnContinue.disabled) {
105+
this.triggerContinue()
106+
}
107+
}
108+
}
74109
},
75110
state() {
76111
return this.$store.state.refBoxState

src/components/control/ControlTeam.vue

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,33 @@
33
<span v-b-tooltip.hover
44
:title="'Prepare for a kickoff (' + Object.keys(keymapKickoff)[0] + ')'">
55
<b-button v-hotkey="keymapKickoff"
6-
v-on:click="send('kickoff')"
6+
ref="btnKickoff"
7+
v-on:click="sendKickoff"
78
v-bind:disabled="halted || running || preparing">
89
Kickoff
910
</b-button>
1011
</span>
1112
<span v-b-tooltip.hover
1213
:title="'Perform direct kick (corner and goal kicks) (' + Object.keys(keymapDirect)[0] + ')'">
1314
<b-button v-hotkey="keymapDirect"
14-
v-on:click="send('direct')"
15+
ref="btnDirect"
16+
v-on:click="sendDirect"
1517
v-bind:disabled="halted || running || preparing || !nonPausedStage">
1618
Direct
1719
</b-button>
1820
</span>
1921
<span v-b-tooltip.hover
2022
:title="'Perform indirect kick (throw-in) (' + Object.keys(keymapIndirect)[0] + ')'">
2123
<b-button v-hotkey="keymapIndirect"
22-
v-on:click="send('indirect')"
24+
ref="btnIndirect"
25+
v-on:click="sendIndirect"
2326
v-bind:disabled="halted || running || preparing || !nonPausedStage">
2427
Indirect
2528
</b-button>
2629
</span>
2730
<span v-b-tooltip.hover
2831
title="Prepare for a penalty kick">
29-
<b-button v-on:click="send('penalty')"
32+
<b-button v-on:click="sendPenalty"
3033
v-bind:disabled="halted || running || preparing || !nonPausedStage">
3134
Penalty
3235
</b-button>
@@ -38,8 +41,7 @@
3841
<b-button v-on:click="addGoal">
3942
Goal
4043
</b-button>
41-
<b-button v-on:click="addYellowCard"
42-
v-hotkey="keymapYellowCard">
44+
<b-button v-on:click="addYellowCard">
4345
Yellow Card
4446
</b-button>
4547

@@ -77,38 +79,48 @@
7779
addGoal: function () {
7880
this.$socket.sendObj({'modify': {'forTeam': this.teamColor, 'goals': this.teamState.goals + 1}})
7981
},
82+
sendKickoff() {
83+
if (!this.$refs.btnKickoff.disabled) {
84+
this.send('kickoff')
85+
}
86+
},
87+
sendDirect() {
88+
if (!this.$refs.btnDirect.disabled) {
89+
this.send('direct')
90+
}
91+
},
92+
sendIndirect() {
93+
if (!this.$refs.btnIndirect.disabled) {
94+
this.send('indirect')
95+
}
96+
},
97+
sendPenalty() {
98+
this.send('penalty')
99+
},
80100
},
81101
computed: {
82102
teamState: function () {
83103
return this.$store.state.refBoxState.teamState[this.teamColor]
84104
},
85105
keymapKickoff() {
86106
if (this.teamColor === 'Yellow') {
87-
return {'numpad 1': () => this.send('kickoff')};
107+
return {'numpad 1': this.sendKickoff};
88108
} else if (this.teamColor === 'Blue') {
89-
return {'numpad 3': () => this.send('kickoff')};
109+
return {'numpad 3': this.sendKickoff};
90110
}
91111
},
92112
keymapDirect() {
93113
if (this.teamColor === 'Yellow') {
94-
return {'numpad 7': () => this.send('direct')};
114+
return {'numpad 7': this.sendDirect};
95115
} else if (this.teamColor === 'Blue') {
96-
return {'numpad 9': () => this.send('direct')};
116+
return {'numpad 9': this.sendDirect};
97117
}
98118
},
99119
keymapIndirect() {
100120
if (this.teamColor === 'Yellow') {
101-
return {'numpad 4': () => this.send('indirect')};
121+
return {'numpad 4': this.sendIndirect};
102122
} else if (this.teamColor === 'Blue') {
103-
return {'numpad 6': () => this.send('indirect')};
104-
}
105-
},
106-
keymapYellowCard() {
107-
switch (this.teamColor) {
108-
case 'Yellow':
109-
return {'numpad 4': this.addYellowCard};
110-
case 'Blue':
111-
return {'numpad 6': this.addYellowCard};
123+
return {'numpad 6': this.sendIndirect};
112124
}
113125
},
114126
state() {

0 commit comments

Comments
 (0)