Skip to content

Commit 0e83348

Browse files
committed
Start button switch added
For player 1 the start button is enabled by default, for others is disabled by default. This is because almost all iterations with the Start button happens with player 1. * Unit tests updated * Direction component using icon Fixed #39.
1 parent fc30ea1 commit 0e83348

28 files changed

+456
-185
lines changed

src/components/DirectionalPadWrapper.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ export default {
55
computed: {
66
...mapGetters([
77
'laf'
8-
])
8+
]),
9+
startEnable () {
10+
return this.$store.state.pad.startEnable
11+
}
912
},
1013
methods: {
1114
touchstart (command) {
@@ -28,6 +31,7 @@ export default {
2831
}
2932
},
3033
mounted () {
34+
// TODO: use $store.state.pad.type instead of hardcoded value!
3135
this.$store.commit('updatePadType', 'directional')
3236
}
3337
}

src/components/RacePadWrapper.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default {
1313
left: false,
1414
right: false,
1515
up: false,
16-
down: false
16+
down: false,
17+
start: false
1718
},
1819
lastCommandSent: null,
1920
interval: null
@@ -23,6 +24,7 @@ export default {
2324
if (window.DeviceMotionEvent !== undefined) {
2425
window.addEventListener('devicemotion', this.onDeviceMotion, true)
2526
}
27+
// TODO: use $store.state.pad.type instead of hardcoded value!
2628
this.$store.commit('updatePadType', 'race')
2729
// Setup a 60fps interval - 15
2830
this.interval = setInterval(() => {

src/components/mqtt_wrapper.js

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export default {
1313
const { hostname, port } = this.$store.state.mqtt
1414
const url = `ws://${hostname}:${port}`
1515
const player = this.$store.state.player
16+
if (!player) {
17+
this.$router.push({ path: '/config' })
18+
return false
19+
}
1620
const options = {
1721
username: player,
1822
password: player

src/components/pad/Buttons.vue

-78
This file was deleted.

src/components/pad/Direction.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
:class="{'is-turning': turning}"
44
:style="{'background-color': bgColor, color: fgColor}">
55
<div v-once>
6-
{{ val }}
6+
<span class="icon is-medium">
7+
<i class="fa"
8+
:class="[icon]"></i>
9+
</span>
710
</div>
811
</div>
912
</template>
@@ -33,12 +36,12 @@ export default {
3336
switch (this.position) {
3437
case 'left':
3538
values = {
36-
val: 'L'
39+
icon: 'fa-caret-left'
3740
}
3841
break
3942
case 'right':
4043
values = {
41-
val: 'R'
44+
icon: 'fa-caret-right'
4245
}
4346
break
4447
}
@@ -62,7 +65,6 @@ export default {
6265
6366
.pad-container__arrows > div {
6467
align-self: center;
65-
font-size: 22px;
6668
}
6769
6870
.is-turning {

src/components/pad/PadButton.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default {
9191
.xs {
9292
width: 60px;
9393
height: 60px;
94-
font-size: 16px;
94+
font-size: 14px;
9595
margin-top: 5px;
9696
}
9797
</style>

src/layouts/directional/Default.vue

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77
:fgColor="laf.btnB.fgColor"
88
:touchstart="touchstart"
99
:touchend="touchend"></PadButton>
10-
<slot name="options"></slot>
10+
<div class="row-1-2">
11+
<slot name="options"></slot>
12+
<PadButton :keyb="laf.btnStart.keyb" size="xs"
13+
:label="laf.btnStart.label"
14+
:bgColor="laf.btnStart.bgColor"
15+
:fgColor="laf.btnStart.fgColor"
16+
:touchstart="touchstart"
17+
:touchend="touchend"
18+
v-show="startEnable"></PadButton>
19+
</div>
1120
<PadButton keyb="X" size="sm"
1221
:label="laf.btnX.label"
1322
:bgColor="laf.btnX.bgColor"
@@ -97,4 +106,10 @@ export default {
97106
height: 50vh;
98107
margin: auto 20px;
99108
}
109+
.row-1-2 {
110+
display: flex;
111+
flex-direction: column;
112+
align-items: center;
113+
justify-content: space-around;
114+
}
100115
</style>

src/layouts/directional/DirectionalAndTwoButtons.vue

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template lang="html">
22
<div class="pad-container">
33
<div class="row-1">
4+
<PadButton :keyb="laf.btnStart.keyb" size="xs"
5+
:label="laf.btnStart.label"
6+
:icon="laf.btnStart.icon || ''"
7+
:bgColor="laf.btnStart.bgColor"
8+
:fgColor="laf.btnStart.fgColor"
9+
:touchstart="touchstart"
10+
:touchend="touchend"
11+
v-show="startEnable"></PadButton>
412
<slot name="options"></slot>
513
<PadButton :keyb="laf[keyset[1]].keyb" size="sm"
614
:label="laf[keyset[1]].label"

src/layouts/directional/ModalLayoutSelector.vue

+18-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
</header>
2020
<section class="modal-card-body">
2121
<div class="content">
22+
<div class="field">
23+
<p class="control">
24+
<label class="checkbox">
25+
<input type="checkbox"
26+
v-model="startEnable">
27+
Toggle Start button
28+
</label>
29+
</p>
30+
</div>
2231
<label class="label">Select Layout</label>
2332
<p class="control players-list">
2433
<layout-selector-item v-for="(value, key) in layouts"
@@ -78,7 +87,15 @@ export default {
7887
computed: {
7988
...mapGetters([
8089
'layouts'
81-
])
90+
]),
91+
startEnable: {
92+
get () {
93+
return this.$store.state.pad.startEnable
94+
},
95+
set (value) {
96+
this.$store.commit('toggleStart', value)
97+
}
98+
}
8299
}
83100
}
84101
</script>

src/layouts/directional/ThreeButtons.vue

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template lang="html">
22
<div class="pad-container">
33
<div class="row-1">
4+
<PadButton :keyb="laf.btnStart.keyb" size="xs"
5+
:label="laf.btnStart.label"
6+
:icon="laf.btnStart.icon || ''"
7+
:bgColor="laf.btnStart.bgColor"
8+
:fgColor="laf.btnStart.fgColor"
9+
:touchstart="touchstart"
10+
:touchend="touchend"
11+
v-show="startEnable"></PadButton>
412
<slot name="options"></slot>
513
</div>
614
<div class="row-1">

src/layouts/directional/TwoButtons.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<template lang="html">
22
<div class="pad-container">
33
<div class="row-1">
4+
<PadButton :keyb="laf.btnStart.keyb" size="xs"
5+
:label="laf.btnStart.label"
6+
:icon="laf.btnStart.icon || ''"
7+
:bgColor="laf.btnStart.bgColor"
8+
:fgColor="laf.btnStart.fgColor"
9+
:touchstart="touchstart"
10+
:touchend="touchend"
11+
v-show="startEnable"></PadButton>
412
<slot name="options"></slot>
513
</div>
614
<div class="row-1">
@@ -70,7 +78,7 @@ export default {
7078
display: flex;
7179
justify-content: space-between;
7280
align-items: center;
73-
padding: 10px 24px;
81+
padding: 20px 24px;
7482
}
7583
.bottom {
7684
display: flex;

src/mixins/mqtt_sender_wrapper.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export default {
1111
left: false,
1212
right: false,
1313
up: false,
14-
down: false
14+
down: false,
15+
start: false
1516
},
1617
lastCommandSent: null,
1718
interval: null

src/pages/Config.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ export default {
100100
},
101101
pad: {
102102
type: '',
103-
enabled: false
103+
enabled: false,
104+
startEnable: false
104105
},
105106
player: '',
106-
accelerationSensibility: 4,
107+
accelerationSensibility: 4.5,
107108
accelerationRange: {
108109
min: 3,
109110
max: 6,
@@ -143,6 +144,7 @@ export default {
143144
},
144145
methods: {
145146
save () {
147+
this.pad.startEnable = (this.player === 'alice')
146148
this.$store.commit('config', {
147149
mqtt: this.mqtt,
148150
pad: this.pad,

0 commit comments

Comments
 (0)