Skip to content

Commit 49eafe3

Browse files
committed
[feature] Update disable states of buttons
1 parent d9f3d54 commit 49eafe3

File tree

7 files changed

+52
-23
lines changed

7 files changed

+52
-23
lines changed

src/components/GameState.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
{{state.stage}}
1010
</span>
1111
|
12+
<span v-b-tooltip.hover title="Current command">
13+
{{state.command}} <span v-if="state.commandForTeam !== ''">for {{state.commandForTeam}}</span>
14+
</span>
15+
|
1216
<span v-format-ns-duration="state.stageTimeElapsed"
1317
v-b-tooltip.hover
1418
title="Total time elapsed in the current stage">
@@ -23,10 +27,6 @@
2327
v-b-tooltip.hover
2428
title="Total real time elapsed since the match has been started">
2529
</span>
26-
|
27-
<span v-b-tooltip.hover title="Current command">
28-
{{state.command}} <span v-if="state.commandForTeam !== ''">for {{state.commandForTeam}}</span>
29-
</span>
3030
</div>
3131
</template>
3232

src/components/control/ControlGeneral.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
:title="'Robots have to keep distance to the ball (' + Object.keys(keymapStop)[0] + ')'">
1313
<b-button v-hotkey="keymapStop"
1414
v-on:click="send('stop')"
15-
v-bind:disabled="stopped || !inNormalHalf">
15+
v-bind:disabled="stopped || !stopAllowed">
1616
Stop
1717
</b-button>
1818
</span>
1919
<span v-b-tooltip.hover
2020
:title="'Restart the game in draw situations (' + Object.keys(keymapForceStart)[0] + ')'">
2121
<b-button v-hotkey="keymapForceStart"
2222
v-on:click="send('forceStart')"
23-
v-bind:disabled="!stopped || !inNormalHalf">
23+
v-bind:disabled="!stopped || !forceStartAllowed">
2424
Force Start
2525
</b-button>
2626
</span>
2727
<span v-b-tooltip.hover
2828
:title="'Continue game after a prepare state (' + Object.keys(keymapNormalStart)[0] + ')'">
2929
<b-button v-hotkey="keymapNormalStart"
3030
v-on:click="send('normalStart')"
31-
v-bind:disabled="!prepareSth || !inNormalHalf">
31+
v-bind:disabled="!prepareSth || !normalStartAllowed">
3232
Normal Start
3333
</b-button>
3434
</span>
@@ -44,7 +44,7 @@
4444
</template>
4545

4646
<script>
47-
import {isInNormalHalf} from "../../main";
47+
import {isNonPausedStage, isPreStage} from "../../refereeState";
4848
4949
export default {
5050
name: "ControlGeneral",
@@ -84,8 +84,15 @@
8484
prepareSth() {
8585
return this.state.command === 'kickoff' || this.state.command === 'penalty';
8686
},
87-
inNormalHalf() {
88-
return isInNormalHalf(this.state);
87+
forceStartAllowed() {
88+
return isNonPausedStage(this.state);
89+
},
90+
normalStartAllowed() {
91+
return isNonPausedStage(this.state) || this.state.command === 'kickoff';
92+
},
93+
stopAllowed() {
94+
return isNonPausedStage(this.$store.state.refBoxState)
95+
|| isPreStage(this.$store.state.refBoxState);
8996
},
9097
gameEventPresent() {
9198
return this.state.gameEvent !== 'none';

src/components/control/ControlMatch.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
</b-button>
2222
<b-button v-b-tooltip.hover title="Change back to the previous stage (if something went wrong)"
2323
v-on:click="previousStage"
24-
:disabled="forbidMatchControls">
24+
:disabled="forbidMatchControls || noPreviousStage">
2525
Previous Stage
2626
</b-button>
2727
<b-button v-b-tooltip.hover title="Proceed to the next stage"
2828
v-on:click="nextStage"
29-
:disabled="forbidMatchControls">
29+
:disabled="forbidMatchControls || noNextStage">
3030
Next Stage
3131
</b-button>
3232
</div>
@@ -79,6 +79,12 @@
7979
},
8080
forbidMatchControls() {
8181
return !this.stopped && !this.halted;
82+
},
83+
noPreviousStage() {
84+
return this.state.stage === 'Pre-First Half';
85+
},
86+
noNextStage() {
87+
return this.state.stage === 'End of Game';
8288
}
8389
}
8490
}

src/components/control/ControlTeam.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
:title="'Perform direct kick (corner and goal kicks) (' + Object.keys(keymapDirect)[0] + ')'">
1313
<b-button v-hotkey="keymapDirect"
1414
v-on:click="send('direct')"
15-
v-bind:disabled="halted || running || preparing">
15+
v-bind:disabled="halted || running || preparing || !nonPausedStage">
1616
Direct
1717
</b-button>
1818
</span>
1919
<span v-b-tooltip.hover
2020
:title="'Perform indirect kick (throw-in) (' + Object.keys(keymapIndirect)[0] + ')'">
2121
<b-button v-hotkey="keymapIndirect"
2222
v-on:click="send('indirect')"
23-
v-bind:disabled="halted || running || preparing">
23+
v-bind:disabled="halted || running || preparing || !nonPausedStage">
2424
Indirect
2525
</b-button>
2626
</span>
2727
<span v-b-tooltip.hover
2828
title="Prepare for a penalty kick">
2929
<b-button v-on:click="send('penalty')"
30-
v-bind:disabled="halted || running || preparing">
30+
v-bind:disabled="halted || running || preparing || !nonPausedStage">
3131
Penalty
3232
</b-button>
3333
</span>
@@ -54,6 +54,7 @@
5454

5555
<script>
5656
import ControlTeamTimeout from "./ControlTeamTimeout";
57+
import {isNonPausedStage} from "../../refereeState";
5758
5859
export default {
5960
name: "ControlTeam",
@@ -125,6 +126,9 @@
125126
preparing() {
126127
return this.state.command === 'kickoff' || this.state.command === 'penalty';
127128
},
129+
nonPausedStage() {
130+
return isNonPausedStage(this.state);
131+
},
128132
}
129133
}
130134
</script>

src/components/control/ControlTeamTimeout.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<span>
33
<b-button v-show="!timeoutRunning"
44
v-on:click="startTimeout"
5-
v-bind:disabled="!inNormalHalf">
5+
v-bind:disabled="disableTimeoutButton">
66
Start Timeout
77
</b-button>
88
<b-button v-show="timeoutRunning"
@@ -13,7 +13,7 @@
1313
</template>
1414

1515
<script>
16-
import {isInNormalHalf} from "../../main";
16+
import {isNonPausedStage, isPreStage} from "../../refereeState";
1717
1818
export default {
1919
name: "ControlTeamTimeout",
@@ -27,8 +27,9 @@
2727
timeoutRunning: function () {
2828
return this.command === "timeout" && this.$store.state.refBoxState.commandForTeam === this.teamColor
2929
},
30-
inNormalHalf() {
31-
return isInNormalHalf(this.$store.state.refBoxState);
30+
disableTimeoutButton() {
31+
return !isNonPausedStage(this.$store.state.refBoxState)
32+
&& !isPreStage(this.$store.state.refBoxState);
3233
},
3334
},
3435
methods: {

src/main.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ library.add(faCaretSquareDown);
2727
library.add(faCaretSquareUp);
2828
Vue.component('font-awesome-icon', FontAwesomeIcon);
2929

30-
export let isInNormalHalf = function (state) {
31-
return state.stage === 'First Half';
32-
};
33-
3430
let wsAddress;
3531
if (process.env.NODE_ENV === 'development') {
3632
// use the default backend port

src/refereeState.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export let isNonPausedStage = function (state) {
2+
return state.stage === 'First Half'
3+
|| state.stage === 'Second Half'
4+
|| state.stage === 'Overtime First Half'
5+
|| state.stage === 'Overtime Second Half'
6+
|| state.stage === 'Shootout';
7+
};
8+
9+
export let isPreStage = function (state) {
10+
return state.stage === 'Pre-First Half'
11+
|| state.stage === 'Pre-Second Half'
12+
|| state.stage === 'Pre-Overtime First Half'
13+
|| state.stage === 'Pre-Overtime Second Half'
14+
|| state.stage === 'Shootout';
15+
};

0 commit comments

Comments
 (0)